Fixed to fit PEP

This commit is contained in:
Chris Pham
2018-01-20 13:57:11 -08:00
parent 1bd9af00f2
commit a37e894605

View File

@@ -31,13 +31,15 @@ import PIL.Image
#####################################
# Constants
#####################################
<<<<<<< 1bd9af00f206c528febfe9b024e50b8bd4ee73fb
<<<<<<< 666f522bf5947794d802e8cbbf221ac004fc4eed
fp = open('key', w)
_KEY = fp.read().rstrip()
fp.close()
=======
=======
_KEYS = []
>>>>>>> Fixed to fit PEP
file_pointer = open('key', 'w')
_KEY = file_pointer.read().rstrip()
for i in file_pointer:
_KEYS.append(file_pointer.readline().rstrip())
file_pointer.close()
>>>>>>> fixed fp naming conventions
@@ -50,7 +52,7 @@ _TILESIZE = 640
# Fastest rate at which we can download tiles without paying
_GRABRATE = 4
# Pixel Radius of Earth for calculations
_pixrad = _EARTHPIX / math.pi
_PIXRAD = _EARTHPIX / math.pi
class GMapsStitcher(object):
@@ -86,7 +88,7 @@ class GMapsStitcher(object):
urlbase += 'center=%f%f&zoom=%d&maptype=%s&size=%dx%d&format=jpg&key=%s'
# 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'
# Tile Image object
@@ -113,12 +115,12 @@ class GMapsStitcher(object):
def _pixels_to_lon(self, iterator, lon_pixels):
# Magic Lines, no idea
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):
# Magic Lines
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)
def fetch_tiles(self,):
@@ -130,10 +132,10 @@ class GMapsStitcher(object):
if self.radius_meters is not None:
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))
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_image = self._new_image(big_size, big_size)
@@ -145,5 +147,4 @@ class GMapsStitcher(object):
tile = self._grab_tile(lon, lat)
big_image.paste(tile, (j * _TILESIZE, k * _TILESIZE))
big_image.save("buttholes.jpg")
big_image.save("testimage.jpg")