PostGIS - 某些多重多边形会导致“BOOM!”无法生成外部点!”

发布于 2024-11-04 11:28:39 字数 1275 浏览 5 评论 0原文

我试图表示一个跨越 180 度经度的矩形区域。有关更多背景信息,请参阅在PostGIS中,大于半个世界的多边形被视为相反

这是我的测试用例:

from django.contrib.gis.geos import Polygon, MultiPolygon
from my_project.my_app.models import Photo

a = Polygon.from_bbox((30, -80, 180, 80))  # the part to the east of 180
b = Polygon.from_bbox((-180, -80, -160, 80))  # a part to the west of 180
c = Polygon.from_bbox((-180, -80, -100, 80))  # a larger part to the west of 180

ok   = MultiPolygon(a,b)
ok2  = MultiPolygon(c)
boom = MultiPolygon(a,c)

# This works
Photo.objects.filter(location__coveredby=ok)[:1]
# This also works so c is ok
Photo.objects.filter(location__coveredby=ok2)[:1]
# This gives "BOOM! Could not generate outside point!"
Photo.objects.filter(location__coveredby=boom)[:1]

# splitting c doesn't help
c1 = Polygon.from_bbox((-180, -80, -140, 80))
c2 = Polygon.from_bbox((-140, -80, -100, 80))
test = MultiPolygon(a,c1,c2)
Photo.objects.filter(location__coveredby=test)[:1]
# BOOM! Could not generate outside point!

通过更改我可以让这个错误来来去去。 例如,(-180, -80, x, 80) 适用于 x <= -140 的情况。对于每个数字都有一个这样的阈值,但我找不到模式。对于具有相同面积的盒子,有些可以工作,有些则不行。对于宽度相同的盒子,有些可以使用,有些则不行。

我可以查看正在生成的 SQL,但这些区域以二进制 (EWKB) 表示,我不知道如何读取它。

谁能解释一下吗?

I'm trying to represent a rectangular area which crosses 180 degrees longitude. For more background see In PostGIS a polygon bigger than half the world is treated as it's opposite

Here's my test case:

from django.contrib.gis.geos import Polygon, MultiPolygon
from my_project.my_app.models import Photo

a = Polygon.from_bbox((30, -80, 180, 80))  # the part to the east of 180
b = Polygon.from_bbox((-180, -80, -160, 80))  # a part to the west of 180
c = Polygon.from_bbox((-180, -80, -100, 80))  # a larger part to the west of 180

ok   = MultiPolygon(a,b)
ok2  = MultiPolygon(c)
boom = MultiPolygon(a,c)

# This works
Photo.objects.filter(location__coveredby=ok)[:1]
# This also works so c is ok
Photo.objects.filter(location__coveredby=ok2)[:1]
# This gives "BOOM! Could not generate outside point!"
Photo.objects.filter(location__coveredby=boom)[:1]

# splitting c doesn't help
c1 = Polygon.from_bbox((-180, -80, -140, 80))
c2 = Polygon.from_bbox((-140, -80, -100, 80))
test = MultiPolygon(a,c1,c2)
Photo.objects.filter(location__coveredby=test)[:1]
# BOOM! Could not generate outside point!

By changing the numbers I can make this error come and go.
(-180, -80, x, 80) works where x <= -140 for example. For every number there is a threshold like this but I can't find a pattern. For boxes with the same area, some will work and others not. For boxes with the same width some will work and others not.

I can look at the SQL being generated but the areas are represented in binary (EWKB) and I'm not sure how to read it.

Can anyone explain this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

穿透光 2024-11-11 11:28:39

问完这个问题后,我发现了 gis.stackexchange.com,所以我也在那里问了。在那里好心人的帮助下,我找到了问题所在(我认为)和解决方案。

看:
<一href="https://gis.stackexchange.com/questions/9217/postgis-certain-multipolygons-cause-boom-could-not-generate-outside-point/9257#9257 ">https://gis.stackexchange.com/questions/9217/postgis-certain-multipolygons-cause-boom-could-not-generate-outside-point/9257#9257

After asking this question I found out about gis.stackexchange.com, so I asked there too. With the help of the good folks there I found out what the problem is (I think) and a solution.

See:
https://gis.stackexchange.com/questions/9217/postgis-certain-multipolygons-cause-boom-could-not-generate-outside-point/9257#9257

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文