# HG changeset patch # User Matti Hamalainen # Date 1686824732 -10800 # Node ID 7f1a0d25aa40ce549282ba46291235eb2371c865 # Parent 2c3df4981df5284b01f4d15658ab70a9e35f5a94 fetch_weather: Cleanups, fix counting of FMI stations. diff -r 2c3df4981df5 -r 7f1a0d25aa40 fetch_weather.pl --- 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