简体   繁体   English

MongoDB / Geojson $geointersects 问题

[英]MongoDB / Geojson $geointersects problems

It's been now 8 hours I'm trying to deal with a MongoDB Geojson $geoIntersects issue:现在已经 8 小时了,我正在尝试处理 MongoDB Geojson $geoIntersects 问题:

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:当我的多边形是正方形或矩形时,它工作得很好,但是当我的多边形有交叉顶点时,我无法从 $geoIntersects 请求中获得一些结果,如下例所示:

在此处输入图像描述

(Image from ( https://geoman.io/geojson-editor )) (图片来自( 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.对于这个例子,我需要知道 Polygon 是否包含我的 Point 坐标。 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:也许尝试使用JTS 拓扑套件并调查您的多边形:

在此处输入图像描述

I don't think $geoIntersects supports Self-intersecting polygon.我不认为$geoIntersects支持自相交多边形。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM