drone_cab.utils¶
Helper utilities.
Collection of various helper functions and utilities.
Functions
|
Calculate the Euclidean distance between two given points. |
Get list of all SUMO IDs of polygons of type 'building' in current simulation. |
|
Get list of all SUMO IDs of lanes in current simulation. |
|
|
Finds the nearest road edge to a given polygon. |
|
Calculate the centroid of given polygon shape. |
- drone_cab.utils.euclidean_distance(point_a: tuple[float, float], point_b: tuple[float, float]) float¶
Calculate the Euclidean distance between two given points.
- Parameters:
point_a (tuple[float, float]) – 2-D coordinates of first point.
point_b (tuple[float, float]) – 2-D coordinates of second point.
- Returns:
Euclidean distance between given two points.
- Raises:
AssertionError – If given coordinates are not 2-D.
- Return type:
float
- drone_cab.utils.get_building_id_list() list[str]¶
Get list of all SUMO IDs of polygons of type ‘building’ in current simulation.
- Returns:
List of SUMO IDs of all polygons of type ‘building’ in current simulation.
- Return type:
list[str]
- drone_cab.utils.get_lane_list() list[str]¶
Get list of all SUMO IDs of lanes in current simulation.
- Returns:
List of SUMO IDs of all lanes in current simulation.
- Return type:
list[str]
- drone_cab.utils.get_nearest_edge_id(polygon_id: str) str¶
Finds the nearest road edge to a given polygon.
- Parameters:
polygon_id (str) – SUMO ID of given polygon.
- Returns:
SUMO ID of road edge that is closest to given polygon.
- Return type:
str
- drone_cab.utils.shape2centroid(shape: list[tuple[float, float]]) tuple[float, float]¶
Calculate the centroid of given polygon shape.
- Parameters:
shape (list[tuple[float, float]]) – List of 2-D coordinates of vertices of given polygon.
- Returns:
2-D coordinates of centroid of given polygon shape.
- Raises:
AssertionError – If given coordinates are not 2-D.
- Return type:
tuple[float, float]