Core geometries module

as_unified_geometry(source_geom: geometry.Polygon | geometry.MultiPolygon) -> geometry.Polygon

Ensures the calculated geometry is returned as a single polygon.

Parameters:
  • source_geom (Polygon | MultiPolygon) –

    Calculated source geometry.

Returns:
  • Polygon

    geometry.Polygon: Unified resulting geometry with its points ordered (first one is the most-left x coordinate).

get_groundlevel_surface(pol_geometry: geometry.Polygon) -> geometry.LineString

Returns all the points which are at 'groundlevel' values (y = 0)

Parameters:
  • pol_geometry (Polygon) –

    Source geometry.

Returns:
  • LineString

    geometry.LineString: Line with points at y = 0.

get_normalized_polygon_difference(left_geom: geometry.Polygon, right_geom: geometry.Polygon) -> geometry.Polygon | geometry.MultiPolygon

Given two polygons calculates the difference between them and removes any residual polygon due to minor precision errors.

Parameters:
  • left_geom (Polygon) –

    Base polygon from where to substract.

  • right_geom (Polygon) –

    Polygon to substract from base.

Returns:
  • Polygon | MultiPolygon

    geometry.Polygon: Resulting normalized substraction polygon.

get_polygon_coordinates(pol_geometry: geometry.Polygon | geometry.MultiPolygon) -> geometry.LineString

Given a single or multi geometry returns the coordinates composing its outer layout.

Parameters:
  • pol_geometry (Polygon | MultiPolygon) –

    Source geometry.

Raises:
  • NotImplementedError

    When the provided geometry is not yet supported.

Returns:
  • LineString

    geometry.LineString: Set of points composing the outer layout of the geometry.

get_polygon_surface_points(base_geometry: geometry.Polygon | geometry.MultiPolygon) -> geometry.LineString

Gets all the points composing the upper surface of a 'dike' geometry. IMPORTANT! The calling of this method assumes the base_geometry points are in order, call order_geometry_points if needed.

Parameters:
  • base_geometry (Union[Polygon, MultiPolygon]) –

    Source geometry.

Returns:
  • LineString

    geometry.LineString: Resulting line with points from the outer geometry.

get_relative_core_layer(core_geometry: geometry.Polygon, coating_geometry: geometry.Polygon) -> geometry.Polygon

Returns a new 'core' from the original core_geometry relative to the coating_geometry.

Parameters:
  • core_geometry (Polygon) –

    Original core geometry on which layers are stacked upon.

  • coating_geometry (Polygon) –

    Layer wrapping the exterior of a core geometry.

Returns:
  • Polygon( Polygon ) –

    Layer wrapping a reduced surface of the core_geometry.

order_geometry_points(dike_polygon: geometry.Polygon) -> geometry.Polygon

In koswat we handle polygon operations expecting the lowest 'x' coordinate to be the initial and last point of a geometry. For this reason we need to ensure all geometries are 'normalized' based on this criteria.

Parameters:
  • dike_polygon (Polygon) –

    Polygon to normalized.

Returns:
  • Polygon

    geometry.Polygon: Normalized polygon.

profile_points_to_polygon(points_list: list[geometry.Point]) -> geometry.Polygon

Transforms a list of points into a valid 'dike' polygon. When there is a difference in height between left and right side then we correct it in the x = 0 coordinate.

Parameters:
  • points_list (List[Point]) –

    List of points representing a dike profile.

Returns:
  • Polygon

    geometry.Polygon: Validated enclosed geometry simple polygon.

remove_layer_from_polygon(dike_polygon: geometry.Polygon, layer_depth: float) -> geometry.Polygon

Gets the dike profile without a layer of provided layer_depth depth.

Parameters:
  • dike_polygon (Polygon) –

    Source geometry.

  • layer_depth (float) –

    Depth of a layer from the outer dike_polygon geometry inwards.

Returns:
  • Polygon

    geometry.Polygon: Resulting geometry when removing the layer.