mirror of
https://github.com/OSURoboticsClub/Rover_2017_2018.git
synced 2025-11-08 18:21:15 +00:00
Fixed to fit PEP
This commit is contained in:
@@ -31,8 +31,10 @@ import PIL.Image
|
|||||||
#####################################
|
#####################################
|
||||||
# Constants
|
# Constants
|
||||||
#####################################
|
#####################################
|
||||||
|
_KEYS = []
|
||||||
file_pointer = open('key', 'w')
|
file_pointer = open('key', 'w')
|
||||||
_KEY = file_pointer.read().rstrip()
|
for i in file_pointer:
|
||||||
|
_KEYS.append(file_pointer.readline().rstrip())
|
||||||
file_pointer.close()
|
file_pointer.close()
|
||||||
|
|
||||||
# Number of pixels in half the earth's circumference at zoom = 21
|
# Number of pixels in half the earth's circumference at zoom = 21
|
||||||
@@ -44,7 +46,7 @@ _TILESIZE = 640
|
|||||||
# Fastest rate at which we can download tiles without paying
|
# Fastest rate at which we can download tiles without paying
|
||||||
_GRABRATE = 4
|
_GRABRATE = 4
|
||||||
# Pixel Radius of Earth for calculations
|
# Pixel Radius of Earth for calculations
|
||||||
_pixrad = _EARTHPIX / math.pi
|
_PIXRAD = _EARTHPIX / math.pi
|
||||||
|
|
||||||
|
|
||||||
class GMapsStitcher(object):
|
class GMapsStitcher(object):
|
||||||
@@ -80,7 +82,7 @@ class GMapsStitcher(object):
|
|||||||
urlbase += 'center=%f%f&zoom=%d&maptype=%s&size=%dx%d&format=jpg&key=%s'
|
urlbase += 'center=%f%f&zoom=%d&maptype=%s&size=%dx%d&format=jpg&key=%s'
|
||||||
|
|
||||||
# Fill the formatting
|
# Fill the formatting
|
||||||
specs = latitude, longitude, self.zoom, self.maptype, _TILESIZE, _KEY
|
specs = latitude, longitude, self.zoom, self.maptype, _TILESIZE, _KEYS[0]
|
||||||
filename = 'Resources/Maps/' + ('%f_%f_%d_%s_%d_%d_%s' % specs) + '.jpg'
|
filename = 'Resources/Maps/' + ('%f_%f_%d_%s_%d_%d_%s' % specs) + '.jpg'
|
||||||
|
|
||||||
# Tile Image object
|
# Tile Image object
|
||||||
@@ -107,12 +109,12 @@ class GMapsStitcher(object):
|
|||||||
def _pixels_to_lon(self, iterator, lon_pixels):
|
def _pixels_to_lon(self, iterator, lon_pixels):
|
||||||
# Magic Lines, no idea
|
# Magic Lines, no idea
|
||||||
degrees = self._pixels_to_degrees(((iterator) - self.num_tiles / 2) * _TILESIZE, self.zoom)
|
degrees = self._pixels_to_degrees(((iterator) - self.num_tiles / 2) * _TILESIZE, self.zoom)
|
||||||
return math.degrees((lon_pixels + degrees - _EARTHPIX) / _pixrad)
|
return math.degrees((lon_pixels + degrees - _EARTHPIX) / _PIXRAD)
|
||||||
|
|
||||||
def _pixels_to_lat(self, iterator, lat_pixels):
|
def _pixels_to_lat(self, iterator, lat_pixels):
|
||||||
# Magic Lines
|
# Magic Lines
|
||||||
degree = self._pixels_to_degrees((iterator - self.num_tiles / 2) * _TILESIZE, self.zoom)
|
degree = self._pixels_to_degrees((iterator - self.num_tiles / 2) * _TILESIZE, self.zoom)
|
||||||
temp = math.atan(math.exp(((lat_pixels + degree) - _EARTHPIX))/ _pixrad)
|
temp = math.atan(math.exp(((lat_pixels + degree) - _EARTHPIX))/ _PIXRAD)
|
||||||
return math.degrees(math.pi / 2 - 2 * temp)
|
return math.degrees(math.pi / 2 - 2 * temp)
|
||||||
|
|
||||||
def fetch_tiles(self,):
|
def fetch_tiles(self,):
|
||||||
@@ -124,10 +126,10 @@ class GMapsStitcher(object):
|
|||||||
if self.radius_meters is not None:
|
if self.radius_meters is not None:
|
||||||
self.num_tiles = int(round(2*self._pixels_to_meters / (_TILESIZE / 2. / self.radius_meters)))
|
self.num_tiles = int(round(2*self._pixels_to_meters / (_TILESIZE / 2. / self.radius_meters)))
|
||||||
|
|
||||||
lon_pixels = _EARTHPIX + self.longitude * math.radians(_pixrad)
|
lon_pixels = _EARTHPIX + self.longitude * math.radians(_PIXRAD)
|
||||||
|
|
||||||
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
|
||||||
big_size = self.num_tiles * _TILESIZE
|
big_size = self.num_tiles * _TILESIZE
|
||||||
|
|
||||||
big_image = self._new_image(big_size, big_size)
|
big_image = self._new_image(big_size, big_size)
|
||||||
@@ -139,5 +141,4 @@ class GMapsStitcher(object):
|
|||||||
tile = self._grab_tile(lon, lat)
|
tile = self._grab_tile(lon, lat)
|
||||||
big_image.paste(tile, (j * _TILESIZE, k * _TILESIZE))
|
big_image.paste(tile, (j * _TILESIZE, k * _TILESIZE))
|
||||||
|
|
||||||
big_image.save("buttholes.jpg")
|
big_image.save("testimage.jpg")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user