Opened 8 years ago

Closed 8 years ago

#27573 closed Bug (fixed)

Distance function returns Distance object instead of raw value on MySQL

Reported by: Sergey Fedoseev Owned by: Sergey Fedoseev
Component: GIS Version: 1.9
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

https://docs.djangoproject.com/en/1.9/ref/contrib/gis/functions/#django.contrib.gis.db.models.functions.Distance

On MySQL, a raw float value is returned, as it’s not possible to automatically determine the unit of the field.

but

In [3]: City.objects.annotate(d=Distance('point', Point(0, 0, srid=4326))).first().d
Out[3]: Distance(m=1.41421356237)

I see two ways how to fix it:

  1. made Distance function to return raw values on MySQL
  2. raise NotImplemented if Distance function is applied to geodetic field

Change History (4)

comment:1 by Sergey Fedoseev, 8 years ago

Owner: changed from nobody to Sergey Fedoseev
Status: newassigned

comment:2 by Tim Graham, 8 years ago

Triage Stage: UnreviewedAccepted

comment:3 by Sergey Fedoseev, 8 years ago

Has patch: set

comment:4 by Tim Graham <timograham@…>, 8 years ago

Resolution: fixed
Status: assignedclosed

In 898e623:

Fixed #27573 -- Made Distance on geodetic coordinates return a raw value on MySQL.

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