我使用geodjango,并希望根据距离从表中筛选行:
geom = models.MultiLineStringField()当我像这样使用geodjango时:
geo_objects.objects.filter(geom__dwithin=(pnt, D(km=10)))其中pnt是'POINT (-73.5666999999996136 45.5000000000000213)‘
Geodjango告诉我:
*** django.core.exceptions.FieldError: Join on field 'geom' not permitted. Did you misspell 'dwithin' for the lookup type?另一方面,在postgres命令行中直接执行相同的操作(据我理解)会返回合理的结果:
select * from geo_objects
WHERE ST_DWithin(geo_objects.geom, 'POINT(-73.5665 45.5000)', 122222, false)效果很好。
我做错什么了?
提前谢谢。
发布于 2014-04-26 20:17:13
这就是答案:为了执行几何查询,你需要一个风水器。https://docs.djangoproject.com/en/dev/ref/contrib/gis/model-api/#geomanager
https://stackoverflow.com/questions/23282264
复制相似问题