MongoDB/Geojson $ geointersects问题 [英] MongoDB / Geojson $geointersects problems
问题描述
现在我已经尝试处理MongoDB Geojson $ geoIntersects问题已经有8个小时了:
当我的多边形是正方形或矩形时,效果很好 但是当我的多边形具有交叉顶点时,我无法从$ geoIntersects请求中得到一些结果,例如以下示例:
(图片来自( https://geoman.io/geojson-editor ))>
多边形数据如下:
{
"type": "Feature",
"properties": {
"shape": "Polygon"
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[-1.565584, 47.226352],
[-1.564704, 47.226927],
[-1.564093, 47.225616],
[-1.563138, 47.226374],
[-1.565584, 47.226352]
]
]
},
"id": "dda54a42-090b-46ea-9dd0-fdda6d240f90"
}
对于此示例,我需要知道多边形是否包含我的点坐标. 这是我的简单查询:
db.geojsondatas.find({
geometry: {
$geoIntersects: {
$geometry: {
type: "Point",
coordinates: [ -1.555638, 47.216245 ]
}
}
}
});
有人知道有没有办法做到这一点?
多谢.
也许尝试使用 JTS拓扑套件并调查您的多边形:
我不认为$geoIntersects
支持自相交多边形.
It's been now 8 hours I'm trying to deal with a MongoDB Geojson $geoIntersects issue :
It's working very well when my polygon is a square, or a rectangle, but I'm unable to get some results from a $geoIntersects request when my Polygon has crossing vertices, like this example :
(Image from (https://geoman.io/geojson-editor))
The polygon data looks like this :
{
"type": "Feature",
"properties": {
"shape": "Polygon"
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[-1.565584, 47.226352],
[-1.564704, 47.226927],
[-1.564093, 47.225616],
[-1.563138, 47.226374],
[-1.565584, 47.226352]
]
]
},
"id": "dda54a42-090b-46ea-9dd0-fdda6d240f90"
}
For this example, I need to know if the Polygon includes my Point coordinates. This is my simple query :
db.geojsondatas.find({
geometry: {
$geoIntersects: {
$geometry: {
type: "Point",
coordinates: [ -1.555638, 47.216245 ]
}
}
}
});
Anyone knows if there is a way to do this ?
Thanks by advance.
Maybe try with JTS Topology Suite and investigate your polygon:
I don't think $geoIntersects
supports Self-intersecting polygon.
这篇关于MongoDB/Geojson $ geointersects问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!