gws.base.grabber.box

Base grabber for boxed sources.

Source code: gws.base.grabber.box

Module Contents

gws.base.grabber.box.MAX_SOURCE_PIXEL_RATIO = 4

Cap on source pixels per target pixel per side, for cross-CRS requests.

class gws.base.grabber.box.Object(opts: gws.base.grabber.core.Options)

Bases: gws.base.grabber.core.Object

Base grabber for sources that render arbitrary boxes.

Composes tiles and boxes from source requests in the source CRS. Provides subclasses with meta-tiling of tile blocks, splitting of large requests into chunks and reprojection into the target CRS.

Subclasses implement fetch_box_as_bytes and fetch_box_as_image.

maxRequestPixels: int

Cap on the pixel size of one source request; larger boxes are fetched in chunks.

requestBuffer: int

Pixels rendered around a block or chunk and cropped, for consistent labels across seams.

requestTiles
compose_box_as_image(extent, w, h, params=None)
compose_tile_block_as_image_dict(mt, params=None)
abstractmethod fetch_box_as_bytes(bounds: gws.Bounds, w: int, h: int, params: dict | None = None) → bytes

Fetch a box from the source with exactly one request, as encoded bytes.

Subclasses must implement this.

Parameters:
  • bounds – Box bounds in the source CRS.

  • w – Width in pixels.

  • h – Height in pixels.

  • params – Dynamic request parameters.

Returns:

The encoded image.

Raises:

NotImplementedError – In the base class.

abstractmethod fetch_box_as_image(bounds: gws.Bounds, w: int, h: int, params: dict | None = None) → gws.Image

Fetch a box from the source with exactly one request, as an image.

Subclasses must implement this.

Parameters:
  • bounds – Box bounds in the source CRS.

  • w – Width in pixels.

  • h – Height in pixels.

  • params – Dynamic request parameters.

Returns:

The image.

Raises:

NotImplementedError – In the base class.