How to change Geo information to real name - api

Is there a way to convert Geo information to real place name? For example, I take a photo on "137-159 New Montgomery St San Francisco, CA 94105", the Geotagging information is :
geo:37.786971,-122.399677
when I type the geo in google map, it can show the place name to me. Does google provide API to get it? Thanks in advance.

Yes, the Google Maps API GeoCoder GClientGeocoder.getLocations() provides reverse geocoding as well:
The term geocoding generally refers to translating a human-readable address into a point on the map. The process of doing the converse, translating a point into a human-readable address, is known as reverse geocoding.
The GClientGeocoder.getLocations() method supports both standard and reverse geocoding. If you pass this method a GLatLng object instead of a String address, the geocoder will perform a reverse lookup and return a structured JSON object of the closest addressable location. Note that the closest addressable location may be some distance from the original latitude and longitude values of the query, if the supplied GLatLng is not an exact match for any addressable locations.

Related

Google Places API and Radar Search Requests in iOS

I would like to find all places (max 200) near current location, depend on types (supported types) and the distance radius (max 50 000 meters). I'm working with Google Places API in Objective-C language.
A Radar Search request is an HTTP URL of the following form:
https://maps.googleapis.com/maps/api/place/radarsearch/output?parameters
Example URL:
https://maps.googleapis.com/maps/api/place/radarsearch/json?location=48.859294,2.347589&radius=5000&types=food|cafe&keyword=vegetarian&key=API_KEY
Now I need to put name these finding places to NSString array. I must make loop which return NO when names of places in array are completly. Could you help me or give me links how to working with JSON and fetch data from JSON format?

Differentiate API responses between hamlets and street without number

We intend to use the Google Maps Geocoding API on our website. We want to use the Google Places Autocomplete API and convert the address into (X,Y) coordinates with the Geocoder API.
Yet, in France, some postal addresses are formatted with a hamlet or a small village and the city (and those are correct addresses) instead of the classical "number, street and city".
Geocoding response for this kind of addresses is:
partial_match = empty
location type = GEOMETRIC_CENTER or RANGE_INTERPOLATED
type = route
But this is the same response as a street name with no street number.
Is there any way to differentiate the API responses between "hamlets" and "street without number"?
Thanks for any insight.
[EDIT] Here is an example of my issue:
Hamlet query : http://maps.googleapis.com/maps/api/geocode/json?address=La+Croix+Fay-de-Bretagne+France&sensor=false
Street without number query : http://maps.googleapis.com/maps/api/geocode/json?address=avenue+Charles+Couchoud+Nantes+France&sensor=false
Both returns the same location_type:
"location_type" : "GEOMETRIC_CENTER"
Short answer - your Hamlet example is actually resolving a street: Map Link
To answer your general question (guessing you have this happening elsewhere where it is not the street) which is how to tell how the Geocoding API determined the partial match. If you get a route it should mean you have returned a street (with or without number). A Hamlet should show up as a sublocality or a neighborhood if not it's own locality (here in Canada this is what I have seen):
neighborhood
sublocality
*Note though that these are NOT valid mailing addresses in Canada, which makes my examples a little different than your specified criteria.
To know whether the route is an exact match or a guess is where the status codes come in:
From the API Doc's:
"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.
I would expect that you would see GEOMETRIC_CENTER more often for neighborhood and sublocality and RANGE_INTERPOLATED more often for roads - but that is a guess, and I think it depend more on how much data they have on the location and how the algorithm ends up calculating the point.
When you do have a Hamlet returning as a route I do not believe there is any way to tell just from the Geocoding API returned data that this is what happened. The only solution I could think of is to handle those cases in code within your application based on a list of known problems - but I can see this being very problematic and labour intensive.
This perhaps speaks to the hamlet concept as an postal / administrative one which does not translate to mapping data at all? I tried to find La Croix here and had no luck differentiating: http://www.laposte.com/find_a_post_code/find
One more note: If the Geocoding API had resolved the Hamlet as well as the street you should have had multiple results to pick from, e.g. Yarmouth Note the types list at the end tells you the type of results returned as well if you have multiple results: "types" : [ "locality", "political" ]
Update
I needed some more examples for me and decided to look for ones which would also benefit your question. I found this list of French Hamlets. Trying a few I got these results:
Blessey: sublocality
Brétigny: sublocality
Hautacam: Either fails to be found altogether or is a park and shows as a locality
La Mongie: sublocality
Ham/Clergy: locality So looks like there may be some which come up as localities - perhaps a size threshold - many of the sublocalities are incredibly small.
I think you can safely assume that if something evaluates as a route your result is for a street and not a hameaux <-- (and to think I did poorly in French Immersion here in Canada). Also if you get a route and a sublocality in the results it is a safe bet which is which.
Finally if you know the address part you have is a sublocality and NOT a street, and wish to specify this in the address I do not believe Google's API allows that. There are other services that do, like ESRI.I have not used them and do not know the how licencing works in detail, but it appears to have both a free and subscription service much like Google.
And just for completeness - I think I found La Croix using the ESRI site in the "address": "La Croix, L'Île-d'Yeu" entry from that list - downside is that it didn't recognize Fay-de-Bretagne and give a single answer.

