annotate artifacts/src/main/java/org/dive4elements/river/utils/RiverUtils.java @ 7056:4713bc0cc0ee

Remove obsolete configuration of DGM-SRID.
author Tom Gottfried <tom@intevation.de>
date Thu, 19 Sep 2013 17:08:02 +0200
parents 1f38656b68c4
children 1a20738e9a21
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.StaticWKmsArtifact;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4994
diff changeset
18 import org.dive4elements.river.artifacts.WINFOArtifact;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4994
diff changeset
19 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
20 import org.dive4elements.river.artifacts.context.RiverContext;
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4994
diff changeset
21 import org.dive4elements.river.artifacts.model.LocationProvider;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4994
diff changeset
22 import org.dive4elements.river.artifacts.model.RiverFactory;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4994
diff changeset
23 import org.dive4elements.river.artifacts.model.WKms;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4994
diff changeset
24 import org.dive4elements.river.artifacts.model.WQ;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4994
diff changeset
25 import org.dive4elements.river.artifacts.model.WQKms;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4994
diff changeset
26 import org.dive4elements.river.artifacts.states.WDifferencesState;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4994
diff changeset
27 import org.dive4elements.river.artifacts.states.WaterlevelSelectState;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4994
diff changeset
28 import org.dive4elements.river.backend.SessionFactoryProvider;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4994
diff changeset
29 import org.dive4elements.river.model.Gauge;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4994
diff changeset
30 import org.dive4elements.river.model.MainValue;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4994
diff changeset
31 import org.dive4elements.river.model.River;
4648
c04db3178d09 Work on river axis mapfile generator.
Christian Lins <christian.lins@intevation.de>
parents: 4635
diff changeset
32
c04db3178d09 Work on river axis mapfile generator.
Christian Lins <christian.lins@intevation.de>
parents: 4635
diff changeset
33 import gnu.trove.TDoubleArrayList;
c04db3178d09 Work on river axis mapfile generator.
Christian Lins <christian.lins@intevation.de>
parents: 4635
diff changeset
34 import gnu.trove.TIntArrayList;
c04db3178d09 Work on river axis mapfile generator.
Christian Lins <christian.lins@intevation.de>
parents: 4635
diff changeset
35 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
36
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
37 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
38 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
39 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
40 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
41 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
42 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
43
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 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
45
4648
c04db3178d09 Work on river axis mapfile generator.
Christian Lins <christian.lins@intevation.de>
parents: 4635
diff changeset
46 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
47 import org.hibernate.SessionFactory;
06c157848c8f Made the floodmap compatible with an Oracle database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1805
diff changeset
48 import org.hibernate.impl.SessionFactoryImpl;
4648
c04db3178d09 Work on river axis mapfile generator.
Christian Lins <christian.lins@intevation.de>
parents: 4635
diff changeset
49 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
50
3047
d20215a0afd8 Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2765
diff changeset
51
4635
53fa4d5c9fb2 Deprecate FLYSUtils
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4616
diff changeset
52 /**
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
53 * Static helper methods to e.g. access D4EArtifacts data.
4635
53fa4d5c9fb2 Deprecate FLYSUtils
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4616
diff changeset
54 *
5865
73da40528cf2 River artifacts: Renamed FLYSUtils to RiverUtils.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
55 * @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
56 * Instead use and/or create a {@link Access} class hierarchy.
53fa4d5c9fb2 Deprecate FLYSUtils
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4616
diff changeset
57 **/
53fa4d5c9fb2 Deprecate FLYSUtils
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4616
diff changeset
58 @Deprecated
5865
73da40528cf2 River artifacts: Renamed FLYSUtils to RiverUtils.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
59 public class RiverUtils {
1095
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
60
1150
5f53b443d67c Implement getArtifact(uuid,context) in FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1129
diff changeset
61 /** The logger that is used in this utility. */
5865
73da40528cf2 River artifacts: Renamed FLYSUtils to RiverUtils.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
62 private static Logger logger = Logger.getLogger(RiverUtils.class);
1150
5f53b443d67c Implement getArtifact(uuid,context) in FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1129
diff changeset
63
2038
f73036b991e2 Bugfix: repaired broken named values in exports - the last solution had bad side effects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2035
diff changeset
64 /**
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 * 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
66 * <i>QFREE</i> <i>QGAUGE</i> <i>WGAUGE</i> <i>WFREE</i> and <i>NONE</i>.
f73036b991e2 Bugfix: repaired broken named values in exports - the last solution had bad side effects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2035
diff changeset
67 */
f73036b991e2 Bugfix: repaired broken named values in exports - the last solution had bad side effects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2035
diff changeset
68 public static enum WQ_MODE { QFREE, QGAUGE, WFREE, WGAUGE, NONE };
f73036b991e2 Bugfix: repaired broken named values in exports - the last solution had bad side effects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2035
diff changeset
69
2422
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
70 /**
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
71 * An enum that represents the 4 possible WQ input modes in FLYS. The 4
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
72 * values are
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
73 * <i>ADAPTED</i> <i>SINGLE</i> <i>RANGE</i> and <i>NONE</i>.
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
74 */
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
75 public static enum WQ_INPUT { ADAPTED, SINGLE, RANGE, NONE };
2068
0cf60d64895c #370 Added a 'W at gauge' column to CSV exports if 'W at gauge' mode has been selected.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2063
diff changeset
76
0cf60d64895c #370 Added a 'W at gauge' column to CSV exports if 'W at gauge' mode has been selected.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2063
diff changeset
77 public static final Pattern NUMBERS_PATTERN =
0cf60d64895c #370 Added a 'W at gauge' column to CSV exports if 'W at gauge' mode has been selected.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2063
diff changeset
78 Pattern.compile("\\D*(\\d++.\\d*)\\D*");
0cf60d64895c #370 Added a 'W at gauge' column to CSV exports if 'W at gauge' mode has been selected.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2063
diff changeset
79
4656
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4648
diff changeset
80 public static final String XPATH_FLOODMAP_RIVER_PROJECTION =
1105
adb52a2005e7 Moved code to extract the river srid defined in the global configuration into FLYSUtils.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1099
diff changeset
81 "/artifact-database/floodmap/river[@name=$name]/srid/@value";
adb52a2005e7 Moved code to extract the river srid defined in the global configuration into FLYSUtils.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1099
diff changeset
82
4656
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4648
diff changeset
83 public static final String XPATH_FLOODMAP_SHAPEFILE_DIR =
1129
da3c3e286c88 Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1118
diff changeset
84 "/artifact-database/floodmap/shapefile-path/@value";
da3c3e286c88 Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1118
diff changeset
85
4656
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4648
diff changeset
86 public static final String XPATH_FLOODMAP_VELOCITY_LOGFILE =
1129
da3c3e286c88 Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1118
diff changeset
87 "/artifact-database/floodmap/velocity/logfile/@path";
da3c3e286c88 Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1118
diff changeset
88
4656
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4648
diff changeset
89 public static final String XPATH_FLOODMAP_MAPSERVER_URL =
1129
da3c3e286c88 Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1118
diff changeset
90 "/artifact-database/floodmap/mapserver/server/@path";
da3c3e286c88 Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1118
diff changeset
91
4864
dc0d37715e16 Floodmap uses the static River-WMS instead of User-WMS via RiverAxisArtifact.
Christian Lins <christian.lins@intevation.de>
parents: 4862
diff changeset
92 public static final String XPATH_RIVERMAP_MAPSERVER_URL =
dc0d37715e16 Floodmap uses the static River-WMS instead of User-WMS via RiverAxisArtifact.
Christian Lins <christian.lins@intevation.de>
parents: 4862
diff changeset
93 "/artifact-database/rivermap/mapserver/server/@path";
dc0d37715e16 Floodmap uses the static River-WMS instead of User-WMS via RiverAxisArtifact.
Christian Lins <christian.lins@intevation.de>
parents: 4862
diff changeset
94
4656
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4648
diff changeset
95 public static final String XPATH_FLOODMAP_MAPFILE_PATH =
1129
da3c3e286c88 Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1118
diff changeset
96 "/artifact-database/floodmap/mapserver/mapfile/@path";
da3c3e286c88 Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1118
diff changeset
97
4656
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4648
diff changeset
98 public static final String XPATH_FLOODMAP_MAPFILE_TEMPLATE =
1129
da3c3e286c88 Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1118
diff changeset
99 "/artifact-database/floodmap/mapserver/map-template/@path";
da3c3e286c88 Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1118
diff changeset
100
4656
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4648
diff changeset
101 public static final String XPATH_FLOODMAP_MAPSERVER_TEMPLATE_PATH =
1129
da3c3e286c88 Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1118
diff changeset
102 "/artifact-database/floodmap/mapserver/templates/@path";
da3c3e286c88 Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1118
diff changeset
103
1095
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
104
5865
73da40528cf2 River artifacts: Renamed FLYSUtils to RiverUtils.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
105 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
106 }
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
107
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
108
2017
e384d78ff78b Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1845
diff changeset
109 /**
e384d78ff78b Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1845
diff changeset
110 * 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
111 * @return D4EArtifact with given UUID or null (in case of errors).
2017
e384d78ff78b Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1845
diff changeset
112 */
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
113 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
114 try {
1174
f58be0d661b9 Improved FLYSUtils: fetch Artifacts from ArtifactDatabase properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1150
diff changeset
115 Artifact artifact = context.getDatabase().getRawArtifact(uuid);
f58be0d661b9 Improved FLYSUtils: fetch Artifacts from ArtifactDatabase properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1150
diff changeset
116
f58be0d661b9 Improved FLYSUtils: fetch Artifacts from ArtifactDatabase properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1150
diff changeset
117 if (artifact == null) {
f58be0d661b9 Improved FLYSUtils: fetch Artifacts from ArtifactDatabase properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1150
diff changeset
118 logger.error("Artifact '" + uuid + "' does not exist.");
f58be0d661b9 Improved FLYSUtils: fetch Artifacts from ArtifactDatabase properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1150
diff changeset
119 return null;
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
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
122 if (!(artifact instanceof D4EArtifact)) {
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
123 logger.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
124 return null;
f58be0d661b9 Improved FLYSUtils: fetch Artifacts from ArtifactDatabase properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1150
diff changeset
125 }
f58be0d661b9 Improved FLYSUtils: fetch Artifacts from ArtifactDatabase properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1150
diff changeset
126
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
127 return (D4EArtifact) artifact;
1150
5f53b443d67c Implement getArtifact(uuid,context) in FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1129
diff changeset
128 }
5f53b443d67c Implement getArtifact(uuid,context) in FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1129
diff changeset
129 // TODO: catch more selective
5f53b443d67c Implement getArtifact(uuid,context) in FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1129
diff changeset
130 catch (Exception e) {
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
131 logger.error("Cannot get D4EArtifact " + uuid
2017
e384d78ff78b Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1845
diff changeset
132 + " from database (" + e.getMessage() + ").");
1150
5f53b443d67c Implement getArtifact(uuid,context) in FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1129
diff changeset
133 return null;
5f53b443d67c Implement getArtifact(uuid,context) in FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1129
diff changeset
134 }
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
135 }
7398280b11a0 Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1105
diff changeset
136
7398280b11a0 Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1105
diff changeset
137
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
138 /**
5866
9a6741ccf6d4 FLYS artifacts: Renamed FLYSContext(Factory) to RiverContext(Factory).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5865
diff changeset
139 * Returns the RiverContext from context object.
1777
a8aa343799a2 Extracet getFlysContext from FLYSArtifact to FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1740
diff changeset
140 *
5866
9a6741ccf6d4 FLYS artifacts: Renamed FLYSContext(Factory) to RiverContext(Factory).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5865
diff changeset
141 * @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
142 *
9a6741ccf6d4 FLYS artifacts: Renamed FLYSContext(Factory) to RiverContext(Factory).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5865
diff changeset
143 * @return the RiverContext.
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 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
146 return context instanceof RiverContext
9a6741ccf6d4 FLYS artifacts: Renamed FLYSContext(Factory) to RiverContext(Factory).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5865
diff changeset
147 ? (RiverContext) context
9a6741ccf6d4 FLYS artifacts: Renamed FLYSContext(Factory) to RiverContext(Factory).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5865
diff changeset
148 : (RiverContext) ((CallContext) context).globalContext();
1777
a8aa343799a2 Extracet getFlysContext from FLYSArtifact to FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1740
diff changeset
149 }
a8aa343799a2 Extracet getFlysContext from FLYSArtifact to FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1740
diff changeset
150
a8aa343799a2 Extracet getFlysContext from FLYSArtifact to FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1740
diff changeset
151
a8aa343799a2 Extracet getFlysContext from FLYSArtifact to FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1740
diff changeset
152 /**
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
153 * 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
154 * 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
155 *
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
156 * @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
157 *
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 * @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
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 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
161 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
162 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
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 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
165 }
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
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
1845
06c157848c8f Made the floodmap compatible with an Oracle database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1805
diff changeset
168 public static boolean isUsingOracle() {
06c157848c8f Made the floodmap compatible with an Oracle database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1805
diff changeset
169 SessionFactory sf = SessionFactoryProvider.getSessionFactory();
06c157848c8f Made the floodmap compatible with an Oracle database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1805
diff changeset
170
06c157848c8f Made the floodmap compatible with an Oracle database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1805
diff changeset
171 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
172
06c157848c8f Made the floodmap compatible with an Oracle database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1805
diff changeset
173 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
174 }
06c157848c8f Made the floodmap compatible with an Oracle database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1805
diff changeset
175
06c157848c8f Made the floodmap compatible with an Oracle database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1805
diff changeset
176
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
177 /**
6528
735df49affd1 Antidoc: Strip "This method" from short doc strings.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6101
diff changeset
178 * 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
179 * 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
180 * 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
181 *
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
182 * @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
183 *
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 * @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
185 */
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
186 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
187 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
188 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
189 }
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
190
2422
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
191 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
192 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
193
2422
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
194 if (values != null) {
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
195 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
196 }
2422
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
197
2423
ac528b883b47 Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2422
diff changeset
198 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
199
4413
c62598c372ab FLYSUtils: Null-guard some conditionals (autoboxes).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4363
diff changeset
200 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
201 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
202 }
4413
c62598c372ab FLYSUtils: Null-guard some conditionals (autoboxes).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4363
diff changeset
203 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
204 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
205 }
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
206 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
207 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
208 }
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
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
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
212 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
213 if (flys == null) {
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
214 return WQ_INPUT.NONE;
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
215 }
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
216
2423
ac528b883b47 Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2422
diff changeset
217 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
218 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
219
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
220 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
221 return WQ_INPUT.ADAPTED;
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
222 }
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 (selection != null && selection) {
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
225 return WQ_INPUT.RANGE;
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 else {
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
228 return WQ_INPUT.SINGLE;
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2296
diff changeset
229 }
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
1095
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
232
2235
ee5310134463 Cosmetics/care/refac.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2216
diff changeset
233 /**
ee5310134463 Cosmetics/care/refac.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2216
diff changeset
234 * Get bounds for river of artifact.
ee5310134463 Cosmetics/care/refac.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2216
diff changeset
235 * @param flysArtifact artifact which has a "river" data.
ee5310134463 Cosmetics/care/refac.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2216
diff changeset
236 * @return double array. min is at[0], max at[1]. null if given artifact is null
ee5310134463 Cosmetics/care/refac.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2216
diff changeset
237 */
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
238 public static double[] getRiverMinMax(D4EArtifact flysArtifact) {
2235
ee5310134463 Cosmetics/care/refac.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2216
diff changeset
239 if (flysArtifact == null) {
ee5310134463 Cosmetics/care/refac.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2216
diff changeset
240 return null;
ee5310134463 Cosmetics/care/refac.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2216
diff changeset
241 }
ee5310134463 Cosmetics/care/refac.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2216
diff changeset
242
ee5310134463 Cosmetics/care/refac.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2216
diff changeset
243 String riverName = flysArtifact.getDataAsString("river");
ee5310134463 Cosmetics/care/refac.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2216
diff changeset
244
ee5310134463 Cosmetics/care/refac.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2216
diff changeset
245 if (riverName == null) {
ee5310134463 Cosmetics/care/refac.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2216
diff changeset
246 riverName = "";
ee5310134463 Cosmetics/care/refac.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2216
diff changeset
247 }
ee5310134463 Cosmetics/care/refac.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2216
diff changeset
248
ee5310134463 Cosmetics/care/refac.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2216
diff changeset
249 logger.debug("Search for the min/max distances of '" + riverName + "'");
ee5310134463 Cosmetics/care/refac.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2216
diff changeset
250
ee5310134463 Cosmetics/care/refac.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2216
diff changeset
251 River river = RiverFactory.getRiver(riverName);
ee5310134463 Cosmetics/care/refac.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2216
diff changeset
252
ee5310134463 Cosmetics/care/refac.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2216
diff changeset
253 return river != null
ee5310134463 Cosmetics/care/refac.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2216
diff changeset
254 ? river.determineMinMaxDistance()
ee5310134463 Cosmetics/care/refac.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2216
diff changeset
255 : null;
ee5310134463 Cosmetics/care/refac.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2216
diff changeset
256 }
ee5310134463 Cosmetics/care/refac.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2216
diff changeset
257
ee5310134463 Cosmetics/care/refac.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2216
diff changeset
258
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
259 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
260 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
261 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
262
3444
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
263 if (strFrom == null) {
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
264 strFrom = flys.getDataAsString("from");
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
265 }
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
266
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
267 if (strTo == null) {
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
268 strTo = flys.getDataAsString("to");
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
269 }
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
270
1095
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
271 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
272 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
273 }
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
274
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
275 try {
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
276 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
277 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
278 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
279 }
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
280 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
281 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
282 }
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
283 }
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
2041
e5f01f2325c9 Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2038
diff changeset
286 /**
e5f01f2325c9 Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2038
diff changeset
287 * Return sorted array of locations at which stuff was calculated
e5f01f2325c9 Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2038
diff changeset
288 * (from ld_locations data), null if not parameterized this way.
e5f01f2325c9 Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2038
diff changeset
289 */
4851
a1ce76091ade FLYSUtils: Made getLocations private, added TODO about resolution.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4812
diff changeset
290 // 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
291 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
292 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
293
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
294 if (locationStr == null || locationStr.length() == 0) {
2765
79f6d0802b06 Prepare improved Discharge curve compatibility.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2600
diff changeset
295 if (flys instanceof WINFOArtifact) {
79f6d0802b06 Prepare improved Discharge curve compatibility.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2600
diff changeset
296 WINFOArtifact winfo = (WINFOArtifact) flys;
4616
e285630569dc Fix reference curve creation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4413
diff changeset
297 if (winfo.getReferenceStartKm() != null && winfo.getReferenceEndKms() != null) {
2765
79f6d0802b06 Prepare improved Discharge curve compatibility.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2600
diff changeset
298 return new double[]
79f6d0802b06 Prepare improved Discharge curve compatibility.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2600
diff changeset
299 {
79f6d0802b06 Prepare improved Discharge curve compatibility.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2600
diff changeset
300 winfo.getReferenceStartKm().doubleValue(),
79f6d0802b06 Prepare improved Discharge curve compatibility.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2600
diff changeset
301 winfo.getReferenceEndKms()[0]
79f6d0802b06 Prepare improved Discharge curve compatibility.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2600
diff changeset
302 };
79f6d0802b06 Prepare improved Discharge curve compatibility.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2600
diff changeset
303 }
79f6d0802b06 Prepare improved Discharge curve compatibility.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2600
diff changeset
304 }
1095
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
305 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
306 }
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
307
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
308 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
309 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
310
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
311 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
312 try {
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
313 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
314 }
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
315 catch (NumberFormatException nfe) {
4656
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4648
diff changeset
316 logger.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
317 }
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
318 }
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
319
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
320 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
321
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
322 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
323 }
1099
af73f196eccc Refactored to use new FLYSUtils, moved getRiver-functionality inside.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1095
diff changeset
324
af73f196eccc Refactored to use new FLYSUtils, moved getRiver-functionality inside.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1095
diff changeset
325
af73f196eccc Refactored to use new FLYSUtils, moved getRiver-functionality inside.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1095
diff changeset
326 /**
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
327 * 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
328 * only instances of WINFOArtifact.
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
329 *
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
330 * @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
331 *
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
332 * @return the Qs.
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
333 */
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
334 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
335 // 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
336 if (flys instanceof WINFOArtifact) {
2423
ac528b883b47 Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2422
diff changeset
337 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
338 }
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
339
6529
da0249ddcba7 RiverUtils: Made two debug output lines unique.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6528
diff changeset
340 logger.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
341
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
342 return null;
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
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
345
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
346 /**
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
347 * 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
348 * only instances of WINFOArtifact.
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
349 *
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
350 * @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
351 *
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
352 * @return the Ws.
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
353 */
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
354 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
355 // 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
356 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
357 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
358 }
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
359
6529
da0249ddcba7 RiverUtils: Made two debug output lines unique.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6528
diff changeset
360 logger.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
361
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
362 return null;
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
363 }
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
364
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
365
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
366 /**
1099
af73f196eccc Refactored to use new FLYSUtils, moved getRiver-functionality inside.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1095
diff changeset
367 * 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
368 * 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
369 *
af73f196eccc Refactored to use new FLYSUtils, moved getRiver-functionality inside.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1095
diff changeset
370 * @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
371 */
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
372 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
373 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
374
af73f196eccc Refactored to use new FLYSUtils, moved getRiver-functionality inside.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1095
diff changeset
375 return (sRiver != null)
af73f196eccc Refactored to use new FLYSUtils, moved getRiver-functionality inside.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1095
diff changeset
376 ? RiverFactory.getRiver(sRiver)
af73f196eccc Refactored to use new FLYSUtils, moved getRiver-functionality inside.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1095
diff changeset
377 : null;
af73f196eccc Refactored to use new FLYSUtils, moved getRiver-functionality inside.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1095
diff changeset
378 }
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
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 /**
2045
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
382 * 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
383 * Artifact.
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
384 *
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
385 * @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
386 *
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
387 * @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
388 */
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
389 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
390 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
391 }
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
392
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
393
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
394 /**
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
395 * 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
396 * 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
397 *
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
398 * @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
399 *
adb52a2005e7 Moved code to extract the river srid defined in the global configuration into FLYSUtils.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1099
diff changeset
400 * @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
401 */
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
402 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
403 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
404
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 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
406 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
407 }
adb52a2005e7 Moved code to extract the river srid defined in the global configuration into FLYSUtils.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1099
diff changeset
408
1805
5e9696c32f04 Added datacage config and loaders for KM WMS layer in floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1792
diff changeset
409 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
410 }
5e9696c32f04 Added datacage config and loaders for KM WMS layer in floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1792
diff changeset
411
5e9696c32f04 Added datacage config and loaders for KM WMS layer in floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1792
diff changeset
412
5e9696c32f04 Added datacage config and loaders for KM WMS layer in floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1792
diff changeset
413 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
414 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
415 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
416
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
417 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
418
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
419 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
420 cfg,
4656
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4648
diff changeset
421 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
422 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
423 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
424 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
425 }
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
426
3284
d9af29a4bb85 Various cosmetic doc fixes.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
427 /**
d9af29a4bb85 Various cosmetic doc fixes.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
428 * 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
429 * the artifact.
d9af29a4bb85 Various cosmetic doc fixes.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
430 * @param flys the artifact in question.
d9af29a4bb85 Various cosmetic doc fixes.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
431 * @return (First) gauge of locations of river of artifact.
d9af29a4bb85 Various cosmetic doc fixes.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
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 getGauge(D4EArtifact flys) {
2045
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
434 River river = getRiver(flys);
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
435
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
436 if (river == null) {
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
437 logger.debug("no river found");
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
438 return null;
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
439 }
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
440
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
441 RangeAccess rangeAccess = new RangeAccess(flys);
4862
b99656db18de FLYSUtils: Use RangeAcces, removed getKmRange.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4852
diff changeset
442 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
443
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
444 if (dist == null) {
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
445 logger.debug("no range found");
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
446 return null;
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
447 }
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
448
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
449 if (logger.isDebugEnabled()) {
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
450 logger.debug("Determine gauge for:");
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
451 logger.debug("... river: " + river.getName());
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
452 logger.debug("... distance: " + dist[0] + " - " + dist[1]);
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
453 }
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
454
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
455 Gauge gauge = river.determineGauge(dist[0], dist[1]);
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
456
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
457 String name = gauge != null ? gauge.getName() : "'n/a";
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
458 logger.debug("Found gauge: " + name);
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
459
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
460 return gauge;
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
461 }
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
462
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
463
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
464 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
465 Gauge gauge = getGauge(flys);
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
466
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
467 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
468 }
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
469
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2041
diff changeset
470
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
471 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
472 Long officialNumber = flys.getDataAsLong("reference_gauge");
6841
ddb0ed040209 (Issue1357) Pull river name into getReferenceGauge
Andre Heinecke <aheinecke@intevation.de>
parents: 6529
diff changeset
473 String river = getRivername(flys);
2128
bf67eb014443 Added convinience functions to FLYSArtifact and FLYSUtils.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2081
diff changeset
474
6841
ddb0ed040209 (Issue1357) Pull river name into getReferenceGauge
Andre Heinecke <aheinecke@intevation.de>
parents: 6529
diff changeset
475 if (officialNumber != null && river != null) {
ddb0ed040209 (Issue1357) Pull river name into getReferenceGauge
Andre Heinecke <aheinecke@intevation.de>
parents: 6529
diff changeset
476 return Gauge.getGaugeByOfficialNumber(officialNumber, river);
ddb0ed040209 (Issue1357) Pull river name into getReferenceGauge
Andre Heinecke <aheinecke@intevation.de>
parents: 6529
diff changeset
477 } else if (officialNumber != null) {
ddb0ed040209 (Issue1357) Pull river name into getReferenceGauge
Andre Heinecke <aheinecke@intevation.de>
parents: 6529
diff changeset
478 return Gauge.getGaugeByOfficialNumber(officialNumber);
ddb0ed040209 (Issue1357) Pull river name into getReferenceGauge
Andre Heinecke <aheinecke@intevation.de>
parents: 6529
diff changeset
479 }
ddb0ed040209 (Issue1357) Pull river name into getReferenceGauge
Andre Heinecke <aheinecke@intevation.de>
parents: 6529
diff changeset
480 return null;
2128
bf67eb014443 Added convinience functions to FLYSArtifact and FLYSUtils.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2081
diff changeset
481 }
bf67eb014443 Added convinience functions to FLYSArtifact and FLYSUtils.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2081
diff changeset
482
bf67eb014443 Added convinience functions to FLYSArtifact and FLYSUtils.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2081
diff changeset
483
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
484 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
485 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
486
997df76c6f58 Create title, subtitle and axes labels for charts from type historical discharge curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2235
diff changeset
487 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
488 ? 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
489 : "-- 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
490 }
997df76c6f58 Create title, subtitle and axes labels for charts from type historical discharge curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2235
diff changeset
491
997df76c6f58 Create title, subtitle and axes labels for charts from type historical discharge curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2235
diff changeset
492
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
493 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
494 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
495 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
496 }
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
497
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
498 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
499
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
500 if (m.matches()) {
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
501 logger.debug("Found a number.");
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
502
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
503 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
504
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
505 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
506 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
507 }
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
508 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
509 }
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
510 }
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
511
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
512 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
513 }
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
514
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
515
4363
9dfec327acc6 FLYSUtils: Minor doc add.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4278
diff changeset
516 /** 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
517 * @param name will be split at '='s.
9dfec327acc6 FLYSUtils: Minor doc add.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4278
diff changeset
518 */
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
519 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
520 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
521 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
522 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
523 ) {
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
524 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
525
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
526 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
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 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
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 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
531 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
532
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
533 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
534
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
535 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
536 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
537
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 namedMainValue = getNamedMainValue(winfo.getGauge(), 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
539 }
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
540 catch (NumberFormatException nfe) {
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 logger.warn("Cannot parse Double of: '" + 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
542 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
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
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
545 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
546
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
547 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
548 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
549 }
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) {
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 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
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 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
556 ? "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
557 : "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
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
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
560
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
561 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
562 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
563 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
564 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
565 ) {
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
566 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
567
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
568 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
569
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
570 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
571
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
572 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
573 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
574
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
575 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
576
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
577 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
578 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
579
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
580 namedMainValue = getNamedMainValue(winfo.getGauge(), 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
581 }
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
582 catch (NumberFormatException nfe) {
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
583 logger.warn("Cannot parse Double of: '" + 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
584 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
585 }
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
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 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
588
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 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
590 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
591 }
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
592
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
593 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
594 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
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
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
597 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
598 ? "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
599 : "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
600 }
8d08f6641372 Improved the title creation of WSP Q and W facets - named main values are taken into account while title creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1174
diff changeset
601
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
602
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
603 /**
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
604 * 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
605 * 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
606 *
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
607 * @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
608 * @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
609 *
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
610 * @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
611 */
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
612 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
613 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
614
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
615 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
616 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
617 }
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
618 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
619 return getNamedMainValue(winfo.getGauge(), 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
620 }
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
621 }
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
622
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
623
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
624 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
625 List<MainValue> mainValues = gauge.getMainValues();
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
626 logger.debug("Search named main value for: " + 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
627
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
628 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
629 if (mv.getValue().doubleValue() == 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
630 logger.debug("Found named main value: " + 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
631 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
632 }
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
633 }
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
634
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
635 logger.debug("Did not find a named main value for: " + 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
636 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
637 }
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
638
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
639
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
640 /**
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
641 *
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
642 * @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
643 *
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
644 * @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
645 */
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
646 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
647 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
648 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
649
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
650 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
651 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
652 }
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
653
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
654 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
655 }
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
656
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
657
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
658 /**
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
659 * 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
660 * <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
661 *
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
662 * @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
663 *
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
664 * @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
665 */
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
666 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
667 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
668 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
669
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
670 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
671 }
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
672
97a25b54eea3 Part 1 of #125: added a description for a location to the WaterlevelExport.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2045
diff changeset
673
4864
dc0d37715e16 Floodmap uses the static River-WMS instead of User-WMS via RiverAxisArtifact.
Christian Lins <christian.lins@intevation.de>
parents: 4862
diff changeset
674 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
675 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
676 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
677
dc0d37715e16 Floodmap uses the static River-WMS instead of User-WMS via RiverAxisArtifact.
Christian Lins <christian.lins@intevation.de>
parents: 4862
diff changeset
678 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
679 }
dc0d37715e16 Floodmap uses the static River-WMS instead of User-WMS via RiverAxisArtifact.
Christian Lins <christian.lins@intevation.de>
parents: 4862
diff changeset
680
dc0d37715e16 Floodmap uses the static River-WMS instead of User-WMS via RiverAxisArtifact.
Christian Lins <christian.lins@intevation.de>
parents: 4862
diff changeset
681
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
682 /**
6528
735df49affd1 Antidoc: Strip "This method" from short doc strings.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6101
diff changeset
683 * 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
684 * 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
685 *
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
686 * @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
687 * @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
688 *
97a25b54eea3 Part 1 of #125: added a description for a location to the WaterlevelExport.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2045
diff changeset
689 * @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
690 * 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
691 */
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
692 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
693 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
694
97a25b54eea3 Part 1 of #125: added a description for a location to the WaterlevelExport.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2045
diff changeset
695 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
696 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
697 }
97a25b54eea3 Part 1 of #125: added a description for a location to the WaterlevelExport.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2045
diff changeset
698
97a25b54eea3 Part 1 of #125: added a description for a location to the WaterlevelExport.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2045
diff changeset
699 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
700 }
2179
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
701
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
702
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
703 /**
6528
735df49affd1 Antidoc: Strip "This method" from short doc strings.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6101
diff changeset
704 * 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
705 *
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
706 * @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
707 * @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
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 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
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 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
712 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
713 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
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 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
716 if(state instanceof WDifferencesState) {
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
717 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
718 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
719
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
720 // 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
721 for (String s: datas) {
4054
102050c4fc00 fix issue909: strange validation code. be fearles.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3969
diff changeset
722 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
723 return "";
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
724 }
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
725 }
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
726
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
727 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
728 return "";
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
729 }
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
730
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
731 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
732 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
733 // 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
734 // 42537f1e-3522-42ef-8968-635b03d8e9c6;longitudinal_section.w;1
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
735 WKms minuendWKms = getWKms(StringUtil.unbracket(datas[i+0]),
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
736 context);
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
737 WKms subtrahendWKms = getWKms(StringUtil.unbracket(datas[i+1]),
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
738 context);
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
739 if (minuendWKms != null && subtrahendWKms != null) {
3076
5642a83420f2 FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3047
diff changeset
740 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
741 + " - " + 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
742 }
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
743 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
744 }
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
745 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
746 }
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
747 else {
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
748 logger.warn("Not a valid state for differences.");
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
749 return "";
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
750 }
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
751 }
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
752
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
753
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
754 protected static WKms getWKms(String mingle, 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
755 String[] def = mingle.split(";");
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
756 String uuid = def[0];
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
757 String name = def[1];
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
758 int idx = Integer.parseInt(def[2]);
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
759
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
760 if (name.startsWith("staticwkms")) {
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
761 StaticWKmsArtifact staticWKms =
5865
73da40528cf2 River artifacts: Renamed FLYSUtils to RiverUtils.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
762 (StaticWKmsArtifact) RiverUtils.getArtifact(
2179
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
763 uuid,
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
764 context);
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
765 WKms wkms = staticWKms.getWKms(idx);
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
766 if (wkms == null)
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
767 logger.error("No WKms from artifact.");
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
768 return wkms;
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
769 }
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
770
5865
73da40528cf2 River artifacts: Renamed FLYSUtils to RiverUtils.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
771 WINFOArtifact flys = (WINFOArtifact) RiverUtils.getArtifact(
2179
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
772 uuid,
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
773 context);
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
774
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
775 if (flys == null) {
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
776 logger.warn("One of the artifacts (1) for diff calculation could not be loaded");
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
777 return null;
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
778 }
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
779 else{
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
780 WQKms[] wqkms = (WQKms[]) flys.getWaterlevelData().
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
781 getData();
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
782 if (wqkms == null)
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
783 logger.warn("not waterlevels in artifact");
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
784 else if (wqkms.length < idx)
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
785 logger.warn("not enough waterlevels in artifact");
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
786 return wqkms[idx];
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
787 }
c3e523a76340 Added method that return the differences for a w-differences calculation as
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2128
diff changeset
788 }
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
789
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 /**
6528
735df49affd1 Antidoc: Strip "This method" from short doc strings.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6101
diff changeset
792 * 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
793 * <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
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 * @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
796 *
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 * @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
798 */
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 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
800 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
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 if (splitted == null || splitted.length == 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
803 logger.warn("No integer values found in '" + 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
804 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
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 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
808
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
809 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
810 try {
3405
b0ba96bbf01d Use Integer.parseInt() instead of Integer.valueOf() + Autounboxing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3284
diff changeset
811 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
812 }
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
813 catch (NumberFormatException nfe) {
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
814 logger.warn("Parsing integer failed: " + nfe);
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
815 }
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
816 }
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
817
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
818 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
819 }
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
820
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
821
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
822 /**
6528
735df49affd1 Antidoc: Strip "This method" from short doc strings.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6101
diff changeset
823 * Transform a string into a long array. Therefore, the string
2600
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
824 * <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
825 *
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
826 * @param raw The raw long array as string separated by a ';'.
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
827 *
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
828 * @return an array of int values.
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
829 */
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
830 public static long[] longArrayFromString(String raw) {
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
831 String[] splitted = raw != null ? raw.split(";") : null;
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
832
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
833 if (splitted == null || splitted.length == 0) {
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
834 logger.warn("No long values found in '" + raw + "'");
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
835 return new long[0];
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
836 }
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
837
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
838 TLongArrayList longs = new TLongArrayList(splitted.length);
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
839
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
840 for (String value: splitted) {
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
841 try {
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
842 longs.add(Long.valueOf(value));
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
843 }
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
844 catch (NumberFormatException nfe) {
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
845 logger.warn("Parsing long failed: " + nfe);
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
846 }
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
847 }
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
848
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
849 return longs.toNativeArray();
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
850 }
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
851
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
852
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
853 /**
6528
735df49affd1 Antidoc: Strip "This method" from short doc strings.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6101
diff changeset
854 * 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
855 * 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
856 * <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
857 *
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
858 * @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
859 *
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
860 * @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
861 */
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
862 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
863 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
864
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
865 if (splitted == null || splitted.length == 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
866 logger.warn("No double values found in '" + 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
867 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
868 }
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
869
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
870 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
871
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
872 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
873 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
874 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
875 }
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
876 catch (NumberFormatException nfe) {
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
877 logger.warn("Parsing double failed: " + nfe);
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
878 }
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
879 }
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
880
31fa7cae0f35 Added new helper methods to FLYSUtils that extract int[] and double[] from string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2179
diff changeset
881 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
882 }
3444
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
883
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
884
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
885 /**
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
886 * 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
887 *
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
888 * @param flys the flys artifact.
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
889 *
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
890 * @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
891 * none/no range set).
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
892 */
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
893 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
894
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
895 River river = getRiver(flys);
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
896 if (river == null) {
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
897 logger.debug("getGauges: no river!");
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
898 return null;
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
899 }
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
900
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
901 RangeAccess rangeAccess = new RangeAccess(flys);
4862
b99656db18de FLYSUtils: Use RangeAcces, removed getKmRange.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4852
diff changeset
902 double[] dist = rangeAccess.getKmRange();
3444
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
903 if (dist == null) {
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
904 logger.debug("getGauges: no dist!");
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
905 return null;
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
906 }
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
907 logger.debug("getGauges: " + dist[0] + " - " + dist[1]);
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
908
f903f1e5aed6 Preparing W/Q per gauge input for FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3405
diff changeset
909 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
910 }
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
911
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
912 /** 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
913 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
914 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
915 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
916 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
917 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
918 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
919 }
1095
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
920 }
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
921 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org