Geocode an Address within a Bounding Box probably not working properly? - here-api

I am trying to understand how exactly bounding box is working, but from my tests at the moment it seems that result is returned regardless of the bounding box limits.
I tried various approaches,but it appears that either the flow is working this way or I am missing something. In short, I have tried to put in example request:
https://developer.here.com/api-explorer/rest/geocoder/latitude-longitude-by-mapview-parameter
mapview in Boston suburban area and search text which is my home address in Bulgaria - few thousand miles away from the bounding box borders. However, I still get a result-my address Geocoded correctly. Since it is out of the bounding box I was expecting either 0 results or some exception. Or there is some parameter in the Response I can use for defining outboxing-for this case that might be the Distnace because I am too far but in addresses close to borders I am not sure if that will be fine.
My URL request:
https://geocoder.api.here.com/6.2/geocode.json?searchtext=g.k.%20Krasna%20polyana%201%2022%D0%91%2C%201373%20g.k.%20Krasna%20polyana%201%2C%20Sofia&mapview=42.3902%2C-71.1293%3B42.3312%2C-71.0228&gen=9&app_id=devportal-demo-20180625&app_code=9v2BkviRwi9Ot26kp2IysQ
The result I got:
'{
"Response": {
"MetaInfo": {
"Timestamp": "2019-08-16T16:31:38.596+0000"
},
"View": [
{
"_type": "SearchResultsViewType",
"ViewId": 0,
"Result": [
{
"Relevance": 0.88,
"Distance": 7276566.3,
"MatchLevel": "houseNumber",
"MatchQuality": {
"City": 1,
"District": 0.88,
"Street": [
0.85
],
"HouseNumber": 1,
"PostalCode": 0.56
},
"MatchType": "interpolated",
"Location": {
"LocationId": "NT_i2D3cJK.runCacYakfrAxD_yIjQ",
"LocationType": "address",
"DisplayPosition": {
"Latitude": 42.69695,
"Longitude": 23.28172
},
"NavigationPosition": [
{
"Latitude": 42.69709,
"Longitude": 23.28169
}
],
"MapView": {
"TopLeft": {
"Latitude": 42.6980742,
"Longitude": 23.2801904
},
"BottomRight": {
"Latitude": 42.6958258,
"Longitude": 23.2832496
}
},
"Address": {
"Label": "жк Красна поляна 1 22Б, 1330 София, България",
"Country": "BGR",
"County": "София-град",
"City": "София",
"District": "Красна поляна",
"Street": "жк Красна поляна 1",
"HouseNumber": "22Б",
"PostalCode": "1330",
"AdditionalData": [
{
"value": "България",
"key": "CountryName"
},
{
"value": "София-град",
"key": "CountyName"
}
]
}
}
}
]
}
]
}
}'
I am expecting some standard way to catch the results out of the bounding box. Actually, it seems that either there is no clear value to count on or I am missing something about the way it works. Thanks in advance!

I think you are looking for this one:
bbox - A type of Spatial Filter. A spatial filter limits the search for any other attributes in the request.
For your example: https://geocoder.api.here.com/6.2/geocode.json?searchtext=g.k.%20Krasna%20polyana%201%2022%D0%91%2C%201373%20g.k.%20Krasna%20polyana%201%2C%20Sofia&bbox=42.3902%2C-71.1293%3B42.3312%2C-71.0228&&app_id=yyy&app_code=xxx

Related

HERE REST API (fleet.ls) Timezone return incorrect for Adelaide (Australia) possible half hour confuses API

HERE REST API fleet.ls
Consider the following REST API call. Note the Long Lats are in Adelaide Australia which has a TZ of +9:30.
https://fleet.ls.hereapi.com/2/calculateroute.json?waypoint0=-34.8751,138.5276&waypoint1=-34.9042,138.5708;sort&waypoint2=stopOver,600!-34.893,138.5546;sort&departure=2021-01-08T17:15:00&mode=fastest;car;traffic:enabled&legAttributes=-li,-mn,le,bt,tt,-tm,sh&routeAttributes=sm,wp&apikey=xxxxxx
The Departure time is set to:
departure=2021-01-08T17:15:00
However the summary returns the following:
"summary": {
"travelTime": 1010,
"distance": 5102,
"baseTime": 882,
"trafficTime": 1010,
"flags": [],
"departure": "2021-01-08T**17:15:00+10**",
"arrival": "2021-01-08T17:31:49+10"
}
The absolute time is incorrect as the location has a timezone of +9.5 (or +10.5 DST). This, is then passed through to other algorithms used and, well, messes everything up by a half an hour.
It appears you are using version 7 of the Calculate Route API, as shown here. It shows timestamps with only whole-hour offsets, such as 2013-07-04T17:00:00+02.
The docs here for version 8+ of the API show a very different format for its output, including timestamps with full hours and minutes in the offset, such as 2019-12-09T16:05:05+01:00. The full example in docs is:
{
"routes": [
{
"id": "bfaed7d0-19c7-4e72-81b7-24eeb148b62b",
"sections": [
{
"arrival": {
"place": {
"location": {
"lat": 52.53232637420297,
"lng": 13.378873988986015
},
"type": "place"
},
"time": "2019-12-09T16:05:05+01:00"
},
"departure": {
"place": {
"location": {
"lat": 52.53098367713392,
"lng": 13.384566977620125
},
"type": "place"
},
"time": "2019-12-09T16:03:02+01:00"
},
"id": "85357f8f-00ad-447e-a510-d8c02e0b264f",
"summary": {
"duration": 123,
"length": 538
},
"transport": {
"mode": "car"
},
"type": "vehicle"
}
]
}
]
}
I suggest you use the latest v8 of the API (8.14.0 at time of writing this). It should give the correct offsets for Adelaide.

