summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorJustin Bronn <jbronn@gmail.com>2008-04-25 23:52:41 +0000
committerJustin Bronn <jbronn@gmail.com>2008-04-25 23:52:41 +0000
commitc03a030fd3c74c8a03fa3fdfca08aec0ee6baa1e (patch)
tree4cd9e87999deae372eec06885a2f05e292c4471d /django
parent115d4170ae2c7ceed0ada45afbd64b15eda7b2bd (diff)
gis: Fixed GEOS tests for those still running 3.0.0RC4.
git-svn-id: http://code.djangoproject.com/svn/django/branches/gis@7463 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
-rw-r--r--django/contrib/gis/tests/test_geos.py32
1 files changed, 20 insertions, 12 deletions
diff --git a/django/contrib/gis/tests/test_geos.py b/django/contrib/gis/tests/test_geos.py
index 0fd45a3b4d..15fdfb66ec 100644
--- a/django/contrib/gis/tests/test_geos.py
+++ b/django/contrib/gis/tests/test_geos.py
@@ -9,6 +9,18 @@ if HAS_GDAL: from django.contrib.gis.gdal import OGRGeometry, SpatialReference,
class GEOSTest(unittest.TestCase):
+ @property
+ def null_srid(self):
+ """
+ Returns the proper null SRID depending on the GEOS version.
+ See the comments in `test15_srid` for more details.
+ """
+ info = geos_version_info()
+ if info['version'] == '3.0.0' and info['release_candidate']:
+ return -1
+ else:
+ return None
+
def test01a_wkt(self):
"Testing WKT output."
for g in wkt_out:
@@ -498,16 +510,10 @@ class GEOSTest(unittest.TestCase):
p1 = fromstr(hex)
self.assertEqual(4326, p1.srid)
- # However, when HEX is exported, the SRID information is lost
- # and set to -1. Essentially, the 'E' of the EWKB is not
- # encoded in HEX by the GEOS C library unless the GEOSWKBWriter
- # method is used. GEOS 3.0.0 will not encode -1 in the HEX
- # as is done in the release candidates.
- info = geos_version_info()
- if info['version'] == '3.0.0' and info['release_candidate']:
- exp_srid = -1
- else:
- exp_srid = None
+ # In GEOS 3.0.0rc1-4 when the EWKB and/or HEXEWKB is exported,
+ # the SRID information is lost and set to -1 -- this is not a
+ # problem on the 3.0.0 version (another reason to upgrade).
+ exp_srid = self.null_srid
p2 = fromstr(p1.hex)
self.assertEqual(exp_srid, p2.srid)
@@ -744,13 +750,15 @@ class GEOSTest(unittest.TestCase):
tgeoms.extend(get_geoms(multilinestrings, 4326))
tgeoms.extend(get_geoms(polygons, 3084))
tgeoms.extend(get_geoms(multipolygons, 900913))
-
+
+ # The SRID won't be exported in GEOS 3.0 release candidates.
+ no_srid = self.null_srid == -1
for geom in tgeoms:
s1, s2 = cPickle.dumps(geom), pickle.dumps(geom)
g1, g2 = cPickle.loads(s1), pickle.loads(s2)
for tmpg in (g1, g2):
self.assertEqual(geom, tmpg)
- self.assertEqual(geom.srid, tmpg.srid)
+ if not no_srid: self.assertEqual(geom.srid, tmpg.srid)
def suite():
s = unittest.TestSuite()