GEOSException on reading from SpatiaLite

658 views
Skip to first unread message

Radim

unread,
May 9, 2011, 11:45:07 AM5/9/11
to geodjango
Hi,
I am getting this error on reading geometry data from SpatiaLite:

Error encountered checking Geometry returned from GEOS C function
"GEOSWKBReader_read_r".

Django 1.3, sqlite 3070500, pysqlite 2.6.0, spatialite 2.3.1

Writing works well, from python shell:

p = Point( id = 10, geo = "POINT(649346.378505 5117479.147196)" )
p.save()
p = Point.objects.get(id=10)
print p.geo
GEOS_ERROR: ParseException: Unknown WKB type 0
ERROR: An unexpected error occurred while tokenizing input
.....
django/contrib/gis/geos/prototypes/errcheck.pyc in check_geom(result,
func, cargs)
41 "Error checking on routines that return Geometries."
42 if not result:
---> 43 raise GEOSException('Error encountered checking
Geometry returned from GEOS C function "%s".' %
func.__name__)
44 return result
45

WKB saved in db:
0001F80B00004968CBC104D12341C6A86BC9898553414968CBC104D12341C6A86BC9898553417C010000004968CBC104D12341C6A86BC989855341FE

So the type (01 = Point) seems to be OK.

Where the problem could be? What other should I check/test?
Please help!

Thanks
Radim

Radim

unread,
May 9, 2011, 11:50:09 AM5/9/11
to geodjango
It seems to be the same problem like this one:

http://groups.google.com/group/geodjango/browse_thread/thread/548247fb4d8a03ff?pli=1

Radim

Radim

unread,
May 9, 2011, 2:16:31 PM5/9/11
to geodjango
I have discovered that the problem is, that data selected from
geometry column are in SpatiaLite internal BLOB format not WKB nor WKT
which GeoDjango expects, AFAIU. If astext() or asbinary() are used for
select from the geometry column, GeoDjango works (I have tested with
view in SpatiaLite).

I dont know however, how to get it working with normal tables.

Radim

Benjamin Wohlwend

unread,
May 19, 2011, 5:17:50 AM5/19/11
to geod...@googlegroups.com
Hi,

I had the same problem and spent quite a while trying to find the problem. Turns out I forgot to use the GeoManager as the default manager. Add this line to your model and you should be fine:

    objects = models.GeoManager()

Kind Regards,
Benjamin
Reply all
Reply to author
Forward
0 new messages