我需要一些帮助: how to insert geojson polygons into a mongodb database and query, based on the coordinates of a certain point, all the polygons which are located at a certain distance from that point
这是我将使用的geojson样本:
var testJson = {
"type" : "Polygon",
"properties": {},
"geometry" : [
[
[ 40.8003, -73.9580 ],
[ 40.7968, -73.9498 ],
[ 40.7648, -73.9737 ],
[ 40.7681, -73.9814 ],
[ 40.8003, -73.9580 ]
]
]
};
我想将它保存到mongodb数据库并能够查询它 . 为此,我执行以下操作:
我创建了一个猫鼬模式:
var GeoSchema = mongoose.Schema({“type”:{“type”:String},“properties”:{“type”:Object},“geometry”:{“type”:Array,“index”:'2dsphere' }};
我创建了一个猫鼬模型:
var GeoModel = mongoose