Geometry Utils#
- backend.app.utils.geometry_utils.geojson_to_geometry(geo_location: Point | None) WKTElement | None[source]#
Convert GeoJSON to PostGIS Geometry (WKTElement). This is needed to transform pydantic GEOJson Objects into WKTElement objects, to store them in the database. Use before writing data from api into postgis db.
- Parameters:
geo_location (Point) – Single GeoJSON object or list of GeoJSON objects.
- Returns:
PostGIS Geometry (WKTElement) or list of WKTElement objects.
- Return type:
WKTElement
- backend.app.utils.geometry_utils.geometry_to_geojson(geometry: WKBElement | None) Point | None[source]#
Convert a PostGIS Geometry (WKBElement) to a GeoJSON Point. This is needed to transform WKBElement objects into pydantic GEOJson Objects, to read them from the database. Use after retrieving data from db to return to api.
- Parameters:
geometry (WKBElement) – A PostGIS Geometry (WKBElement) object.
- Returns:
if location is given: A GeoJSON Point object. Else None.
- Return type:
Point