diff --git a/django/contrib/gis/db/models/query.py b/django/contrib/gis/db/models/query.py
index c89912b..989cb16 100644
a
|
b
|
class GeoQuerySet(QuerySet):
|
85 | 85 | """ |
86 | 86 | return self._geomset_attribute('difference', geom, **kwargs) |
87 | 87 | |
88 | | def distance(self, geom, **kwargs): |
| 88 | def distance(self, geom, att='distance', **kwargs): |
89 | 89 | """ |
90 | 90 | Returns the distance from the given geographic field name to the |
91 | | given geometry in a `distance` attribute on each element of the |
92 | | GeoQuerySet. |
| 91 | given geometry in an attribute named `att` on each element of the |
| 92 | GeoQuerySet, `distance` by default. |
93 | 93 | |
94 | 94 | Keyword Arguments: |
95 | | `spheroid` => If the geometry field is geodetic and PostGIS is |
96 | | the spatial database, then the more accurate |
97 | | spheroid calculation will be used instead of the |
98 | | quicker sphere calculation. |
| 95 | `spheroid` => If the geometry field is geodetic and PostGIS is |
| 96 | the spatial database, then the more accurate |
| 97 | spheroid calculation will be used instead of the |
| 98 | quicker sphere calculation. |
| 99 | |
| 100 | `tolerance` => Used only for Oracle. The tolerance is |
| 101 | in meters -- a default of 5 centimeters (0.05) |
| 102 | is used. |
99 | 103 | |
100 | | `tolerance` => Used only for Oracle. The tolerance is |
101 | | in meters -- a default of 5 centimeters (0.05) |
102 | | is used. |
| 104 | `field_name` => Explicitly set the geometry field name, by default |
| 105 | it uses the first it finds on the model |
103 | 106 | """ |
104 | | return self._distance_attribute('distance', geom, **kwargs) |
| 107 | return self._distance_attribute('distance', geom, att=att, **kwargs) |
105 | 108 | |
106 | 109 | def envelope(self, **kwargs): |
107 | 110 | """ |
… |
… |
class GeoQuerySet(QuerySet):
|
573 | 576 | return self.extra(select={model_att : fmt % settings['procedure_args']}, |
574 | 577 | select_params=settings['select_params']) |
575 | 578 | |
576 | | def _distance_attribute(self, func, geom=None, tolerance=0.05, spheroid=False, **kwargs): |
| 579 | def _distance_attribute(self, func, geom=None, tolerance=0.05, spheroid=False, att=None, **kwargs): |
577 | 580 | """ |
578 | 581 | DRY routine for GeoQuerySet distance attribute routines. |
579 | 582 | """ |
… |
… |
class GeoQuerySet(QuerySet):
|
716 | 719 | # The geometry is passed in as a parameter because we handled |
717 | 720 | # transformation conditions in this routine. |
718 | 721 | s['select_params'] = [backend.Adapter(geom)] |
719 | | return self._spatial_attribute(func, s, **kwargs) |
| 722 | return self._spatial_attribute(att or func, s, **kwargs) |
720 | 723 | |
721 | 724 | def _geom_attribute(self, func, tolerance=0.05, **kwargs): |
722 | 725 | """ |