On Tue, Jun 8, 2010 at 14:43, mschipperheyn <[email protected]>wrote:
> There seems to be a huge issue in the object that Google sends back > when it comes to the short_name of cities. Every city in the world > AFAIK has a unique short_code. E.g. Amsterdam is AMS, That is the IATA code for the Schiphol Airport, although admittedly we tend to think of "Amsterdam" when seeing that. International Air Transport Association airport code http://en.wikipedia.org/wiki/International_Air_Transport_Association_airport_code AMS means many things, but I can't find that "Amsterdam" (just the city) is one of them: http://en.wikipedia.org/wiki/Ams Buenos Aires is BA, Seem right, yet the geocoder won't return Buenos Aires. http://en.wikipedia.org/wiki/BA http://maps.google.com/maps/api/geocode/json?sensor=false&address=BA New York is NY. NY is a bit ambiguous, NY is the short name for the state of New York, NYC is the short name of the city. http://en.wikipedia.org/wiki/NY_(disambiguation) http://maps.google.com/maps/api/geocode/json?sensor=false&latlng=40.7160,-74.0067 This is the way they are tracked at airports and > is how we can have a database agnostic identifier with which to map > Google Map results against database city records. If you are after the airports, Buenos Aires is BAI and New York could be any of these: http://en.wikipedia.org/wiki/New_York_Airport I've only been to JFK and must admit it was the only one I knew about. Unfortunately, > Google Maps returns 'Amsterdam' as a short_name. I would see this as a > bug, but it is probably a feature. Perhaps the short_name is not > intended to hold the short_code. > I think so. If by short_code you mean the IATA airport code, that is indeed not intended to be, in any way, attached to the city. I come from an island with two airports, none of which are any city's airport, they are just the island's airports. On the other hand, which one out of four (LCY, LTN, LHR, LGW) would you call London's airport? Same for Paris and Rome. Which begs the question: how to match against an existing database > city record? That's a good question, I'd start the search for an answer with yet another question: where did those names (in your existing database) come from? Different organizations may use different long and/or short names. Using the long_name or short_name is obviously out of the > question. Any difference in label between Google and your own platform > and it's over. > Precisely. That is my point in the question above. I just checked a random LatLng at my hometown (28.4744,-16.2567) and the short name for the town is the same as the long one. I can't blame anyone for that, I've seen too many short names for that town: Sta. Cruz de Tenerife, S/C de Tenerife, S/C Tenerife, S/C Tfe... Even looking at the short_name for the administrative_area_level_2, it wasn't the one I expected: Santa Cruz de Tenerife (as a province, not as a town) is never seen abbreviated as "TF", but rather in the same way as the town. TF is just the old 2-letter code for vehicle license plates, which is not used any more for new vehicles since years ago. The only thing I can think of, is to do a query on Google Maps based > on just the city name in your database and the country and store the > resulting longitude, latitude and use that as a match. > I'm not sure I understand your proposal but I wouldn't use coordinate to do the match. You can use the geocoder and ask for, let's say that you have this in your database, "NY" http://maps.google.com/maps/api/geocode/json?sensor=false&address=NY That returns a locality named "New York", so know you can establish a tentative equivalency between "NY" and "New York". But then you look for AMS: http://maps.google.com/maps/api/geocode/json?sensor=false&address=AMS But the locality returned there is Haarlemmermeer, the city of Amsterdam is not there, what would you do? You could try using /A.*M.*S.*/i (case-insensitive regular expression) to see if the locality's name is "related" to the short code, for some value of "related". You may also need to look at all results from the geocoder, not just the first one. Using the regexp approach above, TF would better match "Santa Cruz de Tenerife" than "French Southern and Antarctic Lands" even though both have "short_name": "TF", but how could you programmatically tell which one is the good one each time? http://maps.google.com/maps/api/geocode/json?sensor=false&address=TF One way could be, at this point, using coordinates to see which one is closest to what you want. For instance, comparing results #1 and #2 for "TF" with the coordinates for "Tenerife" you could conclude TF is a valid abbreviation for Tenerife. I'm cheating here because I know it is 0:) But you can even find cases where geocoding the short code will not give you any good match, BA is a pretty good example, even BAI is: http://maps.google.com/maps/api/geocode/json?sensor=false&address=BA http://maps.google.com/maps/api/geocode/json?sensor=false&address=BAI Hell of a workaround if you ask me. Terrible indeed, as the problem itself. I'm afraid at some point you'd need manual tweaking, probably the best way would be enabling end users to do the tweaking by themselves, sometimes a few hundred or thousand of end users will do it faster than a small team of engineers. Power to the people ;) No clue why the short_code isn't > supplied. > Considering the above, I'd imagine the short_name for cities and towns is just not unique. Perhaps someone can enlighten me on this subject? > I'm afraid I didn't really help much to solve the problem 0:) Kind regards, > > Marc > > -- > You received this message because you are subscribed to the Google Groups > "Google Maps JavaScript API v3" group. > To post to this group, send email to > [email protected]. > To unsubscribe from this group, send email to > [email protected]<google-maps-js-api-v3%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/google-maps-js-api-v3?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.
