from mercantile import Tile try: from urllib.parse import urlparse, urlencode from urllib.request import urlopen, Request from urllib.error import HTTPError except ImportError: from urlparse import urlparse from urllib import urlencode from urllib2 import urlopen, Request, HTTPError from .catalogs import VirtualCatalog LOG = logging.getLogger(__name__) IMAGE_TRANSFORMATION = Image() IMAGE_FORMAT = Optimal() app = Flask("marblecutter-virtual") app.register_blueprint(bp) app.url_map.strict_slashes = False CORS(app, send_wildcard=True) @lru_cache() def make_catalog(args): if args.get("url", "") == "": raise NoCatalogAvailable() try: return VirtualCatalog(args["url"],
"normal": ELEVATION_CATALOG, "terrarium": ELEVATION_CATALOG, } DATA_BAND_COUNTS = {"imagery": 3} FORMATS = { "buffered_normal": PNG(), "hillshade": ColorRamp(), "imagery": PNG(), "normal": PNG(), "terrarium": PNG(), } RENDERERS = ["hillshade", "imagery", "buffered_normal", "normal", "terrarium"] TRANSFORMATIONS = { "buffered_normal": Normal(collar=2), "hillshade": HILLSHADE_TRANSFORMATION, "imagery": Image(), "normal": Normal(), "terrarium": Terrarium(), } logging.getLogger("botocore.credentials").setLevel(logging.WARNING) def make_prefix(): host = request.headers.get("X-Forwarded-Host", request.headers.get("Host", "")) # sniff for API Gateway if ".execute-api." in host and ".amazonaws.com" in host: return request.headers.get("X-Stage")