mirror of
https://github.com/OSURoboticsClub/Rover_2017_2018.git
synced 2025-11-08 18:21:15 +00:00
Move new_image function to helper
This commit is contained in:
@@ -1,3 +1,8 @@
|
|||||||
|
import PIL.Image
|
||||||
|
|
||||||
class MapHelper(object):
|
class MapHelper(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def new_image(self, width, height):
|
||||||
|
return PIL.Image.new('RGBA', (width, height))
|
||||||
|
|||||||
@@ -26,9 +26,9 @@ import urllib2
|
|||||||
from io import StringIO, BytesIO
|
from io import StringIO, BytesIO
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
import PIL.Image
|
|
||||||
import PIL.ImageDraw
|
import PIL.ImageDraw
|
||||||
import signing
|
import signing
|
||||||
|
import MapHelper
|
||||||
|
|
||||||
#####################################
|
#####################################
|
||||||
# Constants
|
# Constants
|
||||||
@@ -55,6 +55,7 @@ class GMapsStitcher(object):
|
|||||||
def __init__(self, width, height,
|
def __init__(self, width, height,
|
||||||
latitude, longitude, zoom,
|
latitude, longitude, zoom,
|
||||||
maptype, radius_meters=None, num_tiles=4, debug=False):
|
maptype, radius_meters=None, num_tiles=4, debug=False):
|
||||||
|
helper = MapHelper.MapHelper()
|
||||||
self.latitude = latitude
|
self.latitude = latitude
|
||||||
self.longitude = longitude
|
self.longitude = longitude
|
||||||
self.start_latitude = latitude
|
self.start_latitude = latitude
|
||||||
@@ -65,7 +66,7 @@ class GMapsStitcher(object):
|
|||||||
self.maptype = maptype
|
self.maptype = maptype
|
||||||
self.radius_meters = radius_meters
|
self.radius_meters = radius_meters
|
||||||
self.num_tiles = num_tiles
|
self.num_tiles = num_tiles
|
||||||
self.display_image = self._new_image(width, height)
|
self.display_image = helper.new_image(width, height)
|
||||||
self.debug = debug
|
self.debug = debug
|
||||||
|
|
||||||
# Get the big image here
|
# Get the big image here
|
||||||
@@ -87,9 +88,6 @@ class GMapsStitcher(object):
|
|||||||
string_builder += "LatLong of Southeast Corner: %4f, %4f\n" % (self.southeast)
|
string_builder += "LatLong of Southeast Corner: %4f, %4f\n" % (self.southeast)
|
||||||
return string_builder
|
return string_builder
|
||||||
|
|
||||||
def _new_image(self, width, height):
|
|
||||||
return PIL.Image.new('RGBA', (width, height))
|
|
||||||
|
|
||||||
def _fast_round(self, value, precision):
|
def _fast_round(self, value, precision):
|
||||||
return int(value * 10 ** precision) / 10. ** precision
|
return int(value * 10 ** precision) / 10. ** precision
|
||||||
|
|
||||||
@@ -155,7 +153,7 @@ class GMapsStitcher(object):
|
|||||||
sin_lat = math.sin(math.radians(self.latitude))
|
sin_lat = math.sin(math.radians(self.latitude))
|
||||||
lat_pixels = _EARTHPIX - _PIXRAD * math.log((1+sin_lat)/(1-sin_lat))/2
|
lat_pixels = _EARTHPIX - _PIXRAD * math.log((1+sin_lat)/(1-sin_lat))/2
|
||||||
self.big_size = self.num_tiles * _TILESIZE
|
self.big_size = self.num_tiles * _TILESIZE
|
||||||
big_image = self._new_image(self.big_size, self.big_size)
|
big_image = self.helper.new_image(self.big_size, self.big_size)
|
||||||
|
|
||||||
for j in range(self.num_tiles):
|
for j in range(self.num_tiles):
|
||||||
lon = self._pixels_to_lon(j, lon_pixels)
|
lon = self._pixels_to_lon(j, lon_pixels)
|
||||||
|
|||||||
Reference in New Issue
Block a user