|
| 1 | +/* |
| 2 | + * Copyright 2024 Google Inc. All rights reserved. |
| 3 | + * |
| 4 | + * |
| 5 | + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this |
| 6 | + * file except in compliance with the License. You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software distributed under |
| 11 | + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF |
| 12 | + * ANY KIND, either express or implied. See the License for the specific language governing |
| 13 | + * permissions and limitations under the License. |
| 14 | + */ |
| 15 | + |
| 16 | +package com.google.maps.model; |
| 17 | + |
| 18 | +import java.io.Serializable; |
| 19 | +import java.util.Arrays; |
| 20 | + |
| 21 | +/** |
| 22 | + * Represents a descriptor of an address. |
| 23 | + * |
| 24 | + * <p>Please see <a href="https://mapsplatform.google.com/demos/address-descriptors/">Address |
| 25 | + * Descriptors</a> for more detail. |
| 26 | + */ |
| 27 | +public class AddressDescriptor implements Serializable { |
| 28 | + |
| 29 | + private static final long serialVersionUID = 1L; |
| 30 | + |
| 31 | + /** Points of interest that provide a reference point for a location. */ |
| 32 | + public static class Landmark implements Serializable { |
| 33 | + |
| 34 | + private static final long serialVersionUID = 1L; |
| 35 | + |
| 36 | + /** |
| 37 | + * The Place ID of the underlying establishment serving as the landmark. Can be used to resolve |
| 38 | + * more information about the landmark through Place Details or Place Id Lookup. |
| 39 | + */ |
| 40 | + public String placeId; |
| 41 | + |
| 42 | + /** The best name for the landmark. */ |
| 43 | + public LocalizedText displayName; |
| 44 | + |
| 45 | + /** |
| 46 | + * One or more values indicating the type of the returned result. Please see <a |
| 47 | + * href="https://developers.google.com/maps/documentation/places/web-service/supported_types">Types |
| 48 | + * </a> for more detail. |
| 49 | + */ |
| 50 | + public String types[]; |
| 51 | + |
| 52 | + /** An enum representing the relationship in space between the landmark and the target. */ |
| 53 | + public enum SpatialRelationship { |
| 54 | + /** This is the default relationship when nothing more specific below applies. */ |
| 55 | + NEAR("near"), |
| 56 | + /** The landmark has a spatial geometry and the target is within its bounds. */ |
| 57 | + WITHIN("within"), |
| 58 | + /** The target is directly adjacent to the landmark or landmark's access point. */ |
| 59 | + BESIDE("beside"), |
| 60 | + /** The target is directly opposite the landmark on the other side of the road. */ |
| 61 | + ACROSS_THE_ROAD("across_the_road"), |
| 62 | + /** On the same route as the landmark but not besides or across. */ |
| 63 | + DOWN_THE_ROAD("down_the_road"), |
| 64 | + /** Not on the same route as the landmark but a single 'turn' away. */ |
| 65 | + AROUND_THE_CORNER("around_the_corner"), |
| 66 | + /** Close to the landmark's structure but further away from its access point. */ |
| 67 | + BEHIND("behind"); |
| 68 | + |
| 69 | + private final String spatialRelationship; |
| 70 | + |
| 71 | + SpatialRelationship(final String spatialRelationship) { |
| 72 | + this.spatialRelationship = spatialRelationship; |
| 73 | + } |
| 74 | + |
| 75 | + @Override |
| 76 | + public String toString() { |
| 77 | + return spatialRelationship; |
| 78 | + } |
| 79 | + |
| 80 | + public String toCanonicalLiteral() { |
| 81 | + return toString(); |
| 82 | + } |
| 83 | + } |
| 84 | + |
| 85 | + /** Defines the spatial relationship between the target location and the landmark. */ |
| 86 | + public SpatialRelationship spatialRelationship; |
| 87 | + |
| 88 | + /** |
| 89 | + * The straight-line distance between the target location and one of the landmark's access |
| 90 | + * points. |
| 91 | + */ |
| 92 | + public float straightLineDistanceMeters; |
| 93 | + |
| 94 | + /** |
| 95 | + * The travel distance along the road network between the target location's closest point on a |
| 96 | + * road, and the landmark's closest access point on a road. This can be unpopulated if the |
| 97 | + * landmark is disconnected from the road network the target is closest to OR if the target |
| 98 | + * location was not actually considered to be on the road network. |
| 99 | + */ |
| 100 | + public float travelDistanceMeters; |
| 101 | + |
| 102 | + @Override |
| 103 | + public String toString() { |
| 104 | + StringBuilder sb = new StringBuilder("[Landmark: "); |
| 105 | + if (placeId != null) { |
| 106 | + sb.append("placeId=").append(placeId); |
| 107 | + } |
| 108 | + if (displayName != null) { |
| 109 | + sb.append(", displayName=").append(displayName); |
| 110 | + } |
| 111 | + if (types != null && types.length > 0) { |
| 112 | + sb.append(", types=").append(Arrays.toString(types)); |
| 113 | + } |
| 114 | + if (spatialRelationship != null) { |
| 115 | + sb.append(", spatialRelationship=").append(spatialRelationship); |
| 116 | + } |
| 117 | + sb.append(", straightLineDistanceMeters=").append(straightLineDistanceMeters); |
| 118 | + sb.append(", travelDistanceMeters=").append(travelDistanceMeters); |
| 119 | + sb.append("]"); |
| 120 | + return sb.toString(); |
| 121 | + } |
| 122 | + } |
| 123 | + |
| 124 | + /** |
| 125 | + * A ranked list of nearby landmarks. The most useful (recognizable and nearby) landmarks are |
| 126 | + * ranked first. |
| 127 | + */ |
| 128 | + public Landmark landmarks[]; |
| 129 | + |
| 130 | + /** Precise regions that are useful at describing a location. */ |
| 131 | + public static class Area implements Serializable { |
| 132 | + |
| 133 | + private static final long serialVersionUID = 1L; |
| 134 | + |
| 135 | + /** |
| 136 | + * The Place ID of the underlying area feature. Can be used to resolve more information about |
| 137 | + * the area through Place Details or Place Id Lookup. |
| 138 | + */ |
| 139 | + public String placeId; |
| 140 | + |
| 141 | + /** The best name for the area. */ |
| 142 | + public LocalizedText displayName; |
| 143 | + |
| 144 | + /** An enum representing the relationship in space between the area and the target. */ |
| 145 | + public enum Containment { |
| 146 | + /** Indicates an unknown containment returned by the server. */ |
| 147 | + CONTAINMENT_UNSPECIFIED("containment_unspecified"), |
| 148 | + |
| 149 | + /** The target location is within the area region, close to the center. */ |
| 150 | + WITHIN("within"), |
| 151 | + |
| 152 | + /** The target location is within the area region, close to the edge. */ |
| 153 | + OUTSKIRTS("outskirts"), |
| 154 | + |
| 155 | + /** The target location is outside the area region, but close by. */ |
| 156 | + NEAR("near"); |
| 157 | + |
| 158 | + private final String containment; |
| 159 | + |
| 160 | + Containment(final String containment) { |
| 161 | + this.containment = containment; |
| 162 | + } |
| 163 | + |
| 164 | + @Override |
| 165 | + public String toString() { |
| 166 | + return containment; |
| 167 | + } |
| 168 | + |
| 169 | + public String toCanonicalLiteral() { |
| 170 | + return toString(); |
| 171 | + } |
| 172 | + } |
| 173 | + |
| 174 | + /** Defines the spatial relationship between the target location and the political region. */ |
| 175 | + public Containment containment; |
| 176 | + |
| 177 | + @Override |
| 178 | + public String toString() { |
| 179 | + StringBuilder sb = new StringBuilder("[Area: "); |
| 180 | + if (placeId != null) { |
| 181 | + sb.append("placeId=").append(placeId); |
| 182 | + } |
| 183 | + if (displayName != null) { |
| 184 | + sb.append(", displayName=").append(displayName); |
| 185 | + } |
| 186 | + if (containment != null) { |
| 187 | + sb.append(", containment=").append(containment); |
| 188 | + } |
| 189 | + sb.append("]"); |
| 190 | + return sb.toString(); |
| 191 | + } |
| 192 | + } |
| 193 | + |
| 194 | + /** |
| 195 | + * A ranked list of containing or adjacent areas. The most useful (recognizable and precise) areas |
| 196 | + * are ranked first. |
| 197 | + */ |
| 198 | + public Area areas[]; |
| 199 | + |
| 200 | + @Override |
| 201 | + public String toString() { |
| 202 | + StringBuilder sb = new StringBuilder("[AddressDescriptor: "); |
| 203 | + if (areas != null && areas.length > 0) { |
| 204 | + sb.append("areas=").append(Arrays.toString(areas)); |
| 205 | + } |
| 206 | + if (landmarks != null && landmarks.length > 0) { |
| 207 | + sb.append(", landmarks=").append(Arrays.toString(landmarks)); |
| 208 | + } |
| 209 | + sb.append("]"); |
| 210 | + return sb.toString(); |
| 211 | + } |
| 212 | +} |
0 commit comments