| changeset 29 | cc9b7e14412b |
| parent 0 | 0d40e90630ef |
| 28:b758351d191f | 29:cc9b7e14412b |
|---|---|
1 import unittest |
1 import unittest |
2 from django.contrib.gis.db.backend import SpatialBackend |
2 |
3 from django.db import connection |
|
3 from django.contrib.gis.tests.utils import mysql, no_mysql, oracle, postgis, spatialite |
4 from django.contrib.gis.tests.utils import mysql, no_mysql, oracle, postgis, spatialite |
4 if not mysql: |
|
5 from django.contrib.gis.models import SpatialRefSys |
|
6 |
5 |
7 test_srs = ({'srid' : 4326, |
6 test_srs = ({'srid' : 4326, |
8 'auth_name' : ('EPSG', True), |
7 'auth_name' : ('EPSG', True), |
9 'auth_srid' : 4326, |
8 'auth_srid' : 4326, |
10 'srtext' : 'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]]', |
9 'srtext' : 'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]]', |
26 'ellipsoid' : (6378137.0, 6356752.31414, 298.257222101), # From proj's "cs2cs -le" and Wikipedia (semi-minor only) |
25 'ellipsoid' : (6378137.0, 6356752.31414, 298.257222101), # From proj's "cs2cs -le" and Wikipedia (semi-minor only) |
27 'eprec' : (1, 5, 10), |
26 'eprec' : (1, 5, 10), |
28 }, |
27 }, |
29 ) |
28 ) |
30 |
29 |
31 if SpatialBackend.postgis: |
30 if oracle: |
32 major, minor1, minor2 = SpatialBackend.version |
31 from django.contrib.gis.db.backends.oracle.models import SpatialRefSys |
33 POSTGIS_14 = major >=1 and minor1 >= 4 |
32 elif postgis: |
33 from django.contrib.gis.db.backends.postgis.models import SpatialRefSys |
|
34 elif spatialite: |
|
35 from django.contrib.gis.db.backends.spatialite.models import SpatialRefSys |
|
34 |
36 |
35 class SpatialRefSysTest(unittest.TestCase): |
37 class SpatialRefSysTest(unittest.TestCase): |
36 |
38 |
37 @no_mysql |
39 @no_mysql |
38 def test01_retrieve(self): |
40 def test01_retrieve(self): |
50 |
52 |
51 self.assertEqual(sd['auth_srid'], srs.auth_srid) |
53 self.assertEqual(sd['auth_srid'], srs.auth_srid) |
52 |
54 |
53 # No proj.4 and different srtext on oracle backends :( |
55 # No proj.4 and different srtext on oracle backends :( |
54 if postgis: |
56 if postgis: |
55 if POSTGIS_14: |
57 if connection.ops.spatial_version >= (1, 4, 0): |
56 srtext = sd['srtext14'] |
58 srtext = sd['srtext14'] |
57 else: |
59 else: |
58 srtext = sd['srtext'] |
60 srtext = sd['srtext'] |
59 self.assertEqual(srtext, srs.wkt) |
61 self.assertEqual(srtext, srs.wkt) |
60 self.assertEqual(sd['proj4'], srs.proj4text) |
62 self.assertEqual(sd['proj4'], srs.proj4text) |
77 if postgis or spatialite: |
79 if postgis or spatialite: |
78 srs = sr.srs |
80 srs = sr.srs |
79 self.assertEqual(sd['proj4'], srs.proj4) |
81 self.assertEqual(sd['proj4'], srs.proj4) |
80 # No `srtext` field in the `spatial_ref_sys` table in SpatiaLite |
82 # No `srtext` field in the `spatial_ref_sys` table in SpatiaLite |
81 if not spatialite: |
83 if not spatialite: |
82 if POSTGIS_14: |
84 if connection.ops.spatial_version >= (1, 4, 0): |
83 srtext = sd['srtext14'] |
85 srtext = sd['srtext14'] |
84 else: |
86 else: |
85 srtext = sd['srtext'] |
87 srtext = sd['srtext'] |
86 self.assertEqual(srtext, srs.wkt) |
88 self.assertEqual(srtext, srs.wkt) |
87 |
89 |