【发布时间】:2011-05-03 00:26:15
【问题描述】:
我试图表示一个跨越 180 度经度的矩形区域。更多背景见In PostGIS a polygon bigger than half the world is treated as it's opposite
这是我的测试用例:
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
我可以查看正在生成的 SQL,但这些区域以二进制 (EWKB) 表示,我不确定如何读取它。
谁能解释一下?
【问题讨论】: