Django

Code

Changeset 7463

Show
Ignore:
Timestamp:
04/25/08 18:52:41 (2 months ago)
Author:
jbronn
Message:

gis: Fixed GEOS tests for those still running 3.0.0RC4.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/gis/django/contrib/gis/tests/test_geos.py

    r7404 r7463  
    99 
    1010class GEOSTest(unittest.TestCase): 
     11 
     12    @property 
     13    def null_srid(self): 
     14        """ 
     15        Returns the proper null SRID depending on the GEOS version. 
     16        See the comments in `test15_srid` for more details.  
     17        """ 
     18        info = geos_version_info() 
     19        if info['version'] == '3.0.0' and info['release_candidate']: 
     20            return -1 
     21        else: 
     22            return None 
    1123 
    1224    def test01a_wkt(self): 
     
    499511        self.assertEqual(4326, p1.srid) 
    500512 
    501         # However, when HEX is exported, the SRID information is lost 
    502         # and set to -1.  Essentially, the 'E' of the EWKB is not 
    503         # encoded in HEX by the GEOS C library unless the GEOSWKBWriter 
    504         # method is used.  GEOS 3.0.0 will not encode -1 in the HEX 
    505         # as is done in the release candidates. 
    506         info = geos_version_info() 
    507         if info['version'] == '3.0.0' and info['release_candidate']: 
    508             exp_srid = -1 
    509         else: 
    510             exp_srid = None 
     513        # In GEOS 3.0.0rc1-4  when the EWKB and/or HEXEWKB is exported, 
     514        # the SRID information is lost and set to -1 -- this is not a 
     515        # problem on the 3.0.0 version (another reason to upgrade).   
     516        exp_srid = self.null_srid 
    511517 
    512518        p2 = fromstr(p1.hex) 
     
    745751        tgeoms.extend(get_geoms(polygons, 3084)) 
    746752        tgeoms.extend(get_geoms(multipolygons, 900913)) 
    747          
     753 
     754        # The SRID won't be exported in GEOS 3.0 release candidates. 
     755        no_srid = self.null_srid == -1  
    748756        for geom in tgeoms: 
    749757            s1, s2 = cPickle.dumps(geom), pickle.dumps(geom) 
     
    751759            for tmpg in (g1, g2): 
    752760                self.assertEqual(geom, tmpg) 
    753                 self.assertEqual(geom.srid, tmpg.srid) 
     761                if not no_srid: self.assertEqual(geom.srid, tmpg.srid) 
    754762 
    755763def suite():