Mercurial > hg > egg-tcls
comparison fetch_weather.pl @ 169:c12e422a543a
FMI data parsing kinda almost works. It is horrible, though. XML ... :Q
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 02 Jun 2014 22:52:30 +0300 |
parents | 7eee54638b0f |
children | e4faa3746869 |
comparison
equal
deleted
inserted
replaced
168:7eee54638b0f | 169:c12e422a543a |
---|---|
362 if ($res->code >= 200 && $res->code <= 201) | 362 if ($res->code >= 200 && $res->code <= 201) |
363 { | 363 { |
364 my $xml = XMLin($res->decoded_content, | 364 my $xml = XMLin($res->decoded_content, |
365 KeyAttr => { server => 'name' }, | 365 KeyAttr => { server => 'name' }, |
366 ForceArray => [ 'server', 'address' ]); | 366 ForceArray => [ 'server', 'address' ]); |
367 | |
368 my $time_base = time(); | |
369 | |
370 foreach my $item (@{$xml->{"wfs:member"}}) | |
371 { | |
372 my $fitem = $item->{"omso:GridSeriesObservation"}; | |
373 if (defined($fitem->{"om:phenomenonTime"}{"gml:TimePeriod"})) | |
374 { | |
375 $time_base = str2time($fitem->{"om:phenomenonTime"}{"gml:TimePeriod"}{"gml:endPosition"}); | |
376 } | |
377 my $fname = $fitem->{"om:featureOfInterest"}{"sams:SF_SpatialSamplingFeature"}{"sams:shape"}{"gml:MultiPoint"}{"gml:pointMember"}{"gml:Point"}{"gml:name"}; | |
378 | |
379 my $fres = $fitem->{"om:result"}{"gmlcov:MultiPointCoverage"}{"gml:rangeSet"}{"gml:DataBlock"}{"gml:doubleOrNilReasonTupleList"}; | |
380 | |
381 ### TODO XXX HALARM - ei ota viimeista arvoa, kuten pitais | |
382 if ($fres =~ /([\+\-]?\d+\.?\d*)\s+([\+\-]?\d+\.?\d*)/) | |
383 { | |
384 my ($ftemp, $fhumid) = ($1, $2); | |
385 $weatherdata->{$fname} = [ | |
386 $time_base, | |
387 $ftemp, | |
388 "", | |
389 "", | |
390 $fhumid, | |
391 ]; | |
392 } | |
393 } | |
367 } | 394 } |
368 } | 395 } |
369 | 396 |
370 | 397 |
371 ### Output | 398 ### Output |