It is currently February 17th, 2020, 5:18 am

⭐ weather.com - Parsing the JSON

Our most popular Tips and Tricks from the Rainmeter Team and others
Yincognito
Posts: 748
Joined: February 27th, 2015, 2:38 pm

Re: ⭐ weather.com - Parsing the JSON

Post by Yincognito »

SilverAzide wrote:
February 14th, 2020, 12:55 pm
For the first one, I don't know the exact number but I've seen some really long ones. Not sure if it is possible to know the exact number.
For the second item, I think it is the percentage of the sky filled with clouds. Dark Sky has a similar value, where 0 is clear and 1 is completely overcast. Dark Sky leaves it up to you to figure out the difference between clear, fair, partly cloudy, mostly cloudy, and cloudy. This percentage probably drives their description generator, and there's no documentation on what the percentage ranges are for each condition.
Thanks for the info. While the second item is easy to "fix" (English is not my first language, so is "cloud cover" a good term to use for this in a skin?), the first one is quite annoying to me, as I can't fit the "phrase" in the location I reserved for it in my weather skin anymore. Abbreviating stuff would be both ugly and tricky (as I can't cover all word possibilities anyway), so the best solution would be to vertically slide whatever retrieved phrase continuously. Heck, this might even look better than before... :D
jsmorley wrote:
February 14th, 2020, 3:21 pm
Thanks for the links Yincognito.
My pleasure - glad they helped.
User avatar
jsmorley
Developer
Posts: 20225
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: ⭐ weather.com - Parsing the JSON

Post by jsmorley »

Yeah, it will be difficult to "constrain" the Conditions "phrase", as I have seen some very short and some very long ones, and I don't believe that they are even in any way set-in-stone. I have seen some really odd ones, and different ones used at different times to describe the same things. Add to that the issue of "translations", which for some languages can create very long strings indeed, and I just don't see how you can create a space in your skin that will gracefully hold them in all circumstances.

I think you have a few options:

1) Use ClipString=1 and just have the phrase "cut off..." when it is beyond a certain length in pixels.
With this, you might add a ToolTip that contains the entire phrase, set with a ToolTipWidth so it will wrap as needed.
This has the advantage of being really easy, and getting the job done adequately.

2) Use ClipString=2 with ClipStringW and have the phrase "wrap", then have your skin dynamically deal with the change in height.
Not many skin designs are going to look great with this...
3) Use a combination of a Container and an ActionTimer on MouseOver to marquee the contents in and out of a static "viewport".
I sorta lean toward this, as although it is a bit of work, it is a nice effect.
Yincognito
Posts: 748
Joined: February 27th, 2015, 2:38 pm

Re: ⭐ weather.com - Parsing the JSON

Post by Yincognito »

jsmorley wrote:
February 14th, 2020, 3:55 pm
Yeah, it will be difficult to "constrain" the Conditions "phrase", as I have seen some very short and some very long ones, and I don't believe that they are even in any way set-in-stone. I have seen some really odd ones, and different ones used at different times to describe the same things. Add to that the issue of "translations", which for some languages can create very long strings indeed, and I just don't see how you can create a space in your skin that will gracefully hold them in all circumstances.

I think you have a few options:

1) Use ClipString=1 and just have the phrase "cut off..." when it is beyond a certain length in pixels.
2) Use ClipString=2 and have the phrase "wrap", then have your skin dynamically deal with the change in height.
3) Use a combination of a Container and an ActionTimer on MouseOver to slide the contents in and out of a static "viewport".
Yes, indeed. 1) and 2) are out of the question, as I don't want the text truncated or dynamically changed height in my skins, but 3) is going to look fantastic. I already have the code for the horizontal sliding in my feeds skin (see how useful is that "10000 feeds skin" now? :sly: ), I just need to adapt it to slide vertically instead of horizontally, so there will be no confusion over which skin is which in my set.

I did (and will do) use the Container option (great option, by the way), but I prefered to avoid ActionTimer in my previous implementation, and will do so now as well. I also believe it's best to just slide the contents continuously instead of on MouseOver, as the user will expect to read the entire text effortlessly, not to mention that the mouseover also triggers the tooltip (where I have the space for the entire phrase anyway, so a bit of visual redundancy if I trigger mouseover sliding at the same time).
User avatar
jsmorley
Developer
Posts: 20225
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: ⭐ weather.com - Parsing the JSON

Post by jsmorley »

Yincognito wrote:
February 14th, 2020, 4:09 pm
Yes, indeed. 1) and 2) are out of the question, as I don't want the text truncated or dynamically changed height in my skins, but 3) is going to look fantastic. I already have the code for the horizontal sliding in my feeds skin (see how useful is that 10000 feeds skin now? :sly: ), I just need to adapt it to slide vertically instead of horizontally, so there will be no confusion over which skin is which in my set.

I did (and will do) use the Container option (great option, by the way), but I prefered to avoid ActionTimer in my previous implementation, and will do so now as well. I also believe it's best to just slide the contents continuously instead of on MouseOver, as the user will expect to read the entire text effortlessly, not to mention that the mouseover also triggers the tooltip (where I have the space for the entire phrase anyway, so a bit of visual redundancy if I trigger mouseover sliding at the same time).
Sounds good. Personally, I would never have anything in a skin that is moving unasked-for and constantly. I absolutely hate having a distraction like that on my screen. Still, to each his own.
Yincognito
Posts: 748
Joined: February 27th, 2015, 2:38 pm

Re: ⭐ weather.com - Parsing the JSON

Post by Yincognito »

