geonode.thumbs.background

Attributes

logger

WMTS_TILEMATRIXSET_LEVELS

Classes

BaseThumbBackground

Helper class that provides a standard way to create an ABC using

GenericWMSBackground

Helper class that provides a standard way to create an ABC using

GenericXYZBackground

Helper class that provides a standard way to create an ABC using

WikiMediaTileBackground

Helper class that provides a standard way to create an ABC using

OSMTileBackground

Helper class that provides a standard way to create an ABC using

GenericWMTSBackground

Helper class that provides a standard way to create an ABC using

Module Contents

geonode.thumbs.background.logger[source]
class geonode.thumbs.background.BaseThumbBackground(thumbnail_width: int, thumbnail_height: int, max_retries: int = 3, retry_delay: int = 1)[source]

Bases: abc.ABC

Helper class that provides a standard way to create an ABC using inheritance.

thumbnail_width[source]
thumbnail_height[source]
max_retries[source]
retry_delay[source]
abstract fetch(bbox: List, *args, **kwargs) PIL.Image.Image | None[source]

Function fetching background image, based on the given BBOX. On error should raise an exception or return None.

Parameters:

bbox – a dataset compliant BBOX: [west, east, south, north, CRS]

class geonode.thumbs.background.GenericWMSBackground(thumbnail_width: int, thumbnail_height: int, max_retries: int = 3, retry_delay: int = 1)[source]

Bases: BaseThumbBackground

Helper class that provides a standard way to create an ABC using inheritance.

options[source]
service_url[source]
dataset_name[source]
format[source]
version[source]
styles[source]
srid[source]
bbox_to_projection(bbox: List)[source]

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.

Parameters:

bbox – a dataset compliant BBOX: [west, east, south, north, CRS]

fetch(bbox: List, *args, **kwargs)[source]

Function fetching background image, based on the given BBOX. On error should raise an exception or return None.

Parameters:
  • bbox – a dataset compliant BBOX: [west, east, south, north, CRS]

  • args – not used, kept for API compatibility

  • kargs – not used, kept for API compatibility

class geonode.thumbs.background.GenericXYZBackground(thumbnail_width: int, thumbnail_height: int, max_retries: int = 3, retry_delay: int = 1)[source]

Bases: BaseThumbBackground

Helper class that provides a standard way to create an ABC using inheritance.

options[source]
url[source]
tile_size[source]
tms = False[source]
crs = 'EPSG:3857'[source]
_epsg3857_max_x = 20026376.39[source]
_epsg3857_max_y = 20048966.1[source]
_mercantile_bbox = None[source]
point3857to4326(x, y)[source]
point4326to3857(x, y)[source]
bbox3857to4326(x_min, x_max, y_min, y_max)[source]

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.

bbox4326to3857(x_min, x_max, y_min, y_max)[source]

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.

fetch(bbox: List, zoom: int = None, *args, **kwargs)[source]

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.

Parameters:
  • bbox – bounding box of the background image, dataset compliant format: [west, east, south, north, CRS]

  • zoom – zoom with which to retrieve Slippy Map’s tiles (by default, it’s calculated based on width, height)

Returns:

None if the CRS is different from self.tiles_crs, or background Image

calculate_zoom()[source]
class geonode.thumbs.background.WikiMediaTileBackground(thumbnail_width: int, thumbnail_height: int, max_retries: int = 3, retry_delay: int = 1)[source]

Bases: GenericXYZBackground

Helper class that provides a standard way to create an ABC using inheritance.

url = 'https://maps.wikimedia.org/osm-intl/{z}/{x}/{y}.png'[source]
tile_size = 256[source]
class geonode.thumbs.background.OSMTileBackground(thumbnail_width: int, thumbnail_height: int, max_retries: int = 3, retry_delay: int = 1)[source]

Bases: GenericXYZBackground

Helper class that provides a standard way to create an ABC using inheritance.

url = 'https://tile.openstreetmap.org/{z}/{x}/{y}.png'[source]
tile_size = 256[source]
geonode.thumbs.background.WMTS_TILEMATRIXSET_LEVELS = None[source]
class geonode.thumbs.background.GenericWMTSBackground(thumbnail_width: int, thumbnail_height: int, max_retries: int = 3, retry_delay: int = 1)[source]

Bases: BaseThumbBackground

Helper class that provides a standard way to create an ABC using inheritance.

options[source]
levels[source]
thumbnail_width[source]
thumbnail_height[source]
fetch(bbox: List, *args, **kwargs)[source]

Function fetching background image, based on the given BBOX. On error should raise an exception or return None.

Parameters:

bbox – a dataset compliant BBOX: [west, east, south, north, CRS]

build_kvp_request(baseurl, layer, style, xyz)[source]
build_request(xyz)[source]
get_image_bbox_for_level(level, bbox)[source]
get_tiles_coords(level, bbox)[source]
get_level_for_targetpixelspan(target_pixelspan)[source]
get_target_pixelspan(bbox)[source]
get_levels_for_tilematrix()[source]