MongoDB $geoIntersects does not work with polygons that contain negative vertices

喜夏-厌秋 提交于 2019-12-23 23:19:30

问题


I have stored polygons in the database that cross over the x and y axes and I want to search for polygons that contain a given point. To do so, I am using the $geoIntersects operator to specify a point, however, MongoDB does not return any polygons when they cross over an axis. Are there any small changes I can make to my query or schema that will allow for this?

The query:

{
    polygon: {
        $geoIntersects: {
            $geometry: {
                type: 'Point',
                coordinates: [long, lat]
            }
        }
    }
}

The object in the database:

polygon: {

        type: 'Polygon',

        name: 'Name',

        coordinates: [[
            [-180, -90],
            [-180, 90],
            [180, 90],
            [180, -90],
            [-180, -90]
        ]]

    }

来源:https://stackoverflow.com/questions/40392782/mongodb-geointersects-does-not-work-with-polygons-that-contain-negative-vertice

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!