geonode.thumbs.background ========================= .. py:module:: geonode.thumbs.background Attributes ---------- .. autoapisummary:: geonode.thumbs.background.logger geonode.thumbs.background.WMTS_TILEMATRIXSET_LEVELS Classes ------- .. autoapisummary:: geonode.thumbs.background.BaseThumbBackground geonode.thumbs.background.GenericWMSBackground geonode.thumbs.background.GenericXYZBackground geonode.thumbs.background.WikiMediaTileBackground geonode.thumbs.background.OSMTileBackground geonode.thumbs.background.GenericWMTSBackground Module Contents --------------- .. py:data:: logger .. py:class:: BaseThumbBackground(thumbnail_width: int, thumbnail_height: int, max_retries: int = 3, retry_delay: int = 1) Bases: :py:obj:`abc.ABC` Helper class that provides a standard way to create an ABC using inheritance. .. py:attribute:: thumbnail_width .. py:attribute:: thumbnail_height .. py:attribute:: max_retries .. py:attribute:: retry_delay .. py:method:: fetch(bbox: List, *args, **kwargs) -> Optional[PIL.Image.Image] :abstractmethod: Function fetching background image, based on the given BBOX. On error should raise an exception or return None. :param bbox: a dataset compliant BBOX: [west, east, south, north, CRS] .. py:class:: GenericWMSBackground(thumbnail_width: int, thumbnail_height: int, max_retries: int = 3, retry_delay: int = 1) Bases: :py:obj:`BaseThumbBackground` Helper class that provides a standard way to create an ABC using inheritance. .. py:attribute:: options .. py:attribute:: service_url .. py:attribute:: dataset_name .. py:attribute:: format .. py:attribute:: version .. py:attribute:: styles .. py:attribute:: srid .. py:method:: bbox_to_projection(bbox: List) Function converting BBOX to target projection system, keeping the order of the coordinates. To ensure no additional change is performed, conversion is based on top-left and bottom-right points conversion. :param bbox: a dataset compliant BBOX: [west, east, south, north, CRS] .. py:method:: fetch(bbox: List, *args, **kwargs) Function fetching background image, based on the given BBOX. On error should raise an exception or return None. :param bbox: a dataset compliant BBOX: [west, east, south, north, CRS] :param *args*: not used, kept for API compatibility :param **kargs**: not used, kept for API compatibility .. py:class:: GenericXYZBackground(thumbnail_width: int, thumbnail_height: int, max_retries: int = 3, retry_delay: int = 1) Bases: :py:obj:`BaseThumbBackground` Helper class that provides a standard way to create an ABC using inheritance. .. py:attribute:: options .. py:attribute:: url .. py:attribute:: tile_size .. py:attribute:: tms :value: False .. py:attribute:: crs :value: 'EPSG:3857' .. py:attribute:: _epsg3857_max_x :value: 20026376.39 .. py:attribute:: _epsg3857_max_y :value: 20048966.1 .. py:attribute:: _mercantile_bbox :value: None .. py:method:: point3857to4326(x, y) .. py:method:: point4326to3857(x, y) .. py:method:: bbox3857to4326(x_min, x_max, y_min, y_max) Function converting BBOX from EPSG:3857 to EPSG:4326, keeping the order of the coordinates. To ensure no additional change is performed, conversion is based on top-left and bottom-right points conversion. .. py:method:: bbox4326to3857(x_min, x_max, y_min, y_max) Function converting BBOX from EPSG:4326 to EPSG:3857, keeping the order of the coordinates. To ensure no additional change is performed, conversion is based on top-left and bottom-right points conversion. .. py:method:: fetch(bbox: List, zoom: int = None, *args, **kwargs) The function fetching tiles from a Slippy Map provider, composing them into a single image, and cropping it to match the given BBOX. Retrieval of each tile is repeated self.max_retries times, waiting self.retry_delay seconds between consecutive requests. :param bbox: bounding box of the background image, dataset compliant format: [west, east, south, north, CRS] :param zoom: zoom with which to retrieve Slippy Map's tiles (by default, it's calculated based on width, height) :return: None if the CRS is different from self.tiles_crs, or background Image .. py:method:: calculate_zoom() .. py:class:: WikiMediaTileBackground(thumbnail_width: int, thumbnail_height: int, max_retries: int = 3, retry_delay: int = 1) Bases: :py:obj:`GenericXYZBackground` Helper class that provides a standard way to create an ABC using inheritance. .. py:attribute:: url :value: 'https://maps.wikimedia.org/osm-intl/{z}/{x}/{y}.png' .. py:attribute:: tile_size :value: 256 .. py:class:: OSMTileBackground(thumbnail_width: int, thumbnail_height: int, max_retries: int = 3, retry_delay: int = 1) Bases: :py:obj:`GenericXYZBackground` Helper class that provides a standard way to create an ABC using inheritance. .. py:attribute:: url :value: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png' .. py:attribute:: tile_size :value: 256 .. py:data:: WMTS_TILEMATRIXSET_LEVELS :value: None .. py:class:: GenericWMTSBackground(thumbnail_width: int, thumbnail_height: int, max_retries: int = 3, retry_delay: int = 1) Bases: :py:obj:`BaseThumbBackground` Helper class that provides a standard way to create an ABC using inheritance. .. py:attribute:: options .. py:attribute:: levels .. py:attribute:: thumbnail_width .. py:attribute:: thumbnail_height .. py:method:: fetch(bbox: List, *args, **kwargs) Function fetching background image, based on the given BBOX. On error should raise an exception or return None. :param bbox: a dataset compliant BBOX: [west, east, south, north, CRS] .. py:method:: build_kvp_request(baseurl, layer, style, xyz) .. py:method:: build_request(xyz) .. py:method:: get_image_bbox_for_level(level, bbox) .. py:method:: get_tiles_coords(level, bbox) .. py:method:: get_level_for_targetpixelspan(target_pixelspan) .. py:method:: get_target_pixelspan(bbox) .. py:method:: get_levels_for_tilematrix()