mirror of
https://github.com/django/django.git
synced 2025-07-03 17:29:12 +00:00
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
This commit is contained in:
parent
e1d84dd4fb
commit
f49c770b2d
@ -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()."
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user