我有一组 geoJSON LineString 对象,需要确定哪个最接近某个点。我对 Mongo DB 没有太多经验,但我用它$geoNear来找到最近的点。有没有办法让它适应 LineStrings 的集合?
示例集合:
{
"_id": ObjectId("5ee3e2deee404124a8ba4382"),
"geoJSON": {
"type": "Feature",
"geometry": {
"type": "LineString",
"coordinates": [
[
-85.5,
31.0
],
[
-85.6,
31.0
]
]
}
}
}
{
"_id": ObjectId("5ee3e2deee404124a8ba4383"),
"geoJSON": {
"type": "Feature",
"geometry": {
"type": "LineString",
"coordinates": [
[
-85.55,
31.5
],
[
-85.6,
31.5
]
]
}
}
}
{
"_id": ObjectId("5ee3e2deee404124a8ba4384"),
"geoJSON": {
"type": "Feature",
"geometry": {
"type": "LineString",
"coordinates": [
[
-85.5,
32.0
],
[
-85.6,
32.0
]
]
}
}
}
我想搜索此集合以确定哪条线最接近点 [-85.55, 31.77]。这应该返回第三行(下图中的蓝线)。有没有办法在 MongoDB 中有效地做到这一点?