Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#21907 closed Bug (fixed)

GeoQueryset.transform() broken in Spatialite >= 4

Reported by: Akis Kesoglou Owned by: Claude Paroz
Component: GIS Version: dev
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

Description

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:

Traceback:
File "<virtualenv>/src/django/django/core/handlers/base.py" in get_response
  113.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "<project>/views.py" in object_list
  121.             .distance(location.point, field_name='current_location__point'))
File "<virtualenv>/src/django/django/contrib/gis/db/models/query.py" in distance
  104.         return self._distance_attribute('distance', geom, **kwargs)
File "<virtualenv>/src/django/django/contrib/gis/db/models/query.py" 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/fields.py" in get_srid_info
  40.         spheroid = SpatialRefSys.get_spheroid(sr.wkt)
File "<virtualenv>/src/django/django/contrib/gis/db/backends/base.py" in get_spheroid
  323.             srs = gdal.SpatialReference(wkt)
File "<virtualenv>/src/django/django/contrib/gis/gdal/srs.py" in __init__
  94.             self.import_user_input(srs_input)
File "<virtualenv>/src/django/django/contrib/gis/gdal/srs.py" in import_user_input
  295.         capi.from_user_input(self.ptr, force_bytes(user_input))
File "<virtualenv>/src/django/django/contrib/gis/gdal/prototypes/errcheck.py" in check_errcode
  117.     check_err(result)
File "<virtualenv>/src/django/django/contrib/gis/gdal/error.py" 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/models.py:61
  2. Fix django.contrib.gis.utils.add_srs_entry by checking the connection version, similar to how it's done models.py above.

Change History (3)

comment:1 by Claude Paroz, 11 years ago

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

comment:2 by Claude Paroz <claude@…>, 11 years ago

Resolution: fixed
Status: assignedclosed

In 9c8d62a06fc83efa019f23b6b87b39a82c95ab97:

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

Thanks dfunckt for the report.

comment:3 by Claude Paroz, 11 years ago

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

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