我在 2dsphere 索引集合中插入一个点,并尝试在多边形中找到它:
c = db.foo;
c.ensureIndex({'value.geometry': '2dsphere'});
c.insert({value: {geometry: {type: "Point", coordinates: [0, 0]}}});
c.findOne({'value.geometry': {$geoWithin: {$geometry:
{"type":"Polygon","coordinates":[[[-90,-90],[90,-90],[90,90],[-90,90],[-90,-90]]]}}}})
// Point is found
但是,当我对宽度超过 180° 的多边形执行相同操作时,找不到该点:
c = db.foo;
c.ensureIndex({'value.geometry': '2dsphere'});
c.insert({value: {geometry: {type: "Point", coordinates: [0, 0]}}});
c.findOne({'value.geometry': {$geoWithin: {$geometry:
{"type":"Polygon","coordinates":[[[-90.1,-90],[90.1,-90],[90.1,90],[-90.1,90],[-90.1,-90]]]}}}})
// no result -- why?
我在 MongoDB 手册中找不到这方面的任何信息。为什么有限制?