1# ================================================================= 2# 3# Authors: Francesco Bartoli <xbartolone@gmail.com> 4# 5# Copyright (c) 2020 Francesco Bartoli 6# 7# Permission is hereby granted, free of charge, to any person 8# obtaining a copy of this software and associated documentation 9# files (the "Software"), to deal in the Software without 10# restriction, including without limitation the rights to use, 11# copy, modify, merge, publish, distribute, sublicense, and/or sell 12# copies of the Software, and to permit persons to whom the 13# Software is furnished to do so, subject to the following 14# conditions: 15# 16# The above copyright notice and this permission notice shall be 17# included in all copies or substantial portions of the Software. 18# 19# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 21# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 23# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 24# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 25# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 26# OTHER DEALINGS IN THE SOFTWARE. 27# 28# ================================================================= 29 30import logging 31 32from pygeoapi.provider.base import ProviderGenericError 33 34LOGGER = logging.getLogger(__name__) 35 36 37class BaseTileProvider: 38 """generic Tile Provider ABC""" 39 40 def __init__(self, provider_def): 41 """ 42 Initialize object 43 44 :param provider_def: provider definition 45 46 :returns: pygeoapi.provider.tile.BaseTileProvider 47 """ 48 49 self.name = provider_def['name'] 50 self.data = provider_def['data'] 51 self.format_type = provider_def['format']['name'] 52 self.mimetype = provider_def['format']['mimetype'] 53 self.options = provider_def.get('options', None) 54 self.fields = {} 55 56 def get_layer(self): 57 """ 58 Get provider layer name 59 60 :returns: `string` of layer name 61 """ 62 63 def get_fields(self): 64 """ 65 Get provider field information (names, types) 66 67 :returns: `dict` of fields 68 """ 69 70 raise NotImplementedError() 71 72 def get_tiling_schemes(self): 73 """ 74 Get provider field information (names, types) 75 76 :returns: `dict` of tiling schemes 77 """ 78 79 raise NotImplementedError() 80 81 def get_tiles_service(self, baseurl, servicepath, dirpath, 82 tile_type): 83 """ 84 Gets tile service description 85 86 :param baseurl: base URL of endpoint 87 :param servicepath: base path of URL 88 :param dirpath: directory basepath (equivalent of URL) 89 :param tile_type: tile format type 90 91 :returns: `dict` of file listing or `dict` of GeoJSON item or raw file 92 """ 93 94 raise NotImplementedError() 95 96 def get_tiles(self, layer, tileset, z, y, x, format_): 97 """ 98 Gets tiles data 99 100 :param layer: tile layer 101 :param tileset: tile set 102 :param z: z index 103 :param y: y index 104 :param x: x index 105 :param format_: tile format type 106 107 :returns: `binary` of the tile 108 """ 109 110 raise NotImplementedError() 111 112 def get_metadata(self): 113 """ 114 Provide data/file metadata 115 116 :returns: `dict` of metadata construct (format 117 determined by provider/standard) 118 """ 119 120 raise NotImplementedError() 121 122 123class ProviderTileQueryError(ProviderGenericError): 124 """provider tile query error""" 125 pass 126 127 128class ProviderTileNotFoundError(ProviderGenericError): 129 """provider tile not found error""" 130 pass 131 132 133class ProviderTilesetIdNotFoundError(ProviderTileQueryError): 134 """provider tileset matrix query error""" 135 pass 136