#26920: GEOSGeometry objects compare equal despite different SRID
-------------------------------+---------------------------------
Reporter: das-g | Owner: nobody
Type: Uncategorized | Status: new
Component: GIS | Version: 1.9
Severity: Normal | Keywords: geodjango, equality
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+---------------------------------
Checking equality of two `django.contrib.gis.geos.Point` objects (and
presumably any other `GEOSGeometry` objects of equal type) does not take
the geometries' SRIDs into consideration:
{{{#!python
from django.contrib.gis.geos import Point
p0 = Point(5, 23) # SRID implicitly None
p1 = Point(5, 23, srid=4326)
p2 = Point(5, 23, srid=32632)
assert p0.srid != p1.srid # passes
assert p0.srid != p2.srid # passes
assert p1.srid != p2.srid # passes
assert p0 != p1 # AssertionError
assert p0 != p2 # AssertionError
assert p1 != p2 # AssertionError
}}}
The semantic of coordinates depends completely on the spatial reference
system. The same numbers refer to completely different positions when
interpreted in different coordinate systems. Therefore, I think the
geometries should compare unequal if both have an SRID set and those SRIDs
are different. Not sure what should happen when comparing geometries where
exactly one of them has an SRID.
If the currently observed behaviour is the intended one (or if it is
retained for backwards compatibility reasons), the documentation should
point that out.
[https://docs.djangoproject.com/en/1.9/ref/contrib/gis/geos/#geometries-
are-pythonic It already points out that the "Equality operator doesn’t
check spatial equality"], but to me that only made clear that spatial
equality does not imply `GEOSGeometry` object equality, but not that
neither does `GEOSGeometry` object equality imply spatial equality. Also,
[https://docs.djangoproject.com/en/1.9/ref/contrib/gis/geos/#django.contrib.gis.geos.GEOSGeometry.equals
equals()], which is mentioned in that admonition as an alternative doesn't
seem to care about SRID, either:
{{{#!python
assert not p0.equals(p1) # AssertionError
assert not p0.equals(p2) # AssertionError
assert not p1.equals(p2) # AssertionError
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/26920>
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/048.32c2923fbe2893be6ac1fc191986c8e4%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.