Hi I've been using the following REST API:
http://autocomplete.geocoder.nxt.api.here.com/6.2/suggest.json?query=100%20Parramatta%20Rd&app_id=XX&app_code=XX&country=AUS
The result used to be:
{
"Label": "100 Parramatta Road, AUBURN NSW 2144",
"Postcode": "2144",
"State": "",
"UnitNo": "",
"StreetNo": "",
"AddressLine1": "",
"AddressLine2": "",
"Suburb": "",
"City": null,
"Country": null,
"BuildingName": null
}
But recently, the content of the "label" is backward:
{
"Label": "Australia, NSW, Croydon, 100 Parramatta Rd",
"Postcode": "2132",
"State": "NSW",
"UnitNo": "",
"StreetNo": "100",
"AddressLine1": "Parramatta Rd",
"AddressLine2": null,
"Suburb": "Croydon",
"City": "Sydney",
"Country": "Australia",
"BuildingName": null
}
Any suggestion?
Thanks :)
Edited to add a more obvious question:
What should I do to make the label looks like the first one again? I want it to be "100 Parramatta Road, AUBURN NSW 2144", instead of "Australia, NSW, Croydon, 100 Parramatta Rd"
If this is what the API you are querying is outputting, then there's not really much you can do about it, unless it's somehow configurable via your API call. Your best bet would be consulting the API documentation.
That being said, if you only need "Australia, NSW, Croydon, 100 Parramatta Rd" to be "100 Parramatta Rd, Croydon, NSW, Australia" instead, you can try splitting the string by , and then reversing it.
// the code below is in C#
var reverseLabel = string.Join(", ", result.Label.Split(',').Reverse());
Related
When sending city, postcode, country code in a structured query to the API, the results seem to be way off what is actually required.
Example #1 - City, Postcode, Country (removed API Key)
https://geocode.search.hereapi.com/v1/geocode?apiKey=XXXXX&qq=city=OXFORD;postalCode=OX2+0ES;country=GBR
This API call returns a result for postalCode OX1 3 which is not what I am looking for.
{
"title": "Oxford, England",
"id": "here:cm:namedplace:20338152",
"resultType": "locality",
"localityType": "city",
"address": {
"label": "Oxford, England",
"countryCode": "GBR",
"countryName": "England",
"countyCode": "OXF",
"county": "Oxfordshire",
"city": "Oxford",
"postalCode": "OX1 3"
},
"position": {
"lat": 51.75629,
"lng": -1.25951
},
Example #2 - Postcode, Country (removed API Key)
https://geocode.search.hereapi.com/v1/geocode?apiKey=XXXXX&qq=postalCode=OX2+0ES;country=GBR
This call returns the postcode OX2 0, which is closer to what I searched for, but still not accurate enough?
{
"title": "OX2 0, Oxford, England",
"id": "here:cm:namedplace:22218302",
"resultType": "locality",
"localityType": "postalCode",
"address": {
"label": "OX2 0, Oxford, England",
"countryCode": "GBR",
"countryName": "England",
"countyCode": "OXF",
"county": "Oxfordshire",
"city": "Oxford",
"postalCode": "OX2 0"
},
"position": {
"lat": 51.76224,
"lng": -1.27976
},
In some cases I have found while testing, is that the difference between the co-ordindates for the returned partial postcode and the full postcode is >= 8 miles out.
The question is, why when you attempt to be more accurate (including city) the response is inaccurate?
Also, if you are sending a full UK postcode to the Geocoder, why does it only resolve to part of the postcode? Surely if you send a full postcode, it should match?
Or, perhaps I need to use a different API. I did see another question with a similar issue that mentions Places API. Should this be used instead?
The only difference between the two addresses is the number(housenumber).
Request_1:
https://geocoder.api.here.com/6.2/geocode.json?app_id={app_id}&app_code={app_code}&countryfocus=BRA&country=BRA&street=AVENIDA VEREADOR EDENITES DA SILVA VIANA&housenumber=244&city=São Francisco de Itabapoana&district=CENTRO&postalcode=28230000&state=RJ
Response_1: -21.47765, -41.10775
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Request_2:
https://geocoder.api.here.com/6.2/geocode.json?app_id={app_id}&app_code={app_code}&countryfocus=BRA&country=BRA&street=AVENIDA VEREADOR EDENITES DA SILVA VIANA&housenumber=160&city=São Francisco de Itabapoana&district=CENTRO&postalcode=28230000&state=RJ
Response_2: -21.47765, -41.10775
help, please
Reason behind same location position in response is because the matchLevel in your request is street so it doesn't matter if you will change the house number in the request, the position will point to the street address every time until it will find a housenumber/name.
"Result": [
{
"Relevance": 0.9,
"MatchLevel": "street",----> street is matched in response
"MatchQuality": {
"Country": 1.0,
"City": 1.0,
"Street": [
0.9
]
},
In the match quality there is no where it says hosuenumber like below response from the example-
"Result": [
{
"Relevance": 1,
"MatchLevel": "houseNumber",
"MatchQuality": {
"Country": 1,
"City": 1,
"Street": [
0.85
],
"HouseNumber": 1
},
To resolve this please enter the valid housenumber which matches this search.
https://developer.here.com/documentation/examples/rest/geocoder/latitude-longitude-by-partial-address
Want to display transit route near by location of my city, I can get it from next departure but if I want to get all Stops served by that specific route in sequence order?
Following is single object of station returned stations/by_geocoord.json
{
"id": "400702222",
"name": "Cosburn Ave at Woodbine Ave",
"distance": 24,
"duration": "PT0H0M24S",
"x": -79.317285,
"y": 43.696509,
"has_board": 1,
"country": "Canada",
"ccode": "CAN",
"state": "ON",
"postal": "M4C 4G4",
"district": "Woodbine-Lumsden",
"street": "Woodbine Ave",
"number": "1349",
"city": "Toronto",
"Transports": {
"Transport": [
{
"name": "87",
"mode": 5,
"dir": "West - 87A Cosburn towards Broadview Station via East York Acres",
"At": {
"textColor": "#FFFFFF",
"color": "#804000"
}
},
{
"name": "87",
"mode": 5,
"dir": "West - 87C Cosburn towards Broadview Station",
"At": {
"textColor": "#FFFFFF",
"color": "#804000"
}
}
]
}
}
How to get list of stops which are included in dir: West - 87A Cosburn towards Broadview Station via East York Acres
You can try this to get all the transit stations/stops within a given radius by using resource as stations/by_geocoord
Here is the Source for the documentation.
https://developer.here.com/documentation/transit/dev_guide/topics/resource-search-geocoord.html
I need to validate whether or not an address is a PO Box using the Geocoder API, and was thinking that the PostalCodeType result would provide me with the info, but it seems that supplying PO Box addresses returns different results.
For example, the following query is for a real-world PO Box:
?app_id={appId}&app_code={appCode}&country=USA&state=WA&searchtext=PO%20Box%20871570%20Vancouver%20WA%2098687&locationattributes=ar,mr,mv,dt,sd,ad,ai,li,in,tz,nb,rn&additionaldata=PreserveUnitDesignators,true
My expected output would be something along the lines of this:
...
"Address": {
"Label": "PO Box 871570, Vancouver, WA, United States",
"Country": "USA",
"State": "WA",
"County": "Clark",
"City": "Vancouver",
"PostalCode": "98687",
"AdditionalData": [
{
"value": "United States",
"key": "CountryName"
},
{
"value": "Washington",
"key": "StateName"
},
{
"value": "Clark",
"key": "CountyName"
},
{
"value": "P",
"key": "PostalCodeType"
}
]
}
...
However, I am getting this result, for a different postal code, without the PO Box info, and the PostalCodeType of N instead of P
...
"Address": {
"Label": "Vancouver, WA, United States",
"Country": "USA",
"State": "WA",
"County": "Clark",
"City": "Vancouver",
"PostalCode": "98660",
"AdditionalData": [
{
"value": "United States",
"key": "CountryName"
},
{
"value": "Washington",
"key": "StateName"
},
{
"value": "Clark",
"key": "CountyName"
},
{
"value": "N",
"key": "PostalCodeType"
}
]
}
...
Is there a better way to search PO Boxes?
Geocoder "PostalCodeType" parameter
for the USA, the Geocoder result shows supplementary information that describes the type of the 5-Digit ZIP, as according to the USPS. The values are as follows:
"N" = Non-Unique
"M" = Military
"P" = PO Box
"U" = Unique Zip
If you looking only for "P" value, then you can filter the JSON response at your end. Filtering additionalData, based upon postalCodeType is not feasible.
https://geocoder.api.here.com/6.2/geocode.json?app_id=xxxx&app_code=xxx&country=USA&state=WA&searchtext=PO%20Box%20871570%20Vancouver%20WA%2098687&locationattributes=ar,mr,mv,dt,sd,ad,ai,li,in,tz,nb,rn&additionaldata=PreserveUnitDesignators,true&addressattributes=pst
When trying to get suggestions at https://autocomplete.geocoder.api.here.com/6.2/suggest.json?query=search_string
for the following strings: "Korea", "China", "Egypt", "United Arab Emirates", the result is weird: some obscure addresses appear, but no countries. What is even more funny, "Sudan" gives the "South Sudan" as a country, but no (North) Sudan. Is this how it should be? For example the result for the "Korea" is:
{
"suggestions": [
{
"label": "United States, NY, New York, Koreatown",
"language": "en",
"countryCode": "USA",
"locationId": "NT_7wUYOjyc5nhxpMHPtLSTuB",
"address": {
"country": "United States",
"state": "NY",
"county": "New York",
"city": "New York",
"district": "Koreatown",
"postalCode": "10001"
},
"matchLevel": "district"
},
{
"label": "United States, NY, Airmont, Korean War Veterans Memorial Hwy",
"language": "en",
"countryCode": "USA",
"locationId": "NT_kA6TbLAbwsSLEA8vabyxDB",
"address": {
"country": "United States",
"state": "NY",
"county": "Rockland",
"city": "Airmont",
"street": "Korean War Veterans Memorial Hwy",
"postalCode": "10901"
},
"matchLevel": "street"
},
{
"label": "United States, OH, Piqua, Korean War Veterans Memorial Hwy",
"language": "en",
"countryCode": "USA",
"locationId": "NT_vccsaqFIU9eMsXqxfj0UMA",
"address": {
"country": "United States",
"state": "OH",
"county": "Miami",
"city": "Piqua",
"street": "Korean War Veterans Memorial Hwy",
"postalCode": "45356"
},
"matchLevel": "street"
},
{
"label": "United States, NY, Spring Valley, Korean War Veterans Memorial Hwy",
"language": "en",
"countryCode": "USA",
"locationId": "NT_oWAdxNTgggvSioBhhX7LAD",
"address": {
"country": "United States",
"state": "NY",
"county": "Rockland",
"city": "Spring Valley",
"street": "Korean War Veterans Memorial Hwy",
"postalCode": "10977"
},
"matchLevel": "street"
}
]
}
far from what one could expect.
The search for countries with border disputes in Autocomplete has a bug and we are about to fix it.
The API at https://autocomplete.geocoder.api.here.com is the Geocoder Autocomplete API, which is useful to autocomplete addresses.
It looks like the Places Search API would better suit to what you need.
For example, the following request with the query string "korea" returns South Korea, North Korea and Korea (looks like there is an administrative area in India which has that name):
curl \
-H 'X-Map-Viewport:-2.8666,-32.6068,176.4302,65.5563' \
--get 'https://places.api.here.com/places/v1/autosuggest' \
--data-urlencode 'app_code={{APP_CODE}}' \
--data-urlencode 'app_id={{APP_ID}}' \
--data-urlencode 'pretty=true' \
--data-urlencode 'q=korea' \
--data-urlencode 'result_types=place' \
--data-urlencode 'size=5'