Simplified union GIS tests with equals() rather than equals_exact().
This commit is contained in:
parent
21322f9271
commit
f24eea3b69
|
@ -485,8 +485,5 @@ class GISFunctionsTests(TestCase):
|
||||||
def test_union(self):
|
def test_union(self):
|
||||||
geom = Point(-95.363151, 29.763374, srid=4326)
|
geom = Point(-95.363151, 29.763374, srid=4326)
|
||||||
ptown = City.objects.annotate(union=functions.Union('point', geom)).get(name='Dallas')
|
ptown = City.objects.annotate(union=functions.Union('point', geom)).get(name='Dallas')
|
||||||
tol = 0.00001
|
expected = fromstr('MULTIPOINT(-96.801611 32.782057,-95.363151 29.763374)', srid=4326)
|
||||||
# Undefined ordering
|
self.assertTrue(expected.equals(ptown.union))
|
||||||
expected1 = fromstr('MULTIPOINT(-96.801611 32.782057,-95.363151 29.763374)', srid=4326)
|
|
||||||
expected2 = fromstr('MULTIPOINT(-95.363151 29.763374,-96.801611 32.782057)', srid=4326)
|
|
||||||
self.assertTrue(expected1.equals_exact(ptown.union, tol) or expected2.equals_exact(ptown.union, tol))
|
|
||||||
|
|
|
@ -858,8 +858,7 @@ class GeoQuerySetTest(TestCase):
|
||||||
"""
|
"""
|
||||||
tx = Country.objects.get(name='Texas').mpoly
|
tx = Country.objects.get(name='Texas').mpoly
|
||||||
# Houston, Dallas -- Ordering may differ depending on backend or GEOS version.
|
# Houston, Dallas -- Ordering may differ depending on backend or GEOS version.
|
||||||
union1 = fromstr('MULTIPOINT(-96.801611 32.782057,-95.363151 29.763374)')
|
union = GEOSGeometry('MULTIPOINT(-96.801611 32.782057,-95.363151 29.763374)')
|
||||||
union2 = fromstr('MULTIPOINT(-95.363151 29.763374,-96.801611 32.782057)')
|
|
||||||
qs = City.objects.filter(point__within=tx)
|
qs = City.objects.filter(point__within=tx)
|
||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
qs.aggregate(Union('name'))
|
qs.aggregate(Union('name'))
|
||||||
|
@ -868,9 +867,8 @@ class GeoQuerySetTest(TestCase):
|
||||||
# an aggregate method on a spatial column)
|
# an aggregate method on a spatial column)
|
||||||
u1 = qs.aggregate(Union('point'))['point__union']
|
u1 = qs.aggregate(Union('point'))['point__union']
|
||||||
u2 = qs.order_by('name').aggregate(Union('point'))['point__union']
|
u2 = qs.order_by('name').aggregate(Union('point'))['point__union']
|
||||||
tol = 0.00001
|
self.assertTrue(union.equals(u1))
|
||||||
self.assertTrue(union1.equals_exact(u1, tol) or union2.equals_exact(u1, tol))
|
self.assertTrue(union.equals(u2))
|
||||||
self.assertTrue(union1.equals_exact(u2, tol) or union2.equals_exact(u2, tol))
|
|
||||||
qs = City.objects.filter(name='NotACity')
|
qs = City.objects.filter(name='NotACity')
|
||||||
self.assertIsNone(qs.aggregate(Union('point'))['point__union'])
|
self.assertIsNone(qs.aggregate(Union('point'))['point__union'])
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue