diff --git a/packages/google-maps-routing/google/maps/routing/__init__.py b/packages/google-maps-routing/google/maps/routing/__init__.py index 3525247e0abd..ef47c5e1bb55 100644 --- a/packages/google-maps-routing/google/maps/routing/__init__.py +++ b/packages/google-maps-routing/google/maps/routing/__init__.py @@ -25,6 +25,10 @@ FallbackReason, FallbackRoutingMode, ) +from google.maps.routing_v2.types.geocoding_results import ( + GeocodedWaypoint, + GeocodingResults, +) from google.maps.routing_v2.types.location import Location from google.maps.routing_v2.types.maneuver import Maneuver from google.maps.routing_v2.types.navigation_instruction import NavigationInstruction @@ -68,6 +72,8 @@ "FallbackInfo", "FallbackReason", "FallbackRoutingMode", + "GeocodedWaypoint", + "GeocodingResults", "Location", "Maneuver", "NavigationInstruction", 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 7a01b221ac2e..4c3204fd4875 100644 --- a/packages/google-maps-routing/google/maps/routing_v2/__init__.py +++ b/packages/google-maps-routing/google/maps/routing_v2/__init__.py @@ -20,6 +20,7 @@ from .services.routes import RoutesAsyncClient, RoutesClient from .types.fallback_info import FallbackInfo, FallbackReason, FallbackRoutingMode +from .types.geocoding_results import GeocodedWaypoint, GeocodingResults from .types.location import Location from .types.maneuver import Maneuver from .types.navigation_instruction import NavigationInstruction @@ -61,6 +62,8 @@ "FallbackInfo", "FallbackReason", "FallbackRoutingMode", + "GeocodedWaypoint", + "GeocodingResults", "Location", "Maneuver", "NavigationInstruction", diff --git a/packages/google-maps-routing/google/maps/routing_v2/services/routes/async_client.py b/packages/google-maps-routing/google/maps/routing_v2/services/routes/async_client.py index a026c56d4229..c27576e1df92 100644 --- a/packages/google-maps-routing/google/maps/routing_v2/services/routes/async_client.py +++ b/packages/google-maps-routing/google/maps/routing_v2/services/routes/async_client.py @@ -47,7 +47,12 @@ from google.protobuf import duration_pb2 # type: ignore from google.rpc import status_pb2 # type: ignore -from google.maps.routing_v2.types import fallback_info, route, routes_service +from google.maps.routing_v2.types import ( + fallback_info, + geocoding_results, + route, + routes_service, +) from .client import RoutesClient from .transports.base import DEFAULT_CLIENT_INFO, RoutesTransport diff --git a/packages/google-maps-routing/google/maps/routing_v2/services/routes/client.py b/packages/google-maps-routing/google/maps/routing_v2/services/routes/client.py index 4d19e6dd5365..8d4a09c031e3 100644 --- a/packages/google-maps-routing/google/maps/routing_v2/services/routes/client.py +++ b/packages/google-maps-routing/google/maps/routing_v2/services/routes/client.py @@ -50,7 +50,12 @@ from google.protobuf import duration_pb2 # type: ignore from google.rpc import status_pb2 # type: ignore -from google.maps.routing_v2.types import fallback_info, route, routes_service +from google.maps.routing_v2.types import ( + fallback_info, + geocoding_results, + route, + routes_service, +) from .transports.base import DEFAULT_CLIENT_INFO, RoutesTransport from .transports.grpc import RoutesGrpcTransport 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 9efaa71283c5..0fc81931dc68 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 @@ -14,6 +14,7 @@ # limitations under the License. # from .fallback_info import FallbackInfo, FallbackReason, FallbackRoutingMode +from .geocoding_results import GeocodedWaypoint, GeocodingResults from .location import Location from .navigation_instruction import NavigationInstruction from .polyline import Polyline, PolylineEncoding, PolylineQuality @@ -44,6 +45,8 @@ "FallbackInfo", "FallbackReason", "FallbackRoutingMode", + "GeocodedWaypoint", + "GeocodingResults", "Location", "Maneuver", "NavigationInstruction", diff --git a/packages/google-maps-routing/google/maps/routing_v2/types/geocoding_results.py b/packages/google-maps-routing/google/maps/routing_v2/types/geocoding_results.py new file mode 100644 index 000000000000..24a07165a904 --- /dev/null +++ b/packages/google-maps-routing/google/maps/routing_v2/types/geocoding_results.py @@ -0,0 +1,123 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 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 + +from google.rpc import status_pb2 # type: ignore +import proto # type: ignore + +__protobuf__ = proto.module( + package="google.maps.routing.v2", + manifest={ + "GeocodingResults", + "GeocodedWaypoint", + }, +) + + +class GeocodingResults(proto.Message): + r"""Contains GeocodedWaypoints for origin, destination and + intermediate waypoints. Only populated for address waypoints. + + Attributes: + origin (google.maps.routing_v2.types.GeocodedWaypoint): + Origin geocoded waypoint. + destination (google.maps.routing_v2.types.GeocodedWaypoint): + Destination geocoded waypoint. + intermediates (MutableSequence[google.maps.routing_v2.types.GeocodedWaypoint]): + A list of intermediate geocoded waypoints + each containing an index field that corresponds + to the zero-based position of the waypoint in + the order they were specified in the request. + """ + + origin: "GeocodedWaypoint" = proto.Field( + proto.MESSAGE, + number=1, + message="GeocodedWaypoint", + ) + destination: "GeocodedWaypoint" = proto.Field( + proto.MESSAGE, + number=2, + message="GeocodedWaypoint", + ) + intermediates: MutableSequence["GeocodedWaypoint"] = proto.RepeatedField( + proto.MESSAGE, + number=3, + message="GeocodedWaypoint", + ) + + +class GeocodedWaypoint(proto.Message): + r"""Details about the locations used as waypoints. Only populated + for address waypoints. Includes details about the geocoding + results for the purposes of determining what the address was + geocoded to. + + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + geocoder_status (google.rpc.status_pb2.Status): + Indicates the status code resulting from the + geocoding operation. + intermediate_waypoint_request_index (int): + The index of the corresponding intermediate + waypoint in the request. Only populated if the + corresponding waypoint is an intermediate + waypoint. + + This field is a member of `oneof`_ ``_intermediate_waypoint_request_index``. + type_ (MutableSequence[str]): + The type(s) of the result, in the form of + zero or more type tags. Supported types: + https://developers.google.com/maps/documentation/geocoding/requests-geocoding#Types + partial_match (bool): + Indicates that the geocoder did not return an + exact match for the original request, though it + was able to match part of the requested address. + You may wish to examine the original request for + misspellings and/or an incomplete address. + place_id (str): + The place ID for this result. + """ + + geocoder_status: status_pb2.Status = proto.Field( + proto.MESSAGE, + number=1, + message=status_pb2.Status, + ) + intermediate_waypoint_request_index: int = proto.Field( + proto.INT32, + number=2, + optional=True, + ) + type_: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=3, + ) + partial_match: bool = proto.Field( + proto.BOOL, + number=4, + ) + place_id: str = proto.Field( + proto.STRING, + number=5, + ) + + +__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 be3622847d42..44ab9630a649 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 @@ -17,7 +17,7 @@ from typing import MutableMapping, MutableSequence -import google.geo.type.types +from google.geo.type.types import viewport as ggt_viewport from google.protobuf import duration_pb2 # type: ignore import proto # type: ignore @@ -82,7 +82,7 @@ class Route(proto.Message): warnings (MutableSequence[str]): An array of warnings to show when displaying the route. - viewport (google.geo.type.types.Viewport): + viewport (google.geo.type.viewport_pb2.Viewport): The viewport bounding box of the polyline. travel_advisory (google.maps.routing_v2.types.RouteTravelAdvisory): Additional information about the route. @@ -137,10 +137,10 @@ class Route(proto.Message): proto.STRING, number=7, ) - viewport: google.geo.type.types.Viewport = proto.Field( + viewport: ggt_viewport.Viewport = proto.Field( proto.MESSAGE, number=8, - message=google.geo.type.types.Viewport, + message=ggt_viewport.Viewport, ) travel_advisory: "RouteTravelAdvisory" = proto.Field( proto.MESSAGE, @@ -254,19 +254,7 @@ class RouteLegStepTravelAdvisory(proto.Message): Attributes: speed_reading_intervals (MutableSequence[google.maps.routing_v2.types.SpeedReadingInterval]): - Speed reading intervals detailing traffic density. - Applicable in case of ``TRAFFIC_AWARE`` and - ``TRAFFIC_AWARE_OPTIMAL`` routing preferences. The intervals - cover the entire polyline of the RouteLegStep without - overlap. The start point of a specified interval is the same - as the end point of the preceding interval. - - Example: - - :: - - polyline: A ---- B ---- C ---- D ---- E ---- F ---- G - speed_reading_intervals: [A,C), [C,D), [D,G). + NOTE: This field is not currently populated. """ speed_reading_intervals: MutableSequence[ 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 d6b3374333c4..8324d3b000e0 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 @@ -22,6 +22,7 @@ from google.rpc import status_pb2 # type: ignore import proto # type: ignore +from google.maps.routing_v2.types import geocoding_results as gmr_geocoding_results from google.maps.routing_v2.types import routing_preference as gmr_routing_preference from google.maps.routing_v2.types import fallback_info as gmr_fallback_info from google.maps.routing_v2.types import polyline, route @@ -100,7 +101,9 @@ class ComputeRoutesRequest(proto.Message): the request fails. compute_alternative_routes (bool): Optional. Specifies whether to calculate - alternate routes in addition to the route. + alternate routes in addition to the route. No + alternative routes are returned for requests + that have intermediate waypoints. route_modifiers (google.maps.routing_v2.types.RouteModifiers): Optional. A set of conditions to satisfy that affect the way routes are calculated. @@ -259,6 +262,9 @@ class ComputeRoutesResponse(proto.Message): is used, this field contains detailed info about the fallback response. Otherwise this field is unset. + geocoding_results (google.maps.routing_v2.types.GeocodingResults): + Contains geocoding response info for + waypoints specified as addresses. """ routes: MutableSequence[route.Route] = proto.RepeatedField( @@ -271,6 +277,11 @@ class ComputeRoutesResponse(proto.Message): number=2, message=gmr_fallback_info.FallbackInfo, ) + geocoding_results: gmr_geocoding_results.GeocodingResults = proto.Field( + proto.MESSAGE, + number=3, + message=gmr_geocoding_results.GeocodingResults, + ) class ComputeRouteMatrixRequest(proto.Message): diff --git a/packages/google-maps-routing/google/maps/routing_v2/types/waypoint.py b/packages/google-maps-routing/google/maps/routing_v2/types/waypoint.py index a768b3fe1cde..0b8158d4c5ff 100644 --- a/packages/google-maps-routing/google/maps/routing_v2/types/waypoint.py +++ b/packages/google-maps-routing/google/maps/routing_v2/types/waypoint.py @@ -51,6 +51,11 @@ class Waypoint(proto.Message): The POI Place ID associated with the waypoint. + This field is a member of `oneof`_ ``location_type``. + address (str): + Human readable address or a plus code. + See https://plus.codes for details. + This field is a member of `oneof`_ ``location_type``. via (bool): Marks this waypoint as a milestone rather a stopping point. @@ -95,6 +100,11 @@ class Waypoint(proto.Message): number=2, oneof="location_type", ) + address: str = proto.Field( + proto.STRING, + number=7, + oneof="location_type", + ) via: bool = proto.Field( proto.BOOL, number=3, diff --git a/packages/google-maps-routing/setup.py b/packages/google-maps-routing/setup.py index 9baa2a95020c..80774eef6672 100644 --- a/packages/google-maps-routing/setup.py +++ b/packages/google-maps-routing/setup.py @@ -40,7 +40,7 @@ "proto-plus >= 1.22.0, <2.0.0dev", "proto-plus >= 1.22.2, <2.0.0dev; python_version>='3.11'", "protobuf>=3.19.5,<5.0.0dev,!=3.20.0,!=3.20.1,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5", - "google-geo-type<1.0.0dev", + "google-geo-type >= 0.1.0, <1.0.0dev", ] url = "https://github.com/googleapis/google-cloud-python" diff --git a/packages/google-maps-routing/testing/constraints-3.10.txt b/packages/google-maps-routing/testing/constraints-3.10.txt index ed7f9aed2559..2214a366a259 100644 --- a/packages/google-maps-routing/testing/constraints-3.10.txt +++ b/packages/google-maps-routing/testing/constraints-3.10.txt @@ -4,3 +4,4 @@ google-api-core proto-plus protobuf +google-geo-type diff --git a/packages/google-maps-routing/testing/constraints-3.11.txt b/packages/google-maps-routing/testing/constraints-3.11.txt index ed7f9aed2559..2214a366a259 100644 --- a/packages/google-maps-routing/testing/constraints-3.11.txt +++ b/packages/google-maps-routing/testing/constraints-3.11.txt @@ -4,3 +4,4 @@ google-api-core proto-plus protobuf +google-geo-type diff --git a/packages/google-maps-routing/testing/constraints-3.12.txt b/packages/google-maps-routing/testing/constraints-3.12.txt index ed7f9aed2559..2214a366a259 100644 --- a/packages/google-maps-routing/testing/constraints-3.12.txt +++ b/packages/google-maps-routing/testing/constraints-3.12.txt @@ -4,3 +4,4 @@ google-api-core proto-plus protobuf +google-geo-type diff --git a/packages/google-maps-routing/testing/constraints-3.8.txt b/packages/google-maps-routing/testing/constraints-3.8.txt index ed7f9aed2559..2214a366a259 100644 --- a/packages/google-maps-routing/testing/constraints-3.8.txt +++ b/packages/google-maps-routing/testing/constraints-3.8.txt @@ -4,3 +4,4 @@ google-api-core proto-plus protobuf +google-geo-type diff --git a/packages/google-maps-routing/testing/constraints-3.9.txt b/packages/google-maps-routing/testing/constraints-3.9.txt index ed7f9aed2559..2214a366a259 100644 --- a/packages/google-maps-routing/testing/constraints-3.9.txt +++ b/packages/google-maps-routing/testing/constraints-3.9.txt @@ -4,3 +4,4 @@ google-api-core proto-plus protobuf +google-geo-type diff --git a/packages/google-maps-routing/tests/unit/gapic/routing_v2/test_routes.py b/packages/google-maps-routing/tests/unit/gapic/routing_v2/test_routes.py index d55a16fe2d67..068ec592948f 100644 --- a/packages/google-maps-routing/tests/unit/gapic/routing_v2/test_routes.py +++ b/packages/google-maps-routing/tests/unit/gapic/routing_v2/test_routes.py @@ -54,6 +54,7 @@ ) from google.maps.routing_v2.types import ( fallback_info, + geocoding_results, location, polyline, route,