From 37303e3a95020e41aadea474e2d6e95c543f5af0 Mon Sep 17 00:00:00 2001 From: Chris Pham Date: Sat, 3 Feb 2018 13:53:21 -0800 Subject: [PATCH] Moved fast_round to helper --- ground_station/resources/core/MapHelper.py | 3 +++ ground_station/resources/core/mapping.py | 9 +++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ground_station/resources/core/MapHelper.py b/ground_station/resources/core/MapHelper.py index 1d90360..66a99fe 100644 --- a/ground_station/resources/core/MapHelper.py +++ b/ground_station/resources/core/MapHelper.py @@ -6,3 +6,6 @@ class MapHelper(object): def new_image(self, width, height): return PIL.Image.new('RGBA', (width, height)) + + def fast_round(self, value, precision): + return int(value * 10 ** precision) / 10. ** precision diff --git a/ground_station/resources/core/mapping.py b/ground_station/resources/core/mapping.py index d76cbff..9b51f9a 100644 --- a/ground_station/resources/core/mapping.py +++ b/ground_station/resources/core/mapping.py @@ -88,9 +88,6 @@ class GMapsStitcher(object): string_builder += "LatLong of Southeast Corner: %4f, %4f\n" % (self.southeast) return string_builder - def _fast_round(self, value, precision): - return int(value * 10 ** precision) / 10. ** precision - def _pixels_to_degrees(self, pixels, zoom): return pixels * 2 ** (21-zoom) @@ -105,7 +102,7 @@ class GMapsStitcher(object): urlbase += 'center=%.4f,%.4f&zoom=%d&maptype=%s&size=%dx%d&format=png&key=%s' # Fill the formatting - specs = self._fast_round(latitude, 4), self._fast_round(longitude, 4), self.zoom, self.maptype, _TILESIZE, _TILESIZE, _KEYS[0] + specs = self.helper.fast_round(latitude, _DEGREE_PRECISION), self.helper.fast_round(longitude, _DEGREE_PRECISION), self.zoom, self.maptype, _TILESIZE, _TILESIZE, _KEYS[0] filename = 'Resources/Maps/' + ('%.4f_%.4f_%d_%s_%d_%d_%s' % specs) + '.png' # Tile Image object @@ -141,8 +138,8 @@ class GMapsStitcher(object): def fetch_tiles(self): # cap floats to precision amount - self.latitude = self._fast_round(self.latitude, _DEGREE_PRECISION) - self.longitude = self._fast_round(self.longitude, _DEGREE_PRECISION) + self.latitude = self.helper.fast_round(self.latitude, _DEGREE_PRECISION) + self.longitude = self.helper.fast_round(self.longitude, _DEGREE_PRECISION) # number of tiles required to go from center latitude to desired radius in meters if self.radius_meters is not None: