def test_pil(): image_manager = PILImageManager("RGB") osm = OSMManager(image_manager=image_manager) image, bounds = osm.create_osm_image((30, 31, -117, -116), 9) wh_ratio = float(image.size[0]) / image.size[1] image2 = image.resize((int(800 * wh_ratio), 800), Image.ANTIALIAS) del image image2.show()
def _get_osm_image(bbox, zoom, osm_base): # Just a wrapper for osm.createOSMImage to translate coordinate schemes try: from osmviz.manager import PILImageManager, OSMManager osm = OSMManager(cache="./tmp", image_manager=PILImageManager('RGB'), server=osm_base) (c1, c2) = bbox.corners() image, bounds = osm.create_osm_image((c1.lat, c2.lat, c1.lon, c2.lon), zoom) (lat1, lat2, lon1, lon2) = bounds return image, Extent(coords=(LatLon(lat1, lon1), LatLon(lat2, lon2))) except ImportError as e: logging.error( "ImportError: %s.\n" "The --osm option depends on the osmviz module, available from\n" "http://cbick.github.com/osmviz/\n\n" % str(e)) sys.exit(1)
""" This example demonstrates how to create and show a PIL image of OSM tiles patched together. """ from PIL import Image from osmviz.manager import OSMManager, PILImageManager image_manager = PILImageManager("RGB") osm = OSMManager(image_manager=image_manager) image, bounds = osm.create_osm_image((30, 35, -117, -112), 9) wh_ratio = float(image.size[0]) / image.size[1] image2 = image.resize((int(800 * wh_ratio), 800), Image.ANTIALIAS) del image image2.show()