SIP
set location with google-map format entry - Printable Version

+- SIP (https://nosack.com/sipforum)
+-- Forum: SIP (Sustainable Irrigation Platform) (https://nosack.com/sipforum/forumdisplay.php?fid=1)
+--- Forum: Feature requests (https://nosack.com/sipforum/forumdisplay.php?fid=4)
+--- Thread: set location with google-map format entry (/showthread.php?tid=257)



set location with google-map format entry - paul - 2021 Sep 17

Hi Dan,

It is a bit of an effort on a mobile phone to reformat google-map location data ("lat,lon") for the location settings in weather_level_adj plugin.

So here a snippet to do so -- at line number 366 of SIP/plugins/weather_level_adj.py I add:

        # allow for google map loc format (lat, lon)
        loc = lwa_options[u"loc"]
        q_contain_letters = loc.lower().islower() # city name would contain some letters
        if not(q_contain_letters) and (", " in loc):
            lat, lon = loc.split(", ") # assume google map location format: loc="lat, lon"
            lat, lon = map(lambda s: str(round(float(s),4)), [lat, lon]) # keep only 4 decimal places
            loc = "lat="+lat+"_lon="+lon
            lwa_options[u"loc"] = loc

The data will be saved in the original SIP format, "lat=x.xxx_lon=y.yyy", but one can now copy and paste "lat,lon" from google-map drop-pin.

Of course, the original "city name" and SIP formats still work.

Hope it makes setting up SIP a bit easier.

Paul


RE: set location with google-map format entry - dan - 2021 Sep 19

Thanks Paul,

User contributions are always welcome. I have added your update to the weather plugin on GitHub.

The SIP project has been improved to a large extent by contributions like yours.

Dan