Unable to use location.reverse_geocode inside a scene/layer
First of: what an inspiring app Pythonista is! I am a developer, though Python is pretty new to me. But I am a quick learner and start to really enjoy Python.
I run into a strange problem and I do not really understand what I am doing wrong or what might go wrong.
I've succesfully made simple sketching application based on the scene module elaborating on the 'example with layers'
I've also succeeded in using the location module and retrieve my current location and made pythonista show me the address of my current location in the console.
But when I try to use the same location code to retrieve and display my current addres in the scene mode, in either the console (displayed after closing the scene) or using the text() command in the scene, I only get 'none' as a result. Retrieving the gps coordinated does work from within a scene. But location.reverse_gecode does not.
Did anyone run into this as well?
Thanks in advance for the time and effort helping me out here...
Yeah, I’m really not sure what’s happening. I don’t really get it. If you try the code at the very top, it should work as expected and GeoCode and ReverseGeo both work (probably not on your iPad, did you try the working code on your phone?
I only dig up this old thread because the problem seemed to be identical and was hopeful that one of the original posters might remember how (if) they resolved it
@daveM Just try working code on my iPad and ok (gps known via WiFi router even if no iPad cellular)
Ahh found the issue. I didn’t look hard enough. There was another post detailing the answer and it has worked. Placing the first line here before the update gets things working!!
@ui.in_background def update(self): If not...
@daveM well done
the worst is that I knew it, I had read this topic, but I forgot, sad to grow old 👴🏻😢
Only 3 months later, shame on me
Lol. Yes. I saw your name there. All good. I’m not sure how much older than me you might be, but I certainly understand the pains of a failing memory!!! Lol
@daveM Also, be careful, these geocode functions need an Internet connection and if you call them to often, you could be refused during some time...
you should not send more than one geocoding request per minute
Édit: typed before reading your post just under
Rofl re not speaking your age. Lol. I’ve just hit a milestone that involved the words [‘half’,’century’], but as with most people I know, now it is just a number. Nobody really cares (unless you’re looking for work or a partner!!!) lol
Re the geocode API, I’ve been wondering what the “go” is with it. I have been using the google API for a few years and never had any issues. But I’ve always respected the limits and played by the rules. I was surprised Apple has opened them up to third parties. I’ll dig through the Apple docs later and see what restrictions are in place, but I don’t plan to use it too often. I’m developing an in-house tool that will allow using it as required. But it’ll only be 10-20 times a day. Although I may hit limits in testing. I hope that’s not the case. Lol
@cvp you beat me to it! Thanks very much I do appreciate that! Cheers!!
(Damn, if someone could hit me some rep points I’d appreciate it!!! @cvp and I submitted a message about the same time, I can’t respond until the time passes... which is why I added this text to the bottom!!) lol
I localize my contacts on a map using this CLGeocoder and I have more than 200 contacts. The script has to retry a lot because it is too much requests in some seconds.
On GitHub, this explanation of my code:
sometimes, geocodeAddressString returns None. Either the address string is invalid, but somerimes, a retry gives a correct gps localization. Perhaps due to a big number of calls in a short time. In this case, the script display a button 'nn not (yet) localized' and starts a thread which will retry (maximum 100 times) all not yet localized contacts. The delay between two retries increase at each retry. The button title is green if the thread runs and red if not. Tapping this button gives the list of these contacts with their retries number
Nice idea. I do like it. I love that we have such great access to the Apple ecosystem through python. Some of the stuff I’ve seen people put together (yourself included) is encouraging.