我正在使用mongodb和多边形以这种格式存储的多边形
"geometry" : { "type" : "Polygon", "coordinates" : [ [ [ 2.0315, 85.8546219515 ], [ 2.0315, 86.1673780485 ], [ 1.7185, 86.1673780485 ], [ 1.7185, 85.8546219515 ], [ 2.0315, 85.8546219515 ] ] ] }
我正在尝试使用geoIntersect并使用以下内容查询矩形多边形:
find({geometry:{$geoIntersects:{$geometry:{"type": "Polygon", "coordinates":[ [[12,20], [13,20], [13,18], [12,18], [12,20]]]}}}})
当我做这样的小查询时,结果很好,但是当我扩展到非常大的盒子时:
find({geometry:{$geoIntersects:{$geometry:{"type": "Polygon", "coordinates":[ [[-166.2890625,46.55886030311719], [-166.2890625,47.39834920035926], [12.12890625,47.39834920035926], [12.12890625,46.55886030311719], [-166.2890625,46.55886030311719]]]}}}})
然后我开始得到像这样奇怪的结果
"geometry" : { "type" : "Polygon", "coordinates" : [ [ [ 2.9684999999999997, 85.54162195149999 ], [ 2.9684999999999997, 85.8543780485 ], [ 2.6555, 85.8543780485 ], [ 2.6555, 85.54162195149999 ], [ 2.9684999999999997, 85.54162195149999 ] ] ] }
我只从db中返回了几个多边形(总共4个),这些多边形实际上在我的输入多边形内:
"geometry":{"type":"Polygon","coordinates":[[[12.343499999999999,47.1416219515],[12.343499999999999,47.454378048500004],[12.0305,47.454378048500004],[12.0305,47.1416219515],[12.343499999999999,47.1416219515]]]}}
"geometry":{"type":"Polygon","coordinates":[[[12.343499999999999,46.829621951499995],[12.343499999999999,47.1423780485],[12.0305,47.1423780485],[12.0305,46.829621951499995],[12.343499999999999,46.829621951499995]]]}}
"geometry":{"type":"Polygon","coordinates":[[[-166.0935,46.5166219515],[-166.0935,46.829378048500004],[-166.4065,46.829378048500004],[-166.4065,46.5166219515],[-166.0935,46.5166219515]]]}}
"geometry":{"type":"Polygon","coordinates":[[[-166.0935,46.829621951499995],[-166.0935,47.1423780485],[-166.4065,47.1423780485],[-166.4065,46.829621951499995],[-166.0935,46.829621951499995]]]}}
我输入的80年代我不应该有任何自由。我不知道这些来自哪里。它们构成了返回的大部分。 (847/851结果)
答案 0 :(得分:0)
我不认为多边形适合一个半球。来自$geoIntersects docs,
使用GeoJSON指定给$ geoIntersects查询的任何几何都必须适合单个半球。