GeoDjango: Exceptions for basic geographic queries
- by omat
I am having problems with geographic queries with GeoDjango running on SpatiaLite on my development environment.
from django.contrib.gis.db import models
class Test(models.Model):
poly = models.PolygonField()
point = models.PointField()
geom = models.GeometryField()
objects = models.GeoManager()
Testing via shell:
>>> from geotest.models import Test
>>> from django.contrib.gis.geos import GEOSGeometry
>>>
>>> point = GEOSGeometry("POINT(0 0)")
>>> point
<Point object at 0x105743490>
>>> poly = GEOSGeometry("POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))")
>>> poly
<Polygon object at 0x105743370>
>>>
With these definitions, lets try some basic geographic queries. First contains:
>>> Test.objects.filter(point__within=poly)
Assertion failed: (0), function appendGeometryTaggedText, file WKTWriter.cpp, line 228.
Abort trap
And the django shell dies. And with within:
>>> Test.objects.filter(poly__contains=point)
GEOS_ERROR: Geometry must be a Point or LineString
Traceback (most recent call last):
...
GEOSException: Error encountered checking Coordinate Sequence returned from GEOS C function "GEOSGeom_getCoordSeq_r".
>>>
Other combinations also cause a variety of exceptions. I must be missing something obvious as these are very basic. Any ideas?