iPhone iOS5 CLGeocoder how to geocode a large (200) set of addresses?

不想你离开。 提交于 2019-11-28 21:59:56

You can't immediately geocode large sets. iOS throttles you. I have seen that iOS limits you to 50 geocodes at a time, with the "time" factor being an unknown.

I've had a similar problem, but as I needed only to present the geocoding data in a sequence to the user that takes time, I queued all my geocodings.

Effectively, I geocode a chunk of 25 - display the results to the user 1 at a time at about an interval of a half second between each. When I have fewer than 4 left to display, I will geocode the next 25. This continues until everything is geocoded (or in my case, indefinitely).

If you need to have everything geocoded at once, you'll need to chain your geocodings together with delays between each chunk and show some sort of busy indicator until you are done. Which could be some time with large sets of geocodings.

The answer is you are violating the TOS for Apple's geocoder.

From the CLGeocoder documentation.

Applications should be conscious of how they use geocoding. Here are some rules of thumb for using this class effectively:

Send at most one geocoding request for any one user action. If the user performs multiple actions that involve geocoding the same location, reuse the results from the initial geocoding request instead of starting individual requests for each action. When you want to update the user’s current location automatically (such as when the user is moving), issue new geocoding requests only when the user has moved a significant distance and after a reasonable amount of time has passed. For example, in a typical situation, you should not send more than one geocoding request per minute. Do not start a geocoding request at a time when the user will not see the results immediately. For example, do not start a request if your application is inactive or in the background.

Apple would be well within their rights to stop providing responses, cut off your app entirely, or even revoke your developer account.

If you need to process such a large number of address quickly, then you should look into getting a service like Factual for Points of Interest or Data Science Toolkit for postal addresses and geographic regions.


Update

Here is the API docs for Places API - Resolve, which is Factual's places geocoder.


Update 2

Here is the API for Street Address to Coordinates, which is Data Science Toolkit's location geocoder.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!