查询多边形$ geowithin $ box mongodb不返回任何内容 [英] Query polygons $geowithin $box mongodb doesn't return anything

查看:222
本文介绍了查询多边形$ geowithin $ box mongodb不返回任何内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

伙计们我正在尝试通过边界框查询内部的所有多边形,但是它只是返回0.它应该返回许多多边形!

Guys I am trying to query all the polygons inside by bounding box but it simply returns 0.. It should be returning many polygons!

或者,我尝试查询更大的边界框,但没有任何反应!

Alternatively I try to query a much larger bounding box and nothing happens!

我的查询是:

{
 geometry: 
    { $geoWithin: 
        { $box:  
            [ [-73.995762,40.764826], [-73.934034,40.802038] ] 
        } 
    }                       
}

请注意,对于类型为Point

推荐答案

答案如下:

$ box可以与GeoJSON一起使用,但不能与多边形一起使用!您需要使用$ box生成几何.

$box do work with GeoJSON, but not with polygons! You need to generate a geometry with the $box instead.

此外,它始终必须具有起点和起点,因此4点多边形将具有 5个坐标元组

Also, it always has to has the start point and point, so a 4-point polygon will have 5 coordinate tuples

但是变得更复杂,它必须遵循右手规则(逆时针).

BUT it gets trickier, it has to follow the right hand rule (anticlockwise).

使用$ BOX和点测试GEOJSON

TESTING GEOJSON WITH $BOX AND POINTS

我的查询{geometry:{$ geoWithin:{$ box:[[-71.934034,38.764826],[-75.995762,43.802038]]}}}

my query {geometry: { $geoWithin: { $box: [ [-71.934034,38.764826], [-75.995762,43.802038] ] } }}

这篇关于查询多边形$ geowithin $ box mongodb不返回任何内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