Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/CrossSectionArtifact.java @ 2671:055315495f8d
Modified floodmap specific datacage configuration and improved WMS catchment layer.
flys-artifacts/trunk@4359 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 08 May 2012 12:14:55 +0000 |
parents | 734d5f5e55c0 |
children | d35e37b6a211 |
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 |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
15 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
|
16 import de.intevation.flys.artifacts.model.FastCrossSectionLineFactory; |
1964
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
17 |
2126
d626ae185305
Use the fast cross section lines from backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2120
diff
changeset
|
18 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
|
19 |
1967
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
20 import de.intevation.flys.model.CrossSection; |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
21 import de.intevation.flys.model.CrossSectionLine; |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
22 import de.intevation.flys.artifacts.model.CrossSectionFactory; |
1964
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
23 import de.intevation.artifacts.common.ArtifactNamespaceContext; |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
24 import de.intevation.artifacts.common.utils.XMLUtils; |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
25 |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
26 import de.intevation.flys.artifacts.states.StaticState; |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
27 |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
28 import de.intevation.artifactdatabase.state.Facet; |
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 /** Access ids of doc. */ |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
42 public static final String XPATH_IDS = "/art:action/art:ids/@value"; |
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 Artifact. */ |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
45 public static final String CS_ARTIFACT_NAME = "cross_section"; |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
46 |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
47 /** Name of state. */ |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
48 public static final String STATIC_STATE_NAME = "state.cross_section"; |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
49 |
1967
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
50 /** Name of data item keeping the position. */ |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
51 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
|
52 |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
53 /** 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
|
54 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
|
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 think that we are master. */ |
1967
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
57 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
|
58 |
2040
cd9bcdcf6597
Make only newest CrossSection intially active in diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2037
diff
changeset
|
59 /** 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
|
60 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
|
61 |
1964
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
62 /** Own logger. */ |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
63 private static final Logger logger = |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
64 Logger.getLogger(CrossSectionArtifact.class); |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
65 |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
66 |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
67 /** Return given name. */ |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
68 @Override |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
69 public String getName() { |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
70 return CS_ARTIFACT_NAME; |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
71 } |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
72 |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
73 |
1985
07b176b14205
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1982
diff
changeset
|
74 /** Store ids, create a CrossSectionFacet. */ |
1964
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
75 @Override |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
76 public void setup( |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
77 String identifier, |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
78 ArtifactFactory factory, |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
79 Object context, |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
80 CallMeta callMeta, |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
81 Document data) |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
82 { |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
83 logger.info("CrossSectionArtifact.setup"); |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
84 |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
85 super.setup(identifier, factory, context, callMeta, data); |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
86 |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
87 String ids = XMLUtils.xpathString( |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
88 data, XPATH_IDS, ArtifactNamespaceContext.INSTANCE); |
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 if (ids != null && ids.length() > 0) { |
1967
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
91 addStringData(DATA_DBID, ids); |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
92 logger.debug("CrossSectionArtifacts db-id: " + ids); |
1964
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
93 } |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
94 else { |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
95 throw new IllegalArgumentException("No attribute 'ids' found!"); |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
96 } |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
97 |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
98 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
|
99 CrossSection cs = CrossSectionFactory.getCrossSection( |
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
100 Integer.valueOf(ids)); |
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
101 |
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
102 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
|
103 if (!csls.isEmpty()) { |
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
104 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
|
105 // 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
|
106 // then set DATA_KM to min(DATA_KM, minCross). |
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
|
107 double masterKm = Double.valueOf(getDataAsString(DATA_KM)); |
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
|
108 if (masterKm < csl.getKm().doubleValue()) { |
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
|
109 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
|
110 } |
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
|
111 } |
1971
741d2067cfe1
Given CrossSections a name, let crosssection facets survive.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1967
diff
changeset
|
112 fs.add(new CrossSectionFacet(0, cs.getDescription())); |
1964
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
113 |
2040
cd9bcdcf6597
Make only newest CrossSection intially active in diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2037
diff
changeset
|
114 // Find out if we are newest. |
cd9bcdcf6597
Make only newest CrossSection intially active in diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2037
diff
changeset
|
115 boolean isNewest = CrossSectionFactory.isNewest(cs); |
cd9bcdcf6597
Make only newest CrossSection intially active in diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2037
diff
changeset
|
116 String newString = (isNewest) ? "1" : "0"; |
cd9bcdcf6597
Make only newest CrossSection intially active in diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2037
diff
changeset
|
117 addStringData(DATA_IS_NEWEST, newString); |
cd9bcdcf6597
Make only newest CrossSection intially active in diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2037
diff
changeset
|
118 addStringData(DATA_IS_MASTER, newString); |
cd9bcdcf6597
Make only newest CrossSection intially active in diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2037
diff
changeset
|
119 |
1964
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
120 StaticState state = (StaticState) getCurrentState(context); |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
121 |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
122 if (!fs.isEmpty()) { |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
123 facets.put(getCurrentStateId(), fs); |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
124 } |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
125 } |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
126 |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
127 |
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
|
128 /** Copy km where master-artifact "starts". */ |
1964
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
129 @Override |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
130 protected void initialize( |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
131 Artifact artifact, |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
132 Object context, |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
133 CallMeta callMeta) |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
134 { |
2153
734d5f5e55c0
'New chart' for cross sections.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2126
diff
changeset
|
135 FLYSArtifact winfo = (FLYSArtifact) artifact; |
2037
986820795c3b
Better initialize cross_section.km of cross-section-artifacts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2036
diff
changeset
|
136 double[] range = FLYSUtils.getKmRange(winfo); |
986820795c3b
Better initialize cross_section.km of cross-section-artifacts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2036
diff
changeset
|
137 double min = 0.0f; |
986820795c3b
Better initialize cross_section.km of cross-section-artifacts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2036
diff
changeset
|
138 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
|
139 min = range[0]; |
986820795c3b
Better initialize cross_section.km of cross-section-artifacts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2036
diff
changeset
|
140 } |
986820795c3b
Better initialize cross_section.km of cross-section-artifacts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2036
diff
changeset
|
141 this.addStringData(DATA_KM, Double.toString(min)); |
1964
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
142 } |
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 |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
145 /** |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
146 * Create and return a new StaticState with charting output. |
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 @Override |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
149 public State getCurrentState(Object cc) { |
1971
741d2067cfe1
Given CrossSections a name, let crosssection facets survive.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1967
diff
changeset
|
150 final List<Facet> fs = facets.get(getCurrentStateId()); |
1964
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
151 |
1971
741d2067cfe1
Given CrossSections a name, let crosssection facets survive.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1967
diff
changeset
|
152 StaticState state = new StaticState(STATIC_STATE_NAME) { |
1982
8afd6a9bb244
Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1973
diff
changeset
|
153 @Override |
1971
741d2067cfe1
Given CrossSections a name, let crosssection facets survive.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1967
diff
changeset
|
154 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
|
155 if (facets != null) { |
741d2067cfe1
Given CrossSections a name, let crosssection facets survive.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1967
diff
changeset
|
156 facets.addAll(fs); |
741d2067cfe1
Given CrossSections a name, let crosssection facets survive.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1967
diff
changeset
|
157 } |
741d2067cfe1
Given CrossSections a name, let crosssection facets survive.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1967
diff
changeset
|
158 return null; |
741d2067cfe1
Given CrossSections a name, let crosssection facets survive.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1967
diff
changeset
|
159 } |
741d2067cfe1
Given CrossSections a name, let crosssection facets survive.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1967
diff
changeset
|
160 }; |
1964
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
161 |
1967
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
162 state.addDefaultChartOutput("cross_section", fs); |
1964
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
163 |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
164 return state; |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
165 } |
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 /** |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
169 * Get a list containing the one and only State. |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
170 * @param context ignored. |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
171 * @return list with one and only state. |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
172 */ |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
173 @Override |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
174 protected List<State> getStates(Object context) { |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
175 ArrayList<State> states = new ArrayList<State>(); |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
176 states.add(getCurrentState(context)); |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
177 |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
178 return states; |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
179 } |
1967
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
180 |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
181 // TODO all data access needs proper caching. |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
182 |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
183 /** |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
184 * 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
|
185 */ |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
186 public int getDataAsIntNull(String dataName) { |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
187 String val = getDataAsString(dataName); |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
188 try { |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
189 return Integer.valueOf(val); |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
190 } |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
191 catch (NumberFormatException e) { |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
192 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
|
193 return 0; |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
194 } |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
195 } |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
196 |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
197 |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
198 /** Returns database-id of cross-section (from data). */ |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
199 protected int getDBID() { |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
200 return getDataAsIntNull(DATA_DBID); |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
201 } |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
202 |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
203 |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
204 /** |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
205 * 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
|
206 */ |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
207 protected double getKm() { |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
208 String val = getDataAsString(DATA_KM); |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
209 try { |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
210 return Double.valueOf(val); |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
211 } |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
212 catch (NumberFormatException e) { |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
213 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
|
214 return 0; |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
215 } |
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 |
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 /** 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
|
220 * refer to this). */ |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
221 public boolean isMaster() { |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
222 return !getDataAsString(DATA_IS_MASTER).equals("0"); |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
223 } |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
224 |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
225 |
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 * 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
|
228 * |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
229 * @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
|
230 * in the form {{x1, x2} {y1, y2}} ). |
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 public double [][] getCrossSectionData() { |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
233 logger.info("getCrossSectionData() for cross_section.km " |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
234 + getDataAsString(DATA_KM)); |
2120
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
235 FastCrossSectionLine line = searchCrossSectionLine(); |
1967
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
236 |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
237 return line != null |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
238 ? line.fetchCrossSectionProfile() |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
239 : null; |
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 |
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 /** |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
244 * Get CrossSectionLine spatially closest to what is specified in the data |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
245 * "cross_section.km". |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
246 * |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
247 * @return CrossSectionLine closest to "cross_section.km". |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
248 */ |
2120
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
249 public FastCrossSectionLine searchCrossSectionLine() { |
1967
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
250 |
2120
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
251 CrossSection crossSection = CrossSectionFactory |
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
252 .getCrossSection(getDBID()); |
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
253 |
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
254 if (logger.isDebugEnabled()) { |
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
255 logger.debug("dbid " + getDBID() + " : " + crossSection); |
1967
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
256 } |
2120
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
257 |
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
258 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
|
259 .getKms(crossSection.getId()); |
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
260 |
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
261 Double wishKM = getKm(); |
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
262 |
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
263 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
|
264 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
|
265 |
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
266 double floorD = floor != null |
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
267 ? Math.abs(floor - wishKM) |
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
268 : Double.MAX_VALUE; |
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
269 |
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
270 double ceilD = ceil != null |
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
271 ? Math.abs(ceil - wishKM) |
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
272 : Double.MAX_VALUE; |
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
273 |
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
274 double km = floorD < ceilD ? floor : ceil; |
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
275 |
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
276 return FastCrossSectionLineFactory |
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
277 .getCrossSectionLine(crossSection, km); |
1967
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
278 } |
2040
cd9bcdcf6597
Make only newest CrossSection intially active in diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2037
diff
changeset
|
279 |
cd9bcdcf6597
Make only newest CrossSection intially active in diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2037
diff
changeset
|
280 |
cd9bcdcf6597
Make only newest CrossSection intially active in diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2037
diff
changeset
|
281 /** |
cd9bcdcf6597
Make only newest CrossSection intially active in diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2037
diff
changeset
|
282 * Determines Facets initial disposition regarding activity (think of |
cd9bcdcf6597
Make only newest CrossSection intially active in diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2037
diff
changeset
|
283 * selection in Client ThemeList GUI). This will be checked one time |
cd9bcdcf6597
Make only newest CrossSection intially active in diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2037
diff
changeset
|
284 * when the facet enters a collections describe document. |
cd9bcdcf6597
Make only newest CrossSection intially active in diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2037
diff
changeset
|
285 * |
cd9bcdcf6597
Make only newest CrossSection intially active in diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2037
diff
changeset
|
286 * @param outputName Ignored. |
cd9bcdcf6597
Make only newest CrossSection intially active in diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2037
diff
changeset
|
287 * @param facetName Ignored. |
cd9bcdcf6597
Make only newest CrossSection intially active in diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2037
diff
changeset
|
288 * @param index Ignored. |
cd9bcdcf6597
Make only newest CrossSection intially active in diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2037
diff
changeset
|
289 * @return 0 if not active |
cd9bcdcf6597
Make only newest CrossSection intially active in diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2037
diff
changeset
|
290 */ |
cd9bcdcf6597
Make only newest CrossSection intially active in diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2037
diff
changeset
|
291 @Override |
cd9bcdcf6597
Make only newest CrossSection intially active in diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2037
diff
changeset
|
292 public int getInitialFacetActivity(String outputName, String facetName, int index) { |
cd9bcdcf6597
Make only newest CrossSection intially active in diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2037
diff
changeset
|
293 return (getDataAsString(DATA_IS_NEWEST) != null |
cd9bcdcf6597
Make only newest CrossSection intially active in diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2037
diff
changeset
|
294 && getDataAsString(DATA_IS_NEWEST).equals("1")) ? 1 : 0; |
cd9bcdcf6597
Make only newest CrossSection intially active in diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2037
diff
changeset
|
295 } |
1964
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
296 } |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
297 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |