【发布时间】:2015-12-22 19:37:32
【问题描述】:
我正在尝试使用 mongodb (mongodb 2.6) 检查一个点是否在多边形内。 我在 de 集合中插入数据,如下所示:
db.areas.insert({"polygons":
{"type":"Polygon",
coordinates:
[[[-23.0651232, -45.6374645],
[-23.0557255, -45.6435585],
[-23.0370072, -45.6383228],
[-23.0299772, -45.6351471],
[-23.0025649, -45.6480217],
[-22.9723022, -45.6554031],
[-22.9340493, -45.6032181],
[-22.9353140, -45.5925751],
[-22.9383177, -45.5855370],
[-22.9601320, -45.5560112],
[-22.9645577, -45.5597878],
[-22.9938740, -45.5675125],
[-22.9939530, -45.5690575],
[-23.0217620, -45.5712891],
[-23.0241319, -45.5719757],
[-23.0258697, -45.5711174],
[-23.0268966, -45.5721474],
[-23.0656365, -45.6372499],
[-23.0651232, -45.6374645]
]]
}
});
然后像这样查询:
db.areas.find({polygons:
{$geoIntersects:
{$geometry:{ "type" : "Point",
"coordinates" : [ -22.112, -45.56 ] }
}
}
});
但我没有得到任何结果。有什么想法吗?
我看过这个链接: mongodb check if point is in polygon Search all polygons that contains a series of points in mongodb
任何帮助将不胜感激
【问题讨论】:
标签: mongodb ruby-on-rails-4 mongoid