From 10c9dc8451a582e67e8475e2bf161054191f1d02 Mon Sep 17 00:00:00 2001 From: Chris Pham Date: Sat, 3 Feb 2018 14:02:23 -0800 Subject: [PATCH] Make static functions and self reference for helper --- ground_station/resources/core/MapHelper.py | 11 ++++++----- ground_station/resources/core/mapping.py | 5 +++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/ground_station/resources/core/MapHelper.py b/ground_station/resources/core/MapHelper.py index 8c4218c..86724fc 100644 --- a/ground_station/resources/core/MapHelper.py +++ b/ground_station/resources/core/MapHelper.py @@ -1,14 +1,15 @@ import PIL.Image class MapHelper(object): - def __init__(self): - return - def new_image(self, width, height): + @staticmethod + def new_image(width, height): return PIL.Image.new('RGBA', (width, height)) - def fast_round(self, value, precision): + @staticmethod + def fast_round(value, precision): return int(value * 10 ** precision) / 10. ** precision - def pixels_to_degrees(self, pixels, zoom): + @staticmethod + def pixels_to_degrees(pixels, zoom): return pixels * 2 ** (21-zoom) \ No newline at end of file diff --git a/ground_station/resources/core/mapping.py b/ground_station/resources/core/mapping.py index 012e4bd..4c44881 100644 --- a/ground_station/resources/core/mapping.py +++ b/ground_station/resources/core/mapping.py @@ -55,7 +55,7 @@ class GMapsStitcher(object): def __init__(self, width, height, latitude, longitude, zoom, maptype, radius_meters=None, num_tiles=4, debug=False): - helper = MapHelper.MapHelper() + self.helper = MapHelper.MapHelper() self.latitude = latitude self.longitude = longitude self.start_latitude = latitude @@ -66,8 +66,9 @@ class GMapsStitcher(object): self.maptype = maptype self.radius_meters = radius_meters self.num_tiles = num_tiles - self.display_image = helper.new_image(width, height) + self.display_image = self.helper.new_image(width, height) self.debug = debug + # Get the big image here self._fetch()