Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/CrossSectionArtifact.java @ 4858:56fbdcdb7ff2
ChartGenerator, DurationCurveExporter: Updated to use RangeAccess instead of FLYSUtils.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Wed, 23 Jan 2013 13:03:25 +0100 |
parents | c7133c1f8ede |
children | f2e7f07f608d |
rev | line source |
---|---|
1964
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts; |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
2 |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
3 import java.util.ArrayList; |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
4 import java.util.List; |
2120
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
5 import java.util.NavigableMap; |
1964
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
6 |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
7 import org.apache.log4j.Logger; |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
8 |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
9 import org.w3c.dom.Document; |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
10 |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
11 import de.intevation.artifacts.Artifact; |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
12 import de.intevation.artifacts.ArtifactFactory; |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
13 import de.intevation.artifacts.CallMeta; |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
14 |
4857
c7133c1f8ede
CrossSectionArtifact, Calculation4Access: Updated to use RangeAccess instead of FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4497
diff
changeset
|
15 import de.intevation.flys.artifacts.access.RangeAccess; |
1964
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
16 import de.intevation.flys.artifacts.model.CrossSectionFacet; |
2120
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
17 import de.intevation.flys.artifacts.model.FastCrossSectionLineFactory; |
1964
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
18 |
2126
d626ae185305
Use the fast cross section lines from backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2120
diff
changeset
|
19 import de.intevation.flys.model.FastCrossSectionLine; |
d626ae185305
Use the fast cross section lines from backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2120
diff
changeset
|
20 |
1967
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
21 import de.intevation.flys.model.CrossSection; |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
22 import de.intevation.flys.model.CrossSectionLine; |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
23 import de.intevation.flys.artifacts.model.CrossSectionFactory; |
1964
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
24 |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
25 import de.intevation.flys.artifacts.states.StaticState; |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
26 |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
27 import de.intevation.artifactdatabase.state.Facet; |
3556
afc7bfb4800b
Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3405
diff
changeset
|
28 import de.intevation.artifactdatabase.state.FacetActivity; |
1964
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
29 import de.intevation.artifactdatabase.state.State; |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
30 |
2037
986820795c3b
Better initialize cross_section.km of cross-section-artifacts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2036
diff
changeset
|
31 import de.intevation.flys.utils.FLYSUtils; |
986820795c3b
Better initialize cross_section.km of cross-section-artifacts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2036
diff
changeset
|
32 |
2120
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
33 import de.intevation.flys.artifacts.services.CrossSectionKMService; |
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
34 |
1964
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
35 |
1985
07b176b14205
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1982
diff
changeset
|
36 /** |
07b176b14205
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1982
diff
changeset
|
37 * Artifact describing a cross-section. |
07b176b14205
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1982
diff
changeset
|
38 */ |
1964
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
39 public class CrossSectionArtifact extends StaticFLYSArtifact { |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
40 |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
41 /** Name of Artifact. */ |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
42 public static final String CS_ARTIFACT_NAME = "cross_section"; |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
43 |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
44 /** Name of state. */ |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
45 public static final String STATIC_STATE_NAME = "state.cross_section"; |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
46 |
1967
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
47 /** Name of data item keeping the position. */ |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
48 public static final String DATA_KM = "cross_section.km"; |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
49 |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
50 /** Name of data item keeping the database id of this c.s.. */ |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
51 public static final String DATA_DBID = "cross_section.dbid"; |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
52 |
2040
cd9bcdcf6597
Make only newest CrossSection intially active in diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2037
diff
changeset
|
53 /** Name of data item flagging whether we think that we are master. */ |
1967
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
54 public static final String DATA_IS_MASTER = "cross_section.master?"; |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
55 |
2040
cd9bcdcf6597
Make only newest CrossSection intially active in diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2037
diff
changeset
|
56 /** Name of data item flagging whether we are the newest. */ |
cd9bcdcf6597
Make only newest CrossSection intially active in diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2037
diff
changeset
|
57 public static final String DATA_IS_NEWEST = "cross_section.newest?"; |
cd9bcdcf6597
Make only newest CrossSection intially active in diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2037
diff
changeset
|
58 |
3272
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
59 /** Name of data item storing the previous possible km. */ |
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
60 public static final String DATA_PREV_KM = "cross_section.km.previous"; |
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
61 |
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
62 /** Name of data item storing the next possible km. */ |
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
63 public static final String DATA_NEXT_KM = "cross_section.km.next"; |
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
64 |
1964
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
65 /** Own logger. */ |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
66 private static final Logger logger = |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
67 Logger.getLogger(CrossSectionArtifact.class); |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
68 |
3556
afc7bfb4800b
Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3405
diff
changeset
|
69 static { |
afc7bfb4800b
Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3405
diff
changeset
|
70 // TODO: Move to configuration. |
afc7bfb4800b
Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3405
diff
changeset
|
71 FacetActivity.Registry.getInstance().register( |
afc7bfb4800b
Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3405
diff
changeset
|
72 CS_ARTIFACT_NAME, |
afc7bfb4800b
Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3405
diff
changeset
|
73 new FacetActivity() { |
afc7bfb4800b
Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3405
diff
changeset
|
74 @Override |
3558
c3cd414982fe
Adjusted to follow the Chain-of-responsibility pattern in figuring out facet activities.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3556
diff
changeset
|
75 public Boolean isInitialActive( |
3556
afc7bfb4800b
Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3405
diff
changeset
|
76 Artifact artifact, |
afc7bfb4800b
Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3405
diff
changeset
|
77 Facet facet, |
afc7bfb4800b
Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3405
diff
changeset
|
78 String outputName |
afc7bfb4800b
Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3405
diff
changeset
|
79 ) { |
afc7bfb4800b
Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3405
diff
changeset
|
80 if (artifact instanceof FLYSArtifact) { |
afc7bfb4800b
Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3405
diff
changeset
|
81 FLYSArtifact flys = (FLYSArtifact)artifact; |
afc7bfb4800b
Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3405
diff
changeset
|
82 String data = flys.getDataAsString(DATA_IS_NEWEST); |
afc7bfb4800b
Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3405
diff
changeset
|
83 return data != null && data.equals("1"); |
afc7bfb4800b
Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3405
diff
changeset
|
84 } |
3558
c3cd414982fe
Adjusted to follow the Chain-of-responsibility pattern in figuring out facet activities.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3556
diff
changeset
|
85 return null; |
3556
afc7bfb4800b
Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3405
diff
changeset
|
86 } |
afc7bfb4800b
Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3405
diff
changeset
|
87 }); |
afc7bfb4800b
Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3405
diff
changeset
|
88 } |
1964
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
89 |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
90 /** Return given name. */ |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
91 @Override |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
92 public String getName() { |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
93 return CS_ARTIFACT_NAME; |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
94 } |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
95 |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
96 |
1985
07b176b14205
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1982
diff
changeset
|
97 /** Store ids, create a CrossSectionFacet. */ |
1964
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
98 @Override |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
99 public void setup( |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
100 String identifier, |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
101 ArtifactFactory factory, |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
102 Object context, |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
103 CallMeta callMeta, |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
104 Document data) |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
105 { |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
106 logger.info("CrossSectionArtifact.setup"); |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
107 |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
108 super.setup(identifier, factory, context, callMeta, data); |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
109 |
2741
0251393f037c
Refactor usage of now static xpath, other artifacts will follow in later commits.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2740
diff
changeset
|
110 String ids = getDatacageIDValue(data); |
1964
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
111 |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
112 if (ids != null && ids.length() > 0) { |
1967
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
113 addStringData(DATA_DBID, ids); |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
114 logger.debug("CrossSectionArtifacts db-id: " + ids); |
1964
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
115 } |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
116 else { |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
117 throw new IllegalArgumentException("No attribute 'ids' found!"); |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
118 } |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
119 |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
120 List<Facet> fs = new ArrayList<Facet>(); |
2120
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
121 CrossSection cs = CrossSectionFactory.getCrossSection( |
3405
b0ba96bbf01d
Use Integer.parseInt() instead of Integer.valueOf() + Autounboxing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3284
diff
changeset
|
122 Integer.parseInt(ids)); |
2120
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
123 |
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
124 List<CrossSectionLine> csls = cs.getLines(); |
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
125 if (!csls.isEmpty()) { |
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
126 CrossSectionLine csl = csls.get(0); |
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
127 // Find min-km of cross sections, |
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
128 // then set DATA_KM to min(DATA_KM, minCross). |
3272
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
129 double dataKm = Double.valueOf(getDataAsString(DATA_KM)); |
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
130 if (dataKm < csl.getKm().doubleValue()) { |
2036
c03aeb0cf46b
Initialize km of cross-section artifact to a better value (not all cases covered, yet).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1985
diff
changeset
|
131 addStringData(DATA_KM, csl.getKm().toString()); |
c03aeb0cf46b
Initialize km of cross-section artifact to a better value (not all cases covered, yet).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1985
diff
changeset
|
132 } |
c03aeb0cf46b
Initialize km of cross-section artifact to a better value (not all cases covered, yet).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1985
diff
changeset
|
133 } |
1971
741d2067cfe1
Given CrossSections a name, let crosssection facets survive.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1967
diff
changeset
|
134 fs.add(new CrossSectionFacet(0, cs.getDescription())); |
1964
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
135 |
3272
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
136 // Find out if we are newest and become master if so. |
2040
cd9bcdcf6597
Make only newest CrossSection intially active in diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2037
diff
changeset
|
137 boolean isNewest = CrossSectionFactory.isNewest(cs); |
cd9bcdcf6597
Make only newest CrossSection intially active in diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2037
diff
changeset
|
138 String newString = (isNewest) ? "1" : "0"; |
cd9bcdcf6597
Make only newest CrossSection intially active in diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2037
diff
changeset
|
139 addStringData(DATA_IS_NEWEST, newString); |
cd9bcdcf6597
Make only newest CrossSection intially active in diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2037
diff
changeset
|
140 addStringData(DATA_IS_MASTER, newString); |
cd9bcdcf6597
Make only newest CrossSection intially active in diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2037
diff
changeset
|
141 |
1964
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
142 StaticState state = (StaticState) getCurrentState(context); |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
143 |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
144 if (!fs.isEmpty()) { |
4497
a2735a4bf75e
Change facets member variable to private
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3558
diff
changeset
|
145 addFacets(getCurrentStateId(), fs); |
1964
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
146 } |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
147 } |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
148 |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
149 |
2036
c03aeb0cf46b
Initialize km of cross-section artifact to a better value (not all cases covered, yet).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1985
diff
changeset
|
150 /** Copy km where master-artifact "starts". */ |
1964
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
151 @Override |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
152 protected void initialize( |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
153 Artifact artifact, |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
154 Object context, |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
155 CallMeta callMeta) |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
156 { |
4857
c7133c1f8ede
CrossSectionArtifact, Calculation4Access: Updated to use RangeAccess instead of FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4497
diff
changeset
|
157 FLYSArtifact flys = (FLYSArtifact) artifact; |
c7133c1f8ede
CrossSectionArtifact, Calculation4Access: Updated to use RangeAccess instead of FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4497
diff
changeset
|
158 |
c7133c1f8ede
CrossSectionArtifact, Calculation4Access: Updated to use RangeAccess instead of FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4497
diff
changeset
|
159 RangeAccess rangeAccess = new RangeAccess(flys, null); |
c7133c1f8ede
CrossSectionArtifact, Calculation4Access: Updated to use RangeAccess instead of FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4497
diff
changeset
|
160 double[] range = rangeAccess.getKmRange(); |
2037
986820795c3b
Better initialize cross_section.km of cross-section-artifacts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2036
diff
changeset
|
161 double min = 0.0f; |
986820795c3b
Better initialize cross_section.km of cross-section-artifacts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2036
diff
changeset
|
162 if (range != null && range.length > 0) { |
986820795c3b
Better initialize cross_section.km of cross-section-artifacts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2036
diff
changeset
|
163 min = range[0]; |
986820795c3b
Better initialize cross_section.km of cross-section-artifacts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2036
diff
changeset
|
164 } |
986820795c3b
Better initialize cross_section.km of cross-section-artifacts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2036
diff
changeset
|
165 this.addStringData(DATA_KM, Double.toString(min)); |
1964
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
166 } |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
167 |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
168 |
3284
d9af29a4bb85
Various cosmetic doc fixes.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3272
diff
changeset
|
169 /** Returns next possible km for a cross-section. */ |
3272
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
170 public Double getNextKm() { |
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
171 return getDataAsDouble(DATA_NEXT_KM); |
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
172 } |
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
173 |
3284
d9af29a4bb85
Various cosmetic doc fixes.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3272
diff
changeset
|
174 |
d9af29a4bb85
Various cosmetic doc fixes.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3272
diff
changeset
|
175 /** Returns previous possible km for a cross-section. */ |
3272
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
176 public Double getPrevKm() { |
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
177 return getDataAsDouble(DATA_PREV_KM); |
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
178 } |
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
179 |
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
180 |
1964
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
181 /** |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
182 * Create and return a new StaticState with charting output. |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
183 */ |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
184 @Override |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
185 public State getCurrentState(Object cc) { |
4497
a2735a4bf75e
Change facets member variable to private
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3558
diff
changeset
|
186 final List<Facet> fs = getFacets(getCurrentStateId()); |
1964
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
187 |
1971
741d2067cfe1
Given CrossSections a name, let crosssection facets survive.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1967
diff
changeset
|
188 StaticState state = new StaticState(STATIC_STATE_NAME) { |
1982
8afd6a9bb244
Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1973
diff
changeset
|
189 @Override |
1971
741d2067cfe1
Given CrossSections a name, let crosssection facets survive.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1967
diff
changeset
|
190 public Object staticCompute(List<Facet> facets) { |
741d2067cfe1
Given CrossSections a name, let crosssection facets survive.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1967
diff
changeset
|
191 if (facets != null) { |
741d2067cfe1
Given CrossSections a name, let crosssection facets survive.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1967
diff
changeset
|
192 facets.addAll(fs); |
741d2067cfe1
Given CrossSections a name, let crosssection facets survive.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1967
diff
changeset
|
193 } |
741d2067cfe1
Given CrossSections a name, let crosssection facets survive.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1967
diff
changeset
|
194 return null; |
741d2067cfe1
Given CrossSections a name, let crosssection facets survive.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1967
diff
changeset
|
195 } |
741d2067cfe1
Given CrossSections a name, let crosssection facets survive.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1967
diff
changeset
|
196 }; |
1964
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
197 |
1967
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
198 state.addDefaultChartOutput("cross_section", fs); |
1964
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
199 |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
200 return state; |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
201 } |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
202 |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
203 |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
204 /** |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
205 * Get a list containing the one and only State. |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
206 * @param context ignored. |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
207 * @return list with one and only state. |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
208 */ |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
209 @Override |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
210 protected List<State> getStates(Object context) { |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
211 ArrayList<State> states = new ArrayList<State>(); |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
212 states.add(getCurrentState(context)); |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
213 |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
214 return states; |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
215 } |
1967
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
216 |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
217 // TODO all data access needs proper caching. |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
218 |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
219 /** |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
220 * Get a DataItem casted to int (0 if fails). |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
221 */ |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
222 public int getDataAsIntNull(String dataName) { |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
223 String val = getDataAsString(dataName); |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
224 try { |
3405
b0ba96bbf01d
Use Integer.parseInt() instead of Integer.valueOf() + Autounboxing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3284
diff
changeset
|
225 return Integer.parseInt(val); |
1967
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
226 } |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
227 catch (NumberFormatException e) { |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
228 logger.warn("Could not get data " + dataName + " as int", e); |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
229 return 0; |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
230 } |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
231 } |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
232 |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
233 |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
234 /** Returns database-id of cross-section (from data). */ |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
235 protected int getDBID() { |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
236 return getDataAsIntNull(DATA_DBID); |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
237 } |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
238 |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
239 |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
240 /** |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
241 * Return position (km) from data, 0 if not found. |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
242 */ |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
243 protected double getKm() { |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
244 String val = getDataAsString(DATA_KM); |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
245 try { |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
246 return Double.valueOf(val); |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
247 } |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
248 catch (NumberFormatException e) { |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
249 logger.warn("Could not get data " + DATA_KM + " as double", e); |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
250 return 0; |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
251 } |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
252 } |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
253 |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
254 |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
255 /** Returns true if artifact is set to be a "master" (other facets will |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
256 * refer to this). */ |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
257 public boolean isMaster() { |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
258 return !getDataAsString(DATA_IS_MASTER).equals("0"); |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
259 } |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
260 |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
261 |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
262 /** |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
263 * Get points of Profile of cross section at given kilometer. |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
264 * |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
265 * @return an array holding coordinates of points of profile ( |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
266 * in the form {{x1, x2} {y1, y2}} ). |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
267 */ |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
268 public double [][] getCrossSectionData() { |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
269 logger.info("getCrossSectionData() for cross_section.km " |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
270 + getDataAsString(DATA_KM)); |
2120
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
271 FastCrossSectionLine line = searchCrossSectionLine(); |
1967
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
272 |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
273 return line != null |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
274 ? line.fetchCrossSectionProfile() |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
275 : null; |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
276 } |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
277 |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
278 |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
279 /** |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
280 * Get CrossSectionLine spatially closest to what is specified in the data |
2678
d35e37b6a211
Fix issue620: synchron navigation at impossible km.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2153
diff
changeset
|
281 * "cross_section.km", null if considered too far. |
1967
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
282 * |
3272
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
283 * It also adds DataItems to store the next and previous (numerically) |
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
284 * values at which cross-section data was recorded. |
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
285 * |
2678
d35e37b6a211
Fix issue620: synchron navigation at impossible km.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2153
diff
changeset
|
286 * @return CrossSectionLine closest to "cross_section.km", might be null |
d35e37b6a211
Fix issue620: synchron navigation at impossible km.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2153
diff
changeset
|
287 * if considered too far. |
1967
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
288 */ |
2120
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
289 public FastCrossSectionLine searchCrossSectionLine() { |
2678
d35e37b6a211
Fix issue620: synchron navigation at impossible km.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2153
diff
changeset
|
290 double TOO_FAR = 1d; |
2120
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
291 CrossSection crossSection = CrossSectionFactory |
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
292 .getCrossSection(getDBID()); |
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
293 |
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
294 if (logger.isDebugEnabled()) { |
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
295 logger.debug("dbid " + getDBID() + " : " + crossSection); |
1967
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
296 } |
2120
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
297 |
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
298 NavigableMap<Double, Integer> kms = CrossSectionKMService |
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
299 .getKms(crossSection.getId()); |
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
300 |
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
301 Double wishKM = getKm(); |
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
302 |
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
303 Double floor = kms.floorKey(wishKM); |
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
304 Double ceil = kms.ceilingKey(wishKM); |
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
305 |
3272
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
306 Double nextKm; |
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
307 Double prevKm; |
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
308 |
2120
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
309 double floorD = floor != null |
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
310 ? Math.abs(floor - wishKM) |
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
311 : Double.MAX_VALUE; |
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
312 |
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
313 double ceilD = ceil != null |
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
314 ? Math.abs(ceil - wishKM) |
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
315 : Double.MAX_VALUE; |
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
316 |
3272
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
317 double km; |
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
318 if (floorD < ceilD) { |
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
319 km = floor; |
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
320 } |
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
321 else { |
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
322 km = ceil; |
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
323 } |
2120
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
324 |
2678
d35e37b6a211
Fix issue620: synchron navigation at impossible km.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2153
diff
changeset
|
325 // If we are too far from the wished km, return null. |
d35e37b6a211
Fix issue620: synchron navigation at impossible km.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2153
diff
changeset
|
326 if (Math.abs(km - wishKM) > TOO_FAR) { |
d35e37b6a211
Fix issue620: synchron navigation at impossible km.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2153
diff
changeset
|
327 return null; |
d35e37b6a211
Fix issue620: synchron navigation at impossible km.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2153
diff
changeset
|
328 } |
d35e37b6a211
Fix issue620: synchron navigation at impossible km.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2153
diff
changeset
|
329 |
3272
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
330 // Store next and previous km. |
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
331 nextKm = kms.higherKey(km); |
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
332 prevKm = kms.lowerKey(km); |
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
333 |
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
334 if (prevKm == null) { |
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
335 prevKm = -1d; |
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
336 } |
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
337 if (nextKm == null) { |
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
338 nextKm = -1d; |
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
339 } |
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
340 |
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
341 addStringData(DATA_PREV_KM, prevKm.toString()); |
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
342 addStringData(DATA_NEXT_KM, nextKm.toString()); |
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
343 |
2120
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
344 return FastCrossSectionLineFactory |
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
345 .getCrossSectionLine(crossSection, km); |
1967
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
346 } |
1964
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
347 } |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
348 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |