Opened 5 years ago
Closed 5 years ago
#31087 closed Bug (invalid)
SpatialLite backend raises ValueError when getting distance parameter.
Reported by: | tcourtqtm | Owned by: | nobody |
---|---|---|---|
Component: | GIS | Version: | 3.0 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I'm experiencing a ValueError
from the SpatiaLite backend. When doing a query like this:
MyModel.objects.filter(point__dwithin = (some_point, D(km=distance_in_km)))
I am getting this error:
ValueError: Only numeric values of degree units are allowed on geographic DWithin queries.
This does not happen with the PostGIS backend and I believe it's a bug.
After a bit of searching I noticed that the difference between the two backends is that postgis has a conditional to check if the PointField is geographic and, if it is, avoids the exception.
The code from the postgis backend:
if isinstance(value, Distance): if geography: dist_param = value.m elif geodetic: if lookup_type == 'dwithin': raise ValueError('Only numeric values of degree units are ' 'allowed on geographic DWithin queries.') dist_param = value.m else: dist_param = getattr(value, Distance.unit_attname(f.units_name(self.connection)))
And the same function from the spatialite backend:
if isinstance(value, Distance): if f.geodetic(self.connection): if lookup_type == 'dwithin': raise ValueError( 'Only numeric values of degree units are allowed on ' 'geographic DWithin queries.' ) dist_param = value.m else: dist_param = getattr(value, Distance.unit_attname(f.units_name(self.connection)))
I am very unfamiliar with Geo stuff in general but this looks like a simple omission in the spatialite code. I believe it should have a similar if geography
check.
Change History (1)
comment:1 by , 5 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
Summary: | SpatialLite backend raises ValueError when getting distance parameter → SpatialLite backend raises ValueError when getting distance parameter. |
Version: | 2.2 → 3.0 |
geography
columns are supported only on PostGIS, also an example from the ticket description works on SpatiaLite (see similar tests).