gisserver.geometries module

Helper classes to handle geometry data types.

The bounding box can be calculated within Python, or read from a database result.

class gisserver.geometries.BoundingBox(min_x: float, min_y: float, max_x: float, max_y: float, crs: CRS | None = None)

Bases: object

A bounding box. Due to the overlap between 2 types, this element is used for 2 cases:

  • The <ows:WGS84BoundingBox> element for GetCapabilities.

  • The <gml:Envelope> inside an <gml:boundedBy> single feature.

While both classes have no common base class (and exist in different schema’s), their properties are identical.

The X/Y coordinates can be either latitude or longitude, depending on the CRS.

Note this isn’t using the GDAL/OGR “Envelope” object, as that doesn’t expose the CRS, and requires constant copies to merge geometries.

__init__(min_x: float, min_y: float, max_x: float, max_y: float, crs: CRS | None = None) None
extend_to(min_x: float, min_y: float, max_x: float, max_y: float)

Expand the bounding box in-place

classmethod from_geometries(geometries: list[GEOSGeometry], crs: CRS) BoundingBox | None

Calculate the extent of a collection of geometries.

class gisserver.geometries.WGS84BoundingBox(min_x: float, min_y: float, max_x: float, max_y: float)

Bases: BoundingBox

The <ows:WGS84BoundingBox> element for the GetCapabilities element.

This always has coordinates are always in longitude/latitude axis ordering, the CRS is fixed to urn:ogc:def:crs:OGC:2:84.

__init__(min_x: float, min_y: float, max_x: float, max_y: float)