【发布时间】:2018-09-25 12:39:42
【问题描述】:
我可以使用 2dsphere 索引在 MongoDB 中计算点到点的距离。
但是,现在我需要计算从给定点到多边形的距离。
我正在使用以下代码:
Document commandNoIntersect = new Document("geoNear", "Location")
.append("near", new com.mongodb.client.model.geojson.Point(new Position(Longitude, Latitude)))
.append("spherical", true)
.append("query", new Document(new Document("location", locationId)))
.append("distanceMultiplier", 0.001);
database.runCommand(commandNoIntersect);
我的 2dsphere 索引是多边形的坐标。结果与点到点距离不一致。
感谢您的反馈,
【问题讨论】:
标签: mongodb polygon distance geonear