Mercurial > hg > egg-tcls
changeset 687:7f1a0d25aa40
fetch_weather: Cleanups, fix counting of FMI stations.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 15 Jun 2023 13:25:32 +0300 |
parents | 2c3df4981df5 |
children | 2723be85343a |
files | fetch_weather.pl |
diffstat | 1 files changed, 9 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/fetch_weather.pl Fri May 13 15:22:44 2022 +0300 +++ b/fetch_weather.pl Thu Jun 15 13:25:32 2023 +0300 @@ -530,17 +530,23 @@ foreach my $xnode (@{$fdata->{"om:featureOfInterest"}{"sams:SF_SpatialSamplingFeature"}{"sams:shape"}{"gml:MultiPoint"}{"gml:pointMember"}}) { my $floc = $xnode->{"gml:Point"}; - if ($floc->{"gml:pos"} =~ /^\s*([\+\-]?\d+\.\d*)\s+([\+\-]?\d+\.\d*)\s*$/) + if ($floc->{"gml:name"} ne "" && + $floc->{"gml:pos"} =~ /^\s*([\+\-]?\d+\.\d*)\s+([\+\-]?\d+\.\d*)\s*$/) { my ($flat, $flong) = ($1, $2); # Should use a hash - foreach my $frec (@farray) { + # If lat/long matches, and location is not yet defined, or + # if timestamp is newer, store to location data if ($frec->{"lat"} == $flat && $frec->{"long"} == $flong && - $floc->{"gml:name"} ne "") + (!defined($weatherdata->{$floc->{"gml:name"}}) || + $frec->{"time"} >= $weatherdata->{$floc->{"gml:name"}}[4]) + ) { - $nrecords++; + $nrecords++ unless defined($weatherdata->{$floc->{"gml:name"}}); + $weatherdata->{$floc->{"gml:name"}} = [ # Measurement source type