summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2015-01-23 22:45:57 +0100
committerClaude Paroz <claude@2xlibre.net>2015-04-22 19:54:17 +0200
commit44bdbbc316e4e0b2f5d8c7767d04924c9e00f2da (patch)
treeef9ad12dab9b23e19ba4fcb37e2a75f4462e27a9 /tests
parentd9ff5ef36d3f714736d633435d45f03eac9c17b5 (diff)
Added Spatialite support to GIS functions
Diffstat (limited to 'tests')
-rw-r--r--tests/gis_tests/distapp/tests.py6
-rw-r--r--tests/gis_tests/geoapp/test_functions.py22
2 files changed, 21 insertions, 7 deletions
diff --git a/tests/gis_tests/distapp/tests.py b/tests/gis_tests/distapp/tests.py
index f69b66a801..c59772a782 100644
--- a/tests/gis_tests/distapp/tests.py
+++ b/tests/gis_tests/distapp/tests.py
@@ -617,13 +617,15 @@ class DistanceFunctionsTests(TestCase):
len_m1 = 473504.769553813
len_m2 = 4617.668
- if connection.features.supports_distance_geodetic:
+ if connection.features.supports_length_geodetic:
qs = Interstate.objects.annotate(length=Length('path'))
tol = 2 if oracle else 3
self.assertAlmostEqual(len_m1, qs[0].length.m, tol)
+ # TODO: test with spheroid argument (True and False)
else:
# Does not support geodetic coordinate systems.
- self.assertRaises(ValueError, Interstate.objects.annotate(length=Length('path')))
+ with self.assertRaises(ValueError):
+ Interstate.objects.annotate(length=Length('path'))
# Now doing length on a projected coordinate system.
i10 = SouthTexasInterstate.objects.annotate(length=Length('path')).get(name='I-10')
diff --git a/tests/gis_tests/geoapp/test_functions.py b/tests/gis_tests/geoapp/test_functions.py
index 1ce722269c..fb2a88be09 100644
--- a/tests/gis_tests/geoapp/test_functions.py
+++ b/tests/gis_tests/geoapp/test_functions.py
@@ -172,15 +172,22 @@ class GISFunctionsTests(TestCase):
@skipUnlessDBFeature("has_Difference_function")
def test_difference(self):
geom = Point(5, 23, srid=4326)
- qs = Country.objects.annotate(difference=functions.Difference('mpoly', geom))
+ qs = Country.objects.annotate(diff=functions.Difference('mpoly', geom))
+ # For some reason SpatiaLite does something screwy with the Texas geometry here.
+ if spatialite:
+ qs = qs.exclude(name='Texas')
+
for c in qs:
- self.assertEqual(c.mpoly.difference(geom), c.difference)
+ self.assertEqual(c.mpoly.difference(geom), c.diff)
@skipUnlessDBFeature("has_Difference_function")
def test_difference_mixed_srid(self):
"""Testing with mixed SRID (Country has default 4326)."""
geom = Point(556597.4, 2632018.6, srid=3857) # Spherical mercator
qs = Country.objects.annotate(difference=functions.Difference('mpoly', geom))
+ # For some reason SpatiaLite does something screwy with the Texas geometry here.
+ if spatialite:
+ qs = qs.exclude(name='Texas')
for c in qs:
self.assertEqual(c.mpoly.difference(geom), c.difference)
@@ -220,7 +227,12 @@ class GISFunctionsTests(TestCase):
geom = Point(5, 23, srid=4326)
qs = Country.objects.annotate(inter=functions.Intersection('mpoly', geom))
for c in qs:
- self.assertEqual(c.mpoly.intersection(geom), c.inter)
+ if spatialite:
+ # When the intersection is empty, Spatialite returns None
+ expected = None
+ else:
+ expected = c.mpoly.intersection(geom)
+ self.assertEqual(c.inter, expected)
@skipUnlessDBFeature("has_MemSize_function")
def test_memsize(self):
@@ -416,8 +428,8 @@ class GISFunctionsTests(TestCase):
union=functions.Union('mpoly', geom),
)
- # XXX For some reason SpatiaLite does something screwey with the Texas geometry here. Also,
- # XXX it doesn't like the null intersection.
+ # For some reason SpatiaLite does something screwey with the Texas geometry here.
+ # Also, it doesn't like the null intersection.
if spatialite:
qs = qs.exclude(name='Texas')
else: