Skip to content

Commit

Permalink
feat: [google-maps-routing] add API for experimental flyover and narr…
Browse files Browse the repository at this point in the history
…ow 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:
googleapis/googleapis@a3211f3

Source-Link:
googleapis/googleapis-gen@7616de9
Copy-Tag:
eyJwIjoicGFja2FnZXMvZ29vZ2xlLW1hcHMtcm91dGluZy8uT3dsQm90LnlhbWwiLCJoIjoiNzYxNmRlOWM5YjhlNWU0YWJjZGYyNWY5MDY5ZWJlM2UzMjdmNTFlYiJ9

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: ohmayr <omairnaveed@ymail.com>
  • Loading branch information
3 people authored Dec 11, 2024
1 parent 89157d6 commit eb4c7f9
Show file tree
Hide file tree
Showing 6 changed files with 181 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/google-maps-routing/google/maps/routing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -91,6 +92,7 @@
"Polyline",
"PolylineEncoding",
"PolylineQuality",
"PolylineDetails",
"Route",
"RouteLeg",
"RouteLegStep",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -74,6 +75,7 @@
"Maneuver",
"NavigationInstruction",
"Polyline",
"PolylineDetails",
"PolylineEncoding",
"PolylineQuality",
"Route",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -66,6 +67,7 @@
"Polyline",
"PolylineEncoding",
"PolylineQuality",
"PolylineDetails",
"Route",
"RouteLeg",
"RouteLegStep",
Expand Down
Original file line number Diff line number Diff line change
@@ -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))
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit eb4c7f9

Please sign in to comment.