MongoDB: 如何确定 GeoJson LineString 与具有半径的点的交集

MongoDB: How to determine intersection of GeoJson LineString and a Point with radius

如何在 MongoDB 中使用地理空间查询来确定由点和半径确定的圆是否与 LineString 相交?

用例:

MongoDB GeoJson LineString 对象定义如下:

db.places.insert(
{
    loc : { type: "LineString", coordinates: [ [-121.9420624, 37.3734995], [ -121.9388008, 37.3755458], [-121.9408607, 37.3720671] ] },
    name: "Small trail"
});

用户位置是[-121.928887, 37.299849] 如何确定以用户位置为圆心,半径为 10 英里的圆是否与 LineString 相交?

我期待的查询类似于

db.places.find({loc : {$geoIntersects :{$geometry :{$centerSphere: [ [ -121.928887, 37.299849 ], 100 / 3959 ]}}}});

但是这个不行

文档令人困惑,但我认为底线是 $geoIntersects 不适用于 $centerSphere。不过,$centerSphere 确实可以与 $geoWithin 一起使用。这对您的用例有用吗?语义有点不同,但可能足够接近。