Opened 8 years ago

Closed 7 years ago

#27972 closed Cleanup/optimization (fixed)

BaseSpatialField.geodetic should return SpatialReference.geographic

Reported by: Sergey Fedoseev Owned by: Sergey Fedoseev
Component: GIS Version: 1.10
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

At this moment BaseSpatialField.geodetic checks if the unit name associated with the field is in the list of geodetic_units = ('decimal degree', 'degree'), but it could simply return SpatialReference.geographic because units are geodetic iif SRS is geographic.

The current implementation of BaseSpatialField.geodetic gives incorrect result for some SRSes:

In [1]: from django.db import connection
In [2]: from django.contrib.gis.db.models.fields import BaseSpatialField

In [5]: BaseSpatialField(srid=4901).geodetic(connection)
Out[5]: False

In [10]: from django.contrib.gis.gdal import SpatialReference
In [11]: print(SpatialReference(4901))
GEOGCS["ATF (Paris)",
    DATUM["Ancienne_Triangulation_Francaise_Paris",
        SPHEROID["Plessis 1817",6376523,308.64,
            AUTHORITY["EPSG","7027"]],
        AUTHORITY["EPSG","6901"]],
    PRIMEM["Paris RGS",2.337208333333333,
        AUTHORITY["EPSG","8914"]],
    UNIT["grad",0.01570796326794897,
        AUTHORITY["EPSG","9105"]],
    AUTHORITY["EPSG","4901"]]

In [12]: SpatialReference(4901).geographic
Out[12]: True

Change History (4)

comment:1 by Sergey Fedoseev, 8 years ago

Owner: changed from nobody to Sergey Fedoseev
Status: newassigned

comment:2 by Claude Paroz, 8 years ago

Triage Stage: UnreviewedAccepted

comment:3 by Sergey Fedoseev, 7 years ago

Has patch: set

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

Resolution: fixed
Status: assignedclosed

In df8f1d01:

Fixed #27972 -- Made BaseSpatialField.geodetic() use SpatialReference.geographic.

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