def meta(id, **kwargs): meta = get_metadata(id, **kwargs) with app.app_context(): meta['tiles'] = [ '{}/{{z}}/{{x}}/{{y}}.png'.format( url_for('meta', id=id, _external=True, **kwargs)) ] return jsonify(meta)
def wmts(id, **kwargs): with app.app_context(): return render_template('wmts.xml', id=get_id(id, **kwargs), meta=get_metadata(id, **kwargs), base_url=url_for('meta', id=id, _external=True, **kwargs), **kwargs), 200, { 'Content-Type': 'application/xml' }
def tile(id, z, x, y, **kwargs): meta = get_metadata(id, **kwargs) tile = read_tile(id, Tile(x, y, z), **kwargs) headers = { 'Content-Type': 'image/png', } if meta['meta'].get('oinMetadataUrl'): headers['X-OIN-Metadata-URL'] = meta['meta'].get('oinMetadataUrl') if meta['meta'].get('acquisitionStart') or meta['meta'].get( 'acquisitionEnd'): start = meta['meta'].get('acquisitionStart') end = meta['meta'].get('acquisitionEnd') if start and end: start = arrow.get(start) end = arrow.get(end) capture_range = '{}-{}'.format(start.format('M/D/YYYY'), end.format('M/D/YYYY')) headers['X-OIN-Acquisition-Start'] = start.format( 'YYYY-MM-DDTHH:mm:ssZZ') headers['X-OIN-Acquisition-End'] = end.format( 'YYYY-MM-DDTHH:mm:ssZZ') elif start: start = arrow.get(start) capture_range = start.format('M/D/YYYY') headers['X-OIN-Acquisition-Start'] = start.format( 'YYYY-MM-DDTHH:mm:ssZZ') elif end: end = arrow.get(end) capture_range = end.format('M/D/YYYY') headers['X-OIN-Acquisition-End'] = end.format( 'YYYY-MM-DDTHH:mm:ssZZ') # Bing Maps-compatibility (JOSM uses this) headers['X-VE-TILEMETA-CaptureDatesRange'] = capture_range if meta['meta'].get('provider'): headers['X-OIN-Provider'] = unicodedata.normalize( 'NFKD', meta['meta'].get('provider')).encode('ascii', 'ignore') if meta['meta'].get('platform'): headers['X-OIN-Platform'] = unicodedata.normalize( 'NFKD', meta['meta'].get('platform')).encode('ascii', 'ignore') return tile, 200, headers