Geocoder Request No Response - Fail - here-api

Is it possible to have the Geocoding API works and sometimes doesn't work for some reason?
Here is the detail what I am trying to request:
http://geocoder.cit.api.here.com/6.2/geocode.xml?app_id=DemoAppId01082013GAL&app_code=AJKnXv84fjrb0KIHawS0Tg&gen=4&country=Australia&state=Tas&district=Wynyard&postalcode=7321&street=86 Jackson Street
and Here is the demo version from the official website:
http://geocoder.cit.api.here.com/6.2/geocode.xml
?app_id=DemoAppId01082013GAL
&app_code=AJKnXv84fjrb0KIHawS0Tg
&gen=7
&housenumber=425
&street=W+Randolph
&city=Chicago
I am using the Free version of it and I have no idea why it works sometimes and doesn't in other times.
Thank you

When you are making a structured address query, by default, all parts of the address need to match. Given that there is no international standard for addresses, the HERE geocoder could be placing parts of the address in an alternative part of the structure.
In your case Wynard is recognized as a city, not a district. Now it is possible you could want this to fail as an invalid address, but it is also possible to tell the Geocoder to be a little more lenient by using the FlexibleAdminValues parameter in the AdditionalData
see the User Guide here
FlexibleAdminValues
N (positive integer <= 1). Customizes flexibility in the input values
for the admin hierarchy defined in LocationFilterType. The value is a
bitmask defining which hierarchies might be swapped without impacting
the match level:
0: No swapping at all (default). Exact admin hierarchy values are
expected as input
1: City and District swapping
Please note this
option is for geocoding addresses and needs at least street level
input to work as designed. It will not return expected results when
the input is a named place only (e.g. city or district name).
So the following url will work for you provided you have a street address:
http://geocoder.cit.api.here.com/6.2/geocode.xml?app_id=APP_ID&app_code=APP_CODE&gen=7&AdditionalData=FlexibleAdminValues,1&country=Australia&state=tas&district=Wynyard&...etc

Another alternative is to not use the structured input parameters but let the HERE Geocoder sort out the identification and categorization of the input tokens.
By using the searchtext parameter and providing all your data as the input value the Geocoder can match and score the tokens.
E.g.: http://geocoder.cit.api.here.com/6.2/geocode.xml?app_id=DemoAppId01082013GAL&app_code=AJKnXv84fjrb0KIHawS0Tg&gen=7&searchtext=Australia%20Tas%20Wynyard%207321%2086%20Jackson%20Street

Related

Incorrect work of autocomplete with Cyrillic

When sending a request to https://autocomplete.geocode.ls.hereapi.com/6.2/suggest.json?query=Вильнюс with an indication of cyrillic nothing comes and with a latin https: //autocomplete.geocode.ls.heraapi.com/6.2/suggest.json?query=Viln all is well. Tell me what the problem is or what I'm doing wrong?
You're not doing anything wrong. Autocomplete is designed to give you addresses that contain (perfectly match) your input string, and the results are sorted by relevance.
When you make your query in russian and provide only "Вильнюс" as input, the service is finding a lot of results (street names) that it considers are more relevant than the city. The city name is also found, but since the service doesn't think that this is what you're searching for, it puts the city much lower in the results list. You don't see it because you're limiting your query to give you only the first 10 matches (with the maxresults=10 parameter), but if you change the maxresults parameter to 20, for example, you will see that Vilnius appears in the 16th place of the API response.
If you want the service to better understand what is the thing you're querying for, you'll need to provide additional information. For example, if you continue typing and your input string is now "Вильнюс " (with a space at the end) or "Вильнюс Л" (a space and another letter), the service will understand what you mean and will return the result you want.
Another way of providing more information to change the way the service ranks the results is by adding a spatial filter, like the country, mapview, or prox parameters mentioned in the API Reference section of the documentation. Alternatively, the resultType parameter can help you filter out all the results with street names and return only city names, if that's what you want. These are just some options available, the one that is right for you will depend on your use case.

Geocode searchText with State and Country provided shows results outside of State

When using the Nokia Here Geocoding Service the State parameter is ignored when searching by searchText: 315 NE 14th Street, State: FL and Country: US.
The only result returned is a location in Louisiana. Adding the State to the end of the searchText doesn't work either.
Google and MapQuest properly return the result in Florida. The client does not want to include a city but rather an address, state and country.
I know that the Nokia Here algorithm does not filter down a closely as Google and MapQuest but expected that the inclusion of the State parameter would force the result search.
You can try setting a search area, so you can further narrow down the results. The following Android example will return one result in Homestead, Florida City:
String query = "315 NE 14th Street Florida US";
GeocodeRequest geocodeRequest = new GeocodeRequest(query);
GeoCoordinate areaCenterCoordinate = new GeoCoordinate(27.82353, -81.760254);
geocodeRequest.setSearchArea(areaCenterCoordinate , 15000);
According to documentation GeocodeRequest processes text string queries, so I believe you can omit state or country parameters and add state or country as part of the search term. Please note that multiple results can be returned if they all match to the given search term.
An example on how to use GeoCoder can be found here.
Depending on your use case, maybe consider to use SearchRequest instead. If this does not help it would be great if you can provide more details in your question, e.g. what API flavor you are referring to.

Filter Google Places API results based on City

