pyorps.core.path
PYORPS: An Open-Source Tool for Automated Power Line Routing
Reference: [1] Hofmann, M., Stetz, T., Kammer, F., Repo, S.: ‘PYORPS: An Open-Source Tool for
Automated Power Line Routing’, CIRED 2025 - 28th Conference and Exhibition on Electricity Distribution, 16 - 19 June 2025, Geneva, Switzerland
Classes
|
Dataclass representing a path in a raster graph. |
Container for Path objects with O(1) retrieval by path ID and O(n) lookup for source and target information. |
- class pyorps.core.path.Path(source, target, algorithm, graph_api, path_indices, path_coords, path_geometry, euclidean_distance, runtimes, path_id, search_space_buffer_m, neighborhood, total_length=None, total_cost=None, length_by_category=None, length_by_category_percent=None)[source]
Bases:
objectDataclass representing a path in a raster graph. Used as container for all path metrics and information.
- Parameters:
- path_geometry: LineString
- to_geodataframe_dict()[source]
Convert Path object to a dictionary suitable for GeoDataFrame creation.
- Returns:
dictionary with path data formatted for GeoDataFrame
- Return type:
- __str__()[source]
Return a string representation of the path including the path_id, source and target, as well as the path’s total length and total cost.
- Returns:
A string representation of the path.
- Return type:
- __init__(source, target, algorithm, graph_api, path_indices, path_coords, path_geometry, euclidean_distance, runtimes, path_id, search_space_buffer_m, neighborhood, total_length=None, total_cost=None, length_by_category=None, length_by_category_percent=None)
- Parameters:
- Return type:
None
- class pyorps.core.path.PathCollection[source]
Bases:
objectContainer for Path objects with O(1) retrieval by path ID and O(n) lookup for source and target information. Paths can be added with new id by replacing a Path object with the same ID already existing in th PathCollection.
Create an empty PathCollection for collecting Paths with their IDs in a dictionary.
- __init__()[source]
Create an empty PathCollection for collecting Paths with their IDs in a dictionary.
- add(path, replace=False)[source]
Add a path to the PathCollection. If the Path’s path_id is None or if replace is False, the path_id of the Path object will set to self._next_id and self._next_id will be incremented. If the Path’s path_id is not None and replace is True, a Path with the same path_id (if present) will be replaced with the new Path object.
- get(path_id=None, source=None, target=None)[source]
Retrieve a stored path by ID, or by source AND target.
- Parameters:
path_id (int) – The ID of the Path object to retrieve (must be None if path should be found by source and target)
source (Any) – The source Path object to retrieve (only used if path_id is None and target os set too; neglected otherwise)
target (Any) – The target Path object to retrieve (only used if path_id is None and target os set too; neglected otherwise)
- Returns:
The Path object with the specified ID or source/target pair. None if no such path exists.
- Return type:
Path | None
- to_geodataframe_records()[source]
Convert all paths to a list of dictionaries suitable for a GeoDataFrame.
- Returns:
List of dictionaries with path data formatted for a GeoDataFrame
- Return type:
- property all
Return all Path objects from the values of the PathCollection’s _paths dictionary as a list.
- Returns:
A list of all Path objects in the PathCollection.