annotate artifacts/src/main/java/org/dive4elements/river/utils/RiverUtils.java @ 8765:a5e450af498b

(issue1838) Remove method in RiverUtils.
author Tom Gottfried <tom@intevation.de>
date Mon, 17 Aug 2015 11:06:23 +0200
parents 9483a5bf4219
children 5e38e2924c07
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 *
5865
73da40528cf2 River artifacts: Renamed FLYSUtils to RiverUtils.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
54 * @deprecated Don't use RiverUtils to get data from an {@link Artifact} anymore.
4635
53fa4d5c9fb2 Deprecate FLYSUtils
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4616
diff changeset
55 * Instead use and/or create a {@link Access} class hierarchy.
53fa4d5c9fb2 Deprecate FLYSUtils
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4616
diff changeset
56 **/
53fa4d5c9fb2 Deprecate FLYSUtils
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4616
diff changeset
57 @Deprecated
5865
73da40528cf2 River artifacts: Renamed FLYSUtils to RiverUtils.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
58 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
59
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8186
diff changeset
60 /** 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
61 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
62
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
63 /**
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 * An enum that represents the 5 possible WQ modes in FLYS. The 5 values are
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
65 * <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
66 */
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 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
68
2422
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
69 /**
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
70 * 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
71 * values are
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
72 * <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
73 */
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
74 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
75
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 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
77 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
78
4656
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4648
diff changeset
79 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
80 "/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
81
4656
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4648
diff changeset
82 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
83 "/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
84
4656
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4648
diff changeset
85 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
86 "/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
87
4656
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4648
diff changeset
88 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
89 "/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
90
4864
dc0d37715e16 Floodmap uses the static River-WMS instead of User-WMS via RiverAxisArtifact.
Christian Lins <christian.lins@intevation.de>
parents: 4862
diff changeset
91 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
92 "/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
93
4656
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4648
diff changeset
94 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
95 "/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
96
4656
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4648
diff changeset
97 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
98 "/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
99
4656
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4648
diff changeset
100 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
101 "/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
102
7123
1a20738e9a21 Add currentKM context / request mapping to RiverUtils and use it in DiagramGenerator
Andre Heinecke <aheinecke@intevation.de>
parents: 7056
diff changeset
103 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
104
1a20738e9a21 Add currentKM context / request mapping to RiverUtils and use it in DiagramGenerator
Andre Heinecke <aheinecke@intevation.de>
parents: 7056
diff changeset
105 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
106 "/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
107
1095
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
108
5865
73da40528cf2 River artifacts: Renamed FLYSUtils to RiverUtils.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
109 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
110 }
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
2017
e384d78ff78b Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1845
diff changeset
113 /**
e384d78ff78b Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1845
diff changeset
114 * 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
115 * @return D4EArtifact with given UUID or null (in case of errors).
2017
e384d78ff78b Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1845
diff changeset
116 */
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
117 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
118 try {
1174
f58be0d661b9 Improved FLYSUtils: fetch Artifacts from ArtifactDatabase properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1150
diff changeset
119 Artifact artifact = context.getDatabase().getRawArtifact(uuid);
f58be0d661b9 Improved FLYSUtils: fetch Artifacts from ArtifactDatabase properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1150
diff changeset
120
f58be0d661b9 Improved FLYSUtils: fetch Artifacts from ArtifactDatabase properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1150
diff changeset
121 if (artifact == null) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8186
diff changeset
122 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
123 return null;
f58be0d661b9 Improved FLYSUtils: fetch Artifacts from ArtifactDatabase properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1150
diff changeset
124 }
f58be0d661b9 Improved FLYSUtils: fetch Artifacts from ArtifactDatabase properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1150
diff changeset
125
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
126 if (!(artifact instanceof D4EArtifact)) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8186
diff changeset
127 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
128 return null;
f58be0d661b9 Improved FLYSUtils: fetch Artifacts from ArtifactDatabase properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1150
diff changeset
129 }
f58be0d661b9 Improved FLYSUtils: fetch Artifacts from ArtifactDatabase properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1150
diff changeset
130
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
131 return (D4EArtifact) artifact;
1150
5f53b443d67c Implement getArtifact(uuid,context) in FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1129
diff changeset
132 }
5f53b443d67c Implement getArtifact(uuid,context) in FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1129
diff changeset
133 // TODO: catch more selective
5f53b443d67c Implement getArtifact(uuid,context) in FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1129
diff changeset
134 catch (Exception e) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8186
diff changeset
135 log.error("Cannot get D4EArtifact " + uuid
2017
e384d78ff78b Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1845
diff changeset
136 + " from database (" + e.getMessage() + ").");
1150
5f53b443d67c Implement getArtifact(uuid,context) in FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1129
diff changeset
137 return null;
5f53b443d67c Implement getArtifact(uuid,context) in FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1129
diff changeset
138 }
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
139 }
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
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
142 /**
5866
9a6741ccf6d4 FLYS artifacts: Renamed FLYSContext(Factory) to RiverContext(Factory).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5865
diff changeset
143 * Returns the RiverContext from context object.
1777
a8aa343799a2 Extracet getFlysContext from FLYSArtifact to FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1740
diff changeset
144 *
5866
9a6741ccf6d4 FLYS artifacts: Renamed FLYSContext(Factory) to RiverContext(Factory).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5865
diff changeset
145 * @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
146 *
9a6741ccf6d4 FLYS artifacts: Renamed FLYSContext(Factory) to RiverContext(Factory).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5865
diff changeset
147 * @return the RiverContext.
1777
a8aa343799a2 Extracet getFlysContext from FLYSArtifact to FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1740
diff changeset
148 */
5866
9a6741ccf6d4 FLYS artifacts: Renamed FLYSContext(Factory) to RiverContext(Factory).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5865
diff changeset
149 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
150 return context instanceof RiverContext
9a6741ccf6d4 FLYS artifacts: Renamed FLYSContext(Factory) to RiverContext(Factory).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5865
diff changeset
151 ? (RiverContext) context
9a6741ccf6d4 FLYS artifacts: Renamed FLYSContext(Factory) to RiverContext(Factory).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5865
diff changeset
152 : (RiverContext) ((CallContext) context).globalContext();
1777
a8aa343799a2 Extracet getFlysContext from FLYSArtifact to FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1740
diff changeset
153 }
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 /**
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
157 * 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
158 * 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
159 *
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 * @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
161 *
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 * @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
163 */
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 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
165 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
166 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
167
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 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
169 }
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
1845
06c157848c8f Made the floodmap compatible with an Oracle database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1805
diff changeset
172 public static boolean isUsingOracle() {
06c157848c8f Made the floodmap compatible with an Oracle database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1805
diff changeset
173 SessionFactory sf = SessionFactoryProvider.getSessionFactory();
06c157848c8f Made the floodmap compatible with an Oracle database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1805
diff changeset
174
06c157848c8f Made the floodmap compatible with an Oracle database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1805
diff changeset
175 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
176
06c157848c8f Made the floodmap compatible with an Oracle database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1805
diff changeset
177 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
178 }
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
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
181 /**
6528
735df49affd1 Antidoc: Strip "This method" from short doc strings.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6101
diff changeset
182 * 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
183 * 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
184 * 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
185 *
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
186 * @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
187 *
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 * @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
189 */
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
190 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
191 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
192 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
193 }
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
2422
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
195 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
196 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
197
2422
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
198 if (values != null) {
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
199 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
200 }
2422
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
201
2423
ac528b883b47 Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2422
diff changeset
202 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
203
4413
c62598c372ab FLYSUtils: Null-guard some conditionals (autoboxes).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4363
diff changeset
204 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
205 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
206 }
4413
c62598c372ab FLYSUtils: Null-guard some conditionals (autoboxes).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4363
diff changeset
207 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
208 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
209 }
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 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
211 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
212 }
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
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
216 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
217 if (flys == null) {
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
218 return WQ_INPUT.NONE;
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
219 }
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
220
2423
ac528b883b47 Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2422
diff changeset
221 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
222 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
223
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
224 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
225 return WQ_INPUT.ADAPTED;
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
226 }
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 if (selection != null && selection) {
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
229 return WQ_INPUT.RANGE;
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
230 }
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
231 else {
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
232 return WQ_INPUT.SINGLE;
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
233 }
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
1095
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
236
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
237 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
238 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
239 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
240
3444
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
241 if (strFrom == null) {
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
242 strFrom = flys.getDataAsString("from");
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
243 }
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 if (strTo == null) {
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
246 strTo = flys.getDataAsString("to");
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
247 }
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
248
1095
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
249 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
250 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
251 }
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 try {
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
254 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
255 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
256 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
257 }
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
258 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
259 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
260 }
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
2041
e5f01f2325c9 Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2038
diff changeset
264 /**
e5f01f2325c9 Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2038
diff changeset
265 * Return sorted array of locations at which stuff was calculated
e5f01f2325c9 Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2038
diff changeset
266 * (from ld_locations data), null if not parameterized this way.
e5f01f2325c9 Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2038
diff changeset
267 */
4851
a1ce76091ade FLYSUtils: Made getLocations private, added TODO about resolution.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4812
diff changeset
268 // 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
269 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
270 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
271
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
272 if (locationStr == null || locationStr.length() == 0) {
2765
79f6d0802b06 Prepare improved Discharge curve compatibility.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2600
diff changeset
273 if (flys instanceof WINFOArtifact) {
79f6d0802b06 Prepare improved Discharge curve compatibility.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2600
diff changeset
274 WINFOArtifact winfo = (WINFOArtifact) flys;
4616
e285630569dc Fix reference curve creation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4413
diff changeset
275 if (winfo.getReferenceStartKm() != null && winfo.getReferenceEndKms() != null) {
2765
79f6d0802b06 Prepare improved Discharge curve compatibility.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2600
diff changeset
276 return new double[]
79f6d0802b06 Prepare improved Discharge curve compatibility.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2600
diff changeset
277 {
79f6d0802b06 Prepare improved Discharge curve compatibility.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2600
diff changeset
278 winfo.getReferenceStartKm().doubleValue(),
79f6d0802b06 Prepare improved Discharge curve compatibility.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2600
diff changeset
279 winfo.getReferenceEndKms()[0]
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 }
79f6d0802b06 Prepare improved Discharge curve compatibility.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2600
diff changeset
282 }
1095
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
283 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
284 }
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
285
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
286 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
287 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
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 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
290 try {
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
291 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
292 }
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
293 catch (NumberFormatException nfe) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8186
diff changeset
294 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
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 }
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
297
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
298 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
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 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
301 }
1099
af73f196eccc Refactored to use new FLYSUtils, moved getRiver-functionality inside.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1095
diff changeset
302
af73f196eccc Refactored to use new FLYSUtils, moved getRiver-functionality inside.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1095
diff changeset
303
af73f196eccc Refactored to use new FLYSUtils, moved getRiver-functionality inside.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1095
diff changeset
304 /**
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
305 * 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
306 * only instances of WINFOArtifact.
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
307 *
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
308 * @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
309 *
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
310 * @return the Qs.
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
311 */
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
312 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
313 // 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
314 if (flys instanceof WINFOArtifact) {
2423
ac528b883b47 Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2422
diff changeset
315 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
316 }
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
317
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8186
diff changeset
318 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
319
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
320 return null;
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
321 }
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
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
324 /**
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
325 * 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
326 * only instances of WINFOArtifact.
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 * @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
329 *
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
330 * @return the Ws.
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
331 */
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
332 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
333 // 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
334 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
335 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
336 }
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
337
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8186
diff changeset
338 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
339
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
340 return null;
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
341 }
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
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
344 /**
1099
af73f196eccc Refactored to use new FLYSUtils, moved getRiver-functionality inside.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1095
diff changeset
345 * 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
346 * 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
347 *
7644
f2f34d722807 Added two comments about improvements.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7123
diff changeset
348 * @deprecated - use RiverAccess instead
f2f34d722807 Added two comments about improvements.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7123
diff changeset
349 *
1099
af73f196eccc Refactored to use new FLYSUtils, moved getRiver-functionality inside.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1095
diff changeset
350 * @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
351 */
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
352 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
353 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
354
af73f196eccc Refactored to use new FLYSUtils, moved getRiver-functionality inside.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1095
diff changeset
355 return (sRiver != null)
af73f196eccc Refactored to use new FLYSUtils, moved getRiver-functionality inside.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1095
diff changeset
356 ? RiverFactory.getRiver(sRiver)
af73f196eccc Refactored to use new FLYSUtils, moved getRiver-functionality inside.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1095
diff changeset
357 : null;
af73f196eccc Refactored to use new FLYSUtils, moved getRiver-functionality inside.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1095
diff changeset
358 }
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
359
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
360
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
361 /**
2045
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
362 * 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
363 * Artifact.
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
364 *
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
365 * @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
366 *
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
367 * @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
368 */
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
369 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
370 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
371 }
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
372
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
373
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
374 /**
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
375 * 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
376 * 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
377 *
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
378 * @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
379 *
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 * @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
381 */
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
382 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
383 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
384
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
385 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
386 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
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
1805
5e9696c32f04 Added datacage config and loaders for KM WMS layer in floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1792
diff changeset
389 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
390 }
5e9696c32f04 Added datacage config and loaders for KM WMS layer in floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1792
diff changeset
391
5e9696c32f04 Added datacage config and loaders for KM WMS layer in floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1792
diff changeset
392
5e9696c32f04 Added datacage config and loaders for KM WMS layer in floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1792
diff changeset
393 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
394 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
395 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
396
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 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
398
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 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
400 cfg,
4656
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4648
diff changeset
401 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
402 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
403 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
404 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
405 }
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
406
3284
d9af29a4bb85 Various cosmetic doc fixes.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
407 /**
d9af29a4bb85 Various cosmetic doc fixes.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
408 * 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
409 * the artifact.
8755
30b1ddadf275 (issue1801) Unify reference gauge finding code
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8570
diff changeset
410 *
30b1ddadf275 (issue1801) Unify reference gauge finding code
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8570
diff changeset
411 * 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
412 * directly in new code.
30b1ddadf275 (issue1801) Unify reference gauge finding code
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8570
diff changeset
413 *
3284
d9af29a4bb85 Various cosmetic doc fixes.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
414 * @param flys the artifact in question.
8755
30b1ddadf275 (issue1801) Unify reference gauge finding code
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8570
diff changeset
415 * @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
416 */
8760
9483a5bf4219 Remove indirection via RiverUtils to obtain reference gauge and reduce casts.
Tom Gottfried <tom@intevation.de>
parents: 8756
diff changeset
417 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
418 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
419 RangeAccess rangeAccess = new RangeAccess(flys);
4862
b99656db18de FLYSUtils: Use RangeAcces, removed getKmRange.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4852
diff changeset
420 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
421
8755
30b1ddadf275 (issue1801) Unify reference gauge finding code
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8570
diff changeset
422 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
423 }
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
424
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
425
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
426 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
427 Gauge gauge = getGauge(flys);
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
428
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
429 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
430 }
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
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
433 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
434 Long officialNumber = flys.getDataAsLong("reference_gauge");
6841
ddb0ed040209 (Issue1357) Pull river name into getReferenceGauge
Andre Heinecke <aheinecke@intevation.de>
parents: 6529
diff changeset
435 String river = getRivername(flys);
2128
bf67eb014443 Added convinience functions to FLYSArtifact and FLYSUtils.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2081
diff changeset
436
6841
ddb0ed040209 (Issue1357) Pull river name into getReferenceGauge
Andre Heinecke <aheinecke@intevation.de>
parents: 6529
diff changeset
437 if (officialNumber != null && river != null) {
ddb0ed040209 (Issue1357) Pull river name into getReferenceGauge
Andre Heinecke <aheinecke@intevation.de>
parents: 6529
diff changeset
438 return Gauge.getGaugeByOfficialNumber(officialNumber, river);
ddb0ed040209 (Issue1357) Pull river name into getReferenceGauge
Andre Heinecke <aheinecke@intevation.de>
parents: 6529
diff changeset
439 } else if (officialNumber != null) {
ddb0ed040209 (Issue1357) Pull river name into getReferenceGauge
Andre Heinecke <aheinecke@intevation.de>
parents: 6529
diff changeset
440 return Gauge.getGaugeByOfficialNumber(officialNumber);
ddb0ed040209 (Issue1357) Pull river name into getReferenceGauge
Andre Heinecke <aheinecke@intevation.de>
parents: 6529
diff changeset
441 }
ddb0ed040209 (Issue1357) Pull river name into getReferenceGauge
Andre Heinecke <aheinecke@intevation.de>
parents: 6529
diff changeset
442 return null;
2128
bf67eb014443 Added convinience functions to FLYSArtifact and FLYSUtils.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2081
diff changeset
443 }
bf67eb014443 Added convinience functions to FLYSArtifact and FLYSUtils.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2081
diff changeset
444
bf67eb014443 Added convinience functions to FLYSArtifact and FLYSUtils.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2081
diff changeset
445
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
446 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
447 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
448
997df76c6f58 Create title, subtitle and axes labels for charts from type historical discharge curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2235
diff changeset
449 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
450 ? 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
451 : "-- 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
452 }
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
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
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
455 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
456 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
457 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
458 }
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
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 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
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 if (m.matches()) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8186
diff changeset
463 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
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 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
466
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 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
468 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
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 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
471 }
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
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 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
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
4363
9dfec327acc6 FLYSUtils: Minor doc add.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4278
diff changeset
478 /** 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
479 * @param name will be split at '='s.
9dfec327acc6 FLYSUtils: Minor doc add.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4278
diff changeset
480 */
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
481 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
482 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
483 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
484 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
485 ) {
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 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
487
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 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
489
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 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
491
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 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
493 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
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 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
496
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 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
498 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
499
8756
26dedebbe39f (issue1801) Code cleanups
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8755
diff changeset
500 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
501 }
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 catch (NumberFormatException nfe) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8186
diff changeset
503 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
504 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
505 }
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
506
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 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
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 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
510 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
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
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 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
514 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
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
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 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
518 ? "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
519 : "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
520 }
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
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
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 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
524 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
525 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
526 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
527 ) {
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 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
529
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 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
531
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 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
533
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 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
535 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
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 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
538
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 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
540 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
541
8756
26dedebbe39f (issue1801) Code cleanups
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8755
diff changeset
542 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
543 }
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 catch (NumberFormatException nfe) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8186
diff changeset
545 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
546 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
547 }
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
548
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 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
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 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
552 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
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
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 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
556 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
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
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 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
560 ? "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
561 : "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
562 }
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
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
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
565 /**
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
566 * 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
567 * 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
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 * @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
570 * @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
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 * @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
573 */
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 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
575 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
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 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
578 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
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 else {
8756
26dedebbe39f (issue1801) Code cleanups
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8755
diff changeset
581 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
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 }
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
584
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
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
586 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
587 List<MainValue> mainValues = gauge.getMainValues();
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8186
diff changeset
588 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
589
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 for (MainValue mv: mainValues) {
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
591 if (mv.getValue().doubleValue() == value) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8186
diff changeset
592 log.debug("Found named main value: " + 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
593 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
594 }
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 }
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
596
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8186
diff changeset
597 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
598 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
599 }
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
600
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
601
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
602 /**
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
603 *
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
604 * @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
605 *
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
606 * @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
607 */
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 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
609 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
610 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
611
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 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
613 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
614 }
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
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 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
617 }
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
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 /**
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
621 * 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
622 * <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
623 *
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
624 * @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
625 *
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 * @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
627 */
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 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
629 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
630 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
631
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 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
633 }
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
634
97a25b54eea3 Part 1 of #125: added a description for a location to the WaterlevelExport.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2045
diff changeset
635
4864
dc0d37715e16 Floodmap uses the static River-WMS instead of User-WMS via RiverAxisArtifact.
Christian Lins <christian.lins@intevation.de>
parents: 4862
diff changeset
636 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
637 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
638 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
639
dc0d37715e16 Floodmap uses the static River-WMS instead of User-WMS via RiverAxisArtifact.
Christian Lins <christian.lins@intevation.de>
parents: 4862
diff changeset
640 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
641 }
dc0d37715e16 Floodmap uses the static River-WMS instead of User-WMS via RiverAxisArtifact.
Christian Lins <christian.lins@intevation.de>
parents: 4862
diff changeset
642
dc0d37715e16 Floodmap uses the static River-WMS instead of User-WMS via RiverAxisArtifact.
Christian Lins <christian.lins@intevation.de>
parents: 4862
diff changeset
643
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
644 /**
6528
735df49affd1 Antidoc: Strip "This method" from short doc strings.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6101
diff changeset
645 * 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
646 * 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
647 *
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
648 * @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
649 * @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
650 *
97a25b54eea3 Part 1 of #125: added a description for a location to the WaterlevelExport.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2045
diff changeset
651 * @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
652 * 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
653 */
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
654 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
655 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
656
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 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
658 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
659 }
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
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 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
662 }
2179
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
663
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
664
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
665 /**
6528
735df49affd1 Antidoc: Strip "This method" from short doc strings.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6101
diff changeset
666 * 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
667 *
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
668 * @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
669 * @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
670 *
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
671 * @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
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 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
674 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
675 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
676 {
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
677 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
678 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
679 WDifferencesState wState = (WDifferencesState) state;
640342d9ab8a (issue1649) Remove broken getWKms from RiverUtils and use WDifferencesState instead
Andre Heinecke <aheinecke@intevation.de>
parents: 7696
diff changeset
680
2179
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
681 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
682 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
683
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
684 // 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
685 for (String s: datas) {
4054
102050c4fc00 fix issue909: strange validation code. be fearles.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3969
diff changeset
686 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
687 return "";
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 }
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
690
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
691 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
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 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
696 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
697 // e.g.:
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
698 // 42537f1e-3522-42ef-8968-635b03d8e9c6;longitudinal_section.w;1
7697
640342d9ab8a (issue1649) Remove broken getWKms from RiverUtils and use WDifferencesState instead
Andre Heinecke <aheinecke@intevation.de>
parents: 7696
diff changeset
699 WKms minuendWKms = wState.getWKms(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
700 context, 0, 0);
7697
640342d9ab8a (issue1649) Remove broken getWKms from RiverUtils and use WDifferencesState instead
Andre Heinecke <aheinecke@intevation.de>
parents: 7696
diff changeset
701 WKms subtrahendWKms = wState.getWKms(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
702 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
703 if (minuendWKms != null && subtrahendWKms != null) {
3076
5642a83420f2 FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3047
diff changeset
704 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
705 + " - " + 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
706 }
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
707 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
708 }
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
709 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
710 }
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
711 else {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8186
diff changeset
712 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
713 return "";
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
714 }
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
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
717 /**
6528
735df49affd1 Antidoc: Strip "This method" from short doc strings.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6101
diff changeset
718 * 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
719 * <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
720 *
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
721 * @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
722 *
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
723 * @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
724 */
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
725 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
726 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
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 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
729 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
730 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
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
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 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
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 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
736 try {
3405
b0ba96bbf01d Use Integer.parseInt() instead of Integer.valueOf() + Autounboxing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3284
diff changeset
737 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
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 catch (NumberFormatException nfe) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8186
diff changeset
740 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
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 }
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
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
744 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
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
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
747
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 /**
6528
735df49affd1 Antidoc: Strip "This method" from short doc strings.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6101
diff changeset
749 * Transform a string into a long array. Therefore, the string
2600
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
750 * <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
751 *
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
752 * @param raw The raw long array as string separated by a ';'.
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
753 *
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
754 * @return an array of int values.
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
755 */
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
756 public static long[] longArrayFromString(String raw) {
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
757 String[] splitted = raw != null ? raw.split(";") : null;
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 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
760 log.warn("No long values found in '" + raw + "'");
2600
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
761 return new long[0];
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
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
764 TLongArrayList longs = new TLongArrayList(splitted.length);
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 for (String value: splitted) {
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
767 try {
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
768 longs.add(Long.valueOf(value));
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 catch (NumberFormatException nfe) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8186
diff changeset
771 log.warn("Parsing long failed: " + nfe);
2600
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 }
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
774
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
775 return longs.toNativeArray();
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
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
778
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
779 /**
6528
735df49affd1 Antidoc: Strip "This method" from short doc strings.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6101
diff changeset
780 * 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
781 * 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
782 * <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
783 *
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
784 * @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
785 *
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
786 * @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
787 */
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 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
789 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
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 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
792 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
793 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
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
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 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
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 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
799 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
800 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
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 catch (NumberFormatException nfe) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8186
diff changeset
803 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
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 }
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
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 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
808 }
3444
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
809
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
810
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
811 /**
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
812 * 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
813 *
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
814 * @param flys the flys artifact.
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
815 *
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
816 * @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
817 * none/no range set).
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
818 */
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
819 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
820
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
821 River river = getRiver(flys);
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
822 if (river == null) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8186
diff changeset
823 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
824 return null;
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
825 }
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
826
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
827 RangeAccess rangeAccess = new RangeAccess(flys);
4862
b99656db18de FLYSUtils: Use RangeAcces, removed getKmRange.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4852
diff changeset
828 double[] dist = rangeAccess.getKmRange();
3444
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
829 if (dist == 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 dist!");
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 }
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8186
diff changeset
833 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
834
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
835 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
836 }
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
837
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
838 /** 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
839 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
840 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
841 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
842 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
843 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
844 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
845 }
7123
1a20738e9a21 Add currentKM context / request mapping to RiverUtils and use it in DiagramGenerator
Andre Heinecke <aheinecke@intevation.de>
parents: 7056
diff changeset
846
1095
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
847 }
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
848 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org