# encoding=utf-8 # pykarta/maps/layers/tilesets_modestmaps.py # Copyright 2013, 2014, Trinity College # Last modified: 5 September 2014 from tilesets_base import tilesets, MapTilesetRaster tilesets.append(MapTilesetRaster('modestmaps-bluemarble', url_template='http://s3.amazonaws.com/com.modestmaps.bluemarble/{z}-r{y}-c{x}.jpg', attribution=u"NASA", zoom_min=0, zoom_max=9, ))
class MapTilesetBing(MapTilesetRaster): def __init__(self, key, metadata_url=None, **kwargs): MapTilesetRaster.__init__(self, key, **kwargs) self.metadata_url = metadata_url def online_init(self): url = self.metadata_url.replace("{api_key}", self.api_key) response = simple_urlopen(url, extra_headers=self.extra_headers) metadata = json.load(response) print "Bing metadata:", json.dumps(metadata, indent=4, separators=(',', ': ')) resource = metadata['resourceSets'][0]['resources'][0] url_template = resource['imageUrl'].replace("{subdomain}","{s}").replace("{culture}","en-us") print "Bing URL template:", url_template self.set_url_template(url_template) self.subdomains = resource['imageUrlSubdomains'] self.zoom_min = resource['zoomMin'] self.zoom_max = resource['zoomMax'] #print "Bing zoom levels: %d thru %d" % (self.zoom_min, self.zoom_max) self.attribution = surface_from_file_data(simple_urlopen(metadata['brandLogoUri']).read()) for our_layer_key, bing_layer_key in ( ('road', 'Road'), ('aerial', 'Aerial'), ('aerial-with-labels', 'AerialWithLabels') ): tilesets.append(MapTilesetBing('bing-%s' % our_layer_key, metadata_url='http://dev.virtualearth.net/REST/v1/Imagery/Metadata/%s?key={api_key}' % bing_layer_key, attribution="Bing", api_key_name="bing" ))
# http://wiki.openstreetmap.org/wiki/Tile_servers # See http://wiki.openstreetmap.org/wiki/TMS # See http://www.openstreetmap.org/copyright (attribution requirements) # from tilesets_base import tilesets, MapTilesetRaster #----------------------------------------------------------------------------- # Default rendering from Openstreetmap.org #----------------------------------------------------------------------------- tilesets.append( MapTilesetRaster( 'osm-default', url_template='http://tile.openstreetmap.org/{z}/{x}/{y}.png', attribution=u"Map Data: © OpenStreetMap contributors", zoom_max=19, transparent_color=(241, 238, 232), saturation=1.2, )) # https://osm.rrze.fau.de/ # Double-resolution rendering of the default style tilesets.append( MapTilesetRaster( 'osm-default-hd', #url_template='http://a.osm.rrze.fau.de/osmhd/{z}/{x}/{y}.png', url_template='tiles/osm-default-hd/{z}/{x}/{y}.png', attribution=u"© OpenStreetMap contributors", zoom_max=19, transparent_color=(242, 239, 233),
# encoding=utf-8 # pykarta/maps/layers/tilesets_arcgis.py # Copyright 2013, 2014, Trinity College # Last modified: 3 September 2014 # # http://www.esri.com/software/arcgis/arcgis-online-map-and-geoservices/map-services # http://services.arcgisonline.com/ # from tilesets_base import tilesets, MapTilesetRaster tilesets.append(MapTilesetRaster('arcgis-usa-topo', url_template='http://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer/tile/{z}/{y}/{x}', zoom_min=9, zoom_max=15, # This attribution applies to zoom levels 0 thru 8 (which we have disabled). #attribution="© 2013 National Geographic Society, i-cubed" attribution="USGS" )) tilesets.append(MapTilesetRaster('arcgis-world-imagery', url_template='http://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', zoom_min=0, zoom_max=19, attribution="Esri, DigitalGlobe, GeoEye, i-cubed, USDA, USGS, AEX, Getmapping, Aerogrid, IGN, IGP, swisstopo, and the GIS User Community" )) tilesets.append(MapTilesetRaster('arcgis-world-reference-overlay', url_template='http://services.arcgisonline.com/ArcGIS/rest/services/Reference/World_Reference_Overlay/MapServer/tile/{z}/{y}/{x}', zoom_min=0, zoom_max=13, attribution="Esri, DigitalGlobe, GeoEye, i-cubed, USDA, USGS, AEX, Getmapping, Aerogrid, IGN, IGP, swisstopo, and the GIS User Community" ))
# If area in square pixels is greater than that of a 100x100 pixel square, area = area * scale * scale if area > 10000: center = self.scale_point(center, scale) draw_centered_label(ctx, center[0], center[1], text, style=self.label_style) dedup.add(text) tilesets.append( MapTilesetVector( 'osm-vector-landuse', tile_class=MapOsmLanduseTile, url_template="tiles/osm-vector-landuse/{z}/{x}/{y}.geojson", attribution=u"Map © OpenStreetMap contributors", zoom_min=10, )) #----------------------------------------------------------------------------- class MapOsmWaterwaysTile(MapGeoJSONTile): clip = 5 styles = { "river": { 'line-color': (0.53, 0.80, 0.98), 'line-width': (11,0.5, 16, 7.0), }, "stream": {
# # http://wiki.openstreetmap.org/wiki/Tile_servers # See http://wiki.openstreetmap.org/wiki/TMS # See http://www.openstreetmap.org/copyright (attribution requirements) # from tilesets_base import tilesets, MapTilesetRaster #----------------------------------------------------------------------------- # Default rendering from Openstreetmap.org #----------------------------------------------------------------------------- tilesets.append(MapTilesetRaster('osm-default', url_template='http://tile.openstreetmap.org/{z}/{x}/{y}.png', attribution=u"Map Data: © OpenStreetMap contributors", zoom_max=19, transparent_color=(241,238,232), saturation=1.2, )) # https://osm.rrze.fau.de/ # Double-resolution rendering of the default style tilesets.append(MapTilesetRaster('osm-default-hd', #url_template='http://a.osm.rrze.fau.de/osmhd/{z}/{x}/{y}.png', url_template='tiles/osm-default-hd/{z}/{x}/{y}.png', attribution=u"© OpenStreetMap contributors", zoom_max=19, transparent_color=(242,239,233), saturation=1.2, ))
# encoding=utf-8 # pykarta/maps/layers/tilesets_modestmaps.py # Copyright 2013, 2014, Trinity College # Last modified: 5 September 2014 from tilesets_base import tilesets, MapTilesetRaster tilesets.append( MapTilesetRaster( 'modestmaps-bluemarble', url_template= 'http://s3.amazonaws.com/com.modestmaps.bluemarble/{z}-r{y}-c{x}.jpg', attribution=u"NASA", zoom_min=0, zoom_max=9, ))
# encoding=utf-8 # pykarta/maps/layers/tilesets_arcgis.py # Copyright 2013, 2014, Trinity College # Last modified: 3 September 2014 # # http://www.esri.com/software/arcgis/arcgis-online-map-and-geoservices/map-services # http://services.arcgisonline.com/ # from tilesets_base import tilesets, MapTilesetRaster tilesets.append( MapTilesetRaster( 'arcgis-usa-topo', url_template= 'http://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer/tile/{z}/{y}/{x}', zoom_min=9, zoom_max=15, # This attribution applies to zoom levels 0 thru 8 (which we have disabled). #attribution="© 2013 National Geographic Society, i-cubed" attribution="USGS")) tilesets.append( MapTilesetRaster( 'arcgis-world-imagery', url_template= 'http://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', zoom_min=0, zoom_max=19, attribution= "Esri, DigitalGlobe, GeoEye, i-cubed, USDA, USGS, AEX, Getmapping, Aerogrid, IGN, IGP, swisstopo, and the GIS User Community" )) tilesets.append(
style = self.styles.get(landuse, { 'fill-color': (0.90, 0.90, 0.90) }) return style def draw2(self, ctx, scale): dedup = self.dedup for id, area, center, text in self.polygon_labels: if not text in dedup: # If area in square pixels is greater than that of a 100x100 pixel square, area = area * scale * scale if area > 10000: center = self.scale_point(center, scale) draw_centered_label(ctx, center[0], center[1], text, style=self.label_style) dedup.add(text) tilesets.append(MapTilesetVector('osm-vector-landuse', tile_class=MapOsmLanduseTile, url_template="tiles/osm-vector-landuse/{z}/{x}/{y}.geojson", attribution=u"Map © OpenStreetMap contributors", zoom_min=10, )) #----------------------------------------------------------------------------- class MapOsmWaterwaysTile(MapGeoJSONTile): clip = 5 styles = { "river": { 'line-color': (0.53, 0.80, 0.98), 'line-width': (11,0.5, 16, 7.0), }, "stream": { 'line-color': (0.53, 0.80, 0.98), 'line-width': (11,0.25, 16, 3.0),
if house_number and street: # not None and not blank self.labels.append((center, house_number, street)) def choose_polygon_style(self, properties): return {"line-color": (0.0, 0.0, 0.0), "line-width": 0.25} def draw2(self, ctx, scale): zoom = self.zoom + math.log(scale, 2.0) show_street = zoom >= 17.9 for center, house_number, street in self.labels: center = self.scale_point(center, scale) if show_street: text = "%s %s" % (house_number, street) else: text = house_number pykarta.draw.centered_label(ctx, center[0], center[1], text, style={'font-size': 8}) tilesets.append( MapTilesetVector( 'parcels-pykarta', tile_class=MapParcelsTile, url_template="tiles/parcels/{z}/{x}/{y}.geojson", zoom_min=14, zoom_max=16, ))
from tilesets_base import tilesets, MapTilesetRaster, MapTilesetWMS # MassGIS WMS server # http://giswebservices.massgis.state.ma.us/geoserver/wms?service=WMS&version=1.1.1&request=GetCapabilities for name, layers, image_format, transparent in ( ('usgs-topos', 'massgis:GISDATA.IMG_USGSQUADM', 'image/jpeg', False), ('urban-boundaries', 'massgis:GISDATA.MA2000URBBND_POLY', 'image/png', True), ('fishing', 'massgis:GISDATA.OFBA_PT', 'image/png', True), ): tilesets.append( MapTilesetWMS( 'massgis-%s' % name, url_template= 'http://giswebservices.massgis.state.ma.us/geoserver/wms', layers=layers, image_format=image_format, transparent=transparent, )) # Arcgis server for MassGIS for name, layers, zoom_min, zoom_max in ( ("l3parcels", "MassGIS_Level3_Parcels", 15, 18), ("orthos-199X", "BW_Orthos_Tile_Package", 0, 19), ("orthos-2001", "orthos2001_tile_package", 0, 19), ("orthos-2005", "orthos2005_tile_package", 0, 19), ("orthos-2009", "coq0809_from_sids_package", 0, 19), ("orthos-2014", "USGS_Orthos_2013_2014", 0, 20), ): tilesets.append(