【发布时间】:2021-03-12 18:14:51
【问题描述】:
我想在 MongoDB 的“功能”字段上创建一个 2dsphere 索引。但它包含一组 GeoJSON LineStrings。如果没有这个数组,我只能为单个 GeoJSON LineString 创建 2dsphere 索引,例如db.collection.createIndex({ loc : "2dsphere" )。我想执行像collection.find({ $features: { $geometry: bounding_box } })这样的空间查询
有人知道如何为 GeoJSON 对象数组创建 2dsphere 吗?
{
"_id" : ObjectId("..."),
"name" : "street_segment_names",
"features" : [
{
"type" : "Feature",
"geometry" : {
"type" : "LineString",
"coordinates" : [
[.,.],[.,.],[.,.]
]
},
"properties" : {
"speed_limit" : 20
}
},
{
"type" : "Feature",
"geometry" : {
"type" : "LineString",
"coordinates" : [
[.,.],[.,.],[.,.]
]
},
"properties" : {
"speed_limit" : 30
}
}
]
}
【问题讨论】:
标签: mongodb mongodb-query