Some Reverse GeoCode queries return null

We are attempting to retrieve district information for a number of locations.
However the Here API returns no values.
These locations are in the state of Arunachal Pradesh and Jammu & Kashmir in India.
I tested with a number of latitude/longitudes for these states. None of them return any data.
https://reverse.geocoder.ls.hereapi.com/6.2/reversegeocode.json?prox=28.2180,94.7278&mode=retrieveAreas&apiKey=XXXXXXXXXXXXXXXXXXXXXXXXXXX
Response:
{
"Response": {
"MetaInfo": {
"Timestamp": "2020-08-05T15:11:46.711+0000"
},
"View": []
}
}
Even when I choose a location from Google Maps and use that in the API call, it still returns null.
https://reverse.geocoder.ls.hereapi.com/6.2/reversegeocode.json?prox=27.083227, 93.605954&mode=retrieveAreas&apiKey=XXXXXXXXXXXXXXXXXXXXXXXXXXX
Response:
{
"Response": {
"MetaInfo": {
"Timestamp": "2020-08-05T15:11:46.711+0000"
},
"View": []
}
}
The Geocoding and Search API v7 is recommended.
https://revgeocode.search.hereapi.com/v1/revgeocode?at=28.2180%2C94.7278&lang=en-US
{
"items": [
{
"title": "Jomlo Mobuk, Arunachal Pradesh, India",
"id": "here:cm:namedplace:22803761",
"resultType": "locality",
"localityType": "city",
"address": {
"label": "Jomlo Mobuk, Arunachal Pradesh, India",
"countryCode": "IND",
"countryName": "India",
"state": "Arunachal Pradesh",
"county": "Siang",
"city": "Jomlo Mobuk",
"postalCode": "791001"
},
"position": {
"lat": 28.22394,
"lng": 94.85208
},
"distance": 0,
"mapView": {
"west": 94.72013,
"south": 28.17345,
"east": 94.9472,
"north": 28.29374
}
}
]
}

What does the PROXIMITY parameter describe (Incident API)

