Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
from .map_provider import MapProvider
DEFAULT_URL = 'https://{username}.carto.com'
MAX_TILE_SIZE = 8192
class CartoProvider(MapProvider):
def __init__(self, username, api_key, map_id, server_url=DEFAULT_URL, attribution='© CARTO'):
super().__init__([server_url], attribution=attribution)
self.username = username
self.api_key = api_key
self.map_id = map_id
def do_prepare_url(self, url, tile_size, lon, lat, zoom, x, y):
return (url + '/api/v1/map/static/named/{template}/{tile_size}/{tile_size}.png?zoom={zoom}&lat={lat}&lon={lon}&api_key={api_key}').format(username=self.username, template=self.map_id, tile_size=tile_size, zoom=zoom, lat=lat, lon=lon, api_key=self.api_key)
def get_max_tile_size(self):
return MAX_TILE_SIZE
def should_retry(self):
True
from .map_provider import MapProvider
from .utils import tile_2_bbox
class WmsProvider(MapProvider):
def __init__(self, server_url='http://www.ign.es/wms-inspire/pnoa-ma?SERVICE=WMS&SRS=EPSG:4326&REQUEST=GETMAP&bbox={minx},{miny},{maxx},{maxy}&width=256&height=256&format=PNG&transparent=No&layers=OI.OrthoimageCoverage&VERSION=1.0', attribution=None):
super().__init__([server_url], attribution=attribution)
def do_prepare_url(self, url, tile_size, lon, lat, zoom, x, y):
minx, miny, maxx, maxy = tile_2_bbox(x, y, zoom)
return url.format(minx=minx, miny=miny, maxx=maxx, maxy=maxy)
def get_name(self):
return 'wms'
from .map_provider import MapProvider
class ZxyProvider(MapProvider):
def __init__(self, server_urls, attribution=None):
super().__init__(server_urls, attribution=attribution)
def do_prepare_url(self, url, tile_size, lon, lat, zoom, x, y):
return url.format(z=zoom, x=x, y=y)
def get_name(self):
return 'zxy'
from .map_provider import MapProvider
import mercantile
DEFAULT_URLS = [
"https://t0.ssl.ak.tiles.virtualearth.net/tiles/a{q}.jpeg?g=7863",
"https://t1.ssl.ak.tiles.virtualearth.net/tiles/a{q}.jpeg?g=7863",
]
class QuadkeyProvider(MapProvider):
def __init__(self, server_urls=DEFAULT_URLS, attribution=None):
super().__init__(server_urls, attribution=attribution)
def do_prepare_url(self, url, tile_size, lon, lat, zoom, x, y):
quadkey = mercantile.quadkey(x, y, zoom)
return url.format(q=quadkey)
def get_name(self):
return 'quadkey'
from .map_provider import MapProvider
DEFAULT_URLS = ['https://maps1.nyc.gov/tms/1.0.0/carto/basemap/{z}/{x}/{y}.jpg']
class TmsProvider(MapProvider):
def __init__(self, server_urls=DEFAULT_URLS, attribution=None):
super().__init__(server_urls, attribution=attribution)
def do_prepare_url(self, url, tile_size, lon, lat, zoom, x, y):
y = (2 ** zoom) - y - 1
return url.format(z=zoom, x=x, y=y)
def get_name(self):
return 'tms'