在MongoDB中存储GeoJSON多边形 [英] Store GeoJSON polygons in MongoDB

查看:347
本文介绍了在MongoDB中存储GeoJSON多边形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

MongoDB存在以下问题。我从我的祖国获得了一些地理数据,我必须将它们存储到mongodb中以建立一个简单的Web要素服务。此服务主要使用运算符中的 $进行边界框查询。数据采用GeoJSON格式。因此,我首先导入了以这种格式表示为点( [1,2] )的村庄和城市。没问题。下一步是LineStrings的河流和街道,根据GeoJSON这样代表 [[1,2],[3,4]] 。但是当导入区域(实际上是多边形并且根据GeoJSON规范3 dim arrrays)时,我在创建索引时得到错误 geo值必须是数字。 / p>

I have the following problem with MongoDB. I got some geo data from my home country and i have to store them into mongodb to set up a simple Web Feature Service. This service will mostly do bounding box queries using the $within operator. The data is in GeoJSON format. Therefore i imported at first the Villages and Cities which are represented as points ([1,2]) in this format. No problem. Next step rivers and streets which are LineStrings and according to GeoJSON represented this way [[1,2],[3,4]]. But when importing the districts (which are in fact polygon and according to the GeoJSON specification 3 dim arrrays) i got the error geo values have to be numbers when creating the index.

db.collection.ensureIndex({"geometry.coordinates" : "2d"});

所有数据都是有效的GeoJSON,并且在EPSG中是普通的2d坐标:4326投影。

All data are valid GeoJSON, and are in plain 2d coordinates in EPSG:4326 projection.

有人有想法吗?

推荐答案

似乎mongo 2.3.2开发版现在支持GeoJSON:
MongoDB 2.4发行说明

It seems that mongo 2.3.2 development release now has GeoJSON support: Release Notes for MongoDB 2.4

这篇关于在MongoDB中存储GeoJSON多边形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