astuder / lightroom-map-fix

Fixing the Map module in Lightroom Classic
125 stars 17 forks source link

QUESTION: 4000+ Geocoding API calls for a single "Lightroom usage session"? #34

Open till213 opened 4 years ago

till213 commented 4 years ago

Hi all,

First of all, thank you for providing this wonderful patch to bring back the Maps Module, worked like a charm!

By now I received the first Google Cloud Platform bill and was a bit surprised, as it stated the following API usage:

Product: Geocoding API Usage (for May): 4430 Price: 21.57 CHF Product: Maps API Usage (for May): 6 Price: 0.04 CHF

Now as this falls within the "Maps Free Tier" (of 200$ per month, if I understood this correctly) I did not have to pay anything, BUT: I only tried Lightroom 6.14 (on Mac, in case that matters) for as short amount of time, basically just to verify that the Maps Module worked again - by clicking on some random (already geotagged) photos, to locate them on the map etc.

Now the 6 Maps API calls do not worry me - but the Geocoding API calls, which apparently were made 4430 times, in a single Lightroom session do worry me a bit! I must add that I think that at one point I had "all photos" in my collection selected, and perhaps Lightroom was trying to resolve the address (?) of each of those photos (given the GPS coordinates which were already in the metadata of the photos).

What I certainly did not do was importing photos, nor did I geotag additional photos (by "moving them onto the map").

So my actual question: what causes these "Geocoding API" calls actually? Is this high amount of calls to be expected (especially when "all photos" are selected in the Library module)? Because if yes I might have to reconsider this "patch" here, as it may turn out to be a costly fix ;)

UPDATE: I applied the patch end of May 2020 (around 25th May 2020 or so...), based on the GitHub patch files available at that time.

astuder commented 4 years ago

Thank you for reporting the large number of calls to the Geocoding API. Probably worth adding a warning to the instructions. If you haven't already, double check that you configured the API quotas to avoid surprise bills.

I don't know when exactly the Geocoding API is invoked. For example, the basic map functionally worked for me when the Geocoding API was disabled, but some people reported that they had to enable it for the map module to work at all. Maybe related to whether photos have embedded GPS data from the camera?

astuder commented 4 years ago

Added step to restrict budget to step 3 of instructions. https://github.com/astuder/lightroom-map-fix#3-restrict-the-google-maps-api-services

Previously budgets and quotas were only mentioned in the "technical details" appendix.

till213 commented 4 years ago

Thank you for your fast reply! I will keep an eye on the usage, and make sure to limit my budget (I read this chapter, but I'll double-check my settings in the Google Cloud API setup ;)).

I will also try to disable the Geocoding API again: from what I understand it allows a client to "lookup" an address (e.g. some town's name), given a GPS coordinate. If the Map module works without this then that's fine for me (should it really turn out that this high number of Geocoding API calls is somehow justified). Because I don't see a need for me to "reverse lookup" a town's name, once a photo (already) has GPS coordinates: maybe Lightroom uses this to automatically fill in some meta data, such as country, town etc. for a given photo. But again, that's not a use case for me.

Well anyway, I'll see what happens if I simply disable the Geocoding API again in Google Cloud API settings, and report back what happens then (and what still works and what possibly does not).

UPDATE: I just checked what the Geocoding API actually provides: https://developers.google.com/maps/documentation/geocoding/start

It seems it provides "both ways", e.g. "Town" -> GPS and the "reverse": GPS -> "Town". I actually did use that feature to locate a GPS coordinate by its "town name" in Lightroom every then and when. Let's see whether I can do without ;)

vb0 commented 4 years ago

Lightroom has a task that does "Address Lookup", it appears (and auto-hides) in the upper-left with other tasks (like Face Detection). Once you have a number of pics with GPS (most commonly coming from smartphones nowadays, but there are cameras with GPS too) it'll try to do the lookup for town and such even years after you have the pics in the catalog. I actually had tens of thousands of pictures processed with this and had to do it over 2 months after I've got this wonderful fix going.

The interface for setting budgets and quotas is absolutely daunting (BTW good job documenting it, otherwise it would've been impossible to navigate) but it's absolutely annoying that you can't limit the budget (that will send only a warning); you can throttle the requests but not directly related to actual money spent. I wonder if it's possible to use a prepaid card with some minimal amount as a workaround (probably with a throw-away account too as most likely Google won't try to charge you until you rack up a huge bill anyway).

astuder commented 4 years ago

Thanks for sharing your insights. This might explain why I never saw this behavior. I have that feature disabled in my catalog settings: image

till213 commented 4 years ago

Thanks for sharing your insights. This might explain why I never saw this behavior. I have that feature disabled in my catalog settings:

Oh, indeed! Those setting were enabled for me (by default, I guess: I don't remember having taken notice of them so far, let alone having changed them).

When I checked the Maps module I had "All Photos" selected (by chance), so that must have caused those many "reverse lookups" (given the GPS coordinates of all those photos that I have added since 2018, since the Maps module stopped working).

As I do not care about this kind of metadata (I guess IPTC was the "culprit" here: it allows to enter location names as well, besides the GPS coordinates) I have now disabled those settings.

I assume that those settings would be okay in the long run though, once Lightroom has "caught up" with looking up all the data for the photos in the catalogue that have been added since the module stopped working (since end of 2018, if I remember correctly - and assuming of course that one does not add thousands of new photos per month to the catalogue). But it would probably be wise to make people aware of those settings, and that an (initial) run by Lightroom could cause a high Geocoding API usage (if not disabled, as shown in the screenshot abve).

Thank you so much for all this work - you rock! This question issue can be closed as "solved" :)

till213 commented 4 years ago

Dear all, I came back here to confirm that the above suggested solution, to turn off Address Lookup, indeed helped. Last month I was regularly using Lightroom (currently not too often, though - you know, taking pictures at home is not that fun ;)) - and I just received my second bill from Google, which now states:

Geocoding API 1st June - 30th June Count: 14 0.07 CHF Maps API 1st June - 30th June Count: 8 0.05 CHF

Total: 0.00 CHF (due to "Maps Free Tier")

The previous Geocoding API count was over 4000 (with enabled Address Lookup). So that problem is definitively solved.