我有以下型号:
class Share(models.Model):
creator = models.ForeignKey(settings.AUTH_USER_MODEL)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
active = models.BooleanField(default=True)
source = models.PointField(geography=True, srid=4326)
从那里我试图检索源在以下recangle中的所有行
from django.contrib.gis.geos import Polygon
xmin = sw_lng # is 11.1
ymin = sw_lat # is 48.1
xmax = ne_lng # is 11.2
ymax = ne_lat # is 48.2 or whatever
bbox = (xmin, ymin, xmax, ymax)
geom = Polygon.from_bbox(bbox)
queryset = Share.objects.filter(source__contained=geom)
for object in queryset:
print ('gefunden [%s]' % (object.name))
但我收到了
ValueError: PostGIS geography does not support the "@" function/operator.
在postgis中,doku @被标记为已实现。有人有线索吗?
此致
答案 0 :(得分:2)
解决了....来源是“geography”类型,postgis上的“@”不支持我必须使用:
queryset = Share.objects.filter(source__coveredby=geom)
无论如何..