diff options
| author | Claude Paroz <claude@2xlibre.net> | 2015-01-17 15:43:02 +0100 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2015-01-17 15:44:49 +0100 |
| commit | aff0e54d511f55dbcdbae6a79c237fbb3edc9973 (patch) | |
| tree | 2ff4aeb7c2426c2747bb4b3052382626ffaf50c0 | |
| parent | 1b0365ad34151f266fe3faecb4edf31a51a8642c (diff) | |
Fixed PostGIS crosses lookup and added crosses test
| -rw-r--r-- | django/contrib/gis/db/backends/base/features.py | 4 | ||||
| -rw-r--r-- | django/contrib/gis/db/backends/postgis/operations.py | 2 | ||||
| -rw-r--r-- | django/contrib/gis/tests/geoapp/tests.py | 15 |
3 files changed, 20 insertions, 1 deletions
diff --git a/django/contrib/gis/db/backends/base/features.py b/django/contrib/gis/db/backends/base/features.py index f43724dcf7..ecefde493b 100644 --- a/django/contrib/gis/db/backends/base/features.py +++ b/django/contrib/gis/db/backends/base/features.py @@ -42,6 +42,10 @@ class BaseSpatialFeatures(object): return 'contained' in self.connection.ops.gis_operators @property + def supports_crosses_lookup(self): + return 'crosses' in self.connection.ops.gis_operators + + @property def supports_dwithin_lookup(self): return 'dwithin' in self.connection.ops.gis_operators diff --git a/django/contrib/gis/db/backends/postgis/operations.py b/django/contrib/gis/db/backends/postgis/operations.py index 44cab5d12a..2255897f2f 100644 --- a/django/contrib/gis/db/backends/postgis/operations.py +++ b/django/contrib/gis/db/backends/postgis/operations.py @@ -71,7 +71,7 @@ class PostGISOperations(BaseSpatialOperations, DatabaseOperations): 'contains_properly': PostGISOperator(func='ST_ContainsProperly'), 'coveredby': PostGISOperator(func='ST_CoveredBy', geography=True), 'covers': PostGISOperator(func='ST_Covers', geography=True), - 'crosses': PostGISOperator(func='ST_Crosses)'), + 'crosses': PostGISOperator(func='ST_Crosses'), 'disjoint': PostGISOperator(func='ST_Disjoint'), 'equals': PostGISOperator(func='ST_Equals'), 'intersects': PostGISOperator(func='ST_Intersects', geography=True), diff --git a/django/contrib/gis/tests/geoapp/tests.py b/django/contrib/gis/tests/geoapp/tests.py index 8d20ef843a..0dc4ce269d 100644 --- a/django/contrib/gis/tests/geoapp/tests.py +++ b/django/contrib/gis/tests/geoapp/tests.py @@ -286,6 +286,21 @@ class GeoLookupTest(TestCase): self.assertEqual(1, len(qs)) self.assertEqual('Texas', qs[0].name) + @skipUnlessDBFeature("supports_crosses_lookup") + def test_crosses_lookup(self): + Track.objects.create( + name='Line1', + line=LineString([(-95, 29), (-60, 0)]) + ) + self.assertEqual( + Track.objects.filter(line__crosses=LineString([(-95, 0), (-60, 29)])).count(), + 1 + ) + self.assertEqual( + Track.objects.filter(line__crosses=LineString([(-95, 30), (0, 30)])).count(), + 0 + ) + @skipUnlessDBFeature("supports_left_right_lookups") def test_left_right_lookups(self): "Testing the 'left' and 'right' lookup types." |
