Retrieve an address given a location.
The location is given as an object with two numeric fields,
"latitude" and "longitude". For example,
{"latitude": 37.85, "longitude": -122.26}
is
the location of Berkeley, California.
This accessor requires a "key" for the Google Geocoding API, which you can obtain for free at https://developers.google.com/maps/documentation/geocoding/intro .
This accessor looks for a key in $KEYSTORE/geoCoderKey, which resolves to $HOME/.ptKeystore/geoCoderKey (GeoCoding uses the same key as ReverseGeoCoding).
This accessor does not block waiting for the response, but if any additional address input is received before a pending request has received a response or timed out, then the new request will be queued and sent out only after the pending request has completed. This strategy ensures that outputs are produced in the same order as the input requests.
If multiple addresses are returned from the google reverse geocoding service, this accessor outputs the first one on address. The full response is available at the response output.
The accuracy property of the location input is used to filter the returned results. If for example, location is given at a very low accuracy and the given coordinates are intended to represent an entire city or district, it would be overly specific to return the street address. Instead the name of the city should be the output.
- Version:
- $$Id: GeoCoder.js 1804 2017-06-02 19:23:00Z cxh $$
- Source:
Inputs:
Name | Type | Description |
---|---|---|
location |
The location, as an object with a 'latitude' and 'longitude' property. |
Outputs:
Name | Type | Description |
---|---|---|
address |
string | The first returned address, for example "Berkeley, CA". |
response |
An object containing the full address information. |
Methods
(static) filterResponse()
Filter the response, extracting the addresses
(static) setup()
Set up the accessor by defining the inputs and outputs.