From 16f76fad49699b346e15c0fdcfc2edcb814a0123 Mon Sep 17 00:00:00 2001 From: Chris Pham Date: Thu, 18 Jan 2018 13:00:53 -0800 Subject: [PATCH] added _pixels_to_lon helper --- ground_station/resources/core/mapping.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/ground_station/resources/core/mapping.py b/ground_station/resources/core/mapping.py index 64a0d67..a3c3698 100644 --- a/ground_station/resources/core/mapping.py +++ b/ground_station/resources/core/mapping.py @@ -1,8 +1,11 @@ ''' Mapping.py: Objected Orientated Google Maps for Python +Written by Chris Pham + Copyright OSURC, orginal code from GooMPy by Alec Singer and Simon D. Levy + This code is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the @@ -67,7 +70,7 @@ class GMapsStitcher(object): def _pixels_to_degrees(self, pixels, zoom): return pixels * 2 ** (21-zoom) - def _grab_tile(self, sleeptime): + def _grab_tile(self, sleeptime=0): # Make the url string for polling # GET request header gets appended to the string urlbase = 'https://maps.googleapis.com/maps/api/staticmap?' @@ -93,6 +96,13 @@ class GMapsStitcher(object): if not os.path.exists('Resources/Maps'): os.mkdir('Resources/Maps') tile_object.save(filename) + #Added to prevent timeouts on Google Servers + time.sleep(sleeptime) return tile_object - \ No newline at end of file + + def _pixels_to_lon(self, iterator, lon_pixels): + # Magic Lines, no idea + degrees = _pixels_to_degrees(((iterator) - self.num_tiles / 2) * _TILESIZE, self.zoom) + return math.degrees((lon_pixels + degrees - _EARTHPIX) / _pixrad) +