2

I'm implementing both geocoding and place Google APIs. The first returns some points (lat/long) from an address. The second returns some points of interests form a search entry.

I would like, as the iphone Map native application, to determine if the user have typed an address in the search bar, or just some keywords.

For exemple, if I type :

9 bicycle Street, New York => address, use Geocoding API
9 bicycle Street => Geocoding API
bicycle street   => Geocoding API
bicycle        => Place API
bicycle shop   => Place API

I tried to always call geocoding API, and if no result, Place API. But there is always a result.

Should I detect some keywords, like street, highway, ... ?

Martin
  • 11,881
  • 6
  • 64
  • 110

2 Answers2

0

I've finally found the answer.

iPhone Map native application does not determine if the user have typed an address or just some keywords. It calls the equivalent of place API with a Text Search Requests.

Text search requests are more flexible and powerful than Place Search Requests, but consume 10 times more requests in your limited quota:

Both the Google Place Search, and the Google Places Text Search services share the same usage limits; however, the Text Search Service is subject to a 10 times multiplier. That is, each Text Search request that you make will count as 10 requests against your quota.

Martin
  • 11,881
  • 6
  • 64
  • 110
-1

Your question on the last line of your post made me cringe because there's no guarantee that the user would type those suffixes in an address (they're totally optional and formats vary widely). I've seen this a lot before and detecting keywords isn't the way to go. (Besides, what about a shop named "Bicycle Street"?)

I encourage you to look at my answer over here where I discuss the difficulty of identifying or parsing addresses. There are some examples which show how some crazy-looking addresses are still valid addresses, and not place names.

Further, here's a brief article describing the difficulty in using regular expressions (or common patterns) to identify and extract addresses -- similar to what you are seeking to do.

The reason Google's geocoding API is always giving you a result is because it does address approximation -- if the address doesn't exist, Google does what it does best: it searches for something to show you anyway, something that you're looking for. If you type an address that doesn't exist, it'll still show results because it interpolates and makes up the data so you can still have something to go on. This can be useful sometimes, but here it can bite you.

I'd recommend looking for a service which geocodes only valid addresses, and if no results, then use the places API. For example, LiveAddress API by SmartyStreets (where I work) will only return results if the address can be parsed and actually exists. Look at some of the demos to see what I mean.

This should do what you're looking to accomplish.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Matt
  • 22,721
  • 17
  • 71
  • 112
  • Thanks. I'm totally agree with your first §. Now your answers sounds a lot promotionnal. I would prefer some starting points to develop something myself. – Martin Jul 31 '12 at 13:12
  • Well, interpret it how you will -- but it's a helpful answer that is intended to solve your problem. I'm not saying you shouldn't investigate. There are providers of such services out there other than SmartyStreets: Melissa Data, QAS, Cdyne, etc. See which one fits your budget and workflow the best. – Matt Jul 31 '12 at 14:03
  • @Martin By "develop something myself," did you mean writing your own address geocoder, or some sample code to get started? – Matt Jul 31 '12 at 15:25
  • No, I mean develop something that diferenciate address/keywords from a user entry – Martin Jul 31 '12 at 16:27
  • I wish I could help you, but no practical, do-it-yourself solutions come to mind... Good luck. You're in for a long haul to do this on your own. It's already solved problem, and it's not easy to solve. – Matt Jul 31 '12 at 16:51