What exactly does the PROXIMITY parameter describe, and why do ORIGIN and TO always have the same PROXIMITY?
Please see the below json snippet taken from the HERE Incident API for an example -
EDIT:
My question is not specific to the json example below but a more general question regarding the meaning of the PROXIMITY parameter.
For instance, "midway between" is pretty self explanatory. What does it mean for a traffic incident to be "at" two points or "past" two points?
In addition, for all the data I have looked at ORIGIN:PROXIMITY:DESCRIPTION is always the same as TO:PROXIMITY:DESCRIPTION. Why?
{
"INTERSECTION": {
"ORIGIN": {
"ID": "",
"STREET1": {
"ADDRESS1": "Pletschenau"
},
"STREET2": {
"ADDRESS1": "Schillerweg"
},
"COUNTY": "Calw",
"STATE": "",
"PROXIMITY": {
"ID": "MID",
"DESCRIPTION": "midway between"
}
},
"TO": {
"ID": "",
"STREET1": {
"ADDRESS1": "Pletschenau"
},
"STREET2": {
"ADDRESS1": "Birkenweg"
},
"COUNTY": "Calw",
"STATE": "",
"PROXIMITY": {
"ID": "MID",
"DESCRIPTION": "midway between"
}
}
},
"GEOLOC": {
"ORIGIN": {
"LATITUDE": 48.73873,
"LONGITUDE": 8.73767
},
"TO": [{
"LATITUDE": 48.74108,
"LONGITUDE": 8.73581
}]
}
}
```
We expecting that your use case does match with the example as follows https://developer.here.com/documentation/examples/rest/traffic/traffic-incidents-via-proximity
This example retrieves traffic incident information related to a specific area of Berlin, as defined by a radius of 15km around a specific point (the prox parameter)
The start(origin) and to(destination) both represents same waypoint here. this explains why these two are not different. In case your API call is different, please share the rest API call.

Here API: Geocoding Free-Text Query Returns Correct Result But Qualified Query Doesn't

I'm experiencing this weird response from the Geocoding API where, in searching for a known address, it would return the correct geocoding result for a free-text query ("q") but return an empty result for the qualified query ("qq") even though the address details are correctly compartmentalized to each field as returned by the free-text query
https://geocode.search.hereapi.com/v1/geocode?apiKey=REMOVED&in=countryCode:AUS&q=Unit+10%2F232A+MAIN+RD++MAROOCHYDORE+4558+QLD+Australia
{
"items": [
{
"title": "Main Rd, Maroochydore QLD 4558, Australia",
"id": "here:af:street:c3mXot9HjZRObEAATNdRhC",
"resultType": "street",
"address": {
"label": "Main Rd, Maroochydore QLD 4558, Australia",
"countryCode": "AUS",
"countryName": "Australia",
"state": "Queensland",
"city": "Sunshine Coast",
"district": "Maroochydore",
"street": "Main Rd",
"postalCode": "4558"
},
"position": {
"lat": -26.65569,
"lng": 153.06295
},
"mapView": {
"west": 153.05138,
"south": -26.66196,
"east": 153.07228,
"north": -26.65418
},
"scoring": {
"queryScore": 0.77,
"fieldScore": {
"country": 1.0,
"state": 1.0,
"district": 1.0,
"streets": [
1.0
],
"postalCode": 1.0
}
}
}
]
}
https://geocode.search.hereapi.com/v1/geocode?apiKey=REMOVED&in=countryCode:AUS&qq=street=MAIN+RD;district=MAROOCHYDORE;postalCode=4558;state=QLD
{
"items": []
}
How often does this inconsistent behaviour occur and what could I implement to mitigate this?
Can you please try using below request call to check whether it is returning the correct data as you expected it to be. Below works for us.
https://geocode.search.hereapi.com/v1/geocode?apiKey=xxxxx&in=countryCode:AUS&qq=country=Australia;state=Queensland;district=MAROOCHYDORE;street=MAIN RD;postalCode=4558;
There won't be inconsistency if the query would be structured. please report if you encounter such more issues. It is advisable to go from more generic to more specifc while specify the structure in the query

How to Get County Information for the given address when we use Rest API

I am using below code to get the address information and i am getting entire address. But i only need county for the given city and zip of USA. Please help
function getCounty()
{
$.ajax({
url: 'https://geocoder.api.here.com/6.2/geocode.json',
type: 'GET',
dataType: 'jsonp',
jsonp: 'jsoncallback',
data: {
city: 'Farmington',
postalcode: '48335',
country: 'usa',
app_id: '**************************',
app_code: '************************',
gen: '9'
},
success: function (data) {
alert(JSON.stringify(data));
}
});
}
Please try below code to access County attribute of the response.
Hope this help.
alert(data.Response.View[0].Result[0].Location.Address.County);
And please check below full JSON response for the request.
{
"Response": {
"MetaInfo": {
"Timestamp": "2019-01-09T07:08:18.912+0000"
},
"View": [
{
"_type": "SearchResultsViewType",
"ViewId": 0,
"Result": [
{
"Relevance": 1,
"MatchLevel": "postalCode",
"MatchQuality": {
"City": 1,
"PostalCode": 1
},
"Location": {
"LocationId": "NT_9usvaftBv-o9T6WyVpnWRC",
"LocationType": "area",
"DisplayPosition": {
"Latitude": 42.47427,
"Longitude": -83.40889
},
"NavigationPosition": [
{
"Latitude": 42.47427,
"Longitude": -83.40889
}
],
"MapView": {
"TopLeft": {
"Latitude": 42.48732,
"Longitude": -83.4355
},
"BottomRight": {
"Latitude": 42.43954,
"Longitude": -83.37537
}
},
"Address": {
"Label": "48335, Farmington, MI, United States",
"Country": "USA",
"State": "MI",
"County": "Oakland",
"City": "Farmington",
"PostalCode": "48335",
"AdditionalData": [
{
"value": "United States",
"key": "CountryName"
},
{
"value": "Michigan",
"key": "StateName"
},
{
"value": "Oakland",
"key": "CountyName"
},
{
"value": "N",
"key": "PostalCodeType"
}
]
}
}
}
]
}
]
}
}

Resources