How to find the most popular Foursquare venue in each category in a given city?

According to Foursquare API, Venues/Explore returns a list of recommended venues near the current location, Venues/Search returns a list of venues near the current location, optionally matching the search term. So in both cases, the return-list is the collection of venues near the current location. Not the global collection for a given city. In this case, how does 'Plan my next trip' find the most suitable place for each category in a given city? Thanks!
You can send a geocodable string (such as the city name) as the near parameter in the Search API, leaving the ll (lat/long) parameter empty. This will search in the entire city and not rank results by distance to a specific point.
From the docs:
near Chicago, IL
required unless ll is provided. A string naming a place in the world.
If the near string is not geocodable, returns a failed_geocode error.
Otherwise, searches within the bounds of the geocode. Adds a geocode
object to the response. (Required for query searches)
You can specify the latitude and the longitude using the ll parameter.

Get latitude and longitube from city name

I would like to enter the city name in the UISearchBar,then the map will jump to the current city.
How to do it?
You would need some kind of NSDictionary which would contain all of the city names with their map references (lat/long) maybe this could be integrated with google maps or some other mapping software. Otherwise you will need to attain or build the dictionary manually. Once you have the map reference you could scroll the map to the right location.

SpatialQuery for location based search using Lucene

My lucene index has got latitude and longitudes fields indexed as follows:
doc.Add(new Field("latitude", latitude.ToString() , Field.Store.YES, Field.Index.UN_TOKENIZED));
doc.Add(new Field("longitude", longitude.ToString(), Field.Store.YES, Field.Index.UN_TOKENIZED));
I want to retrieve a set of documents from this index whose lat and long values are in a given range.
As you already know, Lat and long could be negative values. How do i correctly store signed decimal numbers in Lucene?
Would the approach mentioned below give correct results or is there any other way to do this?
Term lowerLatitude = new Term("latitude", bounds.South.ToString() );
Term upperLatitude = new Term("latitude", bounds.North.ToString());
RangeQuery latitudeRangeQuery = new RangeQuery(lowerLatitude, upperLatitude, true);
findLocationQuery.Add(latitudeRangeQuery, BooleanClause.Occur.SHOULD);
Term lowerLongitude = new Term("longitude", bounds.West.ToString());
Term upperLongitude = new Term("longitude", bounds.East.ToString());
RangeQuery longitudeRangeQuery = new RangeQuery(lowerLongitude, upperLongitude, true);
findLocationQuery.Add(longitudeRangeQuery, BooleanClause.Occur.SHOULD);
Also,I wanted to know how Lucene's ConstantScoreRangeQuery is better than RangeQuery class.
Am facing another problem in this context:
I've one of the documents in the index with the following 3 cities:
Lyons, IL
Oak Brook, IL
San Francisco, CA
If i give input as "Lyons, IL" then this record comes up.
But if i give San Francisco, CA as input, then it does not.
However, if i store the cities for this document as follows:
San Francisco, CA
Lyons, IL
Oak Brook, IL
and when i give San Francisco, CA as input, then this record shows in the search results.
What i want here is that if i type any of the 3 cities in input,I should get this document in the search results.
Please help me achieve this.
Thanks.
Following up on skaffman's suggestion, you can use the same tile coordinate system used by all the popular map apps. Choose whatever zoom level is granular enough for your needs, and don't forget to pad with leading zeros.
Regarding RangeQuery, it's slower than ConstantScoreRangeQuery and limits the range of values.
Regarding the city-state problem, we can only speculate. But the first things to check are that the indexed terms and the parsed query are what you expect them to be.
I think the best way is to convert/normalize the coordinates as suggested in the previous post. This article does exactly this. It's actually quite nice object orientated code.
Regarding your second problem. I would assume you have some sort of Analyzer problem. Are you using the same Analyzer for indexing and querying? Which tokenizers do you use?
I recommend to use Luke to inspect your generated index to see what tokens are actually searchable.
--Hardy
One option here is to convert the coordinates into a system that doesn't have negative numbers. For example, I've had a similar problem for a google maps webapp for the UK, and I stored UK Easting/Northings (which range from 0 to 7 digits) fields in Lucene alongside the lat/long values. By formatting these eastings/northings with left-padded zeroes, I could do lucene range queries.
Is there a similar coordinate system for the US?