casageo.logistics module
This module provides operations for logistical calculations.
General Information
The functions in this module are single-shot calculations, not batch calculations like in casageo.coder module and casageo.spatial module.
TSP Queries
Calculate the shortest path among a set of waypoints.
TSP Query Options
TBD
TSP Input Columns
The following columns will be read from the input dataframe:
- namestr
Unique string identifier for the waypoint. Required.
- navigation
Point Navigation coordinates corresponding to the waypoint. Instead of a geometry object, you may also specify this as two separate fields
navigation_latitudeandnavigation_longitudeof typefloat. Required.- courseint
Optional.
- position
Point Optional.
- beforelist[str]
Optional.
- appointment_timedatetime | str
Optional.
- service_timetimedelta | float | int
Optional.
- interruptiblebool
Optional.
TSP Output Columns
TBD
- casageo.logistics.AVOIDABLE_FEATURES: Final[Sequence[str]] = ['tollroad', 'motorway', 'boatFerry', 'railFerry', 'tunnel', 'dirtRoad', 'park', 'uTurns']
Features that can be avoided.
- casageo.logistics.CLUSTERING_MODES: Final[Sequence[str]] = ['drivingDistance', 'topologySegment']
Supported clustering modes.
- casageo.logistics.OPTIMIZATION_TARGETS: Final[Sequence[str]] = ['time', 'distance']
Supported optimization targets.
- casageo.logistics.ROUTING_MODES: Final[Sequence[str]] = ['fast', 'short']
Supported routing modes.
- casageo.logistics.TRANSPORT_MODES: Final[Sequence[str]] = ['car', 'pedestrian', 'bicycle', 'truck']
Supported transport modes.
- casageo.logistics.HAZARDOUS_CARGO_TYPES: Final[Sequence[str]] = ['explosive', 'gas', 'flammable', 'combustible', 'organic', 'poison', 'radioActive', 'corrosive', 'poisonousInhalation', 'harmfulToWater', 'other']
Supported types of hazardous cargo.
- casageo.logistics.tsp(client, waypoints, *, origin=None, destination=None, clustering=None, break_times=(), rest_schedule=None, transport_mode='car', routing_mode='fast', optimize='time', departure_time=None, traffic=False, avoid_features=(), exclude_countries=(), vehicle_length=None, vehicle_width=None, vehicle_height=None, vehicle_axle_weight=None, vehicle_total_weight=None, vehicle_trailers=None, hazardous_cargo=(), walking_speed=None, with_coordinates=False)
Calculate the shortest path among a set of waypoints.
See TSP Queries in the module documentation.
- Parameters:
client (CasaGeoClient) – The client object authorizing these queries.
waypoints (DataFrame) – The dataframe of waypoints to visit (see TSP Input Columns).
origin (str | None) – Name of the starting waypoint, defaults to the first waypoint.
destination (str | None) – Name of the destination waypoint, if any.
clustering (str | None) – Enables clustering of waypoints (see
CLUSTERING_MODES).break_times (Collection[tuple[datetime | str, timedelta | float | int]]) – Sets up to five break time slots. Each time slot consists of a starting datetime and a duration in minutes.
rest_schedule (str | None) – Sets a rest schedule for the driver. Set this to
"default"to activate simplified European rules.transport_mode (str) – The mode of transport to use for routing (see
TRANSPORT_MODES).routing_mode (str) – Whether to prefer
"fast"or"short"routes (seeROUTING_MODES).optimize (str) – Whether to optimize the waypoint sequence for
"time"or for"distance"(seeOPTIMIZATION_TARGETS).departure_time (datetime | str | None) – The date and time of departure for time-dependent routing.
traffic (bool) – Whether to consider traffic data during routing.
avoid_features (Collection[str]) – If set, these route features are avoided during routing.
exclude_countries (Collection[str]) – If set, these countries are excluded from routing. Must be a sequence of valid ISO 3166-1 alpha-3 country codes.
vehicle_length (int | None) – Specifies the length of the vehicle in centimeters.
vehicle_width (int | None) – Specifies the width of the vehicle in centimeters.
vehicle_height (int | None) – Specifies the height of the vehicle in centimeters.
vehicle_axle_weight (int | None) – Specifies the per-axle weight of the vehicle in kilograms.
vehicle_total_weight (int | None) – Specifies the total weight of the vehicle in kilograms.
vehicle_trailers (int | None) – Specifies the number of trailers attached to the vehicle.
hazardous_cargo (Collection[str]) – Specifies the types of hazardous cargo carried by the vehicle (see
HAZARDOUS_CARGO_TYPES).walking_speed (int | None) – Specifies the pedestrian walking speed in meters per second.
with_coordinates (bool) – Whether to include numeric coordinates in the output.
- Returns:
The sorted list of waypoints as an EPSG:4326 GeoDataFrame. If waypoint constraints could not be satisfied, the offending waypoints are returned instead with an error code of
"failed_constraints".The shape of the dataframe is described under TSP Output Columns in the module documentation. The geometry column is the
navigationcolumn.- Return type:
- Raises:
InsufficientCreditsError – If the account does not have enough credits.
CasaGeoError – If the request could not be executed for another reason.