From cb03572987491d14c601c36cc19c413b3613e34a Mon Sep 17 00:00:00 2001 From: Brett Morgan Date: Mon, 19 Jun 2017 17:21:55 +1000 Subject: [PATCH 1/2] Adding undocumented address types. Fix for https://github.com/googlemaps/google-maps-services-java/issues/229 --- .../maps/model/AddressComponentType.java | 10 +- .../com/google/maps/model/AddressType.java | 111 ++++++++++++++++-- .../com/google/maps/GeocodingApiTest.java | 31 +++++ 3 files changed, 140 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/google/maps/model/AddressComponentType.java b/src/main/java/com/google/maps/model/AddressComponentType.java index 8d1d28cdf..cc24312c0 100644 --- a/src/main/java/com/google/maps/model/AddressComponentType.java +++ b/src/main/java/com/google/maps/model/AddressComponentType.java @@ -94,6 +94,11 @@ public enum AddressComponentType { */ LOCALITY("locality"), + /** + * {@code WARD} indicates a specific type of Japanese locality, to facilitate distinction between multiple locality components within a Japanese address. + */ + WARD("ward"), + /** * {@code SUBLOCALITY} indicates a first-order civil entity below a locality. For some locations * may receive one of the additional types: sublocality_level_1 to sublocality_level_5. Each @@ -224,11 +229,6 @@ public enum AddressComponentType { */ LIGHT_RAIL_STATION("light_rail_station"), - /** - * {@code WARD} indicates a specific type of Japanese locality, to facilitate distinction between multiple locality components within a Japanese address. - */ - WARD("ward"), - /** * Indicates an unknown address component type returned by the server. The Java Client for Google * Maps Services should be updated to support the new value. diff --git a/src/main/java/com/google/maps/model/AddressType.java b/src/main/java/com/google/maps/model/AddressType.java index 0f5727fd4..6752627e9 100644 --- a/src/main/java/com/google/maps/model/AddressType.java +++ b/src/main/java/com/google/maps/model/AddressType.java @@ -19,7 +19,7 @@ /** * The Address types. Please see - * Address + * Address * Types for more detail. * Some addresses contain additional place categories. Please see * Places @@ -98,6 +98,14 @@ public enum AddressType implements UrlValue { */ LOCALITY("locality"), + /** + * {@code WARD} indicates a specific type of Japanese locality, to facilitate distinction between + * multiple locality components within a Japanese address. + */ + WARD("ward"), + + + /** * {@code SUBLOCALITY} indicates a first-order civil entity below a locality. For some locations * may receive one of the additional types: sublocality_level_1 to sublocality_level_5. Each @@ -216,18 +224,107 @@ public enum AddressType implements UrlValue { */ PLACE_OF_WORSHIP("place_of_worship"), - /** - * {@code WARD} indicates a specific type of Japanese locality, to facilitate distinction between - * multiple locality components within a Japanese address. - */ - WARD("ward"), - /** * {@code POSTAL_TOWN} indicates a grouping of geographic areas, such as locality and sublocality, * used for mailing addresses in some countries. */ POSTAL_TOWN("postal_town"), + /** + * {@code SYNAGOGUE} is currently not a documented return type. + */ + SYNAGOGUE("synagogue"), + + /** + * {@code FOOD} is currently not a documented return type. + */ + FOOD("food"), + + /** + * {@code GROCERY_OR_SUPERMARKET} is currently not a documented return type. + */ + GROCERY_OR_SUPERMARKET("grocery_or_supermarket"), + + /** + * {@code STORE} is currently not a documented return type. + */ + STORE("store"), + + /** + * {@code LAWYER} is currently not a documented return type. + */ + LAWYER("lawyer"), + + /** + * {@code HEALTH} is currently not a documented return type. + */ + HEALTH("health"), + + /** + * {@code INSURANCE_AGENCY} is currently not a documented return type. + */ + INSURANCE_AGENCY("insurance_agency"), + + /** + * {@code GAS_STATION} is currently not a documented return type. + */ + GAS_STATION("gas_station"), + + /** + * {@code CAR_DEALER} is currently not a documented return type. + */ + CAR_DEALER("car_dealer"), + + /** + * {@code CAR_REPAIR} is currently not a documented return type. + */ + CAR_REPAIR("car_repair"), + + /** + * {@code MEAL_TAKEAWAY} is currently not a documented return type. + */ + MEAL_TAKEAWAY("meal_takeaway"), + + /** + * {@code FURNITURE_STORE} is currently not a documented return type. + */ + FURNITURE_STORE("furniture_store"), + + /** + * {@code HOME_GOODS_STORE} is currently not a documented return type. + */ + HOME_GOODS_STORE("home_goods_store"), + + /** + * {@code SHOPPING_MALL} is currently not a documented return type. + */ + SHOPPING_MALL("shopping_mall"), + + /** + * {@code GYM} is currently not a documented return type. + */ + GYM("gym"), + + /** + * {@code ACCOUNTING} is currently not a documented return type. + */ + ACCOUNTING("accounting"), + + /** + * {@code MOVING_COMPANY} is currently not a documented return type. + */ + MOVING_COMPANY("moving_company"), + + /** + * {@code LODGING} is currently not a documented return type. + */ + LODGING("lodging"), + + /** + * {@code STORAGE} is currently not a documented return type. + */ + STORAGE("storage"), + /** * Indicates an unknown address type returned by the server. The Java Client for Google Maps * Services should be updated to support the new value. diff --git a/src/test/java/com/google/maps/GeocodingApiTest.java b/src/test/java/com/google/maps/GeocodingApiTest.java index 1c3b7658e..5e94b5705 100644 --- a/src/test/java/com/google/maps/GeocodingApiTest.java +++ b/src/test/java/com/google/maps/GeocodingApiTest.java @@ -300,4 +300,35 @@ public void testReverseGeocodeWithKitaWard() throws Exception { results[3].addressComponents[0].types[2]); } + /** + * Testing supported Address Types for Geocoding. + */ + @Test + public void testSupportedAddressTypesFood() throws Exception { + GeocodingResult[] results = GeocodingApi.newRequest(context) + .address("Noah's Marketplace, 21800 W Eleven Mile Rd").await(); + + assertNotNull(results); + assertEquals(AddressType.ESTABLISHMENT, results[0].types[0]); + assertEquals(AddressType.FOOD, results[0].types[1]); + assertEquals(AddressType.GROCERY_OR_SUPERMARKET, results[0].types[2]); + assertEquals(AddressType.POINT_OF_INTEREST, results[0].types[3]); + assertEquals(AddressType.STORE, results[0].types[4]); + } + + /** + * Testing supported Address Types for Geocoding - Synagogue. + */ + @Test + public void testSupportedAddressTypesSynagogue() throws Exception { + GeocodingResult[] results = GeocodingApi.newRequest(context) + .address("Ahavas Olam, 15620 W. Ten Mile Road").await(); + + assertNotNull(results); + assertEquals(AddressType.ESTABLISHMENT, results[0].types[0]); + assertEquals(AddressType.PLACE_OF_WORSHIP, results[0].types[1]); + assertEquals(AddressType.POINT_OF_INTEREST, results[0].types[2]); + assertEquals(AddressType.SYNAGOGUE, results[0].types[3]); + } + } From a68b61df1a1a3e00f24b6c8b7ef14e4b6c5c23c5 Mon Sep 17 00:00:00 2001 From: Brett Morgan Date: Mon, 19 Jun 2017 17:32:50 +1000 Subject: [PATCH 2/2] Making PlaceDetailsRequest#Response public --- src/main/java/com/google/maps/PlaceDetailsRequest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/google/maps/PlaceDetailsRequest.java b/src/main/java/com/google/maps/PlaceDetailsRequest.java index 2b388127b..9a5cdfd28 100644 --- a/src/main/java/com/google/maps/PlaceDetailsRequest.java +++ b/src/main/java/com/google/maps/PlaceDetailsRequest.java @@ -49,7 +49,7 @@ protected void validateRequest() { } } - static class Response implements ApiResponse { + public static class Response implements ApiResponse { public String status; public PlaceDetails result; public String[] htmlAttributions;