gmaps_avoid_swiss package
Submodules
gmaps_avoid_swiss.client module
gmaps_avoid_swiss.geo_check module
- class gmaps_avoid_swiss.geo_check.GeographicChecker[source]
Bases:
object- BEAUNE = {'lat': 47.026, 'lng': 4.84}
- FREIBURG = {'lat': 47.999, 'lng': 7.8421}
- INNSBRUCK = {'lat': 47.2692, 'lng': 11.4041}
- LION = {'lat': 45.764, 'lng': 4.8357}
- does_route_cross_swiss(path: Polyline) LineString[source]
Determine whether a route, defined by a polyline (encoded string or GeoJSON), crosses Switzerland.
- Parameters
path (Polyline) – Polyline data which could be an encoded string or a GeoJSON object.
- Returns
True if the route crosses through Switzerland, False otherwise.
- Return type
bool
- is_point_in_swiss(lat: float, lng: float) bool[source]
Check if a geographic point is within Switzerland.
- Parameters
lat (float) – Latitude of the point.
lng (float) – Longitude of the point.
- Returns
True if the point is within the polygon of Switzerland, False otherwise.
- Return type
bool
- sort_cities_by_distance(intersection: Union[LineString, MultiLineString])[source]
Sort the cities based on their total distance to the start and end points of the intersection with Switzerland.
- Parameters
intersection (LineString) – The LineString representing the intersection of the route with Switzerland.
gmaps_avoid_swiss.routes module
- class gmaps_avoid_swiss.routes.RoutesHandler(client: GMapsRoutingClient, default_fields: Optional[list] = None)[source]
Bases:
objectHandles routing functionalities for GMapsRoutingClient.
- compute_route(origin: dict, destination: dict, extra_fields: Optional[list] = None, avoid_ferries: bool = False, avoid_tolls: bool = False, avoid_highways: bool = False) ComputeRoutesResponse[source]
Compute the route from origin to destination with customizable response fields. Extends the default fields with any extra fields specified for this particular call. For detailed information on all available extra fields, refer to the corresponding section in the user guide.
- Parameters
origin (dict) – A dictionary containing the origin location data.
destination (dict) – A dictionary containing the destination location data.
extra_fields (list, optional) – Additional fields to include in the response, in addition to default fields.
avoid_ferries (bool) – Whether to avoid ferries in the computed route.
avoid_tolls (bool) – Whether to avoid toll roads.
avoid_highways (bool) – Whether to avoid highways.
- Returns
The response containing the computed routes.
- Return type
routing_v2.ComputeRoutesResponse
- Raises
Exception – If there is an error while computing the routes.
- geo_checker = <gmaps_avoid_swiss.geo_check.GeographicChecker object>
gmaps_avoid_swiss.waypoints module
- gmaps_avoid_swiss.waypoints.create_waypoint(location_data: dict) Waypoint[source]
Create a Waypoint object from the provided location data.
- Parameters
location_data (dict) – A dictionary containing location information. It should have one of the following keys: - ‘lat’ and ‘lng’ for latitude and longitude coordinates - ‘place_id’ for a Google Maps place ID - ‘address’ for a textual address
- Returns
A Waypoint object created from the location data.
- Return type
Waypoint
- Raises
ValueError – If the provided location data is invalid.
Module contents
Top-level package for GMaps Avoid Swiss Routes.
- class gmaps_avoid_swiss.GMapsRoutingClient(api_key: str)[source]
Bases:
objectClient for Google Maps Routing API V2 that uses an API key for authentication.
- class gmaps_avoid_swiss.RoutesHandler(client: GMapsRoutingClient, default_fields: Optional[list] = None)[source]
Bases:
objectHandles routing functionalities for GMapsRoutingClient.
- compute_route(origin: dict, destination: dict, extra_fields: Optional[list] = None, avoid_ferries: bool = False, avoid_tolls: bool = False, avoid_highways: bool = False) ComputeRoutesResponse[source]
Compute the route from origin to destination with customizable response fields. Extends the default fields with any extra fields specified for this particular call. For detailed information on all available extra fields, refer to the corresponding section in the user guide.
- Parameters
origin (dict) – A dictionary containing the origin location data.
destination (dict) – A dictionary containing the destination location data.
extra_fields (list, optional) – Additional fields to include in the response, in addition to default fields.
avoid_ferries (bool) – Whether to avoid ferries in the computed route.
avoid_tolls (bool) – Whether to avoid toll roads.
avoid_highways (bool) – Whether to avoid highways.
- Returns
The response containing the computed routes.
- Return type
routing_v2.ComputeRoutesResponse
- Raises
Exception – If there is an error while computing the routes.
- geo_checker = <gmaps_avoid_swiss.geo_check.GeographicChecker object>