Skip to content

Commit eb1d3e2

Browse files
author
Martin Pauly
committed
Replace get_coords() by coords in more places
1 parent 60d83b1 commit eb1d3e2

File tree

5 files changed

+13
-13
lines changed

5 files changed

+13
-13
lines changed

haystack/backends/elasticsearch_backend.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ def build_search_kwargs(self, query_string, sort_by=None, start_offset=0, end_of
296296
for field, direction in sort_by:
297297
if field == 'distance' and distance_point:
298298
# Do the geo-enabled sort.
299-
lng, lat = distance_point['point'].get_coords()
299+
lng, lat = distance_point['point'].coords
300300
sort_kwargs = {
301301
"_geo_distance": {
302302
distance_point['field']: [lng, lat],
@@ -455,7 +455,7 @@ def build_search_kwargs(self, query_string, sort_by=None, start_offset=0, end_of
455455
filters.append(within_filter)
456456

457457
if dwithin is not None:
458-
lng, lat = dwithin['point'].get_coords()
458+
lng, lat = dwithin['point'].coords
459459

460460
# NB: the 1.0.0 release of elasticsearch introduce an
461461
# incompatible change on the distance filter formating

haystack/backends/solr_backend.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def build_search_kwargs(self, query_string, sort_by=None, start_offset=0, end_of
173173
if sort_by is not None:
174174
if sort_by in ['distance asc', 'distance desc'] and distance_point:
175175
# Do the geo-enabled sort.
176-
lng, lat = distance_point['point'].get_coords()
176+
lng, lat = distance_point['point'].coords
177177
kwargs['sfield'] = distance_point['field']
178178
kwargs['pt'] = '%s,%s' % (lat, lng)
179179

@@ -290,7 +290,7 @@ def build_search_kwargs(self, query_string, sort_by=None, start_offset=0, end_of
290290

291291
if dwithin is not None:
292292
kwargs.setdefault('fq', [])
293-
lng, lat = dwithin['point'].get_coords()
293+
lng, lat = dwithin['point'].coords
294294
geofilt = '{!geofilt pt=%s,%s sfield=%s d=%s}' % (lat, lng, dwithin['field'], dwithin['distance'].km)
295295
kwargs['fq'].append(geofilt)
296296

haystack/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def _get_distance(self):
133133
if location_field is None:
134134
return None
135135

136-
lf_lng, lf_lat = location_field.get_coords()
136+
lf_lng, lf_lat = location_field.coords
137137
self._distance = Distance(km=geopy_distance.distance((po_lat, po_lng), (lf_lat, lf_lng)).km)
138138

139139
# We've either already calculated it or the backend returned it, so

haystack/utils/geo.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def ensure_wgs84(point):
4343

4444
if not new_point.srid:
4545
# It has no spatial reference id. Assume WGS-84.
46-
new_point.set_srid(WGS_84_SRID)
46+
new_point.srid = WGS_84_SRID
4747
elif new_point.srid != WGS_84_SRID:
4848
# Transform it to get to the right system.
4949
new_point.transform(WGS_84_SRID)
@@ -72,7 +72,7 @@ def generate_bounding_box(bottom_left, top_right):
7272
7373
The two-tuple is in the form ``((min_lat, min_lng), (max_lat, max_lng))``.
7474
"""
75-
west, lat_1 = bottom_left.get_coords()
76-
east, lat_2 = top_right.get_coords()
75+
west, lat_1 = bottom_left.coords
76+
east, lat_2 = top_right.coords
7777
min_lat, max_lat = min(lat_1, lat_2), max(lat_1, lat_2)
7878
return ((min_lat, west), (max_lat, east))

test_haystack/spatial/test_spatial.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def test_ensure_wgs84(self):
3737
self.assertEqual(std_pnt.y, 38.97127105172941)
3838

3939
orig_pnt = Point(-95.23592948913574, 38.97127105172941)
40-
orig_pnt.set_srid(2805)
40+
orig_pnt.srid = 2805
4141
std_pnt = ensure_wgs84(orig_pnt)
4242
self.assertEqual(orig_pnt.srid, 2805)
4343
self.assertEqual(std_pnt.srid, 4326)
@@ -96,8 +96,8 @@ def test_indexing(self):
9696
self.assertEqual(sqs.count(), 1)
9797
self.assertEqual(sqs[0].username, first.username)
9898
# Make sure we've got a proper ``Point`` object.
99-
self.assertAlmostEqual(sqs[0].location.get_coords()[0], first.longitude)
100-
self.assertAlmostEqual(sqs[0].location.get_coords()[1], first.latitude)
99+
self.assertAlmostEqual(sqs[0].location.coords[0], first.longitude)
100+
self.assertAlmostEqual(sqs[0].location.coords[1], first.latitude)
101101

102102
# Double-check, to make sure there was nothing accidentally copied
103103
# between instances.
@@ -106,8 +106,8 @@ def test_indexing(self):
106106
sqs = self.sqs.models(Checkin).filter(django_id=second.pk)
107107
self.assertEqual(sqs.count(), 1)
108108
self.assertEqual(sqs[0].username, second.username)
109-
self.assertAlmostEqual(sqs[0].location.get_coords()[0], second.longitude)
110-
self.assertAlmostEqual(sqs[0].location.get_coords()[1], second.latitude)
109+
self.assertAlmostEqual(sqs[0].location.coords[0], second.longitude)
110+
self.assertAlmostEqual(sqs[0].location.coords[1], second.latitude)
111111

112112
def test_within(self):
113113
self.assertEqual(self.sqs.all().count(), 10)

0 commit comments

Comments
 (0)