module documentation

Utility functions for geo-coordinates and geoJSON

Function geoContains Check if a shape contains another shape.
Function geoIntersects Check if a shape intersects another shape.
Function geoWithin Check if a shape is within another shape.
Function getGeoPoint Get the geo-point from a geoJSON object.
Function getGeoPolygon Get the geo-polygon from a geoJSON object.
Function getGeoShape Get a shapely geometry object from a geoJSON shape.
Function isLocationInsidePolygon Check if a location is inside a polygon.
def geoContains(aType: GeometryType, aShape: tuple | list, bType: GeometryType, bShape: tuple | list) -> bool:

Check if a shape contains another shape.

Parameters
aType:GeometryTypeThe type of the first shape.
aShape:tuple | listThe shape of the first shape.
bType:GeometryTypeThe type of the second shape.
bShape:tuple | listThe shape of the second shape.
Returns
boolTrue if the first shape (fully) contains the second shape, False otherwise.
def geoIntersects(aType: GeometryType, aShape: tuple | list, bType: GeometryType, bShape: tuple | list) -> bool:

Check if a shape intersects another shape.

Parameters
aType:GeometryTypeThe type of the first shape.
aShape:tuple | listThe shape of the first shape.
bType:GeometryTypeThe type of the second shape.
bShape:tuple | listThe shape of the second shape.
Returns
boolTrue if the first shape intersects the second shape, False otherwise.
def geoWithin(aType: GeometryType, aShape: tuple | list, bType: GeometryType, bShape: tuple | list) -> bool:

Check if a shape is within another shape.

Parameters
aType:GeometryTypeThe type of the first shape.
aShape:tuple | listThe shape of the first shape.
bType:GeometryTypeThe type of the second shape.
bShape:tuple | listThe shape of the second shape.
Returns
boolTrue if the first shape is (fully) within the second shape, False otherwise.
def getGeoPoint(jsn: dict | str | None) -> tuple[float, float] | None:

Get the geo-point from a geoJSON object.

Parameters
jsn:dict | str | NoneThe geoJSON object as a dictionary or a string.
Returns
tuple[float, float] | NoneA tuple of the geo-point (latitude, longitude). None if not found or invalid JSON.
def getGeoPolygon(jsn: dict | str | None) -> list[tuple[float, float]] | None:

Get the geo-polygon from a geoJSON object.

Parameters
jsn:dict | str | NoneThe geoJSON object as a dictionary or a string.
Returns
list[tuple[float, float]] | NoneA list of tuples of the geo-polygon (latitude, longitude). None if not found or invalid JSON.
def getGeoShape(typ: GeometryType, shape: tuple | list) -> BaseGeometry:

Get a shapely geometry object from a geoJSON shape.

Parameters
typ:GeometryTypeThe geometry type.
shape:tuple | listThe geoJSON shape as a tuple or list.
Returns
BaseGeometryA shapely geometry object.
def isLocationInsidePolygon(polygon: list[tuple[float, float]], location: tuple[float, float]) -> bool:

Check if a location is inside a polygon.

Parameters
polygon:list[tuple[float, float]]The polygon as a list of tuples (latitude, longitude).
location:tuple[float, float]The location as a tuple (latitude, longitude).
Returns
boolTrue if the location is inside the polygon, False otherwise.