It is currently October 13th, 2024, 1:47 am

WeatherView

Weather skins
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5540
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

WeatherView

Post by eclectic-tech »

Image
WEATHERVIEW

Based on Weather.com
Includes an APIKey retrieval skin and a WeatherComJSON setting skin that can be added to any weather skin using WeatherComJSON files developed on the Rainmeter Forum.

Credits
JSMorley (and others) for WeatherComJSON files
Mordasius, SiiverAzide, and QuakeGuy for AutoLocation inspiration and suggestions
ApexXx-Sensei settings skins

V1.2023.03.29
- Simplified Auto-location (Thanks Mordasius!)
- Corrected webparser error messages display
- APIKey can be saved to variables and copied to clipboard

Download from my DA site
User avatar
Mordasius
Posts: 1178
Joined: January 22nd, 2011, 4:23 pm
Location: GMT +8

Re: WeatherView

Post by Mordasius »

Greetings ET

The ipapi.co/json search you use to identify the location from the IP address returns a latitude / longitude within 3km of where I actually live which is far better than some other sites. For example https://whatismyipaddress.com/ , https://www.whatismyip.com/ and https://www.iplocation.net/find-ip-address/ are are all out by 350km using my IPv4 address and up to 600km using IPv6. By comparison https://ipregistry.co/ gives the same nearbye location as https://ipapi.co using the IPv6 address.

But I digress. In your AutoLocation skin you use https://ipapi.co/json to get the city, region and country identifers which are then passed to https://nominatim to get the Latitude and Longitude for use in the Weatherview.ini skin. In my case this gives latitude and longitude cordinates which are again within 3km of where I live and quite close enough for a weather skin but my question is why do you use the https://nominatim site when you can get what what you need from the original ipapi.co/json search?
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5540
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: WeatherView

Post by eclectic-tech »

Mordasius wrote: March 28th, 2023, 7:12 am Greetings ET

The ipapi.co/json search you use to identify the location from the IP address returns a latitude / longitude within 3km of where I actually live which is far better than some other sites. For example https://whatismyipaddress.com/ , https://www.whatismyip.com/ and https://www.iplocation.net/find-ip-address/ are are all out by 350km using my IPv4 address and up to 600km using IPv6. By comparison https://ipregistry.co/ gives the same nearbye location as https://ipapi.co using the IPv6 address.

But I digress. In your AutoLocation skin you use https://ipapi.co/json to get the city, region and country identifers which are then passed to https://nominatim to get the Latitude and Longitude for use in the Weatherview.ini skin. In my case this gives latitude and longitude cordinates which are again within 3km of where I live and quite close enough for a weather skin but my question is why do you use the https://nominatim site when you can get what what you need from the original ipapi.co/json search?
The quick answer is that I borrowed and combined code from several sources to obtain an auto-location and didn't look at optimization. :Whistle

I will revisit this to see if it can be simplified. If both sites return the same values for latitude and longitude it may be possible to eliminate the nominatim parsing. :???:

EDIT: I also use https://www.mapcoordinates.net/ as an alternative to both sites to manually obtain the latiude and longitude values. Can you have too many methods to find locations :D ?
User avatar
Mordasius
Posts: 1178
Joined: January 22nd, 2011, 4:23 pm
Location: GMT +8

Re: WeatherView

Post by Mordasius »

eclectic-tech wrote: March 28th, 2023, 1:16 pm If both sites return the same values for latitude and longitude it may be possible to eliminate the nominatim parsing. :???:
They don't return exactly the same coordinates but https://ipapi.co/json is actually better in my case which means I can use your [MeasureLocationbyIP] modified as follows to get everything I need.

Code: Select all

[MeasureLocationbyIP]
Measure=WebParser
UpdateRate=1800
URL=https://ipapi.co/json
RegExp=(?siU)"version": "(.*)".*"city": "(.*)".*"region": "(.*)".*"country_name": "(.*)".*"latitude": (.*),.*"longitude": (.*),.*"utc_offset": "(.*)".*
FinishAction=[!SetVariable IPLocation "[mCitybyIP], [mRegionbyIP], [mCountrybyIP]"]
OnConnectErrorAction=[!WriteKeyValue Variables Location "No IP information" "#SettingsFile#"]
OnRegExpErrorAction=[!WriteKeyValue Variables Location "No IP information" "#SettingsFile#"]

[mIPversion]
Measure=WebParser
URL=[MeasureLocationbyIP]
StringIndex=1
RegExpSubstitute=1
Disabled=1

[mCitybyIP]
Measure=WebParser
URL=[MeasureLocationbyIP]
StringIndex=2
RegExpSubstitute=1
Disabled=1

[mRegionbyIP]
Measure=WebParser
URL=[MeasureLocationbyIP]
StringIndex=3
Disabled=1

