#25797: error when using GeoManager.distance on fields with SRID 32140 with no
GDAL
----------------------------+--------------------
Reporter: sir-sigurd | Owner: nobody
Type: Bug | Status: new
Component: GIS | Version: 1.8
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+--------------------
models.py
{{{
class Test(models.Model):
point = models.PointField(srid=32140)
objects = models.GeoManager()
}}}
{{{
In [2]: Test.objects.distance(Point(0, 1, srid=4326))
---------------------------------------------------------------------------
AttributeError Traceback (most recent call
last)
<ipython-input-2-13b46a88fb50> in <module>()
----> 1 Test.objects.distance(Point(0, 1, srid=4326))
/home/sergey/dev/django/django/db/models/manager.pyc in
manager_method(self, *args, **kwargs)
120 def create_method(name, method):
121 def manager_method(self, *args, **kwargs):
--> 122 return getattr(self.get_queryset(), name)(*args,
**kwargs)
123 manager_method.__name__ = method.__name__
124 manager_method.__doc__ = method.__doc__
/home/sergey/dev/django/django/contrib/gis/db/models/query.pyc in
distance(self, geom, **kwargs)
84 is used.
85 """
---> 86 return self._distance_attribute('distance', geom,
**kwargs)
87
88 def envelope(self, **kwargs):
/home/sergey/dev/django/django/contrib/gis/db/models/query.pyc in
_distance_attribute(self, func, geom, tolerance, spheroid, **kwargs)
494 # units of the geometry field.
495 connection = connections[self.db]
--> 496 geodetic = geo_field.geodetic(connection)
497 geography = geo_field.geography
498
/home/sergey/dev/django/django/contrib/gis/db/models/fields.pyc in
geodetic(self, connection)
146 system that uses non-projected units (e.g.,
latitude/longitude).
147 """
--> 148 units_name = self.units_name(connection)
149 # Some backends like MySQL cannot determine units name. In
that case,
150 # test if srid is 4326 (WGS84), even if this is over-
simplification.
/home/sergey/dev/django/django/contrib/gis/db/models/fields.pyc in
units_name(self, connection)
138 def units_name(self, connection):
139 if not hasattr(self, '_units_name'):
--> 140 self._get_srid_info(connection)
141 return self._units_name
142
/home/sergey/dev/django/django/contrib/gis/db/models/fields.pyc in
_get_srid_info(self, connection)
124 def _get_srid_info(self, connection):
125 # Get attributes from `get_srid_info`.
--> 126 self._units, self._units_name, self._spheroid =
get_srid_info(self.srid, connection)
127
128 def spheroid(self, connection):
/home/sergey/dev/django/django/contrib/gis/db/models/fields.pyc in
get_srid_info(srid, connection)
38 # Use `SpatialRefSys` model to query for spatial reference
info.
39 sr =
SpatialRefSys.objects.using(connection.alias).get(srid=srid)
---> 40 units, units_name = sr.units
41 spheroid = SpatialRefSys.get_spheroid(sr.wkt)
42 _srid_cache[connection.alias][srid] = (units, units_name,
spheroid)
/home/sergey/dev/django/django/contrib/gis/db/backends/base/models.pyc in
units(self)
161 "Returns a tuple of the units and the name."
162 if self.projected or self.local:
--> 163 return (self.linear_units, self.linear_name)
164 elif self.geographic:
165 return (self.angular_units, self.angular_name)
/home/sergey/dev/django/django/contrib/gis/db/backends/base/models.pyc in
linear_units(self)
133 else:
134 m = self.units_regex.match(self.wkt)
--> 135 return m.group('unit')
136
137 @property
AttributeError: 'NoneType' object has no attribute 'group'
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/25797>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/053.ea91abcaefa0f43be46ad4ca56297354%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.