comparison fetch_weather.pl @ 414:d623652df6b5

fetch_weather / weather: Add weather measurement station location data (GPS WGS-84 lat/long/height) to weather cache. Not used in weather.tcl yet, tho.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 07 Jan 2017 22:37:56 +0200
parents b63525aed190
children c88f7449b526
comparison
equal deleted inserted replaced
413:b63525aed190 414:d623652df6b5
411 { 411 {
412 $nrecords++; 412 $nrecords++;
413 $weatherdata->{$meta_data->{$wid}{"properties"}{"names"}{"fi"}} = 413 $weatherdata->{$meta_data->{$wid}{"properties"}{"names"}{"fi"}} =
414 [ 414 [
415 1, 415 1,
416
417 $meta_data->{$wid}{"geometry"}{"coordinates"}[1],
418 $meta_data->{$wid}{"geometry"}{"coordinates"}[0],
419 $meta_data->{$wid}{"geometry"}{"coordinates"}[2],
420
416 str2time(plonk_data($wdata->{"measurementtime"}{"utc"})), 421 str2time(plonk_data($wdata->{"measurementtime"}{"utc"})),
417 plonk_data($wdata->{"airtemperature1"}), 422 plonk_data($wdata->{"airtemperature1"}),
418 423
419 plonk_data($wdata->{"humidity"}), 424 plonk_data($wdata->{"humidity"}),
420 plonk_data($wdata->{"averagewindspeed"}), 425 plonk_data($wdata->{"averagewindspeed"}),
529 $nrecords++; 534 $nrecords++;
530 $weatherdata->{$floc->{"gml:name"}} = 535 $weatherdata->{$floc->{"gml:name"}} =
531 [ 536 [
532 1, 537 1,
533 538
539 $frec->{"lat"},
540 $frec->{"long"},
541 0,
542
534 plonk_data($frec->{"time"}), 543 plonk_data($frec->{"time"}),
535 plonk_data($frec->{"temperature"}), 544 plonk_data($frec->{"temperature"}),
536 545
537 plonk_data($frec->{"humidity"}), 546 plonk_data($frec->{"humidity"}),
538 plonk_data($frec->{"windspeedms"}), 547 plonk_data($frec->{"windspeedms"}),
573 my $wqtime = time(); 582 my $wqtime = time();
574 my $nold = scalar(keys %$weatherdata); 583 my $nold = scalar(keys %$weatherdata);
575 584
576 foreach my $key (keys %$weatherdata) 585 foreach my $key (keys %$weatherdata)
577 { 586 {
578 if ($wqtime - $weatherdata->{$key}[1] > (60 * $purge)) 587 if ($wqtime - $weatherdata->{$key}[4] > (60 * $purge))
579 { 588 {
580 delete $$weatherdata{$key}; 589 delete $$weatherdata{$key};
581 } 590 }
582 } 591 }
583 592