Skip to content

Commit

Permalink
Replaced proj4 testing by a regex
Browse files Browse the repository at this point in the history
  • Loading branch information
claudep committed Mar 8, 2013
1 parent cbfb8ed commit 8a92139
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions django/contrib/gis/tests/test_spatialrefsys.py
Expand Up @@ -2,6 +2,7 @@
from django.contrib.gis.gdal import HAS_GDAL
from django.contrib.gis.tests.utils import (no_mysql, oracle, postgis,
spatialite, HAS_SPATIALREFSYS, SpatialRefSys)
from django.utils import six
from django.utils import unittest


Expand All @@ -10,9 +11,8 @@
'auth_srid' : 4326,
# Only the beginning, because there are differences depending on installed libs
'srtext' : 'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84"',
'proj4' : ['+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs ',
# +ellps=WGS84 has been removed in the 4326 proj string in proj-4.8
'+proj=longlat +datum=WGS84 +no_defs '],
# +ellps=WGS84 has been removed in the 4326 proj string in proj-4.8
'proj4_re' : r'\+proj=longlat (\+ellps=WGS84 )?\+datum=WGS84 \+no_defs ',
'spheroid' : 'WGS 84', 'name' : 'WGS 84',
'geographic' : True, 'projected' : False, 'spatialite' : True,
'ellipsoid' : (6378137.0, 6356752.3, 298.257223563), # From proj's "cs2cs -le" and Wikipedia (semi-minor only)
Expand All @@ -22,8 +22,9 @@
'auth_name' : ('EPSG', False),
'auth_srid' : 32140,
'srtext' : 'PROJCS["NAD83 / Texas South Central",GEOGCS["NAD83",DATUM["North_American_Datum_1983",SPHEROID["GRS 1980"',
'proj4' : ['+proj=lcc +lat_1=30.28333333333333 +lat_2=28.38333333333333 +lat_0=27.83333333333333 +lon_0=-99 +x_0=600000 +y_0=4000000 +ellps=GRS80 +datum=NAD83 +units=m +no_defs ',
'+proj=lcc +lat_1=30.28333333333333 +lat_2=28.38333333333333 +lat_0=27.83333333333333 +lon_0=-99 +x_0=600000 +y_0=4000000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs '],
'proj4_re' : r'\+proj=lcc \+lat_1=30.28333333333333 \+lat_2=28.38333333333333 \+lat_0=27.83333333333333 '
r'\+lon_0=-99 \+x_0=600000 \+y_0=4000000 \+ellps=GRS80 '
r'(\+datum=NAD83 |\+towgs84=0,0,0,0,0,0,0)?\+units=m \+no_defs ',
'spheroid' : 'GRS 1980', 'name' : 'NAD83 / Texas South Central',
'geographic' : False, 'projected' : True, 'spatialite' : False,
'ellipsoid' : (6378137.0, 6356752.31414, 298.257222101), # From proj's "cs2cs -le" and Wikipedia (semi-minor only)
Expand Down Expand Up @@ -54,7 +55,7 @@ def test01_retrieve(self):
# No proj.4 and different srtext on oracle backends :(
if postgis:
self.assertTrue(srs.wkt.startswith(sd['srtext']))
self.assertTrue(srs.proj4text in sd['proj4'])
six.assertRegex(self, srs.proj4text, sd['proj4_re'])

@no_mysql
def test02_osr(self):
Expand All @@ -73,7 +74,7 @@ def test02_osr(self):
# Testing the SpatialReference object directly.
if postgis or spatialite:
srs = sr.srs
self.assertTrue(srs.proj4 in sd['proj4'])
six.assertRegex(self, srs.proj4, sd['proj4_re'])
# No `srtext` field in the `spatial_ref_sys` table in SpatiaLite
if not spatialite:
self.assertTrue(srs.wkt.startswith(sd['srtext']))
Expand Down

0 comments on commit 8a92139

Please sign in to comment.