【问题标题】:MongoDB / Geojson $geointersects problemsMongoDB / Geojson $geointersects 问题
【发布时间】:2020-06-05 09:28:39
【问题描述】:

我正在尝试处理 MongoDB Geojson $geoIntersects 问题已经 8 小时了:

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

(图片来自 (https://geoman.io/geojson-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 ]
            }
        }
    }
});

有人知道有没有办法做到这一点?

提前致谢。

【问题讨论】:

    标签: node.js mongodb geojson


    【解决方案1】:

    也许可以尝试使用JTS Topology Suite 并调查您的多边形:

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

    【讨论】:

    • 感谢您的回复,您是对的,$geoIntersects 不支持自相交多边形 :( 我现在正在寻找将它们一分为二的解决方案。再次感谢。
    猜你喜欢
    • 2013-10-06
    • 2014-07-18
    • 2014-02-13
    • 1970-01-01
    • 1970-01-01
    • 2018-03-02
    • 2015-03-05
    • 2019-04-13
    • 1970-01-01
    相关资源
    最近更新 更多