Fixed PostGIS crosses lookup and added crosses test
This commit is contained in:
parent
1b0365ad34
commit
aff0e54d51
|
@ -41,6 +41,10 @@ class BaseSpatialFeatures(object):
|
||||||
def supports_contained_lookup(self):
|
def supports_contained_lookup(self):
|
||||||
return 'contained' in self.connection.ops.gis_operators
|
return 'contained' in self.connection.ops.gis_operators
|
||||||
|
|
||||||
|
@property
|
||||||
|
def supports_crosses_lookup(self):
|
||||||
|
return 'crosses' in self.connection.ops.gis_operators
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def supports_dwithin_lookup(self):
|
def supports_dwithin_lookup(self):
|
||||||
return 'dwithin' in self.connection.ops.gis_operators
|
return 'dwithin' in self.connection.ops.gis_operators
|
||||||
|
|
|
@ -71,7 +71,7 @@ class PostGISOperations(BaseSpatialOperations, DatabaseOperations):
|
||||||
'contains_properly': PostGISOperator(func='ST_ContainsProperly'),
|
'contains_properly': PostGISOperator(func='ST_ContainsProperly'),
|
||||||
'coveredby': PostGISOperator(func='ST_CoveredBy', geography=True),
|
'coveredby': PostGISOperator(func='ST_CoveredBy', geography=True),
|
||||||
'covers': PostGISOperator(func='ST_Covers', geography=True),
|
'covers': PostGISOperator(func='ST_Covers', geography=True),
|
||||||
'crosses': PostGISOperator(func='ST_Crosses)'),
|
'crosses': PostGISOperator(func='ST_Crosses'),
|
||||||
'disjoint': PostGISOperator(func='ST_Disjoint'),
|
'disjoint': PostGISOperator(func='ST_Disjoint'),
|
||||||
'equals': PostGISOperator(func='ST_Equals'),
|
'equals': PostGISOperator(func='ST_Equals'),
|
||||||
'intersects': PostGISOperator(func='ST_Intersects', geography=True),
|
'intersects': PostGISOperator(func='ST_Intersects', geography=True),
|
||||||
|
|
|
@ -286,6 +286,21 @@ class GeoLookupTest(TestCase):
|
||||||
self.assertEqual(1, len(qs))
|
self.assertEqual(1, len(qs))
|
||||||
self.assertEqual('Texas', qs[0].name)
|
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")
|
@skipUnlessDBFeature("supports_left_right_lookups")
|
||||||
def test_left_right_lookups(self):
|
def test_left_right_lookups(self):
|
||||||
"Testing the 'left' and 'right' lookup types."
|
"Testing the 'left' and 'right' lookup types."
|
||||||
|
|
Loading…
Reference in New Issue