annotate artifacts/src/main/java/org/dive4elements/river/utils/RiverUtils.java @ 8930:f972e1da4a63

Another nice flys feature... double == comparison
author gernotbelger
date Tue, 06 Mar 2018 17:02:45 +0100
parents 5e38e2924c07
children
rev   line source
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
2 * Software engineering by Intevation GmbH
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
3 *
5994
af13ceeba52a Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5867
diff changeset
4 * This file is Free Software under the GNU AGPL (>=v3)
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
5994
af13ceeba52a Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5867
diff changeset
6 * documentation coming with Dive4Elements River for details.
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
7 */
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
8
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4994
diff changeset
9 package org.dive4elements.river.utils;
1095
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4994
diff changeset
11 import org.dive4elements.artifactdatabase.state.State;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4994
diff changeset
12 import org.dive4elements.artifacts.Artifact;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4994
diff changeset
13 import org.dive4elements.artifacts.CallContext;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4994
diff changeset
14 import org.dive4elements.artifacts.common.utils.Config;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4994
diff changeset
15 import org.dive4elements.artifacts.common.utils.XMLUtils;
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
16 import org.dive4elements.river.artifacts.D4EArtifact;
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4994
diff changeset
17 import org.dive4elements.river.artifacts.WINFOArtifact;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4994
diff changeset
18 import org.dive4elements.river.artifacts.access.RangeAccess;
5866
9a6741ccf6d4 FLYS artifacts: Renamed FLYSContext(Factory) to RiverContext(Factory).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5865
diff changeset
19 import org.dive4elements.river.artifacts.context.RiverContext;
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4994
diff changeset
20 import org.dive4elements.river.artifacts.model.LocationProvider;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4994
diff changeset
21 import org.dive4elements.river.artifacts.model.RiverFactory;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4994
diff changeset
22 import org.dive4elements.river.artifacts.model.WKms;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4994
diff changeset
23 import org.dive4elements.river.artifacts.model.WQ;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4994
diff changeset
24 import org.dive4elements.river.artifacts.states.WDifferencesState;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4994
diff changeset
25 import org.dive4elements.river.artifacts.states.WaterlevelSelectState;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4994
diff changeset
26 import org.dive4elements.river.backend.SessionFactoryProvider;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4994
diff changeset
27 import org.dive4elements.river.model.Gauge;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4994
diff changeset
28 import org.dive4elements.river.model.MainValue;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4994
diff changeset
29 import org.dive4elements.river.model.River;
8186
a1ceacf15d3a Removed NASTY package clash. We had too org.dive4elements.river.util packages.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7699
diff changeset
30 import org.dive4elements.river.backend.utils.StringUtil;
4648
c04db3178d09 Work on river axis mapfile generator.
Christian Lins <christian.lins@intevation.de>
parents: 4635
diff changeset
31
c04db3178d09 Work on river axis mapfile generator.
Christian Lins <christian.lins@intevation.de>
parents: 4635
diff changeset
32 import gnu.trove.TDoubleArrayList;
c04db3178d09 Work on river axis mapfile generator.
Christian Lins <christian.lins@intevation.de>
parents: 4635
diff changeset
33 import gnu.trove.TIntArrayList;
c04db3178d09 Work on river axis mapfile generator.
Christian Lins <christian.lins@intevation.de>
parents: 4635
diff changeset
34 import gnu.trove.TLongArrayList;
1740
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
35
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
36 import java.text.NumberFormat;
1105
adb52a2005e7 Moved code to extract the river srid defined in the global configuration into FLYSUtils.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1099
diff changeset
37 import java.util.HashMap;
1740
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
38 import java.util.List;
1105
adb52a2005e7 Moved code to extract the river srid defined in the global configuration into FLYSUtils.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1099
diff changeset
39 import java.util.Map;
2068
0cf60d64895c #370 Added a 'W at gauge' column to CSV exports if 'W at gauge' mode has been selected.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2063
diff changeset
40 import java.util.regex.Matcher;
0cf60d64895c #370 Added a 'W at gauge' column to CSV exports if 'W at gauge' mode has been selected.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2063
diff changeset
41 import java.util.regex.Pattern;
1105
adb52a2005e7 Moved code to extract the river srid defined in the global configuration into FLYSUtils.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1099
diff changeset
42
adb52a2005e7 Moved code to extract the river srid defined in the global configuration into FLYSUtils.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1099
diff changeset
43 import javax.xml.xpath.XPathConstants;
adb52a2005e7 Moved code to extract the river srid defined in the global configuration into FLYSUtils.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1099
diff changeset
44
4648
c04db3178d09 Work on river axis mapfile generator.
Christian Lins <christian.lins@intevation.de>
parents: 4635
diff changeset
45 import org.apache.log4j.Logger;
1845
06c157848c8f Made the floodmap compatible with an Oracle database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1805
diff changeset
46 import org.hibernate.SessionFactory;
06c157848c8f Made the floodmap compatible with an Oracle database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1805
diff changeset
47 import org.hibernate.impl.SessionFactoryImpl;
4648
c04db3178d09 Work on river axis mapfile generator.
Christian Lins <christian.lins@intevation.de>
parents: 4635
diff changeset
48 import org.w3c.dom.Document;
1095
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
49
3047
d20215a0afd8 Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2765
diff changeset
50
4635
53fa4d5c9fb2 Deprecate FLYSUtils
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4616
diff changeset
51 /**
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
52 * Static helper methods to e.g. access D4EArtifacts data.
4635
53fa4d5c9fb2 Deprecate FLYSUtils
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4616
diff changeset
53 *
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8765
diff changeset
54 * @deprecated Don't use RiverUtils to get data from an
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8765
diff changeset
55 * {@link Artifact} anymore.
4635
53fa4d5c9fb2 Deprecate FLYSUtils
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4616
diff changeset
56 * Instead use and/or create a {@link Access} class hierarchy.
53fa4d5c9fb2 Deprecate FLYSUtils
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4616
diff changeset
57 **/
53fa4d5c9fb2 Deprecate FLYSUtils
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4616
diff changeset
58 @Deprecated
5865
73da40528cf2 River artifacts: Renamed FLYSUtils to RiverUtils.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
59 public class RiverUtils {
1095
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
60
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8186
diff changeset
61 /** The log that is used in this utility. */
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8186
diff changeset
62 private static Logger log = Logger.getLogger(RiverUtils.class);
1150
5f53b443d67c Implement getArtifact(uuid,context) in FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1129
diff changeset
63
2038
f73036b991e2 Bugfix: repaired broken named values in exports - the last solution had bad side effects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2035
diff changeset
64 /**
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8765
diff changeset
65 * Enum that represents the 5 possible WQ modes in FLYS. The 5 values are
2038
f73036b991e2 Bugfix: repaired broken named values in exports - the last solution had bad side effects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2035
diff changeset
66 * <i>QFREE</i> <i>QGAUGE</i> <i>WGAUGE</i> <i>WFREE</i> and <i>NONE</i>.
f73036b991e2 Bugfix: repaired broken named values in exports - the last solution had bad side effects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2035
diff changeset
67 */
f73036b991e2 Bugfix: repaired broken named values in exports - the last solution had bad side effects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2035
diff changeset
68 public static enum WQ_MODE { QFREE, QGAUGE, WFREE, WGAUGE, NONE };
f73036b991e2 Bugfix: repaired broken named values in exports - the last solution had bad side effects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2035
diff changeset
69
2422
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
70 /**
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
71 * An enum that represents the 4 possible WQ input modes in FLYS. The 4
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
72 * values are
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
73 * <i>ADAPTED</i> <i>SINGLE</i> <i>RANGE</i> and <i>NONE</i>.
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
74 */
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
75 public static enum WQ_INPUT { ADAPTED, SINGLE, RANGE, NONE };
2068
0cf60d64895c #370 Added a 'W at gauge' column to CSV exports if 'W at gauge' mode has been selected.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2063
diff changeset
76
0cf60d64895c #370 Added a 'W at gauge' column to CSV exports if 'W at gauge' mode has been selected.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2063
diff changeset
77 public static final Pattern NUMBERS_PATTERN =
0cf60d64895c #370 Added a 'W at gauge' column to CSV exports if 'W at gauge' mode has been selected.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2063
diff changeset
78 Pattern.compile("\\D*(\\d++.\\d*)\\D*");
0cf60d64895c #370 Added a 'W at gauge' column to CSV exports if 'W at gauge' mode has been selected.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2063
diff changeset
79
4656
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4648
diff changeset
80 public static final String XPATH_FLOODMAP_RIVER_PROJECTION =
1105
adb52a2005e7 Moved code to extract the river srid defined in the global configuration into FLYSUtils.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1099
diff changeset
81 "/artifact-database/floodmap/river[@name=$name]/srid/@value";
adb52a2005e7 Moved code to extract the river srid defined in the global configuration into FLYSUtils.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1099
diff changeset
82
4656
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4648
diff changeset
83 public static final String XPATH_FLOODMAP_SHAPEFILE_DIR =
1129
da3c3e286c88 Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1118
diff changeset
84 "/artifact-database/floodmap/shapefile-path/@value";
da3c3e286c88 Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1118
diff changeset
85
4656
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4648
diff changeset
86 public static final String XPATH_FLOODMAP_VELOCITY_LOGFILE =
1129
da3c3e286c88 Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1118
diff changeset
87 "/artifact-database/floodmap/velocity/logfile/@path";
da3c3e286c88 Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1118
diff changeset
88
4656
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4648
diff changeset
89 public static final String XPATH_FLOODMAP_MAPSERVER_URL =
1129
da3c3e286c88 Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1118
diff changeset
90 "/artifact-database/floodmap/mapserver/server/@path";
da3c3e286c88 Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1118
diff changeset
91
4864
dc0d37715e16 Floodmap uses the static River-WMS instead of User-WMS via RiverAxisArtifact.
Christian Lins <christian.lins@intevation.de>
parents: 4862
diff changeset
92 public static final String XPATH_RIVERMAP_MAPSERVER_URL =
dc0d37715e16 Floodmap uses the static River-WMS instead of User-WMS via RiverAxisArtifact.
Christian Lins <christian.lins@intevation.de>
parents: 4862
diff changeset
93 "/artifact-database/rivermap/mapserver/server/@path";
dc0d37715e16 Floodmap uses the static River-WMS instead of User-WMS via RiverAxisArtifact.
Christian Lins <christian.lins@intevation.de>
parents: 4862
diff changeset
94
4656
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4648
diff changeset
95 public static final String XPATH_FLOODMAP_MAPFILE_PATH =
1129
da3c3e286c88 Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1118
diff changeset
96 "/artifact-database/floodmap/mapserver/mapfile/@path";
da3c3e286c88 Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1118
diff changeset
97
4656
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4648
diff changeset
98 public static final String XPATH_FLOODMAP_MAPFILE_TEMPLATE =
1129
da3c3e286c88 Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1118
diff changeset
99 "/artifact-database/floodmap/mapserver/map-template/@path";
da3c3e286c88 Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1118
diff changeset
100
4656
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4648
diff changeset
101 public static final String XPATH_FLOODMAP_MAPSERVER_TEMPLATE_PATH =
1129
da3c3e286c88 Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1118
diff changeset
102 "/artifact-database/floodmap/mapserver/templates/@path";
da3c3e286c88 Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1118
diff changeset
103
7123
1a20738e9a21 Add currentKM context / request mapping to RiverUtils and use it in DiagramGenerator
Andre Heinecke <aheinecke@intevation.de>
parents: 7056
diff changeset
104 public static final String CURRENT_KM = "currentKm";
1a20738e9a21 Add currentKM context / request mapping to RiverUtils and use it in DiagramGenerator
Andre Heinecke <aheinecke@intevation.de>
parents: 7056
diff changeset
105
1a20738e9a21 Add currentKM context / request mapping to RiverUtils and use it in DiagramGenerator
Andre Heinecke <aheinecke@intevation.de>
parents: 7056
diff changeset
106 public static final String XPATH_CHART_CURRENTKM =
1a20738e9a21 Add currentKM context / request mapping to RiverUtils and use it in DiagramGenerator
Andre Heinecke <aheinecke@intevation.de>
parents: 7056
diff changeset
107 "/art:action/art:attributes/art:currentKm/@art:km";
1a20738e9a21 Add currentKM context / request mapping to RiverUtils and use it in DiagramGenerator
Andre Heinecke <aheinecke@intevation.de>
parents: 7056
diff changeset
108
1095
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
109
5865
73da40528cf2 River artifacts: Renamed FLYSUtils to RiverUtils.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
110 private RiverUtils() {
1095
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
111 }
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
112
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
113
2017
e384d78ff78b Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1845
diff changeset
114 /**
e384d78ff78b Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1845
diff changeset
115 * Pulls Artifact with given UUID fromm database.
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
116 * @return D4EArtifact with given UUID or null (in case of errors).
2017
e384d78ff78b Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1845
diff changeset
117 */
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
118 public static D4EArtifact getArtifact(String uuid, CallContext context) {
1150
5f53b443d67c Implement getArtifact(uuid,context) in FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1129
diff changeset
119 try {
1174
f58be0d661b9 Improved FLYSUtils: fetch Artifacts from ArtifactDatabase properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1150
diff changeset
120 Artifact artifact = context.getDatabase().getRawArtifact(uuid);
f58be0d661b9 Improved FLYSUtils: fetch Artifacts from ArtifactDatabase properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1150
diff changeset
121
f58be0d661b9 Improved FLYSUtils: fetch Artifacts from ArtifactDatabase properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1150
diff changeset
122 if (artifact == null) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8186
diff changeset
123 log.error("Artifact '" + uuid + "' does not exist.");
1174
f58be0d661b9 Improved FLYSUtils: fetch Artifacts from ArtifactDatabase properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1150
diff changeset
124 return null;
f58be0d661b9 Improved FLYSUtils: fetch Artifacts from ArtifactDatabase properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1150
diff changeset
125 }
f58be0d661b9 Improved FLYSUtils: fetch Artifacts from ArtifactDatabase properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1150
diff changeset
126
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
127 if (!(artifact instanceof D4EArtifact)) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8186
diff changeset
128 log.error("Artifact '" +uuid+ "' is no valid D4EArtifact.");
1174
f58be0d661b9 Improved FLYSUtils: fetch Artifacts from ArtifactDatabase properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1150
diff changeset
129 return null;
f58be0d661b9 Improved FLYSUtils: fetch Artifacts from ArtifactDatabase properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1150
diff changeset
130 }
f58be0d661b9 Improved FLYSUtils: fetch Artifacts from ArtifactDatabase properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1150
diff changeset
131
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
132 return (D4EArtifact) artifact;
1150
5f53b443d67c Implement getArtifact(uuid,context) in FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1129
diff changeset
133 }
5f53b443d67c Implement getArtifact(uuid,context) in FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1129
diff changeset
134 // TODO: catch more selective
5f53b443d67c Implement getArtifact(uuid,context) in FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1129
diff changeset
135 catch (Exception e) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8186
diff changeset
136 log.error("Cannot get D4EArtifact " + uuid
2017
e384d78ff78b Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1845
diff changeset
137 + " from database (" + e.getMessage() + ").");
1150
5f53b443d67c Implement getArtifact(uuid,context) in FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1129
diff changeset
138 return null;
5f53b443d67c Implement getArtifact(uuid,context) in FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1129
diff changeset
139 }
1118
7398280b11a0 Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1105
diff changeset
140 }
7398280b11a0 Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1105
diff changeset
141
7398280b11a0 Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1105
diff changeset
142
1129
da3c3e286c88 Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1118
diff changeset
143 /**
5866
9a6741ccf6d4 FLYS artifacts: Renamed FLYSContext(Factory) to RiverContext(Factory).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5865
diff changeset
144 * Returns the RiverContext from context object.
1777
a8aa343799a2 Extracet getFlysContext from FLYSArtifact to FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1740
diff changeset
145 *
5866
9a6741ccf6d4 FLYS artifacts: Renamed FLYSContext(Factory) to RiverContext(Factory).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5865
diff changeset
146 * @param context The CallContext or the RiverContext.
9a6741ccf6d4 FLYS artifacts: Renamed FLYSContext(Factory) to RiverContext(Factory).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5865
diff changeset
147 *
9a6741ccf6d4 FLYS artifacts: Renamed FLYSContext(Factory) to RiverContext(Factory).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5865
diff changeset
148 * @return the RiverContext.
1777
a8aa343799a2 Extracet getFlysContext from FLYSArtifact to FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1740
diff changeset
149 */
5866
9a6741ccf6d4 FLYS artifacts: Renamed FLYSContext(Factory) to RiverContext(Factory).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5865
diff changeset
150 public static RiverContext getFlysContext(Object context) {
9a6741ccf6d4 FLYS artifacts: Renamed FLYSContext(Factory) to RiverContext(Factory).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5865
diff changeset
151 return context instanceof RiverContext
9a6741ccf6d4 FLYS artifacts: Renamed FLYSContext(Factory) to RiverContext(Factory).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5865
diff changeset
152 ? (RiverContext) context
9a6741ccf6d4 FLYS artifacts: Renamed FLYSContext(Factory) to RiverContext(Factory).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5865
diff changeset
153 : (RiverContext) ((CallContext) context).globalContext();
1777
a8aa343799a2 Extracet getFlysContext from FLYSArtifact to FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1740
diff changeset
154 }
a8aa343799a2 Extracet getFlysContext from FLYSArtifact to FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1740
diff changeset
155
a8aa343799a2 Extracet getFlysContext from FLYSArtifact to FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1740
diff changeset
156
a8aa343799a2 Extracet getFlysContext from FLYSArtifact to FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1740
diff changeset
157 /**
1129
da3c3e286c88 Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1118
diff changeset
158 * Convinience function to retrieve an XPath as string with replaced config
da3c3e286c88 Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1118
diff changeset
159 * directory.
da3c3e286c88 Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1118
diff changeset
160 *
da3c3e286c88 Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1118
diff changeset
161 * @param xpath The XPath expression.
da3c3e286c88 Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1118
diff changeset
162 *
da3c3e286c88 Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1118
diff changeset
163 * @return a string with replaced config directory.
da3c3e286c88 Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1118
diff changeset
164 */
da3c3e286c88 Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1118
diff changeset
165 public static String getXPathString(String xpath) {
da3c3e286c88 Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1118
diff changeset
166 String tmp = Config.getStringXPath(xpath);
da3c3e286c88 Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1118
diff changeset
167 tmp = Config.replaceConfigDir(tmp);
da3c3e286c88 Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1118
diff changeset
168
da3c3e286c88 Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1118
diff changeset
169 return tmp;
da3c3e286c88 Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1118
diff changeset
170 }
da3c3e286c88 Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1118
diff changeset
171
da3c3e286c88 Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1118
diff changeset
172
1845
06c157848c8f Made the floodmap compatible with an Oracle database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1805
diff changeset
173 public static boolean isUsingOracle() {
06c157848c8f Made the floodmap compatible with an Oracle database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1805
diff changeset
174 SessionFactory sf = SessionFactoryProvider.getSessionFactory();
06c157848c8f Made the floodmap compatible with an Oracle database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1805
diff changeset
175
06c157848c8f Made the floodmap compatible with an Oracle database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1805
diff changeset
176 String d = SessionFactoryProvider.getDriver((SessionFactoryImpl) sf);
06c157848c8f Made the floodmap compatible with an Oracle database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1805
diff changeset
177
06c157848c8f Made the floodmap compatible with an Oracle database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1805
diff changeset
178 return d != null ? d.indexOf("Oracle") >= 0 : false;
06c157848c8f Made the floodmap compatible with an Oracle database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1805
diff changeset
179 }
06c157848c8f Made the floodmap compatible with an Oracle database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1805
diff changeset
180
06c157848c8f Made the floodmap compatible with an Oracle database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1805
diff changeset
181
2038
f73036b991e2 Bugfix: repaired broken named values in exports - the last solution had bad side effects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2035
diff changeset
182 /**
6528
735df49affd1 Antidoc: Strip "This method" from short doc strings.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6101
diff changeset
183 * Returns an WQ_MODE enum which is based on the parameters
2423
ac528b883b47 Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2422
diff changeset
184 * stored in <i>flys</i> Artifact. If there is no <i>wq_isq</i> parameter
2038
f73036b991e2 Bugfix: repaired broken named values in exports - the last solution had bad side effects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2035
diff changeset
185 * existing, WQ_MODE.NONE is returned.
f73036b991e2 Bugfix: repaired broken named values in exports - the last solution had bad side effects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2035
diff changeset
186 *
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
187 * @param flys The D4EArtifact that stores wq mode relevant parameters.
2038
f73036b991e2 Bugfix: repaired broken named values in exports - the last solution had bad side effects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2035
diff changeset
188 *
f73036b991e2 Bugfix: repaired broken named values in exports - the last solution had bad side effects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2035
diff changeset
189 * @return an enum WQ_MODE.
f73036b991e2 Bugfix: repaired broken named values in exports - the last solution had bad side effects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2035
diff changeset
190 */
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
191 public static WQ_MODE getWQMode(D4EArtifact flys) {
2081
aa9cc91c8193 #444 Take care on NullPointerExceptions in getWQMode. Take 'false' as default value if no 'wq_free' item is existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2068
diff changeset
192 if (flys == null) {
aa9cc91c8193 #444 Take care on NullPointerExceptions in getWQMode. Take 'false' as default value if no 'wq_free' item is existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2068
diff changeset
193 return WQ_MODE.NONE;
aa9cc91c8193 #444 Take care on NullPointerExceptions in getWQMode. Take 'false' as default value if no 'wq_free' item is existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2068
diff changeset
194 }
aa9cc91c8193 #444 Take care on NullPointerExceptions in getWQMode. Take 'false' as default value if no 'wq_free' item is existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2068
diff changeset
195
2422
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
196 String values = flys.getDataAsString("wq_values");
3444
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
197 Boolean isQ = flys.getDataAsBoolean("wq_isq");
2038
f73036b991e2 Bugfix: repaired broken named values in exports - the last solution had bad side effects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2035
diff changeset
198
2422
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
199 if (values != null) {
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
200 return isQ ? WQ_MODE.QGAUGE : WQ_MODE.WGAUGE;
2038
f73036b991e2 Bugfix: repaired broken named values in exports - the last solution had bad side effects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2035
diff changeset
201 }
2422
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
202
2423
ac528b883b47 Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2422
diff changeset
203 Boolean isFree = flys.getDataAsBoolean("wq_isfree");
2422
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
204
4413
c62598c372ab FLYSUtils: Null-guard some conditionals (autoboxes).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4363
diff changeset
205 if (isQ != null && isQ) {
2422
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
206 return isFree ? WQ_MODE.QFREE : WQ_MODE.QGAUGE;
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
207 }
4413
c62598c372ab FLYSUtils: Null-guard some conditionals (autoboxes).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4363
diff changeset
208 else if (isQ != null && !isQ) {
2422
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
209 return isFree ? WQ_MODE.WFREE : WQ_MODE.WGAUGE;
2038
f73036b991e2 Bugfix: repaired broken named values in exports - the last solution had bad side effects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2035
diff changeset
210 }
f73036b991e2 Bugfix: repaired broken named values in exports - the last solution had bad side effects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2035
diff changeset
211 else {
f73036b991e2 Bugfix: repaired broken named values in exports - the last solution had bad side effects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2035
diff changeset
212 return WQ_MODE.NONE;
f73036b991e2 Bugfix: repaired broken named values in exports - the last solution had bad side effects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2035
diff changeset
213 }
f73036b991e2 Bugfix: repaired broken named values in exports - the last solution had bad side effects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2035
diff changeset
214 }
f73036b991e2 Bugfix: repaired broken named values in exports - the last solution had bad side effects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2035
diff changeset
215
f73036b991e2 Bugfix: repaired broken named values in exports - the last solution had bad side effects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2035
diff changeset
216
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
217 public static WQ_INPUT getWQInputMode(D4EArtifact flys) {
2422
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
218 if (flys == null) {
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
219 return WQ_INPUT.NONE;
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
220 }
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
221
2423
ac528b883b47 Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2422
diff changeset
222 Boolean selection = flys.getDataAsBoolean("wq_isrange");
2422
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
223 String adapted = flys.getDataAsString("wq_values");
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
224
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
225 if(adapted != null && adapted.length() > 0) {
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
226 return WQ_INPUT.ADAPTED;
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
227 }
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
228
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
229 if (selection != null && selection) {
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
230 return WQ_INPUT.RANGE;
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
231 }
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
232 else {
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
233 return WQ_INPUT.SINGLE;
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
234 }
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
235 }
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
236
1095
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
237
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
238 public static double[] getKmFromTo(D4EArtifact flys) {
1095
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
239 String strFrom = flys.getDataAsString("ld_from");
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
240 String strTo = flys.getDataAsString("ld_to");
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
241
3444
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
242 if (strFrom == null) {
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
243 strFrom = flys.getDataAsString("from");
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
244 }
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
245
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
246 if (strTo == null) {
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
247 strTo = flys.getDataAsString("to");
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
248 }
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
249
1095
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
250 if (strFrom == null || strTo == null) {
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
251 return null;
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
252 }
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
253
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
254 try {
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
255 return new double[] {
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
256 Double.parseDouble(strFrom),
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
257 Double.parseDouble(strTo) };
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
258 }
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
259 catch (NumberFormatException nfe) {
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
260 return null;
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
261 }
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
262 }
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
263
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
264
2041
e5f01f2325c9 Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2038
diff changeset
265 /**
e5f01f2325c9 Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2038
diff changeset
266 * Return sorted array of locations at which stuff was calculated
e5f01f2325c9 Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2038
diff changeset
267 * (from ld_locations data), null if not parameterized this way.
e5f01f2325c9 Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2038
diff changeset
268 */
4851
a1ce76091ade FLYSUtils: Made getLocations private, added TODO about resolution.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4812
diff changeset
269 // TODO moved to RangeAccess. Resolve remaining calls.
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
270 private static double[] getLocations(D4EArtifact flys) {
1095
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
271 String locationStr = flys.getDataAsString("ld_locations");
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
272
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
273 if (locationStr == null || locationStr.length() == 0) {
2765
79f6d0802b06 Prepare improved Discharge curve compatibility.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2600
diff changeset
274 if (flys instanceof WINFOArtifact) {
79f6d0802b06 Prepare improved Discharge curve compatibility.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2600
diff changeset
275 WINFOArtifact winfo = (WINFOArtifact) flys;
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8765
diff changeset
276 if (winfo.getReferenceStartKm() != null
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8765
diff changeset
277 && winfo.getReferenceEndKms() != null
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8765
diff changeset
278 ) {
2765
79f6d0802b06 Prepare improved Discharge curve compatibility.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2600
diff changeset
279 return new double[]
79f6d0802b06 Prepare improved Discharge curve compatibility.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2600
diff changeset
280 {
79f6d0802b06 Prepare improved Discharge curve compatibility.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2600
diff changeset
281 winfo.getReferenceStartKm().doubleValue(),
79f6d0802b06 Prepare improved Discharge curve compatibility.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2600
diff changeset
282 winfo.getReferenceEndKms()[0]
79f6d0802b06 Prepare improved Discharge curve compatibility.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2600
diff changeset
283 };
79f6d0802b06 Prepare improved Discharge curve compatibility.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2600
diff changeset
284 }
79f6d0802b06 Prepare improved Discharge curve compatibility.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2600
diff changeset
285 }
1095
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
286 return null;
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
287 }
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
288
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
289 String[] tmp = locationStr.split(" ");
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
290 TDoubleArrayList locations = new TDoubleArrayList();
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
291
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
292 for (String l: tmp) {
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
293 try {
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
294 locations.add(Double.parseDouble(l));
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
295 }
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
296 catch (NumberFormatException nfe) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8186
diff changeset
297 log.debug(nfe.getLocalizedMessage(), nfe);
1095
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
298 }
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
299 }
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
300
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
301 locations.sort();
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
302
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
303 return locations.toNativeArray();
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
304 }
1099
af73f196eccc Refactored to use new FLYSUtils, moved getRiver-functionality inside.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1095
diff changeset
305
af73f196eccc Refactored to use new FLYSUtils, moved getRiver-functionality inside.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1095
diff changeset
306
af73f196eccc Refactored to use new FLYSUtils, moved getRiver-functionality inside.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1095
diff changeset
307 /**
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
308 * Returns the Qs for a given D4EArtifact. This method currently accepts
2045
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
309 * only instances of WINFOArtifact.
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
310 *
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
311 * @param flys A D4EArtifact.
2045
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
312 *
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
313 * @return the Qs.
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
314 */
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
315 public static double[] getQs(D4EArtifact flys) {
2045
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
316 // XXX this is not nice!
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
317 if (flys instanceof WINFOArtifact) {
2423
ac528b883b47 Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2422
diff changeset
318 return ((WINFOArtifact) flys).getQs();
2045
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
319 }
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
320
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8186
diff changeset
321 log.warn("This method (getQs) currently supports WINFOArtifact only!");
2045
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
322
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
323 return null;
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
324 }
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
325
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
326
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
327 /**
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
328 * Returns the Ws for a given D4EArtifact. This method currently accepts
2045
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
329 * only instances of WINFOArtifact.
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
330 *
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
331 * @param flys A D4EArtifact.
2045
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
332 *
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
333 * @return the Ws.
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
334 */
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
335 public static double[] getWs(D4EArtifact flys) {
2045
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
336 // XXX this is not nice!
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
337 if (flys instanceof WINFOArtifact) {
2422
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
338 return ((WINFOArtifact) flys).getWs();
2045
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
339 }
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
340
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8186
diff changeset
341 log.warn("This method (getWs) currently supports WINFOArtifact only!");
2045
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
342
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
343 return null;
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
344 }
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
345
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
346
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
347 /**
1099
af73f196eccc Refactored to use new FLYSUtils, moved getRiver-functionality inside.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1095
diff changeset
348 * Returns the selected River object based on the 'river' data that might
af73f196eccc Refactored to use new FLYSUtils, moved getRiver-functionality inside.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1095
diff changeset
349 * have been inserted by the user.
af73f196eccc Refactored to use new FLYSUtils, moved getRiver-functionality inside.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1095
diff changeset
350 *
7644
f2f34d722807 Added two comments about improvements.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7123
diff changeset
351 * @deprecated - use RiverAccess instead
f2f34d722807 Added two comments about improvements.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7123
diff changeset
352 *
1099
af73f196eccc Refactored to use new FLYSUtils, moved getRiver-functionality inside.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1095
diff changeset
353 * @return the selected River or null if no river has been chosen yet.
af73f196eccc Refactored to use new FLYSUtils, moved getRiver-functionality inside.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1095
diff changeset
354 */
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
355 public static River getRiver(D4EArtifact flys) {
2045
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
356 String sRiver = getRivername(flys);
1099
af73f196eccc Refactored to use new FLYSUtils, moved getRiver-functionality inside.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1095
diff changeset
357
af73f196eccc Refactored to use new FLYSUtils, moved getRiver-functionality inside.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1095
diff changeset
358 return (sRiver != null)
af73f196eccc Refactored to use new FLYSUtils, moved getRiver-functionality inside.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1095
diff changeset
359 ? RiverFactory.getRiver(sRiver)
af73f196eccc Refactored to use new FLYSUtils, moved getRiver-functionality inside.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1095
diff changeset
360 : null;
af73f196eccc Refactored to use new FLYSUtils, moved getRiver-functionality inside.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1095
diff changeset
361 }
1105
adb52a2005e7 Moved code to extract the river srid defined in the global configuration into FLYSUtils.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1099
diff changeset
362
adb52a2005e7 Moved code to extract the river srid defined in the global configuration into FLYSUtils.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1099
diff changeset
363
adb52a2005e7 Moved code to extract the river srid defined in the global configuration into FLYSUtils.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1099
diff changeset
364 /**
2045
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
365 * Returns the name of the river specified in the given <i>flys</i>
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
366 * Artifact.
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
367 *
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
368 * @param flys The D4EArtifact that stores a river relevant information.
2045
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
369 *
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
370 * @return the name of the specified river or null.
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
371 */
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
372 public static String getRivername(D4EArtifact flys) {
2045
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
373 return flys != null ? flys.getDataAsString("river") : null;
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
374 }
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
375
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
376
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
377 /**
1105
adb52a2005e7 Moved code to extract the river srid defined in the global configuration into FLYSUtils.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1099
diff changeset
378 * Extracts the SRID defined in the global configuration for the river
adb52a2005e7 Moved code to extract the river srid defined in the global configuration into FLYSUtils.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1099
diff changeset
379 * specified in <i>artifact</i>.
adb52a2005e7 Moved code to extract the river srid defined in the global configuration into FLYSUtils.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1099
diff changeset
380 *
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
381 * @param artifact The D4EArtifact that stores the name of the river.
1105
adb52a2005e7 Moved code to extract the river srid defined in the global configuration into FLYSUtils.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1099
diff changeset
382 *
adb52a2005e7 Moved code to extract the river srid defined in the global configuration into FLYSUtils.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1099
diff changeset
383 * @return the SRID as string (e.g. "31466").
adb52a2005e7 Moved code to extract the river srid defined in the global configuration into FLYSUtils.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1099
diff changeset
384 */
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
385 public static String getRiverSrid(D4EArtifact artifact) {
1105
adb52a2005e7 Moved code to extract the river srid defined in the global configuration into FLYSUtils.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1099
diff changeset
386 String river = artifact.getDataAsString("river");
adb52a2005e7 Moved code to extract the river srid defined in the global configuration into FLYSUtils.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1099
diff changeset
387
adb52a2005e7 Moved code to extract the river srid defined in the global configuration into FLYSUtils.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1099
diff changeset
388 if (river == null || river.length() == 0) {
adb52a2005e7 Moved code to extract the river srid defined in the global configuration into FLYSUtils.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1099
diff changeset
389 return null;
adb52a2005e7 Moved code to extract the river srid defined in the global configuration into FLYSUtils.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1099
diff changeset
390 }
adb52a2005e7 Moved code to extract the river srid defined in the global configuration into FLYSUtils.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1099
diff changeset
391
1805
5e9696c32f04 Added datacage config and loaders for KM WMS layer in floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1792
diff changeset
392 return getRiverSrid(river);
5e9696c32f04 Added datacage config and loaders for KM WMS layer in floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1792
diff changeset
393 }
5e9696c32f04 Added datacage config and loaders for KM WMS layer in floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1792
diff changeset
394
5e9696c32f04 Added datacage config and loaders for KM WMS layer in floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1792
diff changeset
395
5e9696c32f04 Added datacage config and loaders for KM WMS layer in floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1792
diff changeset
396 public static String getRiverSrid(String rivername) {
1105
adb52a2005e7 Moved code to extract the river srid defined in the global configuration into FLYSUtils.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1099
diff changeset
397 Map<String, String> variables = new HashMap<String, String>(1);
1805
5e9696c32f04 Added datacage config and loaders for KM WMS layer in floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1792
diff changeset
398 variables.put("name", rivername);
1105
adb52a2005e7 Moved code to extract the river srid defined in the global configuration into FLYSUtils.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1099
diff changeset
399
adb52a2005e7 Moved code to extract the river srid defined in the global configuration into FLYSUtils.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1099
diff changeset
400 Document cfg = Config.getConfig();
adb52a2005e7 Moved code to extract the river srid defined in the global configuration into FLYSUtils.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1099
diff changeset
401
adb52a2005e7 Moved code to extract the river srid defined in the global configuration into FLYSUtils.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1099
diff changeset
402 return (String) XMLUtils.xpath(
adb52a2005e7 Moved code to extract the river srid defined in the global configuration into FLYSUtils.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1099
diff changeset
403 cfg,
4656
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4648
diff changeset
404 XPATH_FLOODMAP_RIVER_PROJECTION,
1105
adb52a2005e7 Moved code to extract the river srid defined in the global configuration into FLYSUtils.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1099
diff changeset
405 XPathConstants.STRING,
adb52a2005e7 Moved code to extract the river srid defined in the global configuration into FLYSUtils.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1099
diff changeset
406 null,
adb52a2005e7 Moved code to extract the river srid defined in the global configuration into FLYSUtils.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1099
diff changeset
407 variables);
adb52a2005e7 Moved code to extract the river srid defined in the global configuration into FLYSUtils.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1099
diff changeset
408 }
1740
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
409
3284
d9af29a4bb85 Various cosmetic doc fixes.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
410 /**
d9af29a4bb85 Various cosmetic doc fixes.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
411 * Return the (first) Gauge corresponding to the given location(s) of
d9af29a4bb85 Various cosmetic doc fixes.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
412 * the artifact.
8755
30b1ddadf275 (issue1801) Unify reference gauge finding code
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8570
diff changeset
413 *
30b1ddadf275 (issue1801) Unify reference gauge finding code
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8570
diff changeset
414 * This method is left for compatibility. Use river.determineRefGauge()
30b1ddadf275 (issue1801) Unify reference gauge finding code
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8570
diff changeset
415 * directly in new code.
30b1ddadf275 (issue1801) Unify reference gauge finding code
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8570
diff changeset
416 *
3284
d9af29a4bb85 Various cosmetic doc fixes.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
417 * @param flys the artifact in question.
8755
30b1ddadf275 (issue1801) Unify reference gauge finding code
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8570
diff changeset
418 * @return Reference / first gauge of locations of river of artifact.
3284
d9af29a4bb85 Various cosmetic doc fixes.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
419 */
8760
9483a5bf4219 Remove indirection via RiverUtils to obtain reference gauge and reduce casts.
Tom Gottfried <tom@intevation.de>
parents: 8756
diff changeset
420 private static Gauge getGauge(D4EArtifact flys) {
2045
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
421 River river = getRiver(flys);
6101
a0078e5e3b39 Removed unused context from RangeAccess and subclasses leading to some dead code removal.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
422 RangeAccess rangeAccess = new RangeAccess(flys);
4862
b99656db18de FLYSUtils: Use RangeAcces, removed getKmRange.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4852
diff changeset
423 double[] dist = rangeAccess.getKmRange();
2045
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
424
8755
30b1ddadf275 (issue1801) Unify reference gauge finding code
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8570
diff changeset
425 return river.determineRefGauge(dist, rangeAccess.isRange());
2045
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
426 }
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
427
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
428
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
429 public static String getGaugename(D4EArtifact flys) {
2045
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
430 Gauge gauge = getGauge(flys);
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
431
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
432 return gauge != null ? gauge.getName() : null;
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
433 }
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
434
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
435
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
436 public static Gauge getReferenceGauge(D4EArtifact flys) {
2128
bf67eb014443 Added convinience functions to FLYSArtifact and FLYSUtils.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2081
diff changeset
437 Long officialNumber = flys.getDataAsLong("reference_gauge");
6841
ddb0ed040209 (Issue1357) Pull river name into getReferenceGauge
Andre Heinecke <aheinecke@intevation.de>
parents: 6529
diff changeset
438 String river = getRivername(flys);
2128
bf67eb014443 Added convinience functions to FLYSArtifact and FLYSUtils.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2081
diff changeset
439
6841
ddb0ed040209 (Issue1357) Pull river name into getReferenceGauge
Andre Heinecke <aheinecke@intevation.de>
parents: 6529
diff changeset
440 if (officialNumber != null && river != null) {
ddb0ed040209 (Issue1357) Pull river name into getReferenceGauge
Andre Heinecke <aheinecke@intevation.de>
parents: 6529
diff changeset
441 return Gauge.getGaugeByOfficialNumber(officialNumber, river);
ddb0ed040209 (Issue1357) Pull river name into getReferenceGauge
Andre Heinecke <aheinecke@intevation.de>
parents: 6529
diff changeset
442 } else if (officialNumber != null) {
ddb0ed040209 (Issue1357) Pull river name into getReferenceGauge
Andre Heinecke <aheinecke@intevation.de>
parents: 6529
diff changeset
443 return Gauge.getGaugeByOfficialNumber(officialNumber);
ddb0ed040209 (Issue1357) Pull river name into getReferenceGauge
Andre Heinecke <aheinecke@intevation.de>
parents: 6529
diff changeset
444 }
ddb0ed040209 (Issue1357) Pull river name into getReferenceGauge
Andre Heinecke <aheinecke@intevation.de>
parents: 6529
diff changeset
445 return null;
2128
bf67eb014443 Added convinience functions to FLYSArtifact and FLYSUtils.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2081
diff changeset
446 }
bf67eb014443 Added convinience functions to FLYSArtifact and FLYSUtils.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2081
diff changeset
447
bf67eb014443 Added convinience functions to FLYSArtifact and FLYSUtils.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2081
diff changeset
448
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
449 public static String getReferenceGaugeName(D4EArtifact flys) {
2249
997df76c6f58 Create title, subtitle and axes labels for charts from type historical discharge curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2235
diff changeset
450 Gauge refGauge = getReferenceGauge(flys);
997df76c6f58 Create title, subtitle and axes labels for charts from type historical discharge curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2235
diff changeset
451
997df76c6f58 Create title, subtitle and axes labels for charts from type historical discharge curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2235
diff changeset
452 return refGauge != null
997df76c6f58 Create title, subtitle and axes labels for charts from type historical discharge curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2235
diff changeset
453 ? refGauge.getName()
997df76c6f58 Create title, subtitle and axes labels for charts from type historical discharge curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2235
diff changeset
454 : "-- not found --";
997df76c6f58 Create title, subtitle and axes labels for charts from type historical discharge curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2235
diff changeset
455 }
997df76c6f58 Create title, subtitle and axes labels for charts from type historical discharge curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2235
diff changeset
456
997df76c6f58 Create title, subtitle and axes labels for charts from type historical discharge curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2235
diff changeset
457
2068
0cf60d64895c #370 Added a 'W at gauge' column to CSV exports if 'W at gauge' mode has been selected.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2063
diff changeset
458 public static Double getValueFromWQ(WQ wq) {
0cf60d64895c #370 Added a 'W at gauge' column to CSV exports if 'W at gauge' mode has been selected.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2063
diff changeset
459 if (wq == null) {
0cf60d64895c #370 Added a 'W at gauge' column to CSV exports if 'W at gauge' mode has been selected.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2063
diff changeset
460 return null;
0cf60d64895c #370 Added a 'W at gauge' column to CSV exports if 'W at gauge' mode has been selected.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2063
diff changeset
461 }
0cf60d64895c #370 Added a 'W at gauge' column to CSV exports if 'W at gauge' mode has been selected.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2063
diff changeset
462
0cf60d64895c #370 Added a 'W at gauge' column to CSV exports if 'W at gauge' mode has been selected.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2063
diff changeset
463 Matcher m = NUMBERS_PATTERN.matcher(wq.getName());
0cf60d64895c #370 Added a 'W at gauge' column to CSV exports if 'W at gauge' mode has been selected.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2063
diff changeset
464
0cf60d64895c #370 Added a 'W at gauge' column to CSV exports if 'W at gauge' mode has been selected.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2063
diff changeset
465 if (m.matches()) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8186
diff changeset
466 log.debug("Found a number.");
2068
0cf60d64895c #370 Added a 'W at gauge' column to CSV exports if 'W at gauge' mode has been selected.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2063
diff changeset
467
0cf60d64895c #370 Added a 'W at gauge' column to CSV exports if 'W at gauge' mode has been selected.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2063
diff changeset
468 String raw = m.group(1);
0cf60d64895c #370 Added a 'W at gauge' column to CSV exports if 'W at gauge' mode has been selected.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2063
diff changeset
469
0cf60d64895c #370 Added a 'W at gauge' column to CSV exports if 'W at gauge' mode has been selected.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2063
diff changeset
470 try {
0cf60d64895c #370 Added a 'W at gauge' column to CSV exports if 'W at gauge' mode has been selected.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2063
diff changeset
471 return Double.valueOf(raw);
0cf60d64895c #370 Added a 'W at gauge' column to CSV exports if 'W at gauge' mode has been selected.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2063
diff changeset
472 }
0cf60d64895c #370 Added a 'W at gauge' column to CSV exports if 'W at gauge' mode has been selected.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2063
diff changeset
473 catch (NumberFormatException nfe) {
0cf60d64895c #370 Added a 'W at gauge' column to CSV exports if 'W at gauge' mode has been selected.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2063
diff changeset
474 }
0cf60d64895c #370 Added a 'W at gauge' column to CSV exports if 'W at gauge' mode has been selected.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2063
diff changeset
475 }
0cf60d64895c #370 Added a 'W at gauge' column to CSV exports if 'W at gauge' mode has been selected.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2063
diff changeset
476
0cf60d64895c #370 Added a 'W at gauge' column to CSV exports if 'W at gauge' mode has been selected.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2063
diff changeset
477 return null;
0cf60d64895c #370 Added a 'W at gauge' column to CSV exports if 'W at gauge' mode has been selected.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2063
diff changeset
478 }
0cf60d64895c #370 Added a 'W at gauge' column to CSV exports if 'W at gauge' mode has been selected.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2063
diff changeset
479
0cf60d64895c #370 Added a 'W at gauge' column to CSV exports if 'W at gauge' mode has been selected.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2063
diff changeset
480
4363
9dfec327acc6 FLYSUtils: Minor doc add.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4278
diff changeset
481 /** Creates human-readable name for a wsp (waterlevel/longitudinal section).
9dfec327acc6 FLYSUtils: Minor doc add.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4278
diff changeset
482 * @param name will be split at '='s.
9dfec327acc6 FLYSUtils: Minor doc add.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4278
diff changeset
483 */
1740
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
484 public static String createWspWTitle(
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
485 WINFOArtifact winfo,
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
486 CallContext cc,
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
487 String name
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
488 ) {
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
489 String[] parts = name.split("=");
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
490
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
491 NumberFormat nf = Formatter.getWaterlevelW(cc);
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
492
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
493 String namedMainValue = null;
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
494
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
495 boolean isQ = winfo.isQ();
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
496 boolean isFree = winfo.isFreeQ();
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
497
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
498 double v;
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
499
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
500 try {
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
501 v = Double.valueOf(parts[1]);
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
502
8756
26dedebbe39f (issue1801) Code cleanups
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8755
diff changeset
503 namedMainValue = getNamedMainValue(getGauge(winfo), v);
1740
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
504 }
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
505 catch (NumberFormatException nfe) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8186
diff changeset
506 log.warn("Cannot parse Double of: '" + parts[1] + "'");
1740
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
507 return name;
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
508 }
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
509
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
510 String prefix = null;
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
511
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
512 if (isQ && !isFree && namedMainValue != null) {
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
513 return "W (" + namedMainValue + ")";
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
514 }
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
515
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
516 if (isQ) {
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
517 prefix = "Q=";
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
518 }
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
519
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
520 return prefix == null
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
521 ? "W(" + nf.format(v) + ")"
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
522 : "W(" + prefix + nf.format(v) + ")";
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
523 }
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
524
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
525
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
526 public static String createWspQTitle(
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
527 WINFOArtifact winfo,
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
528 CallContext cc,
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
529 String name
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
530 ) {
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
531 String[] parts = name.split("=");
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
532
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
533 NumberFormat nf = Formatter.getWaterlevelQ(cc);
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
534
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
535 String namedMainValue = null;
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
536
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
537 boolean isQ = winfo.isQ();
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
538 boolean isFree = winfo.isFreeQ();
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
539
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
540 double v;
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
541
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
542 try {
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
543 v = Double.valueOf(parts[1]);
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
544
8756
26dedebbe39f (issue1801) Code cleanups
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8755
diff changeset
545 namedMainValue = getNamedMainValue(getGauge(winfo), v);
1740
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
546 }
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
547 catch (NumberFormatException nfe) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8186
diff changeset
548 log.warn("Cannot parse Double of: '" + parts[1] + "'");
1740
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
549 return name;
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
550 }
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
551
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
552 String prefix = null;
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
553
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
554 if (isQ && !isFree && namedMainValue != null) {
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
555 return namedMainValue;
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
556 }
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
557
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
558 if (!isQ) {
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
559 prefix = "W=";
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
560 }
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
561
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
562 return prefix == null
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
563 ? "Q(" + nf.format(v) + ")"
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
564 : "Q(" + prefix + nf.format(v) + ")";
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
565 }
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
566
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
567
2038
f73036b991e2 Bugfix: repaired broken named values in exports - the last solution had bad side effects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2035
diff changeset
568 /**
f73036b991e2 Bugfix: repaired broken named values in exports - the last solution had bad side effects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2035
diff changeset
569 * Returns the named main value if a Q was selected and if this Q fits to a
f73036b991e2 Bugfix: repaired broken named values in exports - the last solution had bad side effects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2035
diff changeset
570 * named main value. Otherwise, this function returns null.
f73036b991e2 Bugfix: repaired broken named values in exports - the last solution had bad side effects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2035
diff changeset
571 *
f73036b991e2 Bugfix: repaired broken named values in exports - the last solution had bad side effects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2035
diff changeset
572 * @param winfo The WINFO Artifact.
f73036b991e2 Bugfix: repaired broken named values in exports - the last solution had bad side effects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2035
diff changeset
573 * @param value The Q (or W) value.
f73036b991e2 Bugfix: repaired broken named values in exports - the last solution had bad side effects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2035
diff changeset
574 *
f73036b991e2 Bugfix: repaired broken named values in exports - the last solution had bad side effects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2035
diff changeset
575 * @return a named main value or null.
f73036b991e2 Bugfix: repaired broken named values in exports - the last solution had bad side effects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2035
diff changeset
576 */
f73036b991e2 Bugfix: repaired broken named values in exports - the last solution had bad side effects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2035
diff changeset
577 public static String getNamedMainValue(WINFOArtifact winfo, double value) {
f73036b991e2 Bugfix: repaired broken named values in exports - the last solution had bad side effects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2035
diff changeset
578 WQ_MODE wqmode = getWQMode(winfo);
f73036b991e2 Bugfix: repaired broken named values in exports - the last solution had bad side effects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2035
diff changeset
579
f73036b991e2 Bugfix: repaired broken named values in exports - the last solution had bad side effects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2035
diff changeset
580 if (wqmode != WQ_MODE.QGAUGE) {
f73036b991e2 Bugfix: repaired broken named values in exports - the last solution had bad side effects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2035
diff changeset
581 return null;
f73036b991e2 Bugfix: repaired broken named values in exports - the last solution had bad side effects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2035
diff changeset
582 }
f73036b991e2 Bugfix: repaired broken named values in exports - the last solution had bad side effects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2035
diff changeset
583 else {
8756
26dedebbe39f (issue1801) Code cleanups
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8755
diff changeset
584 return getNamedMainValue(getGauge(winfo), value);
2038
f73036b991e2 Bugfix: repaired broken named values in exports - the last solution had bad side effects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2035
diff changeset
585 }
f73036b991e2 Bugfix: repaired broken named values in exports - the last solution had bad side effects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2035
diff changeset
586 }
f73036b991e2 Bugfix: repaired broken named values in exports - the last solution had bad side effects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2035
diff changeset
587
f73036b991e2 Bugfix: repaired broken named values in exports - the last solution had bad side effects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2035
diff changeset
588
1740
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
589 public static String getNamedMainValue(Gauge gauge, double value) {
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
590 List<MainValue> mainValues = gauge.getMainValues();
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8186
diff changeset
591 log.debug("Search named main value for: " + value);
1740
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
592
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
593 for (MainValue mv: mainValues) {
8930
f972e1da4a63 Another nice flys feature... double == comparison
gernotbelger
parents: 8856
diff changeset
594 // FIXME: no-go! double == comparison... its simply a wonder that this works in release mode, it definitively does not work in debug mode!
1740
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
595 if (mv.getValue().doubleValue() == value) {
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8765
diff changeset
596 log.debug("Found named main value: "
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8765
diff changeset
597 + mv.getMainValue().getName());
1740
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
598 return mv.getMainValue().getName();
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
599 }
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
600 }
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
601
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8186
diff changeset
602 log.debug("Did not find a named main value for: " + value);
1740
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
603 return null;
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
604 }
1792
49ad801076e4 Enabled the MapGenerator to create WMS layers with database datastore - riveraxis is the first layer that is no longer fetched from static WMS service but from user specific one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1777
diff changeset
605
49ad801076e4 Enabled the MapGenerator to create WMS layers with database datastore - riveraxis is the first layer that is no longer fetched from static WMS service but from user specific one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1777
diff changeset
606
49ad801076e4 Enabled the MapGenerator to create WMS layers with database datastore - riveraxis is the first layer that is no longer fetched from static WMS service but from user specific one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1777
diff changeset
607 /**
2035
3ebbe497d7f7 #252 Set titles in waterlevel exports to named main values if those are existing for given Q values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2017
diff changeset
608 *
3ebbe497d7f7 #252 Set titles in waterlevel exports to named main values if those are existing for given Q values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2017
diff changeset
609 * @param nmv A string that represents a named main value.
3ebbe497d7f7 #252 Set titles in waterlevel exports to named main values if those are existing for given Q values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2017
diff changeset
610 *
3ebbe497d7f7 #252 Set titles in waterlevel exports to named main values if those are existing for given Q values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2017
diff changeset
611 * @throws NullPointerException if nmv is null.
3ebbe497d7f7 #252 Set titles in waterlevel exports to named main values if those are existing for given Q values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2017
diff changeset
612 */
3ebbe497d7f7 #252 Set titles in waterlevel exports to named main values if those are existing for given Q values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2017
diff changeset
613 public static String stripNamedMainValue(String nmv) {
3ebbe497d7f7 #252 Set titles in waterlevel exports to named main values if those are existing for given Q values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2017
diff changeset
614 int startIndex = nmv.indexOf("(");
3ebbe497d7f7 #252 Set titles in waterlevel exports to named main values if those are existing for given Q values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2017
diff changeset
615 int endIndex = nmv.indexOf(")");
3ebbe497d7f7 #252 Set titles in waterlevel exports to named main values if those are existing for given Q values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2017
diff changeset
616
3ebbe497d7f7 #252 Set titles in waterlevel exports to named main values if those are existing for given Q values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2017
diff changeset
617 if (startIndex > 0 && endIndex > 0 && startIndex < endIndex) {
3ebbe497d7f7 #252 Set titles in waterlevel exports to named main values if those are existing for given Q values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2017
diff changeset
618 return nmv.substring(0, startIndex);
3ebbe497d7f7 #252 Set titles in waterlevel exports to named main values if those are existing for given Q values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2017
diff changeset
619 }
3ebbe497d7f7 #252 Set titles in waterlevel exports to named main values if those are existing for given Q values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2017
diff changeset
620
3ebbe497d7f7 #252 Set titles in waterlevel exports to named main values if those are existing for given Q values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2017
diff changeset
621 return nmv;
3ebbe497d7f7 #252 Set titles in waterlevel exports to named main values if those are existing for given Q values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2017
diff changeset
622 }
3ebbe497d7f7 #252 Set titles in waterlevel exports to named main values if those are existing for given Q values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2017
diff changeset
623
3ebbe497d7f7 #252 Set titles in waterlevel exports to named main values if those are existing for given Q values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2017
diff changeset
624
3ebbe497d7f7 #252 Set titles in waterlevel exports to named main values if those are existing for given Q values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2017
diff changeset
625 /**
1792
49ad801076e4 Enabled the MapGenerator to create WMS layers with database datastore - riveraxis is the first layer that is no longer fetched from static WMS service but from user specific one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1777
diff changeset
626 * Returns the URL of user mapfile for the owner of Artifact
49ad801076e4 Enabled the MapGenerator to create WMS layers with database datastore - riveraxis is the first layer that is no longer fetched from static WMS service but from user specific one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1777
diff changeset
627 * <i>artifactId</i>.
49ad801076e4 Enabled the MapGenerator to create WMS layers with database datastore - riveraxis is the first layer that is no longer fetched from static WMS service but from user specific one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1777
diff changeset
628 *
49ad801076e4 Enabled the MapGenerator to create WMS layers with database datastore - riveraxis is the first layer that is no longer fetched from static WMS service but from user specific one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1777
diff changeset
629 * @param artifactId The UUID of an artifact.
49ad801076e4 Enabled the MapGenerator to create WMS layers with database datastore - riveraxis is the first layer that is no longer fetched from static WMS service but from user specific one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1777
diff changeset
630 *
49ad801076e4 Enabled the MapGenerator to create WMS layers with database datastore - riveraxis is the first layer that is no longer fetched from static WMS service but from user specific one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1777
diff changeset
631 * @return the URL of the user wms.
49ad801076e4 Enabled the MapGenerator to create WMS layers with database datastore - riveraxis is the first layer that is no longer fetched from static WMS service but from user specific one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1777
diff changeset
632 */
49ad801076e4 Enabled the MapGenerator to create WMS layers with database datastore - riveraxis is the first layer that is no longer fetched from static WMS service but from user specific one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1777
diff changeset
633 public static String getUserWMSUrl(String artifactId) {
4656
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4648
diff changeset
634 String url = getXPathString(XPATH_FLOODMAP_MAPSERVER_URL);
2296
d69d8dea78dc Be more merciful for building the URL for the user-wms.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2249
diff changeset
635 url = url.endsWith("/") ? url + "user-wms" : url + "/" + "user-wms";
1792
49ad801076e4 Enabled the MapGenerator to create WMS layers with database datastore - riveraxis is the first layer that is no longer fetched from static WMS service but from user specific one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1777
diff changeset
636
49ad801076e4 Enabled the MapGenerator to create WMS layers with database datastore - riveraxis is the first layer that is no longer fetched from static WMS service but from user specific one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1777
diff changeset
637 return url;
49ad801076e4 Enabled the MapGenerator to create WMS layers with database datastore - riveraxis is the first layer that is no longer fetched from static WMS service but from user specific one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1777
diff changeset
638 }
2063
97a25b54eea3 Part 1 of #125: added a description for a location to the WaterlevelExport.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2045
diff changeset
639
97a25b54eea3 Part 1 of #125: added a description for a location to the WaterlevelExport.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2045
diff changeset
640
4864
dc0d37715e16 Floodmap uses the static River-WMS instead of User-WMS via RiverAxisArtifact.
Christian Lins <christian.lins@intevation.de>
parents: 4862
diff changeset
641 public static String getRiverWMSUrl() {
dc0d37715e16 Floodmap uses the static River-WMS instead of User-WMS via RiverAxisArtifact.
Christian Lins <christian.lins@intevation.de>
parents: 4862
diff changeset
642 String url = getXPathString(XPATH_RIVERMAP_MAPSERVER_URL);
dc0d37715e16 Floodmap uses the static River-WMS instead of User-WMS via RiverAxisArtifact.
Christian Lins <christian.lins@intevation.de>
parents: 4862
diff changeset
643 url = url.endsWith("/") ? url + "river-wms" : url + "/" + "river-wms";
dc0d37715e16 Floodmap uses the static River-WMS instead of User-WMS via RiverAxisArtifact.
Christian Lins <christian.lins@intevation.de>
parents: 4862
diff changeset
644
dc0d37715e16 Floodmap uses the static River-WMS instead of User-WMS via RiverAxisArtifact.
Christian Lins <christian.lins@intevation.de>
parents: 4862
diff changeset
645 return url;
dc0d37715e16 Floodmap uses the static River-WMS instead of User-WMS via RiverAxisArtifact.
Christian Lins <christian.lins@intevation.de>
parents: 4862
diff changeset
646 }
dc0d37715e16 Floodmap uses the static River-WMS instead of User-WMS via RiverAxisArtifact.
Christian Lins <christian.lins@intevation.de>
parents: 4862
diff changeset
647
dc0d37715e16 Floodmap uses the static River-WMS instead of User-WMS via RiverAxisArtifact.
Christian Lins <christian.lins@intevation.de>
parents: 4862
diff changeset
648
2063
97a25b54eea3 Part 1 of #125: added a description for a location to the WaterlevelExport.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2045
diff changeset
649 /**
6528
735df49affd1 Antidoc: Strip "This method" from short doc strings.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6101
diff changeset
650 * Returns the description for a given <i>km</i> for a specific
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
651 * river. The river is provided by the D4EArtifact <i>flys</i>.
2063
97a25b54eea3 Part 1 of #125: added a description for a location to the WaterlevelExport.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2045
diff changeset
652 *
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
653 * @param flys The D4EArtifact that provides a river.
2063
97a25b54eea3 Part 1 of #125: added a description for a location to the WaterlevelExport.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2045
diff changeset
654 * @param km The kilometer.
97a25b54eea3 Part 1 of #125: added a description for a location to the WaterlevelExport.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2045
diff changeset
655 *
97a25b54eea3 Part 1 of #125: added a description for a location to the WaterlevelExport.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2045
diff changeset
656 * @return the description for <i>km</i> or an empty string if no
97a25b54eea3 Part 1 of #125: added a description for a location to the WaterlevelExport.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2045
diff changeset
657 * description was found.
97a25b54eea3 Part 1 of #125: added a description for a location to the WaterlevelExport.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2045
diff changeset
658 */
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
659 public static String getLocationDescription(D4EArtifact flys, double km) {
2063
97a25b54eea3 Part 1 of #125: added a description for a location to the WaterlevelExport.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2045
diff changeset
660 String river = getRivername(flys);
97a25b54eea3 Part 1 of #125: added a description for a location to the WaterlevelExport.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2045
diff changeset
661
97a25b54eea3 Part 1 of #125: added a description for a location to the WaterlevelExport.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2045
diff changeset
662 if (river == null) {
97a25b54eea3 Part 1 of #125: added a description for a location to the WaterlevelExport.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2045
diff changeset
663 return "";
97a25b54eea3 Part 1 of #125: added a description for a location to the WaterlevelExport.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2045
diff changeset
664 }
97a25b54eea3 Part 1 of #125: added a description for a location to the WaterlevelExport.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2045
diff changeset
665
97a25b54eea3 Part 1 of #125: added a description for a location to the WaterlevelExport.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2045
diff changeset
666 return LocationProvider.getLocation(river, km);
97a25b54eea3 Part 1 of #125: added a description for a location to the WaterlevelExport.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2045
diff changeset
667 }
2179
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
668
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
669
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
670 /**
6528
735df49affd1 Antidoc: Strip "This method" from short doc strings.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6101
diff changeset
671 * Returns the differences for a w-differences calculation.
2179
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
672 *
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
673 * @param winfo The WINFOArtifact.
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
674 * @param context The context.
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
675 *
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
676 * @return The differences as string separated by semicolon and linebreak.
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
677 */
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
678 public static String getWDifferences(
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
679 WINFOArtifact winfo,
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
680 CallContext context)
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
681 {
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
682 State state = winfo.getCurrentState(context);
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
683 if(state instanceof WDifferencesState) {
7697
640342d9ab8a (issue1649) Remove broken getWKms from RiverUtils and use WDifferencesState instead
Andre Heinecke <aheinecke@intevation.de>
parents: 7696
diff changeset
684 WDifferencesState wState = (WDifferencesState) state;
640342d9ab8a (issue1649) Remove broken getWKms from RiverUtils and use WDifferencesState instead
Andre Heinecke <aheinecke@intevation.de>
parents: 7696
diff changeset
685
2179
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
686 String diffids = winfo.getDataAsString("diffids");
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
687 String datas[] = diffids.split("#");
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
688
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
689 // Validate the Data-Strings.
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
690 for (String s: datas) {
4054
102050c4fc00 fix issue909: strange validation code. be fearles.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3969
diff changeset
691 if (!WaterlevelSelectState.isValueValid(s)) {
2179
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
692 return "";
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
693 }
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
694 }
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
695
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
696 if (datas.length < 2) {
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
697 return "";
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
698 }
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
699
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
700 String diffs = "";
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
701 for(int i = 0; i < datas.length; i+=2) {
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
702 // e.g.:
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8765
diff changeset
703 //42537f1e-3522-42ef-8968-635b03d8e9c6;longitudinal_section.w;1
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8765
diff changeset
704 WKms minuendWKms = wState.getWKms(
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8765
diff changeset
705 StringUtil.unbracket(datas[i + 0]),
8570
1655588ed479 Do not get any wst values just to get the name of the differences for export.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8359
diff changeset
706 context, 0, 0);
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8765
diff changeset
707 WKms subtrahendWKms = wState.getWKms(
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8765
diff changeset
708 StringUtil.unbracket(datas[i + 1]),
8570
1655588ed479 Do not get any wst values just to get the name of the differences for export.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8359
diff changeset
709 context, 0, 0);
2179
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
710 if (minuendWKms != null && subtrahendWKms != null) {
3076
5642a83420f2 FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3047
diff changeset
711 diffs += StringUtil.wWrap(minuendWKms.getName())
2179
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
712 + " - " + StringUtil.wWrap(subtrahendWKms.getName());
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
713 }
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
714 diffs += ";\n";
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
715 }
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
716 return diffs;
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
717 }
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
718 else {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8186
diff changeset
719 log.warn("Not a valid state for differences.");
2179
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
720 return "";
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
721 }
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
722 }
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
723
2216
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
724 /**
6528
735df49affd1 Antidoc: Strip "This method" from short doc strings.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6101
diff changeset
725 * Transform a string into an int array. Therefore, the string
2216
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
726 * <i>raw</i> must consist of int values separated by a <i>';'</i>.
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
727 *
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
728 * @param raw The raw integer array as string separated by a ';'.
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
729 *
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
730 * @return an array of int values.
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
731 */
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
732 public static int[] intArrayFromString(String raw) {
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
733 String[] splitted = raw != null ? raw.split(";") : null;
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
734
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
735 if (splitted == null || splitted.length == 0) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8186
diff changeset
736 log.warn("No integer values found in '" + raw + "'");
2216
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
737 return new int[0];
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
738 }
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
739
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
740 TIntArrayList integers = new TIntArrayList(splitted.length);
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
741
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
742 for (String value: splitted) {
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
743 try {
3405
b0ba96bbf01d Use Integer.parseInt() instead of Integer.valueOf() + Autounboxing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3284
diff changeset
744 integers.add(Integer.parseInt(value));
2216
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
745 }
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
746 catch (NumberFormatException nfe) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8186
diff changeset
747 log.warn("Parsing integer failed: " + nfe);
2216
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
748 }
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
749 }
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
750
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
751 return integers.toNativeArray();
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
752 }
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
753
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
754
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
755 /**
6528
735df49affd1 Antidoc: Strip "This method" from short doc strings.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6101
diff changeset
756 * Transform a string into a long array. Therefore, the string
2600
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
757 * <i>raw</i> must consist of int values separated by a <i>';'</i>.
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
758 *
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
759 * @param raw The raw long array as string separated by a ';'.
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
760 *
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
761 * @return an array of int values.
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
762 */
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
763 public static long[] longArrayFromString(String raw) {
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
764 String[] splitted = raw != null ? raw.split(";") : null;
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
765
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
766 if (splitted == null || splitted.length == 0) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8186
diff changeset
767 log.warn("No long values found in '" + raw + "'");
2600
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
768 return new long[0];
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
769 }
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
770
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
771 TLongArrayList longs = new TLongArrayList(splitted.length);
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
772
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
773 for (String value: splitted) {
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
774 try {
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
775 longs.add(Long.valueOf(value));
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
776 }
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
777 catch (NumberFormatException nfe) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8186
diff changeset
778 log.warn("Parsing long failed: " + nfe);
2600
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
779 }
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
780 }
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
781
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
782 return longs.toNativeArray();
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
783 }
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
784
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
785
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
786 /**
6528
735df49affd1 Antidoc: Strip "This method" from short doc strings.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6101
diff changeset
787 * Transform a string into an double array. Therefore, the
2216
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
788 * string <i>raw</i> must consist of double values separated by a
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
789 * <i>';'</i>.
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
790 *
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
791 * @param raw The raw double array as string separated by a ';'.
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
792 *
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
793 * @return an array of double values.
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
794 */
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
795 public static double[] doubleArrayFromString(String raw) {
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
796 String[] splitted = raw != null ? raw.split(";") : null;
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
797
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
798 if (splitted == null || splitted.length == 0) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8186
diff changeset
799 log.warn("No double values found in '" + raw + "'");
2216
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
800 return new double[0];
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
801 }
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
802
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
803 TDoubleArrayList doubles = new TDoubleArrayList(splitted.length);
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
804
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
805 for (String value: splitted) {
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
806 try {
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
807 doubles.add(Double.valueOf(value));
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
808 }
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
809 catch (NumberFormatException nfe) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8186
diff changeset
810 log.warn("Parsing double failed: " + nfe);
2216
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
811 }
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
812 }
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
813
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
814 return doubles.toNativeArray();
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
815 }
3444
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
816
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
817
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
818 /**
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
819 * Returns the gauges that match the selected kilometer range.
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
820 *
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
821 * @param flys the flys artifact.
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
822 *
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
823 * @return the gauges based on the selected kilometer range (null if
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
824 * none/no range set).
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
825 */
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
826 public static List<Gauge> getGauges(D4EArtifact flys) {
3444
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
827
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
828 River river = getRiver(flys);
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
829 if (river == null) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8186
diff changeset
830 log.debug("getGauges: no river!");
3444
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
831 return null;
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
832 }
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
833
6101
a0078e5e3b39 Removed unused context from RangeAccess and subclasses leading to some dead code removal.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
834 RangeAccess rangeAccess = new RangeAccess(flys);
4862
b99656db18de FLYSUtils: Use RangeAcces, removed getKmRange.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4852
diff changeset
835 double[] dist = rangeAccess.getKmRange();
3444
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
836 if (dist == null) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8186
diff changeset
837 log.debug("getGauges: no dist!");
3444
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
838 return null;
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
839 }
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8186
diff changeset
840 log.debug("getGauges: " + dist[0] + " - " + dist[1]);
3444
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
841
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
842 return river.determineGauges(dist[0], dist[1]);
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
843 }
6941
d322da01d862 (issue1451) Round Q's in the way it is done for AT's and localize KM
Andre Heinecke <aheinecke@intevation.de>
parents: 6841
diff changeset
844
d322da01d862 (issue1451) Round Q's in the way it is done for AT's and localize KM
Andre Heinecke <aheinecke@intevation.de>
parents: 6841
diff changeset
845 /** Round a Q in the AT format style **/
d322da01d862 (issue1451) Round Q's in the way it is done for AT's and localize KM
Andre Heinecke <aheinecke@intevation.de>
parents: 6841
diff changeset
846 public static double roundQ(double q) {
d322da01d862 (issue1451) Round Q's in the way it is done for AT's and localize KM
Andre Heinecke <aheinecke@intevation.de>
parents: 6841
diff changeset
847 if (q < 10d) q = Math.rint((q*1000d)) / 1000d;
d322da01d862 (issue1451) Round Q's in the way it is done for AT's and localize KM
Andre Heinecke <aheinecke@intevation.de>
parents: 6841
diff changeset
848 else if (q < 100d) q = Math.rint((q*100d)) / 100d;
d322da01d862 (issue1451) Round Q's in the way it is done for AT's and localize KM
Andre Heinecke <aheinecke@intevation.de>
parents: 6841
diff changeset
849 else if (q < 1000d) q = Math.rint((q*10d)) / 10d;
d322da01d862 (issue1451) Round Q's in the way it is done for AT's and localize KM
Andre Heinecke <aheinecke@intevation.de>
parents: 6841
diff changeset
850 else if (q >= 1000d) q = Math.rint(q);
d322da01d862 (issue1451) Round Q's in the way it is done for AT's and localize KM
Andre Heinecke <aheinecke@intevation.de>
parents: 6841
diff changeset
851 return q;
d322da01d862 (issue1451) Round Q's in the way it is done for AT's and localize KM
Andre Heinecke <aheinecke@intevation.de>
parents: 6841
diff changeset
852 }
7123
1a20738e9a21 Add currentKM context / request mapping to RiverUtils and use it in DiagramGenerator
Andre Heinecke <aheinecke@intevation.de>
parents: 7056
diff changeset
853
1095
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
854 }
1105
adb52a2005e7 Moved code to extract the river srid defined in the global configuration into FLYSUtils.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1099
diff changeset
855 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org