$geoWithin return 文档位于查询的多边形之外
$geoWithin return document located outside the polygon queried
我最近遇到了这种我无法解释的行为。
$geowithin
return 个多边形外查询的文档。
为了说明我的问题,我制作了一个 mongodb playground,其中包含 3 个文档,其几何图形都位于多边形之外。多边形相当大,我已经阅读了大多边形的reco。
此处 $geoWithin
查询逆时针构建多边形 return 1 个文档。
db.collection.aggregate([
{
$match: {
"featureOfInterest.samplingFeature.geometry": {
$geoWithin: {
$geometry: {
type: "Polygon",
coordinates: [
[
[
-131.484375,
-58.447733
],
[
67.5,
-58.447733
],
[
67.5,
24.20689
],
[
-131.484375,
24.20689
],
[
-131.484375,
-58.447733
]
]
],
crs: {
type: "name",
properties: {
name: "urn:x-mongodb:crs:strictwinding:EPSG:4326"
}
}
}
}
}
}
}
])
我还尝试顺时针构建多边形并查询 return 未被前一个多边形 return 编辑的两个文档。
[
[
[
-131.484375,
-58.447733
],
[
-131.484375,
24.20689
],
[
67.5,
24.20689
],
[
67.5,
-58.447733
],
[
-131.484375,
-58.447733
]
]
]
有人能看出我在这里遗漏了什么吗?
all located outside the polygon
除了他们不是 - 其中两个在外面,一个在里面。
如果您绘制另一个多边形(就像您所做的那样)并在内部看到三个点中的两个,在外部看到第三个(正确),则更容易看到。
我最近遇到了这种我无法解释的行为。
$geowithin
return 个多边形外查询的文档。
为了说明我的问题,我制作了一个 mongodb playground,其中包含 3 个文档,其几何图形都位于多边形之外。多边形相当大,我已经阅读了大多边形的reco。
此处 $geoWithin
查询逆时针构建多边形 return 1 个文档。
db.collection.aggregate([
{
$match: {
"featureOfInterest.samplingFeature.geometry": {
$geoWithin: {
$geometry: {
type: "Polygon",
coordinates: [
[
[
-131.484375,
-58.447733
],
[
67.5,
-58.447733
],
[
67.5,
24.20689
],
[
-131.484375,
24.20689
],
[
-131.484375,
-58.447733
]
]
],
crs: {
type: "name",
properties: {
name: "urn:x-mongodb:crs:strictwinding:EPSG:4326"
}
}
}
}
}
}
}
])
我还尝试顺时针构建多边形并查询 return 未被前一个多边形 return 编辑的两个文档。
[
[
[
-131.484375,
-58.447733
],
[
-131.484375,
24.20689
],
[
67.5,
24.20689
],
[
67.5,
-58.447733
],
[
-131.484375,
-58.447733
]
]
]
有人能看出我在这里遗漏了什么吗?
all located outside the polygon
除了他们不是 - 其中两个在外面,一个在里面。
如果您绘制另一个多边形(就像您所做的那样)并在内部看到三个点中的两个,在外部看到第三个(正确),则更容易看到。