邻近查询与两端之间的 LineString 点不匹配

Proximity query doesn't match LineString points between the ends

我在 collection c:

中为字段 loc 定义了一个“2dsphere”索引
db.c.createIndex( { loc : "2dsphere" } )

我在 c collection 中有以下文档。它是一个从 [0, 0] 到 [10, 10] 的 LineString:

db.c.insert({"name": "myLine", "loc": { type: "LineString", coordinates: [ [ 0, 0 ], [ 10, 10 ] ] }})

注意 [5, 5] 是直线上的一个点。但是,以 [5, 5] 为中心的邻近查询(使用 $near 运算符)与文档不匹配:

db.c.find({
  loc: {
    $near: {
      $geometry: {
         type: "Point" ,
         coordinates: [ 5, 5 ]
       },
       $maxDistance: 0.1,
    } 
  } 
})

也许 LineString 不能那样工作,从地理空间查询的角度来看,只有端点(在本例中为 [0, 0] 和 [10, 10])相关?在那种情况下,MongoDB geo spacial queries implementation or is a limitation in the GJSON standard 是否有限制?

(在我做了这个小实验之前,我认为LineString和MultiPoint之间的区别在于前者考虑了连接点的线而后者只考虑了线末端的点。之后实验,我看不出有什么区别...)。

我必须在 mongodb 和 postgis 之间做出选择。但是 mongodb 有这个缺点。看案例:Find points near LineString in mongodb sorted by distance