wviewweather.com Forum Index wviewweather.com
wview and Weather Topics
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Changing wview to use MM instead of CM for all tags/images.

 
Post new topic   Reply to topic    wviewweather.com Forum Index -> Web Sites and HTML Templates
View previous topic :: View next topic  
Author Message
chrisale



Joined: 09 Nov 2005
Posts: 187

PostPosted: Wed Dec 21, 2005 10:51 am    Post subject: Changing wview to use MM instead of CM for all tags/images. Reply with quote

This has all been updated below... please go there.

Last edited by chrisale on Tue Jan 17, 2006 11:58 am; edited 2 times in total
Back to top
View user's profile Send private message MSN Messenger
chrisale



Joined: 09 Nov 2005
Posts: 187

PostPosted: Tue Jan 17, 2006 11:57 am    Post subject: Updated Reply with quote

I've updated my setup to work with wview 3.0.0 as the image functions changed slightly...

Here's what I'm doing to get MM values for rain charts and dials and hPa values for barometer.

First the easy stuff..

HectoPascals (hPa) are equivalent to millibars... so changing the graphs is easy, simply update images-metric.conf so that all the barometer trend graphs or buckets are using hPa instead of mb for units... like so:

Code:

baromday.png            "Barometer"                     hPa          0   30


Changing the rain bar graphs to show MM instead of CM is similarly easy, but does require one major change to wview's normal operation.

In order to get mm throughout wview, you must change the metric converter function the common/wvutils.c source file so that it multiplies the conversion to cm by 10... to get mm... like so:

Code:
float wvutilsConvertRainInchesToCentimeters (float inches)
{
    float      retVal;
   
    retVal = inches * 2.54 * 10;  //to MM
   
    return retVal;
}


This will change ALL METRIC DATA to mm instead of CM. Including all graphs, dials, charts, and individual tags (<!--dayrain--> etc.)... if you are storing your archives in a mySQL or postgreSQL database it will also change the values stored there. It will *not* affect the wlk archives or the data sent to CWOP/Wunderground because those functions use the raw data from the weather station.

So... once you do this... there is no turning back Smile

Once you've made the above change be sure to "make" ... sudo make-install wview to apply the change. Then you can continue.

Next, we want to change the rain bar charts. Now that everything is in MM all we have to do, again, is edit the user-metric.conf file to use mm instead of cm... like so:

Code:
rainday.png             "Rain/hour"                     mm          0   33
rainmonth.png           "Rain/day"                      mm          0   34
rainyear.png            "Rain/week"                     mm          0   35


Notice the decimal places have changed to 0 intead of 1 or 2... the reason of course is because mm values are much larger, and so do not display correctly with multiple decimal places.

Finally... the hard part. Changing the Rain Dials...

This is not necessary however, because the MM values are so large the default rain dials are not optimal for large values... so, I went ahead and modified htmlGenerate.c to add in more dial settings for larger values... like so...

At the top are the original values.. you'll see where I have added more values...

Code:
static char *netrainLabels0C[12] =
{
    "-3.0", "-2.5", "-2.0", "-1.5", "-1.0", "-0.5", "0", "0.5", "1.0", "1.5", "2.0", "2.5"
};
static char *netrainLabels0F[12] =
{
    "-1.2", "-1.0", "-0.8", "-0.6", "-0.4", "-0.2", "0", "0.2", "0.4", "0.6", "0.8", "1.0"
};
static char *netrainLabels1C[12] =
{
    "-30 ", "-25 ", "-20 ", "-15 ", "-10 ", "-5  ", "0", "  5", " 10", " 15", " 20", " 25"
};
static char *netrainLabels1F[12] =
{
    "-12 ", "-10 ", "-8  ", "-6  ", "-4  ", "-2  ", "0", "  2", "  4", "  6", "  8", " 10"
};
static char *netrainLabels2C[12] =
{
    "-60 ", "-50 ", "-40 ", "-30 ", "-20 ", "-10 ", "0", " 10", " 20", " 30", " 40", " 50"
};
static char *netrainLabels2F[12] =
{
    "-24 ", "-20 ", "-16 ", "-12 ", "-8  ", "-4  ", "0", "  4", "  8", " 12", " 16", " 20"
};
static char *netrainLabels3C[12] =
{
    "-300", "-250", "-200", "-150", "-100", "-50 ", "0", " 50", "100", "150", "200", "250"
};
static char *netrainLabels3F[12] =
{
    "-120", "-100", "-80 ", "-60 ", "-40 ", "-20 ", "0", " 20", " 40", " 60", " 80", "100"
};

///ADDING CUSTOM LABELS///

static char *netrainLabels4C[12] =
{
    "-5 ", "0 ", "5 ", "10 ", "15 ", "20 ", "25", " 30", " 35", " 40", " 45", " 50"
};

static char *netrainLabels4F[12] =
{
    "-10", "0 ", "10 ", "20 ", "30 ", "40 ", "50", " 60", " 70", " 80", " 90", " 100"
};

static char *netrainLabels5C[12] =
{
    "-20", "0 ", "20 ", "40 ", "60 ", "80 ", "100", " 120", " 140", " 160", " 180", " 200"
};

static char *netrainLabels5F[12] =
{
    "-50", "0 ", "50 ", "100", "150", "200", "250", "300", "350", "400", "450", "500"
};

static char *netrainLabels6C[12] =
{
    "-100", "0 ", "100 ", "200", "300", "400", "500", "600", "700", "800", "900", "1000"
};

static char *netrainLabels6F[12] =
{
    "-150", "0 ", "150 ", "300", "450", "600", "750", "900", "1050", "1200", "1350", "1500"
};


Now you also have to update the metric code below the section just shown so as to deal with the new conditions and get the dials to display correctly... after much trial and error I've found these to work.

this starts around line 3922 of your updated htmlGenerate.c file it ends around line 4005 after including the new stuff below... or directly before the "else" for the "(isMetricUnits)" funtion.

Code:
// prepare to plot in metric or English
    if (isMetricUnits)
    {
        rain = wvutilsConvertRainInchesToCentimeters (rain);
       
     //   if (-2.5 <= minval && maxval <= 2.5)
     //   {
     //       baserain = 3;      // - minimum rain
     //       mult = 60;         // degrees per cm
     //       for (i = 0; i < 12; i ++)
     //       {
     //           labels[i] = netrainLabels0C[i];
      //      }
      //  }
       
       if (-25 <= rain && rain <= 25)
        {
            baserain = 30;     // - minimum rain
            mult = 6;          // degrees per cm
            for (i = 0; i < 12; i ++)
            {
                labels[i] = netrainLabels1C[i];
            }
        }
         else if (-5 <= rain && rain <= 50)
        {
            baserain = 5;     // - minimum rain // Amount + rainfall to get 0
            mult = 6;          // degrees per cm // 330 degrees / 0 -> pegged
            for (i = 0; i < 12; i ++)
            {
                labels[i] = netrainLabels4C[i];
            }
        }
       
        else if (-10 <= rain && rain <= 100)
        {
            baserain = 10;     // - minimum rain // Amount + rainfall to get 0
            mult = 3;          // degrees per cm // 330 degrees / 0 -> pegged
            for (i = 0; i < 12; i ++)
            {
                labels[i] = netrainLabels4F[i];
            }
        }
       
         else if (-10 <= rain && rain <= 200)
        {
            baserain = 20;     // - minimum rain // Amount + rainfall to get 0
            mult = 1.5;          // degrees per cm
            for (i = 0; i < 12; i ++)
            {
                labels[i] = netrainLabels5C[i];
            }
        }
       
        else if (-10 <= rain && rain <= 500)
        {
            baserain = 50;     // - minimum rain // Amount + rainfall to get 0
            mult = 0.6;          // degrees per cm
            for (i = 0; i < 12; i ++)
            {
                labels[i] = netrainLabels5F[i];
            }
        }
       
        else if (-10 <= rain && rain <= 1000)
        {
            baserain = 100;     // - minimum rain // Amount + rainfall to get 0
            mult = 0.3;          // degrees per cm
            for (i = 0; i < 12; i ++)
            {
                labels[i] = netrainLabels6C[i];
            }
        }
       
        else
        {
            baserain = 150;    // - minimum rain
            mult = 0.37;        // degrees per cm
            for (i = 0; i < 12; i ++)
            {
                labels[i] = netrainLabels6F[i];
            }
        }
    }


