summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorJustin Bronn <jbronn@gmail.com>2008-04-26 00:36:15 +0000
committerJustin Bronn <jbronn@gmail.com>2008-04-26 00:36:15 +0000
commit5456919782e5cd0b885dd383d57e187a06148307 (patch)
tree7732d58287f29f05c3118a48e9208e78f03f1ac0 /django
parentc03a030fd3c74c8a03fa3fdfca08aec0ee6baa1e (diff)
gis: The `WKTAdaptor` needs the SRID for Oracle; now test geodetic `dwithin` lookups on Oracle.
git-svn-id: http://code.djangoproject.com/svn/django/branches/gis@7464 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
-rw-r--r--django/contrib/gis/db/backend/adaptor.py3
-rw-r--r--django/contrib/gis/tests/distapp/tests.py37
2 files changed, 28 insertions, 12 deletions
diff --git a/django/contrib/gis/db/backend/adaptor.py b/django/contrib/gis/db/backend/adaptor.py
index 1f01cb01e2..b2397e61dd 100644
--- a/django/contrib/gis/db/backend/adaptor.py
+++ b/django/contrib/gis/db/backend/adaptor.py
@@ -5,9 +5,10 @@ class WKTAdaptor(object):
"""
def __init__(self, geom):
self.wkt = geom.wkt
+ self.srid = geom.srid
def __eq__(self, other):
- return self.wkt == other.wkt
+ return self.wkt == other.wkt and self.srid == other.srid
def __str__(self):
return self.wkt
diff --git a/django/contrib/gis/tests/distapp/tests.py b/django/contrib/gis/tests/distapp/tests.py
index 3bedb19b4c..d1fe83ebc5 100644
--- a/django/contrib/gis/tests/distapp/tests.py
+++ b/django/contrib/gis/tests/distapp/tests.py
@@ -41,21 +41,36 @@ class DistanceTest(unittest.TestCase):
def test02_dwithin(self):
"Testing the `dwithin` lookup type."
- pnt = self.stx_pnt
- dists = [7000, D(km=7), D(mi=4.349)]
- for dist in dists:
+ # Distances -- all should be equal (except for the
+ # degree/meter pair in au_cities, that's somewhat
+ # approximate).
+ tx_dists = [7000, D(km=7), D(mi=4.349)]
+ au_dists = [(0.5, 32000), D(km=32), D(mi=19.884)]
+
+ # Expected cities for Australia and Texas.
+ tx_cities = ['Downtown Houston', 'Southside Place']
+ au_cities = ['Mittagong', 'Shellharbour', 'Thirroul', 'Wollongong']
+
+ for dist in tx_dists:
qs = SouthTexasCity.objects.filter(point__dwithin=(self.stx_pnt, dist))
- self.assertEqual(['Downtown Houston', 'Southside Place'], self.get_cities(qs))
+ self.assertEqual(tx_cities, self.get_cities(qs))
+
+ for dist in au_dists:
+ if isinstance(dist, D) and not oracle: type_error = True
+ else: type_error = False
- if isinstance(dist, D):
- # A TypeError should be raised when trying to pass Distance objects
- # into a DWithin query using a geodetic field.
- qs = AustraliaCity.objects.filter(point__dwithin=(self.au_pnt, dist))
+ if isinstance(dist, tuple):
+ if oracle: dist = dist[1]
+ else: dist = dist[0]
+
+ # Creating the query set.
+ qs = AustraliaCity.objects.filter(point__dwithin=(self.au_pnt, dist)).order_by('name')
+ if type_error:
+ # A TypeError should be raised on PostGIS when trying to pass
+ # Distance objects into a DWithin query using a geodetic field.
self.assertRaises(TypeError, qs.count)
else:
- # Actually using a distance value of 0.5 degrees.
- qs = AustraliaCity.objects.filter(point__dwithin=(self.au_pnt, 0.5)).order_by('name')
- self.assertEqual(['Mittagong', 'Shellharbour', 'Thirroul', 'Wollongong'], self.get_cities(qs))
+ self.assertEqual(au_cities, self.get_cities(qs))
def test03_distance_aggregate(self):
"Testing the `distance` GeoQuerySet method."