mirror of
https://github.com/django/django.git
synced 2025-07-04 09:49:12 +00:00
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
This commit is contained in:
parent
115d4170ae
commit
c03a030fd3
@ -9,6 +9,18 @@ if HAS_GDAL: from django.contrib.gis.gdal import OGRGeometry, SpatialReference,
|
|||||||
|
|
||||||
class GEOSTest(unittest.TestCase):
|
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):
|
def test01a_wkt(self):
|
||||||
"Testing WKT output."
|
"Testing WKT output."
|
||||||
for g in wkt_out:
|
for g in wkt_out:
|
||||||
@ -498,16 +510,10 @@ class GEOSTest(unittest.TestCase):
|
|||||||
p1 = fromstr(hex)
|
p1 = fromstr(hex)
|
||||||
self.assertEqual(4326, p1.srid)
|
self.assertEqual(4326, p1.srid)
|
||||||
|
|
||||||
# However, when HEX is exported, the SRID information is lost
|
# In GEOS 3.0.0rc1-4 when the EWKB and/or HEXEWKB is exported,
|
||||||
# and set to -1. Essentially, the 'E' of the EWKB is not
|
# the SRID information is lost and set to -1 -- this is not a
|
||||||
# encoded in HEX by the GEOS C library unless the GEOSWKBWriter
|
# problem on the 3.0.0 version (another reason to upgrade).
|
||||||
# method is used. GEOS 3.0.0 will not encode -1 in the HEX
|
exp_srid = self.null_srid
|
||||||
# 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
|
|
||||||
|
|
||||||
p2 = fromstr(p1.hex)
|
p2 = fromstr(p1.hex)
|
||||||
self.assertEqual(exp_srid, p2.srid)
|
self.assertEqual(exp_srid, p2.srid)
|
||||||
@ -745,12 +751,14 @@ class GEOSTest(unittest.TestCase):
|
|||||||
tgeoms.extend(get_geoms(polygons, 3084))
|
tgeoms.extend(get_geoms(polygons, 3084))
|
||||||
tgeoms.extend(get_geoms(multipolygons, 900913))
|
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:
|
for geom in tgeoms:
|
||||||
s1, s2 = cPickle.dumps(geom), pickle.dumps(geom)
|
s1, s2 = cPickle.dumps(geom), pickle.dumps(geom)
|
||||||
g1, g2 = cPickle.loads(s1), pickle.loads(s2)
|
g1, g2 = cPickle.loads(s1), pickle.loads(s2)
|
||||||
for tmpg in (g1, g2):
|
for tmpg in (g1, g2):
|
||||||
self.assertEqual(geom, tmpg)
|
self.assertEqual(geom, tmpg)
|
||||||
self.assertEqual(geom.srid, tmpg.srid)
|
if not no_srid: self.assertEqual(geom.srid, tmpg.srid)
|
||||||
|
|
||||||
def suite():
|
def suite():
|
||||||
s = unittest.TestSuite()
|
s = unittest.TestSuite()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user