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

后端 未结 2 550
误落风尘
误落风尘 2020-12-15 01:03

I got a large set of about 200 addresses for which I need to know their latitude and longitude. I\'ve created a method that parses the addresses, and now I\'m trying to get

相关标签:
2条回答
  • 2020-12-15 01:34

    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.

    0 讨论(0)
  • 2020-12-15 01:54

    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.

    0 讨论(0)
提交回复
热议问题