Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/model/OfficialLineFinder.java @ 9415:9744ce3c3853
Rework of fixanalysis computation and dWt and WQ facets. Got rid of strange remapping and bitshifting code by explicitely saving the column information and using it in the facets.
The facets also put the valid station range into their xml-metadata
author | gernotbelger |
---|---|
date | Thu, 16 Aug 2018 16:27:53 +0200 |
parents | 5e38e2924c07 |
children |
rev | line source |
---|---|
6385
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
2 * Software engineering by Intevation GmbH |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
3 * |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
4 * This file is Free Software under the GNU AGPL (>=v3) |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
6 * documentation coming with Dive4Elements River for details. |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
7 */ |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
8 |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
9 package org.dive4elements.river.artifacts.model; |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
10 |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
11 import java.util.ArrayList; |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
12 import java.util.Collections; |
6510
1e6bd2831280
artifacts: Desktop-FLYS conform official line messages in error reports.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6494
diff
changeset
|
13 import java.util.Date; |
6385
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
14 import java.util.HashMap; |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
15 import java.util.List; |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
16 import java.util.Map; |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
17 |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
18 import net.sf.ehcache.Cache; |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
19 import net.sf.ehcache.Element; |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
20 |
6494
1e97d2e95410
Amtl. Linien: Fixed problem that only a random official line is detect.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6397
diff
changeset
|
21 import org.apache.log4j.Logger; |
6385
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
22 import org.dive4elements.river.artifacts.D4EArtifact; |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
23 import org.dive4elements.river.artifacts.cache.CacheFactory; |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
24 import org.dive4elements.river.model.Gauge; |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
25 import org.dive4elements.river.model.MainValue; |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
26 import org.dive4elements.river.model.NamedMainValue; |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
27 import org.dive4elements.river.model.OfficialLine; |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
28 import org.dive4elements.river.model.River; |
6510
1e6bd2831280
artifacts: Desktop-FLYS conform official line messages in error reports.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6494
diff
changeset
|
29 import org.dive4elements.river.model.TimeInterval; |
6385
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
30 import org.dive4elements.river.model.Wst; |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
31 import org.dive4elements.river.model.WstColumn; |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
32 |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
33 public class OfficialLineFinder |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
34 { |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
35 public static final String CACHE_NAME = "official-lines"; |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
36 |
6494
1e97d2e95410
Amtl. Linien: Fixed problem that only a random official line is detect.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6397
diff
changeset
|
37 private static Logger log = Logger.getLogger(OfficialLineFinder.class); |
1e97d2e95410
Amtl. Linien: Fixed problem that only a random official line is detect.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6397
diff
changeset
|
38 |
6385
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
39 // We will only have one entry in this cache. |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
40 public static final String CACHE_KEY = CACHE_NAME; |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
41 |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
42 public static final double EPSILON = 1e-4; |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
43 |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
44 |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
45 public static class ValueRange extends Range { |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
46 |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
47 private double value; |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
48 private int wstId; |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
49 private int columnPos; |
6397
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
50 private String name; |
6510
1e6bd2831280
artifacts: Desktop-FLYS conform official line messages in error reports.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6494
diff
changeset
|
51 private String source; |
1e6bd2831280
artifacts: Desktop-FLYS conform official line messages in error reports.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6494
diff
changeset
|
52 private Date date; |
6385
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
53 |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
54 public ValueRange( |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
55 double start, |
7248
1dff8e71c4d6
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6932
diff
changeset
|
56 double end, |
6385
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
57 double value, |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
58 int wstId, |
6397
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
59 int columnPos, |
6510
1e6bd2831280
artifacts: Desktop-FLYS conform official line messages in error reports.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6494
diff
changeset
|
60 String name, |
1e6bd2831280
artifacts: Desktop-FLYS conform official line messages in error reports.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6494
diff
changeset
|
61 String source, |
1e6bd2831280
artifacts: Desktop-FLYS conform official line messages in error reports.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6494
diff
changeset
|
62 Date date |
6385
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
63 ) { |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
64 super(start, end); |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
65 this.value = value; |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
66 this.wstId = wstId; |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
67 this.columnPos = columnPos; |
6397
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
68 this.name = name; |
6510
1e6bd2831280
artifacts: Desktop-FLYS conform official line messages in error reports.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6494
diff
changeset
|
69 this.source = source; |
1e6bd2831280
artifacts: Desktop-FLYS conform official line messages in error reports.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6494
diff
changeset
|
70 this.date = date; |
6385
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
71 } |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
72 |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
73 public boolean sameValue(double value) { |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
74 return Math.abs(value - this.value) < EPSILON; |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
75 } |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
76 |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
77 public int getWstId() { |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
78 return wstId; |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
79 } |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
80 |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
81 public int getColumnPos() { |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
82 return columnPos; |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
83 } |
6397
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
84 |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
85 public boolean intersectsValueRange(Range r) { |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
86 return r.inside(value); |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
87 } |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
88 |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
89 public String getName() { |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
90 return name; |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
91 } |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
92 |
6510
1e6bd2831280
artifacts: Desktop-FLYS conform official line messages in error reports.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6494
diff
changeset
|
93 public String getSource() { |
1e6bd2831280
artifacts: Desktop-FLYS conform official line messages in error reports.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6494
diff
changeset
|
94 return source; |
1e6bd2831280
artifacts: Desktop-FLYS conform official line messages in error reports.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6494
diff
changeset
|
95 } |
1e6bd2831280
artifacts: Desktop-FLYS conform official line messages in error reports.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6494
diff
changeset
|
96 |
1e6bd2831280
artifacts: Desktop-FLYS conform official line messages in error reports.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6494
diff
changeset
|
97 public Date getDate() { |
1e6bd2831280
artifacts: Desktop-FLYS conform official line messages in error reports.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6494
diff
changeset
|
98 return date; |
1e6bd2831280
artifacts: Desktop-FLYS conform official line messages in error reports.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6494
diff
changeset
|
99 } |
1e6bd2831280
artifacts: Desktop-FLYS conform official line messages in error reports.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6494
diff
changeset
|
100 |
6397
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
101 @Override |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
102 public boolean equals(Object o) { |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
103 if (!(o instanceof ValueRange)) { |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
104 return false; |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
105 } |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
106 ValueRange r = (ValueRange)o; |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
107 return wstId == r.wstId && columnPos == r.columnPos; |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
108 } |
6494
1e97d2e95410
Amtl. Linien: Fixed problem that only a random official line is detect.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6397
diff
changeset
|
109 |
1e97d2e95410
Amtl. Linien: Fixed problem that only a random official line is detect.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6397
diff
changeset
|
110 @Override |
1e97d2e95410
Amtl. Linien: Fixed problem that only a random official line is detect.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6397
diff
changeset
|
111 public String toString() { |
1e97d2e95410
Amtl. Linien: Fixed problem that only a random official line is detect.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6397
diff
changeset
|
112 return "[" + name + |
1e97d2e95410
Amtl. Linien: Fixed problem that only a random official line is detect.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6397
diff
changeset
|
113 " value: " + value + |
1e97d2e95410
Amtl. Linien: Fixed problem that only a random official line is detect.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6397
diff
changeset
|
114 " wstId: " + wstId + |
6510
1e6bd2831280
artifacts: Desktop-FLYS conform official line messages in error reports.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6494
diff
changeset
|
115 " pos: " + columnPos + |
1e6bd2831280
artifacts: Desktop-FLYS conform official line messages in error reports.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6494
diff
changeset
|
116 " source: " + source + |
6519
862c7f511c35
Artifacts: Another fix for the 'Amtlichen Linien'. Stupid copy/paste error while taking the range of a gauge.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6510
diff
changeset
|
117 " date: " + date + |
9415
9744ce3c3853
Rework of fixanalysis computation and dWt and WQ facets. Got rid of strange remapping and bitshifting code by explicitely saving the column information and using it in the facets.
gernotbelger
parents:
8856
diff
changeset
|
118 " from: " + getStart() + |
9744ce3c3853
Rework of fixanalysis computation and dWt and WQ facets. Got rid of strange remapping and bitshifting code by explicitely saving the column information and using it in the facets.
gernotbelger
parents:
8856
diff
changeset
|
119 " to: " + getEnd() + "]"; |
6494
1e97d2e95410
Amtl. Linien: Fixed problem that only a random official line is detect.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6397
diff
changeset
|
120 } |
6385
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
121 } |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
122 |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
123 public OfficialLineFinder() { |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
124 } |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
125 |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
126 public static Map<String, List<ValueRange>> getAll() { |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
127 Cache cache = CacheFactory.getCache(CACHE_NAME); |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
128 |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
129 if (cache == null) { |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
130 return getAllUncached(); |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
131 } |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
132 |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
133 Element element = cache.get(CACHE_KEY); |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
134 |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
135 if (element != null) { |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
136 return (Map<String, List<ValueRange>>)element.getValue(); |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
137 } |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
138 |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
139 Map<String, List<ValueRange>> result = getAllUncached(); |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
140 if (result != null) { |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
141 cache.put(new Element(CACHE_KEY, result)); |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
142 } |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
143 return result; |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
144 |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
145 } |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
146 |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
147 public static Map<String, List<ValueRange>> getAllUncached() { |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
148 |
6494
1e97d2e95410
Amtl. Linien: Fixed problem that only a random official line is detect.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6397
diff
changeset
|
149 boolean debug = log.isDebugEnabled(); |
1e97d2e95410
Amtl. Linien: Fixed problem that only a random official line is detect.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6397
diff
changeset
|
150 |
6385
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
151 Map<String, List<ValueRange>> rivers2officialLines = |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
152 new HashMap<String, List<ValueRange>>(); |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
153 |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
154 for (OfficialLine line: OfficialLine.fetchAllOfficalLines()) { |
6510
1e6bd2831280
artifacts: Desktop-FLYS conform official line messages in error reports.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6494
diff
changeset
|
155 NamedMainValue nmv = line.getNamedMainValue(); |
1e6bd2831280
artifacts: Desktop-FLYS conform official line messages in error reports.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6494
diff
changeset
|
156 Integer mnvId = nmv.getId(); |
1e6bd2831280
artifacts: Desktop-FLYS conform official line messages in error reports.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6494
diff
changeset
|
157 WstColumn wc = line.getWstColumn(); |
1e6bd2831280
artifacts: Desktop-FLYS conform official line messages in error reports.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6494
diff
changeset
|
158 Wst wst = wc.getWst(); |
1e6bd2831280
artifacts: Desktop-FLYS conform official line messages in error reports.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6494
diff
changeset
|
159 TimeInterval ti = wc.getTimeInterval(); |
1e6bd2831280
artifacts: Desktop-FLYS conform official line messages in error reports.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6494
diff
changeset
|
160 Date date = ti != null ? ti.getStartTime() : null; |
1e6bd2831280
artifacts: Desktop-FLYS conform official line messages in error reports.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6494
diff
changeset
|
161 String source = wc.getSource(); |
6385
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
162 |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
163 List<ValueRange> ranges = new ArrayList<ValueRange>(); |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
164 |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
165 River river = wst.getRiver(); |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
166 List<Gauge> gauges = river.getGauges(); |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
167 for (Gauge gauge: gauges) { |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
168 List<MainValue> mainValues = gauge.getMainValues(); |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
169 for (MainValue mainValue: mainValues) { |
6494
1e97d2e95410
Amtl. Linien: Fixed problem that only a random official line is detect.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6397
diff
changeset
|
170 NamedMainValue tnmv = mainValue.getMainValue(); |
1e97d2e95410
Amtl. Linien: Fixed problem that only a random official line is detect.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6397
diff
changeset
|
171 if (tnmv.getId().equals(mnvId)) { |
6385
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
172 // found gauge with this main value |
6494
1e97d2e95410
Amtl. Linien: Fixed problem that only a random official line is detect.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6397
diff
changeset
|
173 double from = gauge.getRange().getA().doubleValue(); |
6519
862c7f511c35
Artifacts: Another fix for the 'Amtlichen Linien'. Stupid copy/paste error while taking the range of a gauge.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6510
diff
changeset
|
174 double to = gauge.getRange().getB().doubleValue(); |
6385
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
175 double value = mainValue.getValue().doubleValue(); |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
176 int wstId = wst.getId(); |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
177 int pos = wc.getPosition(); |
6494
1e97d2e95410
Amtl. Linien: Fixed problem that only a random official line is detect.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6397
diff
changeset
|
178 ValueRange range = new ValueRange( |
6510
1e6bd2831280
artifacts: Desktop-FLYS conform official line messages in error reports.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6494
diff
changeset
|
179 from, to, value, wstId, pos, |
1e6bd2831280
artifacts: Desktop-FLYS conform official line messages in error reports.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6494
diff
changeset
|
180 nmv.getName(), source, date); |
6494
1e97d2e95410
Amtl. Linien: Fixed problem that only a random official line is detect.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6397
diff
changeset
|
181 |
1e97d2e95410
Amtl. Linien: Fixed problem that only a random official line is detect.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6397
diff
changeset
|
182 if (debug) { |
1e97d2e95410
Amtl. Linien: Fixed problem that only a random official line is detect.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6397
diff
changeset
|
183 log.debug( |
1e97d2e95410
Amtl. Linien: Fixed problem that only a random official line is detect.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6397
diff
changeset
|
184 "river: " + river.getName() + |
1e97d2e95410
Amtl. Linien: Fixed problem that only a random official line is detect.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6397
diff
changeset
|
185 " gauge: " + gauge.getName() + |
1e97d2e95410
Amtl. Linien: Fixed problem that only a random official line is detect.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6397
diff
changeset
|
186 " ol: " + range); |
1e97d2e95410
Amtl. Linien: Fixed problem that only a random official line is detect.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6397
diff
changeset
|
187 } |
6385
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
188 ranges.add(range); |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
189 break; |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
190 } |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
191 } |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
192 } |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
193 |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
194 if (!ranges.isEmpty()) { |
6494
1e97d2e95410
Amtl. Linien: Fixed problem that only a random official line is detect.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6397
diff
changeset
|
195 String rname = river.getName(); |
1e97d2e95410
Amtl. Linien: Fixed problem that only a random official line is detect.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6397
diff
changeset
|
196 List<ValueRange> old = rivers2officialLines.get(rname); |
1e97d2e95410
Amtl. Linien: Fixed problem that only a random official line is detect.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6397
diff
changeset
|
197 if (old != null) { |
1e97d2e95410
Amtl. Linien: Fixed problem that only a random official line is detect.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6397
diff
changeset
|
198 old.addAll(ranges); |
1e97d2e95410
Amtl. Linien: Fixed problem that only a random official line is detect.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6397
diff
changeset
|
199 } |
1e97d2e95410
Amtl. Linien: Fixed problem that only a random official line is detect.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6397
diff
changeset
|
200 else { |
1e97d2e95410
Amtl. Linien: Fixed problem that only a random official line is detect.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6397
diff
changeset
|
201 rivers2officialLines.put(rname, ranges); |
1e97d2e95410
Amtl. Linien: Fixed problem that only a random official line is detect.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6397
diff
changeset
|
202 } |
6385
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
203 } |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
204 } |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
205 |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
206 return rivers2officialLines; |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
207 } |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
208 |
8856 | 209 public static final Range MAX_RANGE = |
210 new Range(-Double.MAX_VALUE, +Double.MAX_VALUE); | |
6395
d2803cc7a338
Artifacts: Official lines: Only apply in Q-Calculations and filter against the ranges of the gauges.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6385
diff
changeset
|
211 |
d2803cc7a338
Artifacts: Official lines: Only apply in Q-Calculations and filter against the ranges of the gauges.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6385
diff
changeset
|
212 private static final String nn(String s) { |
d2803cc7a338
Artifacts: Official lines: Only apply in Q-Calculations and filter against the ranges of the gauges.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6385
diff
changeset
|
213 return s != null ? s : ""; |
d2803cc7a338
Artifacts: Official lines: Only apply in Q-Calculations and filter against the ranges of the gauges.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6385
diff
changeset
|
214 } |
d2803cc7a338
Artifacts: Official lines: Only apply in Q-Calculations and filter against the ranges of the gauges.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6385
diff
changeset
|
215 |
d2803cc7a338
Artifacts: Official lines: Only apply in Q-Calculations and filter against the ranges of the gauges.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6385
diff
changeset
|
216 public static Range extractRange(D4EArtifact artifact) { |
6494
1e97d2e95410
Amtl. Linien: Fixed problem that only a random official line is detect.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6397
diff
changeset
|
217 |
6395
d2803cc7a338
Artifacts: Official lines: Only apply in Q-Calculations and filter against the ranges of the gauges.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6385
diff
changeset
|
218 String mode = nn(artifact.getDataAsString("ld_mode")); |
d2803cc7a338
Artifacts: Official lines: Only apply in Q-Calculations and filter against the ranges of the gauges.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6385
diff
changeset
|
219 String locations = nn(artifact.getDataAsString("ld_locations")); |
d2803cc7a338
Artifacts: Official lines: Only apply in Q-Calculations and filter against the ranges of the gauges.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6385
diff
changeset
|
220 String from = nn(artifact.getDataAsString("ld_from")); |
d2803cc7a338
Artifacts: Official lines: Only apply in Q-Calculations and filter against the ranges of the gauges.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6385
diff
changeset
|
221 String to = nn(artifact.getDataAsString("ld_to")); |
d2803cc7a338
Artifacts: Official lines: Only apply in Q-Calculations and filter against the ranges of the gauges.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6385
diff
changeset
|
222 |
6494
1e97d2e95410
Amtl. Linien: Fixed problem that only a random official line is detect.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6397
diff
changeset
|
223 if (log.isDebugEnabled()) { |
1e97d2e95410
Amtl. Linien: Fixed problem that only a random official line is detect.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6397
diff
changeset
|
224 log.debug("ld_mode: '" + mode + "'"); |
1e97d2e95410
Amtl. Linien: Fixed problem that only a random official line is detect.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6397
diff
changeset
|
225 log.debug("ld_locations: '" + locations + "'"); |
1e97d2e95410
Amtl. Linien: Fixed problem that only a random official line is detect.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6397
diff
changeset
|
226 log.debug("ld_from: '" + from + "'"); |
1e97d2e95410
Amtl. Linien: Fixed problem that only a random official line is detect.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6397
diff
changeset
|
227 log.debug("ld_to: '" + to + "'"); |
1e97d2e95410
Amtl. Linien: Fixed problem that only a random official line is detect.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6397
diff
changeset
|
228 } |
1e97d2e95410
Amtl. Linien: Fixed problem that only a random official line is detect.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6397
diff
changeset
|
229 |
6395
d2803cc7a338
Artifacts: Official lines: Only apply in Q-Calculations and filter against the ranges of the gauges.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6385
diff
changeset
|
230 if (mode.equals("location")) { |
d2803cc7a338
Artifacts: Official lines: Only apply in Q-Calculations and filter against the ranges of the gauges.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6385
diff
changeset
|
231 try { |
d2803cc7a338
Artifacts: Official lines: Only apply in Q-Calculations and filter against the ranges of the gauges.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6385
diff
changeset
|
232 String loc = locations.replace(" ", ""); |
d2803cc7a338
Artifacts: Official lines: Only apply in Q-Calculations and filter against the ranges of the gauges.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6385
diff
changeset
|
233 String[] split = loc.split(","); |
d2803cc7a338
Artifacts: Official lines: Only apply in Q-Calculations and filter against the ranges of the gauges.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6385
diff
changeset
|
234 if (split.length < 1) { |
d2803cc7a338
Artifacts: Official lines: Only apply in Q-Calculations and filter against the ranges of the gauges.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6385
diff
changeset
|
235 return MAX_RANGE; |
d2803cc7a338
Artifacts: Official lines: Only apply in Q-Calculations and filter against the ranges of the gauges.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6385
diff
changeset
|
236 } |
d2803cc7a338
Artifacts: Official lines: Only apply in Q-Calculations and filter against the ranges of the gauges.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6385
diff
changeset
|
237 double min = Double.parseDouble(split[0]); |
d2803cc7a338
Artifacts: Official lines: Only apply in Q-Calculations and filter against the ranges of the gauges.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6385
diff
changeset
|
238 double max = min; |
d2803cc7a338
Artifacts: Official lines: Only apply in Q-Calculations and filter against the ranges of the gauges.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6385
diff
changeset
|
239 for (int i = 1; i < split.length; ++i) { |
d2803cc7a338
Artifacts: Official lines: Only apply in Q-Calculations and filter against the ranges of the gauges.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6385
diff
changeset
|
240 double v = Double.parseDouble(split[i]); |
d2803cc7a338
Artifacts: Official lines: Only apply in Q-Calculations and filter against the ranges of the gauges.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6385
diff
changeset
|
241 if (v > max) max = v; |
d2803cc7a338
Artifacts: Official lines: Only apply in Q-Calculations and filter against the ranges of the gauges.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6385
diff
changeset
|
242 if (v < min) min = v; |
d2803cc7a338
Artifacts: Official lines: Only apply in Q-Calculations and filter against the ranges of the gauges.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6385
diff
changeset
|
243 } |
d2803cc7a338
Artifacts: Official lines: Only apply in Q-Calculations and filter against the ranges of the gauges.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6385
diff
changeset
|
244 return new Range(min, max); |
d2803cc7a338
Artifacts: Official lines: Only apply in Q-Calculations and filter against the ranges of the gauges.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6385
diff
changeset
|
245 } |
d2803cc7a338
Artifacts: Official lines: Only apply in Q-Calculations and filter against the ranges of the gauges.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6385
diff
changeset
|
246 catch (NumberFormatException nfe) { |
d2803cc7a338
Artifacts: Official lines: Only apply in Q-Calculations and filter against the ranges of the gauges.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6385
diff
changeset
|
247 return MAX_RANGE; |
d2803cc7a338
Artifacts: Official lines: Only apply in Q-Calculations and filter against the ranges of the gauges.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6385
diff
changeset
|
248 } |
d2803cc7a338
Artifacts: Official lines: Only apply in Q-Calculations and filter against the ranges of the gauges.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6385
diff
changeset
|
249 } |
d2803cc7a338
Artifacts: Official lines: Only apply in Q-Calculations and filter against the ranges of the gauges.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6385
diff
changeset
|
250 try { |
8509
32c94ca227bc
(issue1782) Invert artifact range if necessary in officiallinefinder
Andre Heinecke <andre.heinecke@intevation.de>
parents:
7248
diff
changeset
|
251 double f = Double.parseDouble(from); |
32c94ca227bc
(issue1782) Invert artifact range if necessary in officiallinefinder
Andre Heinecke <andre.heinecke@intevation.de>
parents:
7248
diff
changeset
|
252 double t = Double.parseDouble(to); |
32c94ca227bc
(issue1782) Invert artifact range if necessary in officiallinefinder
Andre Heinecke <andre.heinecke@intevation.de>
parents:
7248
diff
changeset
|
253 if (f > t) { |
32c94ca227bc
(issue1782) Invert artifact range if necessary in officiallinefinder
Andre Heinecke <andre.heinecke@intevation.de>
parents:
7248
diff
changeset
|
254 return new Range(t, f); |
32c94ca227bc
(issue1782) Invert artifact range if necessary in officiallinefinder
Andre Heinecke <andre.heinecke@intevation.de>
parents:
7248
diff
changeset
|
255 } |
32c94ca227bc
(issue1782) Invert artifact range if necessary in officiallinefinder
Andre Heinecke <andre.heinecke@intevation.de>
parents:
7248
diff
changeset
|
256 return new Range(f, t); |
6395
d2803cc7a338
Artifacts: Official lines: Only apply in Q-Calculations and filter against the ranges of the gauges.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6385
diff
changeset
|
257 } |
d2803cc7a338
Artifacts: Official lines: Only apply in Q-Calculations and filter against the ranges of the gauges.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6385
diff
changeset
|
258 catch (NumberFormatException nfe) { |
d2803cc7a338
Artifacts: Official lines: Only apply in Q-Calculations and filter against the ranges of the gauges.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6385
diff
changeset
|
259 return MAX_RANGE; |
d2803cc7a338
Artifacts: Official lines: Only apply in Q-Calculations and filter against the ranges of the gauges.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6385
diff
changeset
|
260 } |
d2803cc7a338
Artifacts: Official lines: Only apply in Q-Calculations and filter against the ranges of the gauges.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6385
diff
changeset
|
261 } |
d2803cc7a338
Artifacts: Official lines: Only apply in Q-Calculations and filter against the ranges of the gauges.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6385
diff
changeset
|
262 |
8856 | 263 private static List<ValueRange> filterByRange( |
264 Range range, | |
265 List<ValueRange> ranges | |
266 ) { | |
6395
d2803cc7a338
Artifacts: Official lines: Only apply in Q-Calculations and filter against the ranges of the gauges.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6385
diff
changeset
|
267 List<ValueRange> list = new ArrayList<ValueRange>(ranges.size()); |
d2803cc7a338
Artifacts: Official lines: Only apply in Q-Calculations and filter against the ranges of the gauges.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6385
diff
changeset
|
268 for (ValueRange r: ranges) { |
d2803cc7a338
Artifacts: Official lines: Only apply in Q-Calculations and filter against the ranges of the gauges.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6385
diff
changeset
|
269 if (r.intersects(range)) { |
d2803cc7a338
Artifacts: Official lines: Only apply in Q-Calculations and filter against the ranges of the gauges.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6385
diff
changeset
|
270 list.add(r); |
d2803cc7a338
Artifacts: Official lines: Only apply in Q-Calculations and filter against the ranges of the gauges.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6385
diff
changeset
|
271 } |
d2803cc7a338
Artifacts: Official lines: Only apply in Q-Calculations and filter against the ranges of the gauges.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6385
diff
changeset
|
272 } |
d2803cc7a338
Artifacts: Official lines: Only apply in Q-Calculations and filter against the ranges of the gauges.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6385
diff
changeset
|
273 return list; |
d2803cc7a338
Artifacts: Official lines: Only apply in Q-Calculations and filter against the ranges of the gauges.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6385
diff
changeset
|
274 } |
d2803cc7a338
Artifacts: Official lines: Only apply in Q-Calculations and filter against the ranges of the gauges.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6385
diff
changeset
|
275 |
8856 | 276 private static List<ValueRange> filterByQRange( |
277 Range range, | |
278 List<ValueRange> ranges | |
279 ) { | |
6397
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
280 List<ValueRange> list = new ArrayList<ValueRange>(ranges.size()); |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
281 for (ValueRange r: ranges) { |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
282 if (r.intersectsValueRange(range) && !list.contains(r)) { |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
283 list.add(r); |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
284 } |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
285 } |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
286 return list; |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
287 } |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
288 |
8856 | 289 private static List<ValueRange> filterByQValues( |
290 double[] values, | |
291 List<ValueRange> ranges | |
292 ) { | |
6932
b78d110135ec
(issue1451) Use distinct values for single_wq mode filtering instead of ranges.
Andre Heinecke <aheinecke@intevation.de>
parents:
6519
diff
changeset
|
293 List<ValueRange> list = new ArrayList<ValueRange>(ranges.size()); |
b78d110135ec
(issue1451) Use distinct values for single_wq mode filtering instead of ranges.
Andre Heinecke <aheinecke@intevation.de>
parents:
6519
diff
changeset
|
294 for (ValueRange r: ranges) { |
b78d110135ec
(issue1451) Use distinct values for single_wq mode filtering instead of ranges.
Andre Heinecke <aheinecke@intevation.de>
parents:
6519
diff
changeset
|
295 for (double val: values) { |
b78d110135ec
(issue1451) Use distinct values for single_wq mode filtering instead of ranges.
Andre Heinecke <aheinecke@intevation.de>
parents:
6519
diff
changeset
|
296 if (r.sameValue(val) && !list.contains(r)) { |
b78d110135ec
(issue1451) Use distinct values for single_wq mode filtering instead of ranges.
Andre Heinecke <aheinecke@intevation.de>
parents:
6519
diff
changeset
|
297 list.add(r); |
b78d110135ec
(issue1451) Use distinct values for single_wq mode filtering instead of ranges.
Andre Heinecke <aheinecke@intevation.de>
parents:
6519
diff
changeset
|
298 } |
b78d110135ec
(issue1451) Use distinct values for single_wq mode filtering instead of ranges.
Andre Heinecke <aheinecke@intevation.de>
parents:
6519
diff
changeset
|
299 } |
b78d110135ec
(issue1451) Use distinct values for single_wq mode filtering instead of ranges.
Andre Heinecke <aheinecke@intevation.de>
parents:
6519
diff
changeset
|
300 } |
b78d110135ec
(issue1451) Use distinct values for single_wq mode filtering instead of ranges.
Andre Heinecke <aheinecke@intevation.de>
parents:
6519
diff
changeset
|
301 return list; |
b78d110135ec
(issue1451) Use distinct values for single_wq mode filtering instead of ranges.
Andre Heinecke <aheinecke@intevation.de>
parents:
6519
diff
changeset
|
302 } |
b78d110135ec
(issue1451) Use distinct values for single_wq mode filtering instead of ranges.
Andre Heinecke <aheinecke@intevation.de>
parents:
6519
diff
changeset
|
303 |
6395
d2803cc7a338
Artifacts: Official lines: Only apply in Q-Calculations and filter against the ranges of the gauges.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6385
diff
changeset
|
304 private static boolean isQ(D4EArtifact artifact) { |
d2803cc7a338
Artifacts: Official lines: Only apply in Q-Calculations and filter against the ranges of the gauges.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6385
diff
changeset
|
305 Boolean b = artifact.getDataAsBoolean("wq_isq"); |
d2803cc7a338
Artifacts: Official lines: Only apply in Q-Calculations and filter against the ranges of the gauges.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6385
diff
changeset
|
306 return b != null && b; |
d2803cc7a338
Artifacts: Official lines: Only apply in Q-Calculations and filter against the ranges of the gauges.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6385
diff
changeset
|
307 } |
d2803cc7a338
Artifacts: Official lines: Only apply in Q-Calculations and filter against the ranges of the gauges.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6385
diff
changeset
|
308 |
6397
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
309 private static boolean isRange(D4EArtifact artifact) { |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
310 Boolean b = artifact.getDataAsBoolean("wq_isrange"); |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
311 return b != null && b; |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
312 } |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
313 |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
314 public static final Range Q_OUT_OF_RANGE = new Range(-10000, -9999); |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
315 |
6932
b78d110135ec
(issue1451) Use distinct values for single_wq mode filtering instead of ranges.
Andre Heinecke <aheinecke@intevation.de>
parents:
6519
diff
changeset
|
316 private static double[] singleQs(D4EArtifact artifact) { |
6397
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
317 String singleData = nn(artifact.getDataAsString("wq_single")); |
6932
b78d110135ec
(issue1451) Use distinct values for single_wq mode filtering instead of ranges.
Andre Heinecke <aheinecke@intevation.de>
parents:
6519
diff
changeset
|
318 String[] values = singleData.split(" "); |
b78d110135ec
(issue1451) Use distinct values for single_wq mode filtering instead of ranges.
Andre Heinecke <aheinecke@intevation.de>
parents:
6519
diff
changeset
|
319 double[] ret = new double[values.length]; |
b78d110135ec
(issue1451) Use distinct values for single_wq mode filtering instead of ranges.
Andre Heinecke <aheinecke@intevation.de>
parents:
6519
diff
changeset
|
320 int i = 0; |
6397
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
321 |
6932
b78d110135ec
(issue1451) Use distinct values for single_wq mode filtering instead of ranges.
Andre Heinecke <aheinecke@intevation.de>
parents:
6519
diff
changeset
|
322 for (String value: values) { |
6397
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
323 try { |
6932
b78d110135ec
(issue1451) Use distinct values for single_wq mode filtering instead of ranges.
Andre Heinecke <aheinecke@intevation.de>
parents:
6519
diff
changeset
|
324 ret[i] = Double.parseDouble(value); |
6397
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
325 } |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
326 catch (NumberFormatException nfe) { |
6932
b78d110135ec
(issue1451) Use distinct values for single_wq mode filtering instead of ranges.
Andre Heinecke <aheinecke@intevation.de>
parents:
6519
diff
changeset
|
327 ret[i] = -1; // INVALID_Q_VALUE |
6397
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
328 } |
6932
b78d110135ec
(issue1451) Use distinct values for single_wq mode filtering instead of ranges.
Andre Heinecke <aheinecke@intevation.de>
parents:
6519
diff
changeset
|
329 i++; |
6397
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
330 } |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
331 |
6932
b78d110135ec
(issue1451) Use distinct values for single_wq mode filtering instead of ranges.
Andre Heinecke <aheinecke@intevation.de>
parents:
6519
diff
changeset
|
332 return ret; |
6397
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
333 } |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
334 |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
335 private static Range qRange(D4EArtifact artifact) { |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
336 try { |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
337 Double from = artifact.getDataAsDouble("wq_from"); |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
338 Double to = artifact.getDataAsDouble("wq_to"); |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
339 |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
340 if (from == null || to == null) { |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
341 return Q_OUT_OF_RANGE; |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
342 } |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
343 double f = from; |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
344 double t = to; |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
345 return new Range(Math.min(f, t), Math.max(f, t)); |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
346 } |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
347 catch (NumberFormatException nfe) { |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
348 return Q_OUT_OF_RANGE; |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
349 } |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
350 } |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
351 |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
352 private static Range tripleQRange(D4EArtifact artifact) { |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
353 String rangesData = nn(artifact.getDataAsString("wq_values")); |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
354 |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
355 double min = Double.MAX_VALUE; |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
356 double max = -Double.MAX_VALUE; |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
357 |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
358 for (String range: rangesData.split(":")) { |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
359 String [] parts = range.split(";"); |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
360 if (parts.length < 3) { |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
361 continue; |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
362 } |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
363 String [] values = parts[2].split(","); |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
364 for (String value: values) { |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
365 try { |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
366 double x = Double.parseDouble(value); |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
367 if (x < min) min = x; |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
368 if (x > max) max = x; |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
369 } |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
370 catch (NumberFormatException nfe) { |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
371 } |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
372 } |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
373 } |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
374 |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
375 return min == Double.MAX_VALUE |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
376 ? Q_OUT_OF_RANGE |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
377 : new Range(min, max); |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
378 } |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
379 |
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
380 public static List<ValueRange> findOfficialLines(D4EArtifact artifact) { |
6385
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
381 |
6395
d2803cc7a338
Artifacts: Official lines: Only apply in Q-Calculations and filter against the ranges of the gauges.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6385
diff
changeset
|
382 if (!isQ(artifact)) { // Only handle Q calculations |
6397
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
383 return Collections.<ValueRange>emptyList(); |
6395
d2803cc7a338
Artifacts: Official lines: Only apply in Q-Calculations and filter against the ranges of the gauges.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6385
diff
changeset
|
384 } |
d2803cc7a338
Artifacts: Official lines: Only apply in Q-Calculations and filter against the ranges of the gauges.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6385
diff
changeset
|
385 |
6385
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
386 Map<String, List<ValueRange>> rivers2officialLines = getAll(); |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
387 |
6395
d2803cc7a338
Artifacts: Official lines: Only apply in Q-Calculations and filter against the ranges of the gauges.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6385
diff
changeset
|
388 String riverName = nn(artifact.getDataAsString("river")); |
6385
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
389 |
6395
d2803cc7a338
Artifacts: Official lines: Only apply in Q-Calculations and filter against the ranges of the gauges.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6385
diff
changeset
|
390 List<ValueRange> ranges = rivers2officialLines.get(riverName); |
d2803cc7a338
Artifacts: Official lines: Only apply in Q-Calculations and filter against the ranges of the gauges.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6385
diff
changeset
|
391 |
d2803cc7a338
Artifacts: Official lines: Only apply in Q-Calculations and filter against the ranges of the gauges.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6385
diff
changeset
|
392 if (ranges == null) { |
6397
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
393 return Collections.<ValueRange>emptyList(); |
6385
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
394 } |
6494
1e97d2e95410
Amtl. Linien: Fixed problem that only a random official line is detect.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6397
diff
changeset
|
395 boolean debug = log.isDebugEnabled(); |
1e97d2e95410
Amtl. Linien: Fixed problem that only a random official line is detect.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6397
diff
changeset
|
396 |
1e97d2e95410
Amtl. Linien: Fixed problem that only a random official line is detect.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6397
diff
changeset
|
397 if (debug) { |
1e97d2e95410
Amtl. Linien: Fixed problem that only a random official line is detect.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6397
diff
changeset
|
398 log.debug("Before range filter:" + ranges); |
1e97d2e95410
Amtl. Linien: Fixed problem that only a random official line is detect.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6397
diff
changeset
|
399 } |
6385
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
400 |
6395
d2803cc7a338
Artifacts: Official lines: Only apply in Q-Calculations and filter against the ranges of the gauges.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6385
diff
changeset
|
401 ranges = filterByRange(extractRange(artifact), ranges); |
6385
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
402 |
6494
1e97d2e95410
Amtl. Linien: Fixed problem that only a random official line is detect.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6397
diff
changeset
|
403 if (debug) { |
1e97d2e95410
Amtl. Linien: Fixed problem that only a random official line is detect.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6397
diff
changeset
|
404 log.debug("After range filter:" + ranges); |
1e97d2e95410
Amtl. Linien: Fixed problem that only a random official line is detect.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6397
diff
changeset
|
405 } |
1e97d2e95410
Amtl. Linien: Fixed problem that only a random official line is detect.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6397
diff
changeset
|
406 |
6385
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
407 if (ranges.isEmpty()) { |
6397
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
408 return Collections.<ValueRange>emptyList(); |
6385
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
409 } |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
410 |
6932
b78d110135ec
(issue1451) Use distinct values for single_wq mode filtering instead of ranges.
Andre Heinecke <aheinecke@intevation.de>
parents:
6519
diff
changeset
|
411 if (isRange(artifact)) { |
b78d110135ec
(issue1451) Use distinct values for single_wq mode filtering instead of ranges.
Andre Heinecke <aheinecke@intevation.de>
parents:
6519
diff
changeset
|
412 Range qRange = qRange(artifact); |
b78d110135ec
(issue1451) Use distinct values for single_wq mode filtering instead of ranges.
Andre Heinecke <aheinecke@intevation.de>
parents:
6519
diff
changeset
|
413 if (qRange == Q_OUT_OF_RANGE) { |
b78d110135ec
(issue1451) Use distinct values for single_wq mode filtering instead of ranges.
Andre Heinecke <aheinecke@intevation.de>
parents:
6519
diff
changeset
|
414 qRange = tripleQRange(artifact); |
b78d110135ec
(issue1451) Use distinct values for single_wq mode filtering instead of ranges.
Andre Heinecke <aheinecke@intevation.de>
parents:
6519
diff
changeset
|
415 } |
b78d110135ec
(issue1451) Use distinct values for single_wq mode filtering instead of ranges.
Andre Heinecke <aheinecke@intevation.de>
parents:
6519
diff
changeset
|
416 ranges = filterByQRange(qRange, ranges); |
b78d110135ec
(issue1451) Use distinct values for single_wq mode filtering instead of ranges.
Andre Heinecke <aheinecke@intevation.de>
parents:
6519
diff
changeset
|
417 if (debug) { |
b78d110135ec
(issue1451) Use distinct values for single_wq mode filtering instead of ranges.
Andre Heinecke <aheinecke@intevation.de>
parents:
6519
diff
changeset
|
418 log.debug("Q range filter: " + qRange); |
b78d110135ec
(issue1451) Use distinct values for single_wq mode filtering instead of ranges.
Andre Heinecke <aheinecke@intevation.de>
parents:
6519
diff
changeset
|
419 } |
b78d110135ec
(issue1451) Use distinct values for single_wq mode filtering instead of ranges.
Andre Heinecke <aheinecke@intevation.de>
parents:
6519
diff
changeset
|
420 } else { |
b78d110135ec
(issue1451) Use distinct values for single_wq mode filtering instead of ranges.
Andre Heinecke <aheinecke@intevation.de>
parents:
6519
diff
changeset
|
421 ranges = filterByQValues(singleQs(artifact), ranges); |
6397
f579e4a80b84
Artifacts: Official lines finder: handle the cases from the state model.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6395
diff
changeset
|
422 } |
6385
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
423 |
6494
1e97d2e95410
Amtl. Linien: Fixed problem that only a random official line is detect.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6397
diff
changeset
|
424 if (debug) { |
1e97d2e95410
Amtl. Linien: Fixed problem that only a random official line is detect.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6397
diff
changeset
|
425 log.debug("After q range filter: " + ranges); |
1e97d2e95410
Amtl. Linien: Fixed problem that only a random official line is detect.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6397
diff
changeset
|
426 } |
1e97d2e95410
Amtl. Linien: Fixed problem that only a random official line is detect.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6397
diff
changeset
|
427 |
1e97d2e95410
Amtl. Linien: Fixed problem that only a random official line is detect.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6397
diff
changeset
|
428 return ranges; |
6385
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
429 } |
ef08c4f57ede
Artifacts: First part of the official lines guessing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
430 } |