多边形数据如下:{ "type": "Feature", "properties": { "shape": "Polygon" }, "geometry": { "type": "Polygon", "coordinates": [ [ [-1.565584, 47.226352], [-1.564704, 47.226927], [-1.564093, 47.225616], [-1.563138, 47.226374], [-1.565584, 47.226352] ] ] }, "id": "dda54a42-090b-46ea-9dd0-fdda6d240f90" }对于此示例,我需要知道多边形是否包含我的点坐标.这是我的简单查询:db.geojsondatas.find({ geometry: { $geoIntersects: { $geometry: { type: "Point", coordinates: [ -1.555638, 47.216245 ] } } }});有人知道有没有办法做到这一点?多谢.解决方案也许尝试使用 JTS拓扑套件并调查您的多边形: 我不认为$geoIntersects支持自相交多边形. It's been now 8 hours I'm trying to deal with a MongoDB Geojson $geoIntersects issue :It's working very well when my polygon is a square, or a rectangle,but I'm unable to get some results from a $geoIntersects request when my Polygon has crossing vertices, like this example :(Image from (https://geoman.io/geojson-editor))The polygon data looks like this :{ "type": "Feature", "properties": { "shape": "Polygon" }, "geometry": { "type": "Polygon", "coordinates": [ [ [-1.565584, 47.226352], [-1.564704, 47.226927], [-1.564093, 47.225616], [-1.563138, 47.226374], [-1.565584, 47.226352] ] ] }, "id": "dda54a42-090b-46ea-9dd0-fdda6d240f90" }For this example, I need to know if the Polygon includes my Point coordinates.This is my simple query :db.geojsondatas.find({ geometry: { $geoIntersects: { $geometry: { type: "Point", coordinates: [ -1.555638, 47.216245 ] } } }});Anyone knows if there is a way to do this ?Thanks by advance. 解决方案 Maybe try with JTS Topology Suite and investigate your polygon:I don't think $geoIntersects supports Self-intersecting polygon. 这篇关于MongoDB/Geojson $ geointersects问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-12 10:52