For one of my applications, I will let the users choose a City and then an Area. What I want to achieve is that based on the user's city selection, the Area field(which is using the autocomplete from Google Places) to display areas from that City. Eg: If user chooses the city as New York, the Area field should autocomplete only the areas from New York. Is this something which can be achieved?
1] In autocomplete API, pass the "Lat,Long" in "location" parameter and "100000" in "radius" parameter. It will bias search result within 100Km in that city.
Eg: Pass "40.7128,74.0059" for NewYork and it will give you result within 100Km in NewYork city.
OR
2] There is a trick you can use.If a user chooses a city, just add the city name as a prefix in the search string. It will only give the search suggestions in which the user is searching. eg, pass "NewYork" as a prefix in your search string, now type any word, it will only give you results for NewYork city restaurant, cafes, places, etc
You can do it by restricting the results of your autocomplete by a specified area.
Here are the ways that you can use:
Location Biasing - you may bias the results to a specified circle by passing a location and a radius parameter. This instructs the Place Autocomplete service to prefer showing results within that circle. Results outside of the defined area may still be displayed. You can use the components parameter to filter results to show only those places within a specified country.
Location Restrict - it can restrict the results to the region defined by location and a radius parameter, by adding the strictbounds parameter. This instructs the Place Autocomplete service to return only results within that region.
Places Types - you can restrict results from a Place Autocomplete request to be of a certain type by passing a types parameter. The parameter specifies a type or a type collection, as listed in the supported types below. If nothing is specified, all types are returned.
Hope this information helps you.

Interpret Google Geocoding API Response returned to know which of them are accurate

We have a program which calls the Google Geocoding API passing an address. we would like to understand for which of the address, the latitude and longitude values are very correct and for which of them it is approximated.
in the response, there are some tags like address_component which can have multiple "type" tag. there is also location_type under 'geometry'-->'location'
There is also 'type' directly 'result'
we are going which the following logic to understand if the lat and long are accurate.
Check for the multiple "type" under "address_components" and if we find either value "route" or "street_number" in any of the type tags, then it is very accurate.. should we use anyother tags from geocoder response like "location_type" under "location" or "type" under "result" tags.
There is some information on Google Geocoding info, but did not figure out if there is a kind of logic we could apply.
Regards
Siva
The location_type tells you the accuracy of that result, partial match tells you the geocoder did not return an exact match for the request.
See the documentation: Results: location_type/partial match
geometry contains the following information:
location contains the geocoded latitude,longitude value. For normal address lookups, this field is typically the most important.
location_type stores additional data about the specified location. The following values are currently supported:
"ROOFTOP" indicates that the returned result is a precise geocode for which we have location information accurate down to street address precision.
"RANGE_INTERPOLATED" indicates that the returned result reflects an approximation (usually on a road) interpolated between two precise points (such as intersections). Interpolated results are generally returned when rooftop geocodes are unavailable for a street address.
"GEOMETRIC_CENTER" indicates that the returned result is the geometric center of a result such as a polyline (for example, a street) or polygon (region).
"APPROXIMATE" indicates that the returned result is approximate.
partial_match indicates that the geocoder did not return an exact match for the original request, though it was able to match part of the requested address. You may wish to examine the original request for misspellings and/or an incomplete address.
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, "21 Henr 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.

How does Google Maps decide when to use a specific icon?

I am using the Google Maps Places library to do a search for nearby hospitals, but it returns results that aren't necessary hospitals (but have 'hospital' as one of their types). However, I've noticed that actual hospitals have a hospital icon on the map, so Google must somehow know which establishments are actually hospitals. Does anyone know if the public has access to this data?
This is the icon I'm referring to: https://www.dropbox.com/s/1jfqcayxavjhlyi/Screenshot%202015-03-17%2017.20.19.png?dl=0
Example of request I'm making:
var request = {
location: self.location,
radius: 20000,
types: ['hospital'],
keyword: 'hospital'
};
Example result that isn't a hospital:
{"geometry":{"location":{"k":44.815958,"D":-68.808244}},
"icon":"http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png","id":"de6e60bd70b90ba4cb86afe149a60169553607f1",
"name":"Penobscot Community Health Center",
"opening_hours":{"open_now":true,"weekday_text":[]},
"photos":[{"height":320,"html_attributions":[],"width":320}],"place_id":"ChIJj--4INRKrkwRN0z2XkoJtVU",
"rating":3.1,
"reference":"CoQBdAAAADmf3YA0659efzMbCSPOK6SZttkfus7aWBDhrZZyX63Szl256BRcpz81LH6rIuONldYv256tsN7Zv-N6ZkOkJadlD2VS01bs7C4ierKvGUMyJOJu657xL5MvidF3Tgs9iejeJcXsxjDJYOwtN3m3sbfClfWYVnnIL4hMLYV8P9TnEhBurfJv_30CAG2wp1V73POVGhR-7fz1mCdh4OYWSa3Pw0mPupckoQ",
"scope":"GOOGLE",
"types":["hospital","pharmacy","store","health","establishment"],
"vicinity":"1012 Union Street, Bangor",
"html_attributions":[]}
My guess is there are a couple ways to get around this. You might remove the keyword argument from the API, which acts like a search term rather than a specific match on a type of location like the type field does.
You may want to be careful about your radius value choice.
Next, if you do a search on Google Maps in general you'll get a broad assortment of results. Do you need every result to be an actual hospital or can you do your own filtering afterwards?
If you do your own filtering it looks like type information and even icons are embedded in the result JSON. You might see if there's a distinguishing characteristic between the types of results you want and filter by that. Otherwise, any additional graphical data would not be accessible via the API.

Resources