def set_center_and_radius(self, lon, lat, radius=None, geographic=True): coords = Coord(lon, lat) box = Envelope(coords.x - radius, coords.y - radius, coords.x + radius, coords.y + radius) if geographic and not self.proj_obj.geographic: box = box.forward(self.proj_obj) self.zoom_to_box(box)
def set_center_and_radius(self,lon,lat,radius=None,geographic=True): coords = Coord(lon,lat) box = Envelope(coords.x - radius, coords.y - radius, coords.x + radius, coords.y + radius) if geographic and not self.proj_obj.geographic: box = box.forward(self.proj_obj) self.zoom_to_box(box)
def project(coords, projection): """Reproject coords from WGS84 to given projection""" bbox = Envelope(coords[0], coords[1]) return bbox.forward(projection)
from mapnik import render, Image, Map, load_map, Projection, Coord, Envelope projection = Projection("+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 " "+lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m " "+nadgrids=@null +no_defs +over") map = Map(600, 600) load_map(map, "simple.xml") bbox = Envelope(Coord(-179.999999975, -85.0511287776), Coord(179.999999975, 85.0511287776)) map.zoom_to_box(bbox.forward(projection)) image = Image(600, 600) render(map, image) with open('test.png', 'w') as image_file: image_file.write(image.tostring('png'))
def zoom_max(self): max_extent = Envelope(-179.99999694572804, -85.0511285163245, 179.99999694572804, 85.0511287798066) if not self.proj_obj.geographic: max_extent = max_extent.forward(self.proj_obj) self.zoom_to_box(max_extent)
def zoom_max(self): max_extent = Envelope(-179.99999694572804,-85.0511285163245,179.99999694572804,85.0511287798066) if not self.proj_obj.geographic: max_extent = max_extent.forward(self.proj_obj) self.zoom_to_box(max_extent)