annotate artifacts/src/main/java/org/dive4elements/river/utils/RiverUtils.java @ 7697:640342d9ab8a

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

http://dive4elements.wald.intevation.org