MongoDB Geojson $geointersects问题。

问题描述 投票:0回答:1

现在已经8个小时了,我一直在尝试处理MongoDB Geojson $geoIntersects的问题,当我的多边形是一个正方形或矩形时,它的工作非常好,但当我的多边形有交叉顶点时,我无法从$geoIntersects请求中得到一些结果。

当我的多边形是一个正方形或矩形时,它工作得很好,但当我的多边形有交叉顶点时,我无法从$geoIntersects请求中得到一些结果,比如这个例子。

enter image description here

(图片来自(https:/geoman.iogeojson-editor。))

多边形的数据是这样的。

{
        "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 ]
            }
        }
    }
});

Anyone knows if there is a way to do this ?

感谢提前。

node.js mongodb geojson
1个回答
1
投票

也许可以尝试用 JTS拓扑套件 并调查你的多边形。

enter image description here

我不认为 $geoIntersects 支持自相交的多边形。

© www.soinside.com 2019 - 2024. All rights reserved.