jsmorley wrote:
February 14th, 2020, 4:13 pm
Personally, I would never have anything in a skin that is moving unasked-for and constantly. I absolutely hate having a distraction like that on my screen. Still, to each his own.
It's not so much a distraction, as the skins in the set are quite small, the added CPU usage almost unnoticeable. One thing is compensating another. Other than that, how else can one represent something of variable length in a fixed space? Now they can have a novel there as "phrase", I don't give a freaking flick about it. 8-)

P.S. By the way, the "snowRange" field in DailyForecast is NOT constrained to a "number-number" string, it can be "< number" or "> number" as well, with the "<" and ">" Unicode encoded, naturally.
User avatar
jsmorley
Developer
Posts: 20225
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: ⭐ weather.com - Parsing the JSON

Post by jsmorley »

Yincognito wrote:
February 14th, 2020, 4:23 pm
P.S. By the way, the "snowRange" field in DailyForecast is NOT constrained to a "number-number" string, it can be "< number" or "> number" as well, with the "<" and ">" Unicode encoded, naturally.
Ah, Ok. I don't try to "evaluate" that anyway, just display it.

2-4
< 5
> 1

All work fine for me.
User avatar
SilverAzide
Posts: 680
Joined: March 23rd, 2015, 5:26 pm

Re: ⭐ weather.com - Parsing the JSON

Post by SilverAzide »

The longest Conditions phrase I've encountered (in English) is "Scattered Thunderstorms in the Vicinity". I'm there are longer variations in other languages. :)
DeviantArt Gadgets More...
User avatar
jsmorley
Developer
Posts: 20225
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: ⭐ weather.com - Parsing the JSON

Post by jsmorley »

I'm not certain either way what cloudPct means. It is actually not in "Observation", but only in "Forecast", and I think it is just as likely to mean "percent chance that it will be cloudy" as it does "percent of the sky that is likely to be cloudy". I sorta lean toward the former. The later seems suspiciously "exact" to me. The sky is an undefined and very big place, and it sorta depends on your point of view... What measurement defines the "total" of "sky" in order to obtain a percentage?

On the other hand, I see percentages like 2% and 18% and 74% and the like that don't feel much like the kind of percentages you see for things like "percent precipitation". Those tend to be more even and spaced out like 10%, 30%, 50%, 70%, etc. I've actually never seen a percentage for that that wasn't a multiple of 10. That would tend to point you more toward the second possibility. Feels more like a "measurement" and not a "judgement". I mean, 2% would be a strange number for "How likely is?", that feels a lot more like "How much of?".

In either case, I added it to the @Include. What is to be done with it by a skin author is still TBD a bit I think. It depends if it ends up meaning "will it be cloudy?" or "how cloudy will it be?".

Feels hard to tell for sure from the "Narrative" to me, as the number is presumably going to go up the more "cloudy" it is going to be, no matter which meaning it actually has.

.rmskin in the first post of this thread.
Yincognito
Posts: 748
Joined: February 27th, 2015, 2:38 pm

Re: ⭐ weather.com - Parsing the JSON

Post by Yincognito »

jsmorley wrote:
February 14th, 2020, 4:41 pm
Ah, Ok. I don't try to "evaluate" that anyway, just display it.
All good then.
SilverAzide wrote:
February 14th, 2020, 5:27 pm
The longest Conditions phrase I've encountered (in English) is "Scattered Thunderstorms in the Vicinity". I'm there are longer variations in other languages. :)
Many, many (and again many) thanks. I wanted to ask exactly that, but I thought you'd say "Do you expect me to remember the longest one from so many encountered?", so I never asked in the end. For the time being, I'm gonna risk and go with some "new style abbreviations" based on Unicode chars along the lines of:

Code: Select all

Substitute="(?i)Partly":"◒","(?i)Mostly":"◕","(?i)Early":"↑","(?i)Late":"↓","(?i)Morning":"AM","(?i)Afternoon":"PM","(?i)Scattered":"※","(?i)Shower":"Shr","(?i)Thunder":"T-","(?i)Storm":"St","(?i)in the Vicinity":"near","/":"|"," ":" "
and see how it works, before deciding whether or not to go ahead with sliding the text.
jsmorley wrote:
February 14th, 2020, 5:36 pm
I'm not certain either way what cloudPct means. It is actually not in "Observation", but only in "Forecast", and I think it is just as likely to mean "percent chance that it will be cloudy" as it does "percent of the sky that is likely to be cloudy". I sorta lean toward the former. The later seems suspiciously "exact" to me.
Well, if they get those percentages from taking a photo or a similar measurement from a satellite and then estimate the forecast based on cloud and atmospheric movement - something that can be done automatically in specialized software -, then that would explain why they are so precise, if we talk about the "percent of the sky that is likely to be cloudy". There is too much correlation between that percent and phrase to lean toward the former, in my view. I think SilverAzide is correct on this one, since even if the "percent of the sky that is likely to be cloudy" is low, there could be a high "percent chance that it will be cloudy" - and I've never seen a high cloudPct associated with a "mostly clear" sky phrase.
User avatar
jsmorley
Developer
Posts: 20225
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: ⭐ weather.com - Parsing the JSON

Post by jsmorley »

Yincognito wrote:
February 15th, 2020, 12:30 pm
Well, if they get those percentages from taking a photo or a similar measurement from a satellite and then estimate the forecast based on cloud and atmospheric movement - something that can be done automatically in specialized software -, then that would explain why they are so precise, if we talk about the "percent of the sky that is likely to be cloudy". There is too much correlation between that percent and phrase to lean toward the former, in my view. I think SilverAzide is correct on this one, since even if the "percent of the sky that is likely to be cloudy" is low, there could be a high "percent chance that it will be cloudy" - and I've never seen a high cloudPct associated with a "mostly clear" sky phrase.
Yeah, on reflection, I think that is right.