From eb4c7f9f785f5433191efac7e21a7d2ccc2d28bc Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Thu, 12 Dec 2024 04:04:18 +0500 Subject: [PATCH] feat: [google-maps-routing] add API for experimental flyover and narrow road polyline details (#13328) BEGIN_COMMIT_OVERRIDE feat: add API for experimental flyover and narrow road polyline details END_COMMIT_OVERRIDE - [ ] Regenerate this pull request now. PiperOrigin-RevId: 703138506 Source-Link: https://github.com/googleapis/googleapis/commit/a3211f3342219aad1b310ec1739476586384473a Source-Link: https://github.com/googleapis/googleapis-gen/commit/7616de9c9b8e5e4abcdf25f9069ebe3e327f51eb Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLW1hcHMtcm91dGluZy8uT3dsQm90LnlhbWwiLCJoIjoiNzYxNmRlOWM5YjhlNWU0YWJjZGYyNWY5MDY5ZWJlM2UzMjdmNTFlYiJ9 --------- Co-authored-by: Owl Bot Co-authored-by: ohmayr --- .../google/maps/routing/__init__.py | 2 + .../google/maps/routing_v2/__init__.py | 2 + .../google/maps/routing_v2/types/__init__.py | 2 + .../maps/routing_v2/types/polyline_details.py | 150 ++++++++++++++++++ .../google/maps/routing_v2/types/route.py | 9 ++ .../maps/routing_v2/types/routes_service.py | 16 ++ 6 files changed, 181 insertions(+) create mode 100644 packages/google-maps-routing/google/maps/routing_v2/types/polyline_details.py diff --git a/packages/google-maps-routing/google/maps/routing/__init__.py b/packages/google-maps-routing/google/maps/routing/__init__.py index c2b64f0bba8a..e89adf18f486 100644 --- a/packages/google-maps-routing/google/maps/routing/__init__.py +++ b/packages/google-maps-routing/google/maps/routing/__init__.py @@ -38,6 +38,7 @@ PolylineEncoding, PolylineQuality, ) +from google.maps.routing_v2.types.polyline_details import PolylineDetails from google.maps.routing_v2.types.route import ( Route, RouteLeg, @@ -91,6 +92,7 @@ "Polyline", "PolylineEncoding", "PolylineQuality", + "PolylineDetails", "Route", "RouteLeg", "RouteLegStep", diff --git a/packages/google-maps-routing/google/maps/routing_v2/__init__.py b/packages/google-maps-routing/google/maps/routing_v2/__init__.py index 8bdbacf666b7..5b59323f802a 100644 --- a/packages/google-maps-routing/google/maps/routing_v2/__init__.py +++ b/packages/google-maps-routing/google/maps/routing_v2/__init__.py @@ -26,6 +26,7 @@ from .types.maneuver import Maneuver from .types.navigation_instruction import NavigationInstruction from .types.polyline import Polyline, PolylineEncoding, PolylineQuality +from .types.polyline_details import PolylineDetails from .types.route import ( Route, RouteLeg, @@ -74,6 +75,7 @@ "Maneuver", "NavigationInstruction", "Polyline", + "PolylineDetails", "PolylineEncoding", "PolylineQuality", "Route", diff --git a/packages/google-maps-routing/google/maps/routing_v2/types/__init__.py b/packages/google-maps-routing/google/maps/routing_v2/types/__init__.py index 3f2434b49918..78311f179f3d 100644 --- a/packages/google-maps-routing/google/maps/routing_v2/types/__init__.py +++ b/packages/google-maps-routing/google/maps/routing_v2/types/__init__.py @@ -20,6 +20,7 @@ from .maneuver import Maneuver from .navigation_instruction import NavigationInstruction from .polyline import Polyline, PolylineEncoding, PolylineQuality +from .polyline_details import PolylineDetails from .route import ( Route, RouteLeg, @@ -66,6 +67,7 @@ "Polyline", "PolylineEncoding", "PolylineQuality", + "PolylineDetails", "Route", "RouteLeg", "RouteLegStep", diff --git a/packages/google-maps-routing/google/maps/routing_v2/types/polyline_details.py b/packages/google-maps-routing/google/maps/routing_v2/types/polyline_details.py new file mode 100644 index 000000000000..ca63290efcaa --- /dev/null +++ b/packages/google-maps-routing/google/maps/routing_v2/types/polyline_details.py @@ -0,0 +1,150 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from __future__ import annotations + +from typing import MutableMapping, MutableSequence + +import proto # type: ignore + +__protobuf__ = proto.module( + package="google.maps.routing.v2", + manifest={ + "PolylineDetails", + }, +) + + +class PolylineDetails(proto.Message): + r"""Details corresponding to a given index or contiguous segment of a + polyline. Given a polyline with points P_0, P_1, ... , P_N + (zero-based index), the ``PolylineDetails`` defines an interval and + associated metadata. + + Attributes: + flyover_info (MutableSequence[google.maps.routing_v2.types.PolylineDetails.FlyoverInfo]): + Flyover details along the polyline. + narrow_road_info (MutableSequence[google.maps.routing_v2.types.PolylineDetails.NarrowRoadInfo]): + Narrow road details along the polyline. + """ + + class RoadFeatureState(proto.Enum): + r"""Encapsulates the states of road features along a stretch of + polyline. + + Values: + ROAD_FEATURE_STATE_UNSPECIFIED (0): + The road feature's state was not computed + (default value). + EXISTS (1): + The road feature exists. + DOES_NOT_EXIST (2): + The road feature does not exist. + """ + ROAD_FEATURE_STATE_UNSPECIFIED = 0 + EXISTS = 1 + DOES_NOT_EXIST = 2 + + class PolylinePointIndex(proto.Message): + r"""Encapsulates the start and end indexes for a polyline detail. For + instances where the data corresponds to a single point, + ``start_index`` and ``end_index`` will be equal. + + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + start_index (int): + The start index of this detail in the + polyline. + + This field is a member of `oneof`_ ``_start_index``. + end_index (int): + The end index of this detail in the polyline. + + This field is a member of `oneof`_ ``_end_index``. + """ + + start_index: int = proto.Field( + proto.INT32, + number=1, + optional=True, + ) + end_index: int = proto.Field( + proto.INT32, + number=2, + optional=True, + ) + + class FlyoverInfo(proto.Message): + r"""Encapsulates information about flyovers along the polyline. + + Attributes: + flyover_presence (google.maps.routing_v2.types.PolylineDetails.RoadFeatureState): + Output only. Denotes whether a flyover exists + for a given stretch of the polyline. + polyline_point_index (google.maps.routing_v2.types.PolylineDetails.PolylinePointIndex): + The location of flyover related information + along the polyline. + """ + + flyover_presence: "PolylineDetails.RoadFeatureState" = proto.Field( + proto.ENUM, + number=1, + enum="PolylineDetails.RoadFeatureState", + ) + polyline_point_index: "PolylineDetails.PolylinePointIndex" = proto.Field( + proto.MESSAGE, + number=2, + message="PolylineDetails.PolylinePointIndex", + ) + + class NarrowRoadInfo(proto.Message): + r"""Encapsulates information about narrow roads along the + polyline. + + Attributes: + narrow_road_presence (google.maps.routing_v2.types.PolylineDetails.RoadFeatureState): + Output only. Denotes whether a narrow road + exists for a given stretch of the polyline. + polyline_point_index (google.maps.routing_v2.types.PolylineDetails.PolylinePointIndex): + The location of narrow road related + information along the polyline. + """ + + narrow_road_presence: "PolylineDetails.RoadFeatureState" = proto.Field( + proto.ENUM, + number=1, + enum="PolylineDetails.RoadFeatureState", + ) + polyline_point_index: "PolylineDetails.PolylinePointIndex" = proto.Field( + proto.MESSAGE, + number=2, + message="PolylineDetails.PolylinePointIndex", + ) + + flyover_info: MutableSequence[FlyoverInfo] = proto.RepeatedField( + proto.MESSAGE, + number=12, + message=FlyoverInfo, + ) + narrow_road_info: MutableSequence[NarrowRoadInfo] = proto.RepeatedField( + proto.MESSAGE, + number=13, + message=NarrowRoadInfo, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/packages/google-maps-routing/google/maps/routing_v2/types/route.py b/packages/google-maps-routing/google/maps/routing_v2/types/route.py index a1f0286ea2bf..886dd86714fa 100644 --- a/packages/google-maps-routing/google/maps/routing_v2/types/route.py +++ b/packages/google-maps-routing/google/maps/routing_v2/types/route.py @@ -32,6 +32,7 @@ from google.maps.routing_v2.types import ( navigation_instruction as gmr_navigation_instruction, ) +from google.maps.routing_v2.types import polyline_details as gmr_polyline_details from google.maps.routing_v2.types import localized_time, location from google.maps.routing_v2.types import polyline as gmr_polyline from google.maps.routing_v2.types import toll_info as gmr_toll_info @@ -123,6 +124,9 @@ class Route(proto.Message): ``TRAFFIC_AWARE`` or ``TRAFFIC_AWARE_OPTIMAL``. ``Route.route_token`` is not supported for requests that have Via waypoints. + polyline_details (google.maps.routing_v2.types.PolylineDetails): + Contains information about details along the + polyline. """ class RouteLocalizedValues(proto.Message): @@ -225,6 +229,11 @@ class RouteLocalizedValues(proto.Message): proto.STRING, number=12, ) + polyline_details: gmr_polyline_details.PolylineDetails = proto.Field( + proto.MESSAGE, + number=14, + message=gmr_polyline_details.PolylineDetails, + ) class RouteTravelAdvisory(proto.Message): diff --git a/packages/google-maps-routing/google/maps/routing_v2/types/routes_service.py b/packages/google-maps-routing/google/maps/routing_v2/types/routes_service.py index 02becc425942..b5004890cfb0 100644 --- a/packages/google-maps-routing/google/maps/routing_v2/types/routes_service.py +++ b/packages/google-maps-routing/google/maps/routing_v2/types/routes_service.py @@ -243,12 +243,28 @@ class ExtraComputation(proto.Enum): presented as a formatted HTML text string. This content is meant to be read as-is. This content is for display only. Do not programmatically parse it. + FLYOVER_INFO_ON_POLYLINE (7): + Flyover information for the route(s). The + ``routes.polyline_details.flyover_info`` fieldmask must be + specified to return this information. This data will only + currently be populated for certain metros in India. This + feature is experimental, and the SKU/charge is subject to + change. + NARROW_ROAD_INFO_ON_POLYLINE (8): + Narrow road information for the route(s). The + ``routes.polyline_details.narrow_road_info`` fieldmask must + be specified to return this information. This data will only + currently be populated for certain metros in India. This + feature is experimental, and the SKU/charge is subject to + change. """ EXTRA_COMPUTATION_UNSPECIFIED = 0 TOLLS = 1 FUEL_CONSUMPTION = 2 TRAFFIC_ON_POLYLINE = 3 HTML_FORMATTED_NAVIGATION_INSTRUCTIONS = 4 + FLYOVER_INFO_ON_POLYLINE = 7 + NARROW_ROAD_INFO_ON_POLYLINE = 8 origin: gmr_waypoint.Waypoint = proto.Field( proto.MESSAGE,