Hi. So I have completed all of the weather skin measures (and sometimes go back and tweak a regex when there is an error in the log), and am working on the meters. The display of the current conditions, and of the daily forecast, is more or less complete, but I am looking for some improvements in my code. I'll start off with two specific examples.
One of the attributes being displayed in the current conditions is wind, and it looks something like this: Wind WNW 28 G 39 km/h. Now from the XML, the direction, the wind speed, and the gust speed are each an individual measure, and the gust speed may be an empty string (eg. <gust.../>). The wind speed may be 00, indicating "Calm". The desired result is that the wind may display a direction, speed, and gust speed as above, or when there is no gusts, it should display Wind WNW 28 km/h, or when there is no wind it should display Wind Calm. Note that in the wind speed measure, I have substituted "00" with an empty string.
So what I have is this:The label "Wind" and the actual values are two separate meters because the label is left justified and the value is right justified (if there is some way to do that in a single meter, please let me know). This works fine.
Next, I am doing the same thing for the daily forecasts. Now in the daily forecast, there are thirteen periods, but from my observation (and there is no real documentation that I could find), only the first three periods have wind conditions. But those periods may be day, night, day... or night, day, night... depending on whether it is currently day or night. So this then involves four (not three) meters for the wind. In the forecast display, the wind label/value is combined in a single meter, but for each, there is still the like pair of measures shown above. So now that's ten measures.
The second example involves Wind Chill and Humidex, which are mutually exclusive, and either of which are displayed in the same position using the same meter. When neither are present, the meter display is given a colour of clear (0,0,0,1) to make it invisible, rather than hiding the meter, in order to keep the relative positions of other meters the same. Here is the code:Like the first example, the label and value are two separate meters (the first left justified, the second right justified) in the current conditions, but a single meter in the daily forecast periods. This, too, works correctly. So now there are 20 measures to handle the variations in these meters.
But, now I am beginning to work on the hourly forecast, in which there are 24 periods (hours), each of which may potentially have wind speed/gust, and humidex/wind chill. If the same technique were used, that would involve an additional 96 measures! So, I'm wondering if there are better ways of doing this?
One of the attributes being displayed in the current conditions is wind, and it looks something like this: Wind WNW 28 G 39 km/h. Now from the XML, the direction, the wind speed, and the gust speed are each an individual measure, and the gust speed may be an empty string (eg. <gust.../>). The wind speed may be 00, indicating "Calm". The desired result is that the wind may display a direction, speed, and gust speed as above, or when there is no gusts, it should display Wind WNW 28 km/h, or when there is no wind it should display Wind Calm. Note that in the wind speed measure, I have substituted "00" with an empty string.
So what I have is this:
Code:
[msrNowNoWindGust]Measure=StringString=[msrCurrentWindGust]DynamicVariables=1IfMatchMode=1IfMatch=^$IfMatchAction=[!SetVariable nowWindText "%1 %2 km/h"]IfNotMatchAction=[!SetVariable nowWindText "%1 %2 G %3 km/h"][msrNowWindCalm]Measure=StringString=[msrCurrentWindSpeed]DynamicVariables=1IfMatchMode=1IfMatch=^$IfMatchAction=[!SetOption mtrNowWind Text "Calm"]IfNotMatchAction=[!SetOption mtrNowWind Text "#nowWindText#"][mtrNowWindLabel]Group=Current | NowMeter=StringMeterStyle=styleLabelDynamicVariables=1X=#nowIconSize#Y=#margin#RText="Wind"[mtrNowWind]Group=Current | NowMeter=StringMeterStyle=styleAttributeMeasureName=msrCurrentWindDirectionMeasureName2=msrCurrentWindSpeedMeasureName3=msrCurrentWindGustDynamicVariables=1X=(#skinWidth#-#margin#)Y=0r
Next, I am doing the same thing for the daily forecasts. Now in the daily forecast, there are thirteen periods, but from my observation (and there is no real documentation that I could find), only the first three periods have wind conditions. But those periods may be day, night, day... or night, day, night... depending on whether it is currently day or night. So this then involves four (not three) meters for the wind. In the forecast display, the wind label/value is combined in a single meter, but for each, there is still the like pair of measures shown above. So now that's ten measures.
The second example involves Wind Chill and Humidex, which are mutually exclusive, and either of which are displayed in the same position using the same meter. When neither are present, the meter display is given a colour of clear (0,0,0,1) to make it invisible, rather than hiding the meter, in order to keep the relative positions of other meters the same. Here is the code:
Code:
[msrNowNoHumidex]Measure=StringString=[msrCurrentHumidex]DynamicVariables=1IfMatchMode=1IfMatch=^$IfMatchAction=[!SetOption mtrNowHumidexWCLabel FontColor "#colorClear#"][!SetOption mtrNowHumidexWC FontColor "#colorClear#"]IfNotMatchAction=[!SetOption mtrNowHumidexWCLabel FontColor "#colorText#"][!SetOption mtrNowHumidexWC FontColor "#colorText#"][!SetOption mtrNowHumidexWCLabel Text "Humidex"][!SetOption mtrNowHumidexWC Text "%1#degrees#C"][msrNowNoWindChill]Measure=StringString=[msrCurrentWindChill]DynamicVariables=1IfMatchMode=1IfMatch=^$IfNotMatchAction=[!SetOption mtrNowHumidexWCLabel FontColor "#colorText#"][!SetOption mtrNowHumidexWC FontColor "#colorText#"][!SetOption mtrNowHumidexWCLabel Text "Wind Chill"][!SetOption mtrNowHumidexWC Text "%2#degrees#C"][mtrNowHumidexWCLabel]Group=Current | NowMeter=StringMeterStyle=styleLabelDynamicVariables=1X=#nowIconSize#Y=#margin#rText="Wind Chill"[mtrNowHumidexWC]Group=Current | NowMeter=StringMeterStyle=styleAttributeMeasureName=msrCurrentHumidexMeasureName2=msrCurrentWindChillDynamicVariables=1X=(#skinWidth#-#margin#)Y=0rText="%1#degrees#C"
But, now I am beginning to work on the hourly forecast, in which there are 24 periods (hours), each of which may potentially have wind speed/gust, and humidex/wind chill. If the same technique were used, that would involve an additional 96 measures! So, I'm wondering if there are better ways of doing this?
Statistics: Posted by qwerky — Yesterday, 5:58 pm