I would like to build a feature in my app that uses that requires knowing the name and/or address of locations where photos in their library were taken. It appears there's no Photos API to get details about a location for each photo, besides PHAsset.location which gives you latitude and longitude. I can reverse geocode that to get the name, address, etc. The problem is geocoding requests are rate limited. For my use-case, users select the photos they want (possibly hundreds), then tap a button to process those photos in a short amount of time.
My questions:
My questions:
What is the limit, and is it per app or per user? If one person processes x number of photos and hits the limit, then can no one else in the world process photos or just that one person? If it's per person, I can limit how many photos they can process at once to be within the usage limits.
Is there any solution you see to implement this and avoid hitting the limit?
Is there any possibility to get more location info from the PHAsset so I don’t need to reverse geocode at all? The Photos app shows a location name for each photo in the nav bar but there's no API to get that.
The geocoding APIs are designed for use in the most common user scenarios, such as looking up the address of the user's current location or that of a "dropped pin" on the map. They are not intended for "bulk" use such as the one you've described.
The simplest fix for this is to look at all the coordinates you need to geocode and group them by their proximity to each other using a pre-defined radius. Then for all the coordinates within that radius, only perform a single geocode. Because users tend to take more than one photo at a given location it is reasonably likely that you can significantly reduce the number of requests you make this way.
Please feel free to file enhancement requests for both the PHAsset (to expose the address) and CoreLocation APIs (for bulk geocoding) at https://developer.apple.com/bug-reporting/.
The simplest fix for this is to look at all the coordinates you need to geocode and group them by their proximity to each other using a pre-defined radius. Then for all the coordinates within that radius, only perform a single geocode. Because users tend to take more than one photo at a given location it is reasonably likely that you can significantly reduce the number of requests you make this way.
Please feel free to file enhancement requests for both the PHAsset (to expose the address) and CoreLocation APIs (for bulk geocoding) at https://developer.apple.com/bug-reporting/.