That's it for htmlGenerate.c!

Finally, you need to modify the rain dials so that they show the mm instead of cm.

Usually, you would do this by going back to images-metric.conf and simply changing the units from cm to mm for the Rain Dials. Unfortunately, this doesn't seem to have any effect, even though the dials themselves are updated with the correct MM values and the dial "ticks" are correct.. the units don't change. I've put in a troubleshooting request to have this looked at...

in the mean time, you can create your own images using the user-image.c and user-image.conf files.

Here is the code to create the dials in MM.. there is actually no change from the original rain dials.. the only difference is that these user-made images look for their units from the images-user.conf file instead of images-metric.conf:

Code:

////Net Rain daily dial in MM////
static int generateDialNetRainDayMM (HTML_IMG *img)
{
    char        temp[256];

    sprintf (temp, "%s/%s", img->mgrWork->imagePath, img->fname);

    return (htmlGenPngDialNetRain (temp,
                                   img->mgrWork->isMetricUnits,
                                   sensorGetCumulative(&img->mgrWork->hilowStore.sensor[STF_DAY][SENSOR_RAIN]),
                                   sensorGetCumulative(&img->mgrWork->hilowStore.sensor[STF_DAY][SENSOR_ET]),
                                   img->title,
                                   img->units));
}

////Net Rain monthly dial in MM////
static int generateDialNetRainMonthMM (HTML_IMG *img)
{
    char        temp[256];

    sprintf (temp, "%s/%s", img->mgrWork->imagePath, img->fname);

    return (htmlGenPngDialNetRain (temp,
                                   img->mgrWork->isMetricUnits,
                                   sensorGetCumulative(&img->mgrWork->hilowStore.sensor[STF_MONTH][SENSOR_RAIN]),
                                   sensorGetCumulative(&img->mgrWork->hilowStore.sensor[STF_MONTH][SENSOR_ET]),
                                   img->title,
                                   img->units));
}

////Net Rain yearly dial in MM////
static int generateDialNetRainYearMM (HTML_IMG *img)
{
    char        temp[256];

    sprintf (temp, "%s/%s", img->mgrWork->imagePath, img->fname);

    return (htmlGenPngDialNetRain (temp,
                                   img->mgrWork->isMetricUnits,
                                   sensorGetCumulative(&img->mgrWork->hilowStore.sensor[STF_YEAR][SENSOR_RAIN]),
                                   sensorGetCumulative(&img->mgrWork->hilowStore.sensor[STF_YEAR][SENSOR_ET]),
                                   img->title,
                                   img->units));
}





//  ... this is the user-defined generator jump table;
//  ... Indexes from images-user.conf are used to index into this table -
//  ... Thus, order is VERY important...
//  ... Add custom generators here and call them out by index in
//  ... images-user.conf
int (*user_generators[]) (HTML_IMG *img) =
    {
    generateDialNetRainDayMM,      // 0
    generateDialNetRainMonthMM,      // 1
    generateDialNetRainYearMM,      // 2
    NULL
    };


Here is the images-user.conf file:

Code:

dayRainDialMM.png   "Precip Day"                   mm        2   1
monthRainDialMM.png "Precip Month"                   mm        2   2
yearRainDialMM.png    "Precip Year"                   mm        2   3


That's it!

You should be all millimeter--ified.

Just be careful when you upgrade to include the changes to htmlgenerate.c, wvutils.c and images-user.c!

Also... there are efforts underway in other threads to get mm support buil right into wview. This would be an excellent upgrade! And would negate the need for all this hacking. So if this is something you'd like be sure to lend your words of support, or if you're a coder, and can help actually get it done, then that would be the best of all!

Cheers

Chris
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    wviewweather.com Forum Index -> Web Sites and HTML Templates All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group