[mCountrybyIP]
Measure=WebParser
URL=[MeasureLocationbyIP]
StringIndex=4
Disabled=1

[mLatitudebyIP]
Measure=WebParser
URL=[MeasureLocationbyIP]
StringIndex=5
Disabled=1

[mLongitudebyIP]
Measure=WebParser
URL=[MeasureLocationbyIP]
StringIndex=6
Disabled=1

[mTimeZonebyIP]
Measure=WebParser
URL=[MeasureLocationbyIP]
StringIndex=7
Substitute="15":".25","45":".75", "00":"","01":"1","02":"2","03":"3","04":"4","05":"5","06":"6","07":"7","08":"8","09":"9"
Disabled=1
User avatar
Yincognito
Rainmeter Sage
Posts: 8442
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: WeatherView

Post by Yincognito »

Mordasius wrote: March 28th, 2023, 7:12 amThe ipapi.co/json search you use to identify the location from the IP address returns a latitude / longitude within 3km of where I actually live which is far better than some other sites.
It surely is better (and lighter) than the alternatives you mentioned (about the same as https://whatismyip.live/ for IPv6), but in my case the coordinates are 45 km of where I live, thus not exactly a good fit for weather. Of course, I doubt there is a perfect fit anyway, when it comes to free and common folk usable alternatives. Automating this is a nice thing to have, however nothing beats the manual setting of such coordinates.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
Mordasius
Posts: 1178
Joined: January 22nd, 2011, 4:23 pm
Location: GMT +8

Re: WeatherView

Post by Mordasius »

eclectic-tech wrote: March 28th, 2023, 1:16 pm I also use https://www.mapcoordinates.net/ as an alternative to both sites to manually obtain the latiude and longitude values. Can you have too many methods to find locations :D ?
No you can't have too many sites and what is special about https://www.mapcoordinates.net/ is that it also gives the elevation above sea level which is a requirement for super-accurate Prayer Times. If only someone knew a way to scape the site.....
Yincognito wrote: March 28th, 2023, 2:24 pm It surely is better (and lighter) than the alternatives you mentioned (about the same as https://whatismyip.live/ for IPv6)
Yes this is another goodie for your location from IPv6 which gives the time zone and is easily scaped.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5540
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: WeatherView

Post by eclectic-tech »

Thanks for the code... I will have some time later today or tomorrow to update the skin with this and perhaps an option as suggested by Yincognito.

Accurate "Automatic Locating" is a pipe dream, but offering as many options as possible to the end user should let them make the skin as accurate as possible (within the limits of weather.com's station locations).

Thanks again :thumbup:
User avatar
Yincognito
Rainmeter Sage
Posts: 8442
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: WeatherView

Post by Yincognito »

eclectic-tech wrote: March 28th, 2023, 2:52 pm... perhaps an option as suggested by Yincognito.
Well, I don't know about suggesting something, I was merely reflecting that such a site might give for someone (e.g. Mordasius) a 3 km range and for another (e.g. me) a 50 km one - ipapi.co and whatismyip.live are exactly the same in that regard for me, by the way, they both give a location at 45 km from where I live.

Other than that, I like how fast and detailed is ipapi.co - I would have probably changed my current ident.me site that I use for IPv4/IPv6 detection to it in my network skin, if only ipapi.co provided an IPv4 address to begin with (I display both v4 and v6 addresses, along with the used protocol, so not only the address for the used protocol).
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5540
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: WeatherView

Post by eclectic-tech »

Updated to V1.2023.03.29
- Simplified Auto-location (Thanks Mordasius!)
- Corrected webparser error messages display
- APIKey retrieval can be saved to the JSON variables file and copied to clipboard

Auto-locating will use your ISP location which can be anywhere from a few kilometers or nearly 75 kilometers away from your actual location.
The skin offers an internet map lookup of your location latitude and longitude (then copy and paste) or by entering the values directly in the settings skin.
User avatar
Mordasius
Posts: 1178
Joined: January 22nd, 2011, 4:23 pm
Location: GMT +8

Re: WeatherView

Post by Mordasius »

eclectic-tech wrote: March 29th, 2023, 9:08 pm - Simplified Auto-location (Thanks Mordasius!)
Oops. The [mTimeZonebyIP] I posted above has a dud Substitute string that will not pick up the correct TimeZone for the many places that have a xx30 UTC offset (India, Nepal, Afganistan, Iran, parts of Australia, etc.). The correct version is:

Code: Select all

[mTimeZonebyIP]
Measure=WebParser
URL=[MeasureLocationbyIP]
StringIndex=7
Substitute="30":".5","45":".75", "00":"","01":"1","02":"2","03":"3","04":"4","05":"5","06":"6","07":"7","08":"8","09":"9"
Disabled=1
Apologies.. :oops:
Last edited by Mordasius on March 30th, 2023, 2:44 am, edited 1 time in total.