Skip to content

Commit b6ace56

Browse files
committed
Minor improvements related to style
1 parent c62bd0f commit b6ace56

File tree

5 files changed

+16
-17
lines changed

5 files changed

+16
-17
lines changed

rest_framework_gis/fields.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def from_native(self, value):
3838

3939
try:
4040
return GEOSGeometry(value)
41-
except (ValueError, GEOSException, OGRException, TypeError) as e:
41+
except (ValueError, GEOSException, OGRException, TypeError):
4242
raise ValidationError(_('Invalid format: string or unicode input unrecognized as WKT EWKT, and HEXEWKB.'))
4343

4444
return value

rest_framework_gis/filters.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ def get_filter_point(self, request):
118118
p = Point(x,y)
119119
return p
120120

121-
122121
def dist_to_deg(self, distance, latitude):
123122
"""
124123
distance = distance in meters
@@ -146,8 +145,7 @@ def dist_to_deg(self, distance, latitude):
146145
earthRadius = 6378160.0
147146
latitudeCorrection = 0.5 * (1 + cos(lat * pi / 180))
148147
return (distance / (earthRadius * latitudeCorrection) * rad2deg)
149-
150-
148+
151149
def filter_queryset(self, request, queryset, view):
152150
filter_field = getattr(view, 'distance_filter_field', None)
153151
convert_distance_input = getattr(view, 'distance_filter_convert_meters', False)

rest_framework_gis/tilenames.py

100644100755
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
#!/usr/bin/env python
2-
#-------------------------------------------------------
2+
# -------------------------------------------------------
33
# Translates between lat/long and the slippy-map tile
44
# numbering scheme
55
#
66
# http://wiki.openstreetmap.org/index.php/Slippy_map_tilenames
77
#
88
# Written by Oliver White, 2007
99
# This file is public-domain
10-
#-------------------------------------------------------
11-
from math import pi, atan, sinh, degrees, pow
10+
# -------------------------------------------------------
11+
from math import pi, atan, sinh, degrees, pow as math_pow
12+
1213

1314
def num_tiles(z):
14-
return(pow(2,z))
15+
return(math_pow(2,z))
1516

1617

1718
def lat_edges(y,z):

tests/django_restframework_gis_tests/tests.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -529,11 +529,11 @@ def test_DistanceToPointFilter_filtering(self):
529529

530530
# Filter parameters
531531
distance = 5000 #meters
532-
point_inside_ggpark = [ -122.49034881591797, 37.76949349270407 ]
533-
point_on_golden_gate_bridge = [ -122.47894, 37.8199 ]
534-
point_on_alcatraz = [-122.4222, 37.82667 ]
535-
point_on_treasure_island = [ -122.3692, 37.8244 ]
536-
point_on_angel_island = [ -122.4326, 37.86091 ]
532+
point_inside_ggpark = [-122.49034881591797, 37.76949349270407]
533+
point_on_golden_gate_bridge = [-122.47894, 37.8199]
534+
point_on_alcatraz = [-122.4222, 37.82667]
535+
point_on_treasure_island = [-122.3692, 37.8244]
536+
point_on_angel_island = [-122.4326, 37.86091]
537537

538538
url_params = '?dist=%0.4f&point=%0.4f,%0.4f&format=json' % (distance, point_on_alcatraz[0], point_on_alcatraz[1])
539539

@@ -634,20 +634,18 @@ def test_DistanceToPointFilter_filtering(self):
634634
ggpark.save()
635635

636636
# Make sure we only get back the ones within the distance
637-
response = self.client.get(self.location_within_distance_of_point_list_url + url_params)
637+
response = self.client.get('%s%s' % (self.location_within_distance_of_point_list_url, url_params))
638638
self.assertEqual(len(response.data['features']), 1)
639639
for result in response.data['features']:
640640
self.assertEqual(result['properties']['name'] in (treasure_island.name), True)
641641

642642
# Make sure we get back all the ones within the distance
643643
distance = 7000
644644
url_params = '?dist=%0.4f&point=%0.4f,%0.4f&format=json' % (distance, point_on_alcatraz[0], point_on_alcatraz[1])
645-
response = self.client.get(self.location_within_distance_of_point_list_url + url_params)
645+
response = self.client.get('%s%s' % (self.location_within_distance_of_point_list_url, url_params))
646646
self.assertEqual(len(response.data['features']), 2)
647647
for result in response.data['features']:
648648
self.assertEqual(result['properties']['name'] in (ggpark.name, treasure_island.name), True)
649-
650-
651649

652650
# Make sure we only get back the ones within the distance
653651
degrees = .05

tests/django_restframework_gis_tests/views.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ class GeojsonLocationOverlapsTileList(GeojsonLocationContainedInTileList):
6464

6565
geojson_location_overlaps_tile_list = GeojsonLocationOverlapsTileList.as_view()
6666

67+
6768
class GeojsonLocationWithinDistanceOfPointList(generics.ListAPIView):
6869
model = Location
6970
serializer_class = LocationGeoFeatureSerializer
@@ -74,6 +75,7 @@ class GeojsonLocationWithinDistanceOfPointList(generics.ListAPIView):
7475

7576
geojson_location_within_distance_of_point_list = GeojsonLocationWithinDistanceOfPointList.as_view()
7677

78+
7779
class GeojsonLocationWithinDegreesOfPointList(GeojsonLocationWithinDistanceOfPointList):
7880
distance_filter_convert_meters = False #Default setting
7981

0 commit comments

Comments
 (0)