mirror of
https://github.com/OSURoboticsClub/Rover_2017_2018.git
synced 2025-11-08 18:21:15 +00:00
Working updates and fetching, starting on zoom functionality
This commit is contained in:
@@ -65,6 +65,17 @@ class GMapsStitcher(object):
|
||||
self.maptype = maptype
|
||||
self.radius_meters = radius_meters
|
||||
self.num_tiles = num_tiles
|
||||
self.display_image = self._new_image(width, height)
|
||||
self.image_zoom = 1.0
|
||||
|
||||
|
||||
# Get the big image here
|
||||
self._fetch()
|
||||
middle = self.big_image.size[0] // 2
|
||||
self.left_x = middle
|
||||
self.upper_y = middle
|
||||
|
||||
self.update()
|
||||
|
||||
def _new_image(self, width, height):
|
||||
return PIL.Image.new('RGB', (width, height))
|
||||
@@ -147,3 +158,38 @@ class GMapsStitcher(object):
|
||||
big_image.paste(tile, (j * _TILESIZE, k * _TILESIZE))
|
||||
|
||||
big_image.save("testimage.jpg")
|
||||
|
||||
west = self._pixels_to_lon(0, lon_pixels)
|
||||
east = self._pixels_to_lon(self.num_tiles - 1, lat_pixels)
|
||||
|
||||
north = self._pixels_to_lat(0, lat_pixels)
|
||||
south = self._pixels_to_lat(self.num_tiles - 1, lat_pixels)
|
||||
return big_image, (north, west), (south, east)
|
||||
|
||||
def get_image(self):
|
||||
return self.display_image
|
||||
|
||||
def move(self, dx, dy):
|
||||
self._constrain_x(dx)
|
||||
self._constrain_y(dy)
|
||||
self.update()
|
||||
|
||||
def _constrain_x(self, diff):
|
||||
new_value = self.left_x - diff
|
||||
return new_value if (new_value > 0 and (new_value < self.big_image.size[0] - self.width)) else self.left_x
|
||||
|
||||
def _constrain_y(self, diff):
|
||||
new_value = self.upper_y - diff
|
||||
return new_value if new_value > 0 and new_value < self.big_image.size[0] - self.height else self.upper_y
|
||||
|
||||
def update(self):
|
||||
self.display_image.paste(self.big_image, (-self.left_x, -self.upper_y))
|
||||
self.display_image.resize((self.image_zoom, self.image_zoom))
|
||||
|
||||
def _fetch(self):
|
||||
self.big_image, self.northwest, self.southeast = self.fetch_tiles()
|
||||
print self.northwest
|
||||
|
||||
def useZoom(self, new_zoom):
|
||||
self.image_zoom = new_zoom
|
||||
self.update()
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import mapping
|
||||
|
||||
obj = mapping.GMapsStitcher(1, 1, 44.57078, -123.275998, 18, 'terrain', None, 20)
|
||||
obj = mapping.GMapsStitcher(2000, 2000, 44.57078, -123.275998, 18, 'terrain', None, 20)
|
||||
|
||||
obj.fetch_tiles()
|
||||
obj.useZoom(1.2)
|
||||
|
||||
obj.display_image.save("display_image.jpg")
|
||||
|
||||
Reference in New Issue
Block a user