summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Bronn <jbronn@gmail.com>2008-04-22 18:14:29 +0000
committerJustin Bronn <jbronn@gmail.com>2008-04-22 18:14:29 +0000
commitf49c770b2dc40a4e23c6fe5f3ced62ba80a8502c (patch)
tree6a15a56e5669d1a7865d2d8e13bfe0285f10daed
parente1d84dd4fb3b53905e8bbc92a8233b9b65b7a0bd (diff)
gis: Updated KML tests for PostGIS 1.3.3 and GDAL tests to not perform `close_rings` test for versions 1.4.1 and below.
git-svn-id: http://code.djangoproject.com/svn/django/branches/gis@7441 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/contrib/gis/tests/geoapp/tests.py14
-rw-r--r--django/contrib/gis/tests/test_gdal_geom.py10
2 files changed, 21 insertions, 3 deletions
diff --git a/django/contrib/gis/tests/geoapp/tests.py b/django/contrib/gis/tests/geoapp/tests.py
index df2cfce80d..be4eb2ac7f 100644
--- a/django/contrib/gis/tests/geoapp/tests.py
+++ b/django/contrib/gis/tests/geoapp/tests.py
@@ -1,6 +1,7 @@
import os, unittest
from models import Country, City, State, Feature
from django.contrib.gis import gdal
+from django.contrib.gis.db.backend import SpatialBackend
from django.contrib.gis.geos import *
from django.contrib.gis.measure import Distance
from django.contrib.gis.tests.utils import no_oracle, no_postgis, oracle, postgis
@@ -123,11 +124,22 @@ class GeoModelTest(unittest.TestCase):
qs = City.objects.all()
self.assertRaises(TypeError, qs.kml, 'name')
+ # The reference KML depends on the version of PostGIS used
+ # (the output stopped including altitude in 1.3.3).
+ major, minor1, minor2 = SpatialBackend.version
+ ref_kml1 = '<Point><coordinates>-104.609252,38.255001,0</coordinates></Point>'
+ ref_kml2 = '<Point><coordinates>-104.609252,38.255001</coordinates></Point>'
+ if major == 1:
+ if minor1 > 3 or (minor1 == 3 and minor2 >= 3): ref_kml = ref_kml2
+ else: ref_kml = ref_kml1
+ else:
+ ref_kml = ref_kml2
+
# Ensuring the KML is as expected.
ptown1 = City.objects.kml('point', precision=9).get(name='Pueblo')
ptown2 = City.objects.kml(precision=9).get(name='Pueblo')
for ptown in [ptown1, ptown2]:
- self.assertEqual('<Point><coordinates>-104.609252,38.255001,0</coordinates></Point>', ptown.kml)
+ self.assertEqual(ref_kml, ptown.kml)
def test03b_gml(self):
"Testing GML output from the database using GeoManager.gml()."
diff --git a/django/contrib/gis/tests/test_gdal_geom.py b/django/contrib/gis/tests/test_gdal_geom.py
index aa4e325116..37fa2e7071 100644
--- a/django/contrib/gis/tests/test_gdal_geom.py
+++ b/django/contrib/gis/tests/test_gdal_geom.py
@@ -1,6 +1,7 @@
import unittest
from django.contrib.gis.gdal import OGRGeometry, OGRGeomType, \
- OGRException, OGRIndexError, SpatialReference, CoordTransform
+ OGRException, OGRIndexError, SpatialReference, CoordTransform, \
+ gdal_version
from django.contrib.gis.tests.geometries import *
class OGRGeomTest(unittest.TestCase):
@@ -196,7 +197,12 @@ class OGRGeomTest(unittest.TestCase):
self.fail('Should have raised an OGRException!')
print "\nEND - expecting IllegalArgumentException; safe to ignore.\n"
- # Closing the rings
+ # Closing the rings -- doesn't work on GDAL versions 1.4.1 and below:
+ # http://trac.osgeo.org/gdal/ticket/1673
+ major, minor1, minor2 = gdal_version().split('.')
+ if major == '1':
+ iminor1 = int(minor1)
+ if iminor1 < 4 or (iminor1 == 4 and minor2.startswith('1')): return
poly.close_rings()
self.assertEqual(10, poly.point_count) # Two closing points should've been added
self.assertEqual(OGRGeometry('POINT(2.5 2.5)'), poly.centroid)