While that Latitude / Longitude skin I included works pretty well, if you want to be really precise on the location, do this:
- Go to https://www.google.com/maps
- Search for and find your house on the map. Zoom in and right-click on your bedroom.
- Select "What's here?" from the context menu.
- A small card will appear, with the latitude and longitude. Click on the latitude and longitude.
- That latitude and longitude will appear in a sidebar window on the left. Copy them.
- Paste them in as Latitude= and Longitude= in WeatherComJSONVariables.inc
- Refresh
This will reflect your actual location, accurate to a few feet or so.
https://support.google.com/maps/answer/18539?co=GENIE.Platform%3DDesktop&hl=en
Now, the display name that is returned, and to be honest the actual station where the weather is observed isn't actually going to be "Bob's Bedroom", unless you live at the airport maybe, but some administrative district or town name that is nearby. Still, this approach is going to be as accurate as is possible for your location.
If I right-click the skin and select the display name at the top of the context menu, it goes directly to my bedroom in Google Maps. That's accuracy.
Using Latitude / Longitude is certainly more accurate from the standpoint of actual, physical location than any of the "location codes" that the site uses, but the downside is that a code like USVA0944 was tied in a database to a display name of "Fort Hunt", which pleased me, since that is what my "area" is called. Latitude and Longitude return a display name that is a little more general, probably the nearest town. However, the weather itself is as accurate as it possibly can be. Hey, just use a String measure and hard code "Gator Gulch" or whatever you want for display name if you like...
It is currently September 9th, 2024, 1:02 pm
⭐ Weather.com - Parsing the V3 JSON
-
- Developer
- Posts: 22724
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
-
- Developer
- Posts: 22724
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: ⭐ Weather.com - Parsing the V3 JSON - NEW!
My reasoning behind what I get is that there are really only three fields that as I see it are always populated. AdminDistrict (which is state in the US, and some other region name in other countries), Country (there is always a country), and DisplayName (there is always a display name).jazde86 wrote: ↑July 31st, 2020, 9:36 pm Hey jsmorley, thanks for the update. I would prefer if you could replace the LocationName with the City string, as the website does not resolve to the precise place where you live too. Or add it as LocationCity maybe, because it's in the JSON available. More options are always welcome.
Thanks for your effort.
All the other fields, including "city", may or may not be populated, and so you can't really depend on them in a generic way.
It's unlikely but possible that AdminDistrict could be null as well, but since "Springfield US" means exactly nothing, as there are hundreds of towns named Springfield in the US, I simply had to get the "state / region". You can use IfMatch to deal with missing AdminDistrict values if you like.
Still, your observation of "the more the merrier" has some charm. I'll look at getting and offering ALL the fields returned by "location", and leave it up to you which ones you want to use, and how you want to deal with null values for many of them.
-
- Posts: 588
- Joined: February 28th, 2011, 3:20 pm
- Location: Vienna, Austria
Re: ⭐ Weather.com - Parsing the V3 JSON - NEW!
@jsmorley:
thank you very much for all the includes so we can easily concentrate on the contebnt of our skins!
One thing: could you please add a to the measure "[@CurrentObservationDate]" in all of your WeatherComJSONMeasures... -inc-files?
So that, eg. the weekday (or any other local date-part) would be in the locale we can set in the WeatherComJSONVariables.inc
Thank you very much!
thank you very much for all the includes so we can easily concentrate on the contebnt of our skins!
One thing: could you please add a
Code: Select all
FormatLocale=#Language#
So that, eg. the weekday (or any other local date-part) would be in the locale we can set in the WeatherComJSONVariables.inc
Thank you very much!
-
- Developer
- Posts: 22724
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: ⭐ Weather.com - Parsing the V3 JSON - NEW!
Good idea. The next time I have to put out the .inc files that will be there. You can add it to yours in the meantime.ikarus1969 wrote: ↑August 1st, 2020, 6:18 am @jsmorley:
thank you very much for all the includes so we can easily concentrate on the contebnt of our skins!
One thing: could you please add ato the measure "[@CurrentObservationDate]" in all of your WeatherComJSONMeasures... -inc-files?Code: Select all
FormatLocale=#Language#
So that, eg. the weekday (or any other local date-part) would be in the locale we can set in the WeatherComJSONVariables.inc
Thank you very much!
-
- Rainmeter Sage
- Posts: 2734
- Joined: March 23rd, 2015, 5:26 pm
Re: ⭐ Weather.com - Parsing the V3 JSON - NEW!
Sorry to report this, but I've noticed a regex error popping up: RegExp matching error (-1) ([@AlertsParent])
It only happens on the second and later calls to fetch the weather.com data; i.e., the initial call is fine. Perhaps due to the measure being enabled on the second/subsequent calls? Also, it only happens when there are no weather alerts for the location.
It only happens on the second and later calls to fetch the weather.com data; i.e., the initial call is fine. Perhaps due to the measure being enabled on the second/subsequent calls? Also, it only happens when there are no weather alerts for the location.
-
- Developer
- Posts: 22724
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: ⭐ Weather.com - Parsing the V3 JSON - NEW!
Ah, so if it transitions from having one or more alerts to having none. It fails. I assume this is using WeatherComJSONAlerts.inc ?SilverAzide wrote: ↑August 1st, 2020, 5:32 pm Sorry to report this, but I've noticed a regex error popping up: RegExp matching error (-1) ([@AlertsParent])
It only happens on the second and later calls to fetch the weather.com data; i.e., the initial call is fine. Perhaps due to the measure being enabled on the second/subsequent calls? Also, it only happens when there are no weather alerts for the location.
-
- Rainmeter Sage
- Posts: 2734
- Joined: March 23rd, 2015, 5:26 pm
Re: ⭐ Weather.com - Parsing the V3 JSON - NEW!
Correct... Although for me it is barfing on not having any alerts even at the start, but on the second refresh (the first is always clean).
-
- Developer
- Posts: 22724
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: ⭐ Weather.com - Parsing the V3 JSON - NEW!
Simply replace the contents of WeatherComJSONAlerts.inc with this:SilverAzide wrote: ↑August 1st, 2020, 9:24 pm Correct... Although for me it is barfing on not having any alerts even at the start, but on the second refresh (the first is always clean).
Code: Select all
; =================================================================================================
; WeatherComJSONAlerts.inc by JSMorley
; "Weather.com - Parsing the JSON" (https://forum.rainmeter.net/viewtopic.php?f=118&t=34628)
;
; Requires that WeatherComJSONVariables.inc and WeatherComJSONMeasures.inc
; be @Included in the skin before this file.
;
; Updated July 31, 2020
; ==================================================================================================
[@AlertsParent]
Measure=WebParser
Group=Parents
URL=[@EntireSiteSuperParent]
Disabled=1
LogSubstringErrors=0
StringIndex=1
RegExp=(?siU)"v3alertsHeadlines":(?(?=.*{.*,"alerts":).*{.*,"alerts":.*(?(?=.*{"detailKey").*:".*",.*,"eventDescription":"(.*)","severityCode":(.*),"severity":"(.*)",.*,"headlineText":"(.*)",.*}).*(?(?=.*{"detailKey").*:".*",.*,"eventDescription":"(.*)","severityCode":(.*),"severity":"(.*)",.*,"headlineText":"(.*)",.*}).*(?(?=.*{"detailKey").*:".*",.*,"eventDescription":"(.*)","severityCode":(.*),"severity":"(.*)",.*,"headlineText":"(.*)",.*}).*(?(?=.*{"detailKey").*:".*",.*,"eventDescription":"(.*)","severityCode":(.*),"severity":"(.*)",.*,"headlineText":"(.*)",.*}).*(?(?=.*{"detailKey").*:".*",.*,"eventDescription":"(.*)","severityCode":(.*),"severity":"(.*)",.*,"headlineText":"(.*)",.*}).*(?(?=.*{"detailKey").*:".*",.*,"eventDescription":"(.*)","severityCode":(.*),"severity":"(.*)",.*,"headlineText":"(.*)",.*}).*(?(?=.*{"detailKey").*:".*",.*,"eventDescription":"(.*)","severityCode":(.*),"severity":"(.*)",.*,"headlineText":"(.*)",.*}).*(?(?=.*{"detailKey").*:".*",.*,"eventDescription":"(.*)","severityCode":(.*),"severity":"(.*)",.*,"headlineText":"(.*)",.*}).*)
[@Alert1Description]
Measure=WebParser
Url=[@AlertsParent]
StringIndex=1
DecodeCharacterReference=1
RegExpSubstitute=1
Substitute=#CommonSubstitute#
DynamicVariables=1
[@Alert1SeverityCode]
Measure=WebParser
Url=[@AlertsParent]
StringIndex=2
Substitute=#CommonSubstitute#
[@Alert1Severity]
Measure=WebParser
Url=[@AlertsParent]
StringIndex=3
Substitute=#CommonSubstitute#
[@Alert1Text]
Measure=WebParser
Url=[@AlertsParent]
DecodeCharacterReference=1
StringIndex=4
Substitute=#CommonSubstitute#
[@Alert2Description]
Measure=WebParser
Url=[@AlertsParent]
StringIndex=5
DecodeCharacterReference=1
RegExpSubstitute=1
Substitute=#CommonSubstitute#
DynamicVariables=1
[@Alert2SeverityCode]
Measure=WebParser
Url=[@AlertsParent]
StringIndex=6
Substitute=#CommonSubstitute#
[@Alert2Severity]
Measure=WebParser
Url=[@AlertsParent]
StringIndex=7
Substitute=#CommonSubstitute#
[@Alert2Text]
Measure=WebParser
Url=[@AlertsParent]
StringIndex=8
DecodeCharacterReference=1
Substitute=#CommonSubstitute#
[@Alert3Description]
Measure=WebParser
Url=[@AlertsParent]
StringIndex=9
DecodeCharacterReference=1
RegExpSubstitute=1
Substitute=#CommonSubstitute#
DynamicVariables=1
[@Alert3SeverityCode]
Measure=WebParser
Url=[@AlertsParent]
StringIndex=10
Substitute=#CommonSubstitute#
[@Alert3Severity]
Measure=WebParser
Url=[@AlertsParent]
StringIndex=11
Substitute=#CommonSubstitute#
[@Alert3Text]
Measure=WebParser
Url=[@AlertsParent]
StringIndex=12
DecodeCharacterReference=1
Substitute=#CommonSubstitute#
[@Alert4Description]
Measure=WebParser
Url=[@AlertsParent]
StringIndex=13
DecodeCharacterReference=1
RegExpSubstitute=1
Substitute=#CommonSubstitute#
DynamicVariables=1
[@Alert4SeverityCode]
Measure=WebParser
Url=[@AlertsParent]
StringIndex=14
Substitute=#CommonSubstitute#
[@Alert4Severity]
Measure=WebParser
Url=[@AlertsParent]
StringIndex=15
Substitute=#CommonSubstitute#
[@Alert4Text]
Measure=WebParser
Url=[@AlertsParent]
StringIndex=16
DecodeCharacterReference=1
Substitute=#CommonSubstitute#
[@Alert5Description]
Measure=WebParser
Url=[@AlertsParent]
StringIndex=17
DecodeCharacterReference=1
RegExpSubstitute=1
Substitute=#CommonSubstitute#
DynamicVariables=1
[@Alert5SeverityCode]
Measure=WebParser
Url=[@AlertsParent]
StringIndex=18
Substitute=#CommonSubstitute#
[@Alert5Severity]
Measure=WebParser
Url=[@AlertsParent]
StringIndex=19
Substitute=#CommonSubstitute#
[@Alert5Text]
Measure=WebParser
Url=[@AlertsParent]
StringIndex=20
DecodeCharacterReference=1
Substitute=#CommonSubstitute#
[@Alert6Description]
Measure=WebParser
Url=[@AlertsParent]
StringIndex=21
DecodeCharacterReference=1
RegExpSubstitute=1
Substitute=#CommonSubstitute#
DynamicVariables=1
[@Alert6SeverityCode]
Measure=WebParser
Url=[@AlertsParent]
StringIndex=22
Substitute=#CommonSubstitute#
[@Alert6Severity]
Measure=WebParser
Url=[@AlertsParent]
StringIndex=23
Substitute=#CommonSubstitute#
[@Alert6Text]
Measure=WebParser
Url=[@AlertsParent]
StringIndex=24
DecodeCharacterReference=1
Substitute=#CommonSubstitute#
[@Alert7Description]
Measure=WebParser
Url=[@AlertsParent]
StringIndex=25
DecodeCharacterReference=1
RegExpSubstitute=1
Substitute=#CommonSubstitute#
DynamicVariables=1
[@Alert7SeverityCode]
Measure=WebParser
Url=[@AlertsParent]
StringIndex=26
Substitute=#CommonSubstitute#
[@Alert7Severity]
Measure=WebParser
Url=[@AlertsParent]
StringIndex=27
Substitute=#CommonSubstitute#
[@Alert7Text]
Measure=WebParser
Url=[@AlertsParent]
StringIndex=28
DecodeCharacterReference=1
Substitute=#CommonSubstitute#
[@Alert8Description]
Measure=WebParser
Url=[@AlertsParent]
StringIndex=29
DecodeCharacterReference=1
RegExpSubstitute=1
Substitute=#CommonSubstitute#
DynamicVariables=1
[@Alert8SeverityCode]
Measure=WebParser
Url=[@AlertsParent]
StringIndex=30
Substitute=#CommonSubstitute#
[@Alert8Severity]
Measure=WebParser
Url=[@AlertsParent]
StringIndex=31
Substitute=#CommonSubstitute#
[@Alert8Text]
Measure=WebParser
Url=[@AlertsParent]
StringIndex=32
DecodeCharacterReference=1
Substitute=#CommonSubstitute#
I didn't spot this since I live right on the Potomac River, and there are virtually ALWAYS at least one low-level "Small Craft Advisory" alerts in my feed any day of the week whose name ends in "y".
This will be corrected in the file the next time I distribute new .inc files, which likely won't be long, since I want to get that "pollen" stuff in soon.
-
- Rainmeter Sage
- Posts: 2734
- Joined: March 23rd, 2015, 5:26 pm
-
- Posts: 78
- Joined: April 7th, 2010, 2:34 pm
Re: ⭐ Weather.com - Parsing the V3 JSON - NEW!
In my weather skin, when clicking the city name at the top has always opened the city page in the weather.com website.
Using this url: https://weather.com/#Language#/weather/today/l/#LocationCode#
Now after converting to the new Latitude & Longitude method instead of the weather code one, that url obviously does not work anymore.
I know that I can force the user to also enter the location code in addition to the coordinates and that will fix this, but that is something I prefer not to do as it will confuse a lot of my users.
So I wonder if there's some alternative url that uses Latitude & Longitude to open the city page in the weather.com site?
Using this url: https://weather.com/#Language#/weather/today/l/#LocationCode#
Now after converting to the new Latitude & Longitude method instead of the weather code one, that url obviously does not work anymore.
I know that I can force the user to also enter the location code in addition to the coordinates and that will fix this, but that is something I prefer not to do as it will confuse a lot of my users.
So I wonder if there's some alternative url that uses Latitude & Longitude to open the city page in the weather.com site?