Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#21907 closed Bug (fixed)

GeoQueryset.transform() broken in Spatialite >= 4

Reported by: Akis Kesoglou Owned by: Claude Paroz
Component: GIS Version: master
Severity: Normal Keywords: geodjango, spatialite, geoqueryset, transform, srs, google, mercator, 900913,
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


Hello, changeset #362dd68fb20 broke adding Google's 900913 SRS entry in spatialite. django.contrib.gis.utils.add_srs_entry leaves the new srtext field empty, resulting in GeoQueryset.transform() raising an OGRException exception. Here's the traceback:

File "<virtualenv>/src/django/django/core/handlers/" in get_response
  113.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "<project>/" in object_list
  121.             .distance(location.point, field_name='current_location__point'))
File "<virtualenv>/src/django/django/contrib/gis/db/models/" in distance
  104.         return self._distance_attribute('distance', geom, **kwargs)
File "<virtualenv>/src/django/django/contrib/gis/db/models/" in _distance_attribute
  648.                 u, unit_name, s = get_srid_info(self.query.transformed_srid, connection)
File "<virtualenv>/src/django/django/contrib/gis/db/models/" in get_srid_info
  40.         spheroid = SpatialRefSys.get_spheroid(sr.wkt)
File "<virtualenv>/src/django/django/contrib/gis/db/backends/" in get_spheroid
  323.             srs = gdal.SpatialReference(wkt)
File "<virtualenv>/src/django/django/contrib/gis/gdal/" in __init__
  94.             self.import_user_input(srs_input)
File "<virtualenv>/src/django/django/contrib/gis/gdal/" in import_user_input
  295.         capi.from_user_input(self.ptr, force_bytes(user_input))
File "<virtualenv>/src/django/django/contrib/gis/gdal/prototypes/" in check_errcode
  117.     check_err(result)
File "<virtualenv>/src/django/django/contrib/gis/gdal/" in check_err
  53.         raise e(msg)

Exception Type: OGRException at /url
Exception Value: Corrupt data.

Poking inside django.contrib.gis, I figure there are 2 ways this can be resolved:

  1. Add a check or not self.srtext at spatialite/
  2. Fix django.contrib.gis.utils.add_srs_entry by checking the connection version, similar to how it's done above.

Change History (3)

comment:1 Changed 6 years ago by Claude Paroz

Owner: changed from nobody to Claude Paroz
Status: newassigned
Triage Stage: UnreviewedAccepted

comment:2 Changed 6 years ago by Claude Paroz <claude@…>

Resolution: fixed
Status: assignedclosed

In 9c8d62a06fc83efa019f23b6b87b39a82c95ab97:

Fixed #21907 -- Fixed add_srs_entry for Spatialite >= 4

Thanks dfunckt for the report.

comment:3 Changed 6 years ago by Claude Paroz

Note: the test was added in the previous commit: [fabc678f930431fd6e502fe7930ee772eff96898]

Note: See TracTickets for help on using tickets.
Back to Top