Quiq/Timeseries/Synchronizer.pm

filter: Statementstmt 95.8% 162 / 169 Branchbran 74.1% 89 / 120 Conditioncond 52.1% 12 / 23 MC/DCmcdc 30.7% 4 / 13 Subroutinesub 100% 14 / 14 Podpod 100% 5 / 5 totaltotal 83.1% 286 / 344 CC 70 SCAR 37.9
CC
70
Cov
84%
rows
63.9
add
19.4
new
3.0
CRAP 44.1
« Quiq/Path.pm ↑ Summary Quiq/Database/Row/Object/Join.pm »
1 # -----------------------------------------------------------------------------
2  
3 =encoding utf8
4  
5 =head1 NAME
6  
7 Quiq::Timeseries::Synchronizer - Rasterung/Synchronisation von Zeitreihen
8  
9 =head1 BASE CLASS
10  
11 L<Quiq::Hash>
12  
13 =head1 SYNOPSIS
14  
15 Instantiiere Objekt, vereinbare Zeitraster und Werte
16  
17 my $tsy = Quiq::Timeseries::Synchronizer->new(600,
18 qw/Temperature Windspeed/,
19 -geoCoordinates => 1, # $latitude,$longitude bei add()
20 -offset => 300,
21 );
22  
23 Füge Temperatur-Daten hinzu
24  
25 for my $row (Temperature->select($db,@where)) {
26 $tsy->add($row->time,$row->latitude,$row->longitude,
27 Temperature => $row->value,
28 );
29 }
30  
31 Füge Windgeschwindigkeits-Daten hinzu
32  
33 for my $row (WindSpeed->select($db,@where)) {
34 $tsy->add($row->time,$row->latitude,$row->longitude,
35 Windspeed => $row->value,
36 );
37 }
38  
39 Generiere Tabelle mit Daten
40  
41 my ($titleA,$rowA) = $tsy->rows(
42 Temperature => [roundTo=>2,meanValue=>1,count=>1,stdDeviation=>1],
43 WindSpeed => [roundTo=>2,meanValue=>1,count=>1,stdDeviation=>1],
44 -noValue => 'NULL',
45 );
46  
47 Die resultierende Tabelle besitzt folgende Kolumnen:
48  
49 0 Time (Rasterpunkt)
50 1 Latitude (Breite des Geo-Mittelpunkts)
51 2 Longitude (Länge des Geo-Mittelpunkts)
52 3 Temperature (Mittelwert)
53 4 Temperature_Count (Anzahl Werte)
54 5 Temperature_StdDev (Standardabweichung)
55 6 WindSpeed (Mittelwert)
56 7 WindSpeed_Count (Anzahl Werte)
57 8 WindSpeed_StdDev (Standardabweichung)
58  
59 =head1 DESCRIPTION
60  
61 Die Klasse richtet eine oder mehrere Zeitreihen auf ein
62 gemeinsames Zeitraster mit der Intervallbreite $interval aus. Die
63 Intervallbreite wird in Sekunden angegeben.
64  
65 $interval = 600;
66  
67 legt das Zeitraster auf 0, 10, 20, 30, 40, 50 Minuten.
68  
69 $interval = 600, -offset => 300
70  
71 legt das Zeitraster auf 5, 15, 25, 35, 45, 55 Minuten.
72  
73 =cut
74  
75 # -----------------------------------------------------------------------------
76  
77 package Quiq::Timeseries::Synchronizer;
78 1 ▶use base qw/Quiq::Hash/;
Subroutine BEGIN: called CC=1 SCAR=0.0
79  
80 1 ▶use v5.10;
Subroutine BEGIN: called CC=1 SCAR=0.0
81 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
82 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
83  
84 1 our $VERSION = '1.240';
85  
86 1 ▶use Quiq::Option;
Subroutine BEGIN: called CC=1 SCAR=0.0
87 1 ▶use Quiq::Array;
Subroutine BEGIN: called CC=1 SCAR=0.0
88 1 ▶use Quiq::Time;
Subroutine BEGIN: called CC=1 SCAR=0.0
89 1 ▶use Quiq::Math;
Subroutine BEGIN: called CC=1 SCAR=0.0
90 1 ▶use Quiq::Formatter;
Subroutine BEGIN: called CC=1 SCAR=0.0
91  
92 # -----------------------------------------------------------------------------
93  
94 =head1 METHODS
95  
96 =head2 Konstruktor
97  
98 =head3 new() - Konstruktor/Destruktor
99  
100 =head4 Synopsis
101  
102 $tsy = $class->new($interval,@param,@opt);
103  
104 =head4 Options
105  
106 =over 4
107  
108 =item -geoCoordinates => $bool (Default: 0)
109  
110 Die Messerwerte haben zusätzlich zur Zeit eine Ortskoordinate.
111 Wenn gesetzt, erwartet die Methode L<add|"add() - Füge Parameterwerte hinzu">() zusätzlich die
112 Ortsangaben $latitude und $longitude.
113  
114 =item -minTime => $t (Default: undef)
115  
116 Ignoriere alle Daten, die vor Zeitpunkt $t (Unixzeit) liegen.
117  
118 =item -maxTime => $t (Default: undef)
119  
120 Ignoriere alle Daten, die nach Zeitpunkt $t (Unixzeit) liegen.
121  
122 =item -offset => $s (Default: 0)
123  
124 Versetze das Zeitraster um einem Offset von $s Sekunden.
125 Beispiel: Ein Offset von 300 bei einer Intervallbreite von 600 Sekunden
126 legt die Rasterpunkte auf 5, 15, 25, 35, 45, 55 Minuten.
127  
128 =item -window => $s (Default: undef)
129  
130 Betrachte nur Daten, die innerhalb von $s Sekunden um einen Rasterpunkt
131 liegen. Ignoriere Daten, die außerhalb liegen.
132  
133 =back
134  
135 =head4 Description
136  
137 Instantiiere Synchronizer-Objekt für die Parameter @param mit einem
138 Zeitraster von $interval Sekunden und liefere eine Referenz auf
139 dieses Objekt zurück.
140  
141 Die Liste @param vereinbart die Parameternamen, die auch bei add()
142 und rows() angegeben werden.
143  
144 =cut
145  
146 # -----------------------------------------------------------------------------
147  
148 7 ▶sub new {
Subroutine new: called CC=3 SCAR=11.0
Pod documented
149 7 my $class = shift;
150 7 my $interval = shift;
151 # @_: @param,@opt
152  
153 # Optionen
154  
155 7 my $geoCoordinates = 0;
156 7 my $maxTime;
157 my $minTime;
158 7 my $offset = 0;
159 7 my $window;
160  
161 7 Quiq::Option->extract(\@_,
162 -geoCoordinates => \$geoCoordinates,
163 -maxTime => \$maxTime,
164 -minTime => \$minTime,
165 -offset => \$offset,
166 -window => \$window,
167 );
168  
169 # Parameter-Liste
170  
171 7 my %paramHash;
172 7 @paramHash{@_} = (1)x@_;
173  
174 7 ▶ if ($window) {
Branch: 1 branch
BranchTrueFalseTotal
if ($window) 1 6 7
175 1 ▶ if ($window > $interval/2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($window > $interval / 2) 0 1 1
176 0 $class->throw(
177 'TSYNC-00099: Windowbreite groesser Intervallbreite',
178 WindowWidth => $window,
179 IntervalWidth => $interval,
180 );
181 }
182 }
183  
184 # Objekt instantiieren
185  
186 7 my $self = $class->SUPER::new(
187 geoCoordinates => $geoCoordinates,
188 interval => $interval,
189 maxTime => $maxTime,
190 minTime => $minTime,
191 offset => $offset,
192 window => $window,
193 raster => {},
194 paramArr => \@_,
195 paramHash => \%paramHash,
196 );
197 7 $self->lockKeys;
198  
199 7 return $self;
200 }
201  
202 # -----------------------------------------------------------------------------
203  
204 =head2 Methoden
205  
206 =head3 add() - Füge Parameterwerte hinzu
207  
208 =head4 Synopsis
209  
210 $tsy->add($time,$param=>$value,...);
211 $tsy->add($time,$latitude,$longitude,$param=>$value,...);
212  
213 =head4 Description
214  
215 Füge Wert $value des Parameters $param zur Zeit $time (Unixtime)
216 und (optional) dem Ort ($latitude, $longitude) hinzu. Die Methode
217 liefert keinen Wert zurück. Es können mehrere Parameter/Wert-Paare
218 für dieselbe Zeit und demselben Ort hinzugefügt werden.
219  
220 =cut
221  
222 # -----------------------------------------------------------------------------
223  
224 132 ▶sub add {
Subroutine add: called CC=16 SCAR=29.6
Pod documented
225 132 my $self = shift;
226 132 my $time = shift;
227 # @_: $latitude,$logitude,$param=>$value,... -or- $param=>$value,...
228  
229 132 my $geoCoordinates = $self->{'geoCoordinates'};
230 132 my $interval = $self->{'interval'};
231 132 my $minTime = $self->{'minTime'};
232 132 my $maxTime = $self->{'maxTime'};
233 132 my $offset = $self->{'offset'};
234 132 my $window = $self->{'window'};
235 132 my $raster = $self->{'raster'};
236 132 my $paramHash = $self->{'paramHash'};
237 132 my $paramArr = $self->{'paramArr'};
238  
239 # Werte außerhalb des Gesamtzeitbereichs (falls angegeben) wegfiltern
240  
241 132 ▶ if (defined $minTime && $time < $minTime
Branch: 1 branch
BranchTrueFalseTotal
if (defined $minTime and $time < $minTime or defined $maxTime and $time > $maxTime) 0 132 132
Condition33%3/9
defined $minTime and $time < $minTime or defined $maxTime and $time > $maxTime
l!l&&r!l&&!r
00132
defined $minTime and $time < $minTime
!ll&&!rl&&r
13200
defined $maxTime and $time > $maxTime
!ll&&!rl&&r
13200
MC/DC0%0/4
defined $minTime and $time < $minTime or defined $maxTime and $time > $maxTime
defined $minTime $time < $minTime defined $maxTime $time > $maxTime
Truth table14%1/7
A and B or C and D
A= defined $minTimeB= $time < $minTimeC= defined $maxTimeD= $time > $maxTime
ABCDresult
11XX1
0X111
10111
0X0X0
0X100
100X0
10100
242 || defined $maxTime && $time > $maxTime) {
243 0 return;
244 }
245  
246 # Raster-Zeitpunkt ermitteln (sicheres Runden wie in roundToInt())
247 132 my $point = int(($time-$offset)/$interval+0.5)*$interval+$offset;
248  
249 # Abstand zu Rasterpunkt ermitteln
250 132 my $distance = abs $time-$point;
251  
252 # Wert ignorieren, wenn er außerhalb des Fensters um den Rasterpunkt liegt
253 132 ▶ return if $window && $distance > $window;
Branch: 1 branch
BranchTrueFalseTotal
if $window and $distance > $window 0 132 132
Condition33%1/3
$window and $distance > $window
!ll&&!rl&&r
13200
MC/DC0%0/2
$window and $distance > $window
$window $distance > $window
Truth table33%1/3
A and B
A= $windowB= $distance > $window
ABresult
0X0
100
111
254  
255 # Geoposition sichern
256  
257 132 my ($latitude,$longitude);
258 132 ▶ if ($geoCoordinates) {
Branch: 1 branch
BranchTrueFalseTotal
if ($geoCoordinates) 3 129 132
259 3 $latitude = shift;
260 3 $longitude = shift;
261 }
262  
263 132 ▶ for (my $i = 0; $i < @_; $i += 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @_) 132 132 264
264 132 my ($param,$value) = @_[$i,$i+1];
265  
266 # Gültigkeit des Parameter-Bezeichners prüfen
267  
268 132 ▶ if (!$paramHash->{$param}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($paramHash->{$param}) 0 132 132
269 0 $self->throw(
270 'TSYNC-00099: Unbekannter Parameter',
271 Parameter => $param,
272 );
273 }
274  
275 # Nullwerte ignorieren
276  
277 132 ▶ if (!defined $value || $value eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $value or $value eq "") 0 132 132
Condition33%1/3
not defined $value or $value eq ""
l!l&&r!l&&!r
00132
MC/DC0%0/2
not defined $value or $value eq ""
not defined $value $value eq ""
Truth table33%1/3
not(A) or B
A= not defined $valueB= $value eq ""
ABresult
1X1
011
000
278 0 next;
279 }
280  
281 # Wert in Punktraster eintragen. Aufbau der Datenstruktur:
282 # $raster->{$point}->{$param}->[\@vals,\@coordinates,
283 # $closestDist,$closestVal]
284  
285 132 ▶ my $infoArr = $raster->{$point}->{$param} ||=
Condition100%2/2
$raster->{$point}{$param} ||= ["Quiq::Array"->new, [], undef, undef]
l!l
10824
MC/DC100%1/1
$raster->{$point}{$param} ||= ["Quiq::Array"->new, [], undef, undef]
$raster->{$point}{$param}
Truth table100%2/2
A
A= $raster->{$point}{$param}
Aresult
11
00
286 [Quiq::Array->new,[],undef,undef];
287  
288 # Wert auf Liste pushen
289 132 push @{$infoArr->[0]},$value;
290  
291 # Wert mit kleinstem zeitlichen Abstand zum Rasterpunkt speichern
292  
293 132 ▶ if (!defined $infoArr->[2] || $distance < $infoArr->[2]) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $infoArr->[2] or $distance < $infoArr->[2]) 82 50 132
Condition100%3/3
not defined $infoArr->[2] or $distance < $infoArr->[2]
l!l&&r!l&&!r
245850
MC/DC100%2/2
not defined $infoArr->[2] or $distance < $infoArr->[2]
not defined $infoArr->[2] $distance < $infoArr->[2]
Truth table100%3/3
not(A) or B
A= not defined $infoArr->[2]B= $distance < $infoArr->[2]
ABresult
1X1
011
000
294 82 $infoArr->[2] = $distance;
295 82 $infoArr->[3] = $value;
296 }
297  
298 # Ortskoordinate auf Liste pushen
299  
300 132 ▶ if ($geoCoordinates) {
Branch: 1 branch
BranchTrueFalseTotal
if ($geoCoordinates) 3 129 132
301 3 push @{$infoArr->[1]},[$latitude,$longitude];
302 }
303 }
304  
305 132 return;
306 }
307  
308 # -----------------------------------------------------------------------------
309  
310 =head3 addParameter() - Füge Parameter hinzu
311  
312 =head4 Synopsis
313  
314 $tsy->addParameter($param);
315  
316 =head4 Description
317  
318 Füge den zusätzlichen Parameter $param zum Objekt hinzu.
319 Die Methode liefert keinen Wert zurück.
320  
321 =cut
322  
323 # -----------------------------------------------------------------------------
324  
325 3 ▶sub addParameter {
Subroutine addParameter: called CC=1 SCAR=0.0
Pod documented
326 3 my ($self,$param) = @_;
327  
328 3 my ($paramArr,$paramHash) = $self->get(qw/paramArr paramHash/);
329 3 push @$paramArr,$param;
330 3 $paramHash->{$param} = 1;
331  
332 3 return;
333 }
334  
335 # -----------------------------------------------------------------------------
336  
337 =head3 parameters() - Liefere Liste der Parameterbezeichner
338  
339 =head4 Synopsis
340  
341 @arr | $arr = $tsy->parameters;
342  
343 =head4 Description
344  
345 Liefere die Liste der Parameterbezeichner. Im Skalarkontext liefere
346 eine Referenz auf die Liste.
347  
348 =cut
349  
350 # -----------------------------------------------------------------------------
351  
352 6 ▶sub parameters {
Subroutine parameters: called CC=2 SCAR=6.9
Pod documented
353 6 my $self = shift;
354 6 ▶ return wantarray? @{$self->{'paramArr'}}: $self->{'paramArr'};
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 4 2 6
355 }
356  
357 # -----------------------------------------------------------------------------
358  
359 =head3 rows() - Liefere Tabelle mit Zeitraster-Daten
360  
361 =head4 Synopsis
362  
363 [$titleA,$rowA] = $tsy->rows(
364 $param => [$paramOpt=>$val,...],
365 ...,
366 @opt,
367 );
368  
369 =head4 Options
370  
371 =over 4
372  
373 =item -noValue => $str (Default: '')
374  
375 Zeichenkette für "Wert nicht vorhanden".
376  
377 =item -timeFormat => $fmt (Default: 'yyyymmddhhmmss')
378  
379 Format der Zeitkolumne.
380  
381 =back
382  
383 =head4 Description
384  
385 Die erste Kolumne enthält die Zeit. Wenn bei Konstruktor die
386 Option -geoCoordinates gesetzt wurde, folgen geografische Breite
387 und Lnge. Danach folgen die angegebenen Parameter mit ihren
388 Kolumnen.
389  
390 B<Parameter-Optionen>
391  
392 =over 4
393  
394 =item meanValue => $bool
395  
396 Generiere Kolumne mit Mittelwert über den Werten im Intervall.
397  
398 =item stdDeviation => $bool
399  
400 Generiere Kolumne mit Standardabweichung über den Werten im Intervall.
401  
402 =item min => $bool
403  
404 Generiere Kolumne mit kleinstem Wert im Intervall.
405  
406 =item max => $bool
407  
408 Generiere Kolumne mit größtem Wert im Intervall.
409  
410 =item roundTo => $n
411  
412 Runde die folgenden Kolumnenwerte auf $n Nachkommastellen.
413 Undef bedeutet keine Rundung, alle Stellen werden wiedergegeben.
414  
415 =item count => $bool
416  
417 Generiere Kolumne mit Anzahl der Werte im Intervall.
418  
419 =item closestValue => $bool
420  
421 Generiere Kolumne mit dem zeitlich am dichtesten am Rasterpunkt
422 gelegenen Wert.
423  
424 =item closestTime => $bool
425  
426 Generiere Kolumne mit dem Abstand in Sekunden, den der zeitlich
427 am dichtesten am Rasterpunkt gelegenen Wert hat.
428  
429 =back
430  
431 =cut
432  
433 # -----------------------------------------------------------------------------
434  
435 2 ▶sub rows {
Subroutine rows: called CC=52 SCAR=41.6
Pod documented
436 2 my $self = shift;
437 # @_: $param=>\@paramOpt,...@opt
438  
439 # Optionen
440  
441 2 my $noValue = '';
442 2 my $timeFormat = 'yyyymmddhhmmss';
443  
444 2 Quiq::Option->extract(\@_,
445 -noValue => \$noValue,
446 -timeFormat => \$timeFormat,
447 );
448  
449 # Objektattribute
450  
451 2 my $geoCoordinates = $self->{'geoCoordinates'};
452 2 my $paramHash = $self->{'paramHash'};
453 2 my $raster = $self->{'raster'};
454  
455 # Prüfe die Existenz der angegebenen Parameter
456  
457 2 ▶ for (my $i = 0; $i < @_; $i += 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @_) 2 2 4
458 2 my $param = $_[$i];
459  
460 2 ▶ unless ($paramHash->{$param}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($paramHash->{$param}) 0 2 2
461 0 $self->throw(
462 'TSYNC-00099: Unbekannter Parameter',
463 Parameter => $param,
464 );
465 }
466 }
467  
468 # Liste der Kolumnentitel erzeugen
469  
470 2 my @titles = ('Time');
471 2 ▶ if ($geoCoordinates) {
Branch: 1 branch
BranchTrueFalseTotal
if ($geoCoordinates) 1 1 2
472 1 push @titles,'Latitude','Longitude';
473 }
474 2 ▶ for (my $i = 0; $i < @_; $i += 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @_) 2 2 4
475 2 my ($param,$optA) = @_[$i,$i+1];
476  
477 2 ▶ for (my $i = 0; $i < @$optA; $i += 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @$optA) 11 2 13
478 11 my ($opt,$optVal) = ($optA->[$i],$optA->[$i+1]);
479  
480 11 ▶ if ($opt eq 'roundTo') {
Branch: 8 branches
BranchTrueFalseTotal
if ($opt eq 'roundTo') { } 1 10 11
elsif ($opt eq 'meanValue') { } 2 8 10
elsif ($opt eq 'stdDeviation') { } 2 6 8
elsif ($opt eq 'min') { } 1 5 6
elsif ($opt eq 'max') { } 1 4 5
elsif ($opt eq 'count') { } 2 2 4
elsif ($opt eq 'closestValue') { } 1 1 2
elsif ($opt eq 'closestTime') { } 1 0 1
481 1 next;
482 }
483 elsif ($opt eq 'meanValue') {
484 2 ▶ next if !$optVal;
Branch: 1 branch
BranchTrueFalseTotal
unless $optVal 0 2 2
485 2 push @titles,$param;
486 }
487 elsif ($opt eq 'stdDeviation') {
488 2 ▶ next if !$optVal;
Branch: 1 branch
BranchTrueFalseTotal
unless $optVal 0 2 2
489 2 push @titles,$param.'_StdDev';
490 }
491 elsif ($opt eq 'min') {
492 1 ▶ next if !$optVal;
Branch: 1 branch
BranchTrueFalseTotal
unless $optVal 0 1 1
493 1 push @titles,$param.'_Min';
494 }
495 elsif ($opt eq 'max') {
496 1 ▶ next if !$optVal;
Branch: 1 branch
BranchTrueFalseTotal
unless $optVal 0 1 1
497 1 push @titles,$param.'_Max';
498 }
499 elsif ($opt eq 'count') {
500 2 ▶ next if !$optVal;
Branch: 1 branch
BranchTrueFalseTotal
unless $optVal 0 2 2
501 2 push @titles,$param.'_Count';
502 }
503 elsif ($opt eq 'closestValue') {
504 1 ▶ next if !$optVal;
Branch: 1 branch
BranchTrueFalseTotal
unless $optVal 0 1 1
505 1 push @titles,$param.'_ClosestValue';
506 }
507 elsif ($opt eq 'closestTime') {
508 1 ▶ next if !$optVal;
Branch: 1 branch
BranchTrueFalseTotal
unless $optVal 0 1 1
509 1 push @titles,$param.'_ClosestTime';
510 }
511 else {
512 0 $self->throw(
513 'TSYNC-00099: Unbekannte Parameter-Option',
514 Option => $opt,
515 );
516 }
517 }
518 }
519  
520 # Tabelle erzeugen
521  
522 2 my @rows;
523  
524 # Durchlaufe aufsteigend alle Raster-Zeitpunkte
525  
526 2 for my $point (sort keys %$raster) {
527 8 my @row;
528 8 my $ti = Quiq::Time->new(utc=>$point);
529 8 push @row,$ti->$timeFormat;
530  
531 8 ▶ if ($geoCoordinates) {
Branch: 1 branch
BranchTrueFalseTotal
if ($geoCoordinates) 1 7 8
532 # Mittele die Geo-Koordinaten
533  
534 1 my @coordinates;
535 1 ▶ for (my $i = 0; $i < @_; $i += 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @_) 1 1 2
536 1 my $param = $_[$i];
537 # Quick-Fix: Wann ist das Array nicht definiert?
538 1 ▶ if ($raster->{$point}->{$param}->[1]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($raster->{$point}{$param}[1]) 1 0 1
539 1 push @coordinates,@{$raster->{$point}->{$param}->[1]};
540 }
541 }
542 1 push @row,Quiq::Math->geoMidpoint(\@coordinates);
543 }
544  
545 # Durchlaufe alle Parameter
546  
547 8 ▶ for (my $i = 0; $i < @_; $i += 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @_) 8 8 16
548 8 my ($param,$optA) = @_[$i,$i+1];
549  
550 8 my ($valueA,$coordA,$timeLag,$closestVal);
551 8 ▶ if (exists $raster->{$point}->{$param}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $raster->{$point}{$param}) 8 0 8
552 ($valueA,$coordA,$timeLag,$closestVal) =
553 8 @{$raster->{$point}->{$param}};
554 }
555  
556 # Durchlaufe Parameter-Optionen
557  
558 8 my $places;
559 8 ▶ for (my $i = 0; $i < @$optA; $i += 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @$optA) 65 8 73
560 65 my ($opt,$optVal) = ($optA->[$i],$optA->[$i+1]);
561  
562 65 ▶ if ($opt eq 'roundTo') {
Branch: 1 branch
BranchTrueFalseTotal
if ($opt eq "roundTo") 7 58 65
563 7 $places = $optVal;
564 7 next;
565 }
566  
567 58 my $val;
568 58 ▶ if ($opt eq 'meanValue') {
Branch: 7 branches
BranchTrueFalseTotal
if ($opt eq 'meanValue') { } 8 50 58
elsif ($opt eq 'stdDeviation') { } 14 36 50
elsif ($opt eq 'min') { } 7 29 36
elsif ($opt eq 'max') { } 7 22 29
elsif ($opt eq 'count') { } 8 14 22
elsif ($opt eq 'closestValue') { } 7 7 14
elsif ($opt eq 'closestTime') { } 7 0 7
569 8 ▶ next if !$optVal;
Branch: 1 branch
BranchTrueFalseTotal
unless $optVal 0 8 8
570 8 ▶ $val = $valueA? $valueA->meanValue: undef;
Branch: 1 branch
BranchTrueFalseTotal
$valueA ? : 8 0 8
571 }
572 elsif ($opt eq 'stdDeviation') {
573 14 ▶ next if !$optVal;
Branch: 1 branch
BranchTrueFalseTotal
unless $optVal 0 14 14
574 14 ▶ $val = $valueA? $valueA->standardDeviation: undef;
Branch: 1 branch
BranchTrueFalseTotal
$valueA ? : 14 0 14
575 }
576 elsif ($opt eq 'min') {
577 7 ▶ next if !$optVal;
Branch: 1 branch
BranchTrueFalseTotal
unless $optVal 0 7 7
578 7 ▶ $val = $valueA? $valueA->min: undef;
Branch: 1 branch
BranchTrueFalseTotal
$valueA ? : 7 0 7
579 }
580 elsif ($opt eq 'max') {
581 7 ▶ next if !$optVal;
Branch: 1 branch
BranchTrueFalseTotal
unless $optVal 0 7 7
582 7 ▶ $val = $valueA? $valueA->max: undef;
Branch: 1 branch
BranchTrueFalseTotal
$valueA ? : 7 0 7
583 }
584 elsif ($opt eq 'count') {
585 8 ▶ next if !$optVal;
Branch: 1 branch
BranchTrueFalseTotal
unless $optVal 0 8 8
586 8 ▶ $val = $valueA? @$valueA: undef;
Branch: 1 branch
BranchTrueFalseTotal
$valueA ? : 8 0 8
587 }
588 elsif ($opt eq 'closestValue') {
589 7 ▶ next if !$optVal;
Branch: 1 branch
BranchTrueFalseTotal
unless $optVal 0 7 7
590 7 ▶ $val = $valueA? $closestVal: undef;
Branch: 1 branch
BranchTrueFalseTotal
$valueA ? : 7 0 7
591 }
592 elsif ($opt eq 'closestTime') {
593 7 ▶ next if !$optVal;
Branch: 1 branch
BranchTrueFalseTotal
unless $optVal 0 7 7
594 7 ▶ $val = $valueA? $timeLag: undef;
Branch: 1 branch
BranchTrueFalseTotal
$valueA ? : 7 0 7
595 }
596 else {
597 0 $self->throw(
598 'TSYNC-00099: Unbekannte Parameter-Option',
599 Option => $opt,
600 );
601 }
602  
603 58 ▶ if (defined $places && defined $val) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $places and defined $val) 7 51 58
Condition66%2/3
defined $places and defined $val
!ll&&!rl&&r
5107
MC/DC50%1/2
defined $places and defined $val
defined $places defined $val
Truth table66%2/3
A and B
A= defined $placesB= defined $val
ABresult
0X0
100
111
604 7 $val = Quiq::Math->roundTo($val,$places);
605 }
606  
607 58 push @row,Quiq::Formatter->normalizeNumber($val);
608 }
609 }
610 8 push @rows,\@row;
611 }
612  
613 2 return (\@titles,\@rows);
614 }
615  
616 # -----------------------------------------------------------------------------
617  
618 =head1 VERSION
619  
620 1.240
621  
622 =head1 AUTHOR
623  
624 Frank Seitz, L<http://fseitz.de/>
625  
626 =head1 COPYRIGHT
627  
628 Copyright (C) 2026 Frank Seitz
629  
630 =head1 LICENSE
631  
632 This code is free software; you can redistribute it and/or modify
633 it under the same terms as Perl itself.
634  
635 =cut
636  
637 # -----------------------------------------------------------------------------
638  
639 1 1;
640  
641 # eof
« Quiq/Path.pm ↑ Summary Quiq/Database/Row/Object/Join.pm »