Appendix C: Google Geocoding Output {-}

Example Output {-}

"results": [
    {
        "address_components": [
            {
                "long_name": "1600",
                "short_name": "1600",
                "types": [
                    "street_number"
                ]
            },
            {
                "long_name": "Amphitheatre Parkway",
                "short_name": "Amphitheatre Pkwy",
                "types": [
                    "route"
                ]
            },
            {
                "long_name": "Mountain View",
                "short_name": "Mountain View",
                "types": [
                    "locality",
                    "political"
                ]
            },
            {
                "long_name": "Santa Clara County",
                "short_name": "Santa Clara County",
                "types": [
                    "administrative_area_level_2",
                    "political"
                ]
            },
            {
                "long_name": "California",
                "short_name": "CA",
                "types": [
                    "administrative_area_level_1",
                    "political"
                ]
            },
            {
                "long_name": "United States",
                "short_name": "US",
                "types": [
                    "country",
                    "political"
                ]
            },
            {
                "long_name": "94043",
                "short_name": "94043",
                "types": [
                    "postal_code"
                ]
            }
        ],
        "formatted_address": "1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA",
        "geometry": {
            "location": {
                "lat": 37.4224428,
                "lng": -122.0842467
            },
            "location_type": "ROOFTOP",
            "viewport": {
                "northeast": {
                    "lat": 37.4239627802915,
                    "lng": -122.0829089197085
                },
                "southwest": {
                    "lat": 37.4212648197085,
                    "lng": -122.0856068802915
                }
            }
        },
        "place_id": "ChIJeRpOeF67j4AR9ydy_PIzPuM",
        "plus_code": {
            "compound_code": "CWC8+X8 Mountain View, CA",
            "global_code": "849VCWC8+X8"
        },
        "types": [
            "street_address"
        ]
    }
],
"status": "OK"

Results Decode {-}

When the geocoder returns results, it places them within a (JSON) results array. Even if the geocoder returns no results (such as if the address doesn't exist) it still returns an empty results array. (XML responses consist of zero or more <result> elements.)

A typical result contains the following fields:

Often this address is equivalent to the postal address. Note that some countries, such as the United Kingdom, do not allow distribution of true postal addresses due to licensing restrictions.

The formatted address is logically composed of one or more address components. For example, the address "111 8th Avenue, New York, NY" consists of the following components: "111" (the street number), "8th Avenue" (the route), "New York" (the city) and "NY" (the US state).

Do not parse the formatted address programmatically. Instead you should use the individual address components, which the API response includes in addition to the formatted address field.

Each address component typically contains the following fields:

Note the following facts about the address_components[] array:

To handle the array of components, you should parse the response and select appropriate values via expressions.

The plus code is formatted as a global code and a compound code:

- __global_code__ is a 4 character area code and 6 character or longer local code (849VCWC8+R9).

- __compound_code__ is a 6 character or longer local code with an explicit location (CWC8+R9, Mountain View, CA, USA). Do not programmatically parse this content.

Typically, both the global code and compound code are returned. However, if the result is in a remote location (for example, an ocean or desert) only the global code may be returned.

Partial matches most often occur for street addresses that do not exist within the locality you pass in the request. Partial matches may also be returned when a request matches two or more locations in the same locality. For example, "Hillpar St, Bristol, UK" will return a partial match for both Henry Street and Henrietta Street. Note that if a request includes a misspelled address component, the geocoding service may suggest an alternative address. Suggestions triggered in this way will also be marked as a partial match.

Address types and address component types {-}

The types[] array in the result indicates the address type. Examples of address types include a street address, a country, or a political entity. There is also a types[] array in the address_components[], indicating the type of each part of the address. Examples include street number or country. (Below is a full list of types.) Addresses may have multiple types. The types may be considered 'tags'. For example, many cities are tagged with the political and the locality type.

The following types are supported and returned by the geocoder in both the address type and address component type arrays:

An empty list of types indicates there are no known types for the particular address component, for example, Lieu-dit in France.

In addition to the above, address components may include the types listed here. This list is not exhaustive, and is subject to change.

Note: The Geocoding API isn't guaranteed to return any particular component for an address within our data set. What may be thought of as the city, such as Brooklyn, may not show up as locality, but rather as another component - in this case, sublocality_level_1. What specific components are returned is subject to change without notice. Design your code to be flexible if you are attempting to extract address components from the response.



companieshouse/DARr documentation built on Oct. 22, 2022, 8:26 p.m.