Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/CrossSectionArtifact.java @ 9464:c77255da734b
cross-section logs removed
author | gernotbelger |
---|---|
date | Thu, 30 Aug 2018 10:53:40 +0200 |
parents | da7b5f07303d |
children |
rev | line source |
---|---|
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
2 * Software engineering by Intevation GmbH |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
3 * |
5994
af13ceeba52a
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5867
diff
changeset
|
4 * This file is Free Software under the GNU AGPL (>=v3) |
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
5994
af13ceeba52a
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5867
diff
changeset
|
6 * documentation coming with Dive4Elements River for details. |
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
7 */ |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
8 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4863
diff
changeset
|
9 package org.dive4elements.river.artifacts; |
1964
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 java.util.ArrayList; |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
12 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
|
13 import java.util.NavigableMap; |
1964
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 org.apache.log4j.Logger; |
9460 | 16 import org.dive4elements.artifactdatabase.state.Facet; |
17 import org.dive4elements.artifactdatabase.state.FacetActivity; | |
18 import org.dive4elements.artifactdatabase.state.State; | |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4863
diff
changeset
|
19 import org.dive4elements.artifacts.Artifact; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4863
diff
changeset
|
20 import org.dive4elements.artifacts.ArtifactFactory; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4863
diff
changeset
|
21 import org.dive4elements.artifacts.CallMeta; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4863
diff
changeset
|
22 import org.dive4elements.river.artifacts.access.RangeAccess; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4863
diff
changeset
|
23 import org.dive4elements.river.artifacts.model.CrossSectionFacet; |
9460 | 24 import org.dive4elements.river.artifacts.model.CrossSectionFactory; |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4863
diff
changeset
|
25 import org.dive4elements.river.artifacts.model.FastCrossSectionLineFactory; |
9460 | 26 import org.dive4elements.river.artifacts.services.CrossSectionKMService; |
27 import org.dive4elements.river.artifacts.states.StaticState; | |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4863
diff
changeset
|
28 import org.dive4elements.river.model.CrossSection; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4863
diff
changeset
|
29 import org.dive4elements.river.model.CrossSectionLine; |
9460 | 30 import org.dive4elements.river.model.FastCrossSectionLine; |
31 import org.w3c.dom.Document; | |
1964
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
32 |
1985
07b176b14205
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1982
diff
changeset
|
33 /** |
07b176b14205
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1982
diff
changeset
|
34 * Artifact describing a cross-section. |
07b176b14205
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1982
diff
changeset
|
35 */ |
5867
59ff03ff48f1
River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
36 public class CrossSectionArtifact extends StaticD4EArtifact { |
1964
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
37 |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
38 /** Name of Artifact. */ |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
39 public static final String CS_ARTIFACT_NAME = "cross_section"; |
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 state. */ |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
42 public static final String STATIC_STATE_NAME = "state.cross_section"; |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
43 |
1967
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
44 /** Name of data item keeping the position. */ |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
45 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
|
46 |
6537
f2722602936c
issue1157: Store parents initial km at CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6101
diff
changeset
|
47 /** Name of data item keeping the 'parents' km. */ |
f2722602936c
issue1157: Store parents initial km at CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6101
diff
changeset
|
48 public static final String PARENT_KM = "cross_section.parent.km"; |
f2722602936c
issue1157: Store parents initial km at CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6101
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 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. */ |
9460 | 54 private static final String DATA_IS_MASTER = "cross_section.master?"; |
1967
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. */ |
9460 | 57 private static final String DATA_IS_NEWEST = "cross_section.newest?"; |
2040
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 |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7842
diff
changeset
|
65 /** Own log. */ |
9460 | 66 private static final Logger log = Logger.getLogger(CrossSectionArtifact.class); |
1964
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
67 |
3556
afc7bfb4800b
Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3405
diff
changeset
|
68 static { |
afc7bfb4800b
Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3405
diff
changeset
|
69 // TODO: Move to configuration. |
9460 | 70 FacetActivity.Registry.getInstance().register(CS_ARTIFACT_NAME, new FacetActivity() { |
71 @Override | |
72 public Boolean isInitialActive(final Artifact artifact, final Facet facet, final String outputName) { | |
73 if (artifact instanceof D4EArtifact) { | |
74 final D4EArtifact flys = (D4EArtifact) artifact; | |
75 final String data = flys.getDataAsString(DATA_IS_NEWEST); | |
76 return data != null && data.equals("1"); | |
3556
afc7bfb4800b
Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3405
diff
changeset
|
77 } |
9460 | 78 return null; |
79 } | |
80 }); | |
3556
afc7bfb4800b
Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3405
diff
changeset
|
81 } |
1964
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 /** Return given name. */ |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
84 @Override |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
85 public String getName() { |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
86 return CS_ARTIFACT_NAME; |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
87 } |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
88 |
1985
07b176b14205
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1982
diff
changeset
|
89 /** Store ids, create a CrossSectionFacet. */ |
1964
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
90 @Override |
9460 | 91 public void setup(final String identifier, final ArtifactFactory factory, final Object context, final CallMeta callMeta, final Document data, |
92 final List<Class> loadFacets) { | |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7842
diff
changeset
|
93 log.info("CrossSectionArtifact.setup"); |
1964
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
94 |
7842
8d5ca5175038
Updated signature of artifacts setup method; Removed unnecessary setup overrides.
Raimund Renkert <rrenkert@intevation.de>
parents:
6936
diff
changeset
|
95 super.setup(identifier, factory, context, callMeta, data, loadFacets); |
1964
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
96 |
9460 | 97 final String ids = getDatacageIDValue(data); |
1964
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
98 |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
99 if (ids != null && ids.length() > 0) { |
1967
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
100 addStringData(DATA_DBID, ids); |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7842
diff
changeset
|
101 log.debug("CrossSectionArtifacts db-id: " + ids); |
9460 | 102 } else { |
1964
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
103 throw new IllegalArgumentException("No attribute 'ids' found!"); |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
104 } |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
105 |
9460 | 106 final List<Facet> fs = new ArrayList<>(); |
107 final CrossSection cs = CrossSectionFactory.getCrossSection(Integer.parseInt(ids)); | |
2120
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
108 |
9460 | 109 final List<CrossSectionLine> csls = cs.getLines(); |
2120
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
110 if (!csls.isEmpty()) { |
9460 | 111 final CrossSectionLine csl = csls.get(0); |
2120
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
112 // 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
|
113 // then set DATA_KM to min(DATA_KM, minCross). |
9460 | 114 final String dataKmValue = getDataAsString(DATA_KM); |
115 final double dataKm = (dataKmValue != null) ? Double.valueOf(dataKmValue) : Double.MIN_VALUE; | |
3272
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
116 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
|
117 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
|
118 } |
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
|
119 } |
1971
741d2067cfe1
Given CrossSections a name, let crosssection facets survive.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1967
diff
changeset
|
120 fs.add(new CrossSectionFacet(0, cs.getDescription())); |
1964
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
121 |
3272
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
122 // Find out if we are newest and become master if so. |
9460 | 123 final boolean isNewest = cs.shouldBeMaster(getParentKm()); |
124 final String newString = (isNewest) ? "1" : "0"; | |
2040
cd9bcdcf6597
Make only newest CrossSection intially active in diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2037
diff
changeset
|
125 addStringData(DATA_IS_NEWEST, newString); |
cd9bcdcf6597
Make only newest CrossSection intially active in diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2037
diff
changeset
|
126 addStringData(DATA_IS_MASTER, newString); |
9464 | 127 |
1964
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
128 if (!fs.isEmpty()) { |
4497
a2735a4bf75e
Change facets member variable to private
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3558
diff
changeset
|
129 addFacets(getCurrentStateId(), fs); |
1964
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
130 } |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
131 } |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
132 |
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
|
133 /** Copy km where master-artifact "starts". */ |
1964
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
134 @Override |
9460 | 135 protected void initialize(final Artifact master, final Object context, final CallMeta callMeta) { |
136 final D4EArtifact masterArtifact = (D4EArtifact) master; | |
4857
c7133c1f8ede
CrossSectionArtifact, Calculation4Access: Updated to use RangeAccess instead of FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4497
diff
changeset
|
137 |
9460 | 138 final RangeAccess rangeAccess = new RangeAccess(masterArtifact); |
139 final 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
|
140 if (range != null && range.length > 0) { |
6539
4c463ca9b36e
issue1157: Make a better choice for master and active CrossSection.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6537
diff
changeset
|
141 this.addStringData(DATA_KM, Double.toString(range[0])); |
4c463ca9b36e
issue1157: Make a better choice for master and active CrossSection.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6537
diff
changeset
|
142 this.addStringData(PARENT_KM, Double.toString(range[0])); |
2037
986820795c3b
Better initialize cross_section.km of cross-section-artifacts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2036
diff
changeset
|
143 } |
1964
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 |
3284
d9af29a4bb85
Various cosmetic doc fixes.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3272
diff
changeset
|
146 /** 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
|
147 public Double getNextKm() { |
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
148 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
|
149 } |
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
150 |
3284
d9af29a4bb85
Various cosmetic doc fixes.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3272
diff
changeset
|
151 /** 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
|
152 public Double getPrevKm() { |
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
153 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
|
154 } |
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
155 |
1964
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
156 /** |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
157 * Create and return a new StaticState with charting output. |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
158 */ |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
159 @Override |
9460 | 160 public State getCurrentState(final Object cc) { |
4497
a2735a4bf75e
Change facets member variable to private
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3558
diff
changeset
|
161 final List<Facet> fs = getFacets(getCurrentStateId()); |
1964
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
162 |
9460 | 163 final StaticState state = new StaticState(STATIC_STATE_NAME) { |
1982
8afd6a9bb244
Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1973
diff
changeset
|
164 @Override |
9460 | 165 public Object staticCompute(final List<Facet> facets) { |
1971
741d2067cfe1
Given CrossSections a name, let crosssection facets survive.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1967
diff
changeset
|
166 if (facets != null) { |
741d2067cfe1
Given CrossSections a name, let crosssection facets survive.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1967
diff
changeset
|
167 facets.addAll(fs); |
741d2067cfe1
Given CrossSections a name, let crosssection facets survive.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1967
diff
changeset
|
168 } |
741d2067cfe1
Given CrossSections a name, let crosssection facets survive.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1967
diff
changeset
|
169 return null; |
741d2067cfe1
Given CrossSections a name, let crosssection facets survive.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1967
diff
changeset
|
170 } |
741d2067cfe1
Given CrossSections a name, let crosssection facets survive.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1967
diff
changeset
|
171 }; |
1964
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
172 |
1967
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
173 state.addDefaultChartOutput("cross_section", fs); |
1964
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
174 |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
175 return state; |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
176 } |
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 /** |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
179 * Get a list containing the one and only State. |
9460 | 180 * |
181 * @param context | |
182 * ignored. | |
1964
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
183 * @return list with one and only state. |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
184 */ |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
185 @Override |
9460 | 186 protected List<State> getStates(final Object context) { |
187 final ArrayList<State> states = new ArrayList<>(); | |
1964
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
188 states.add(getCurrentState(context)); |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
189 |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
190 return states; |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
191 } |
1967
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
192 |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
193 // TODO all data access needs proper caching. |
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 * 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
|
197 */ |
9460 | 198 public int getDataAsIntNull(final String dataName) { |
199 final String val = getDataAsString(dataName); | |
1967
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
200 try { |
3405
b0ba96bbf01d
Use Integer.parseInt() instead of Integer.valueOf() + Autounboxing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3284
diff
changeset
|
201 return Integer.parseInt(val); |
1967
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
202 } |
9460 | 203 catch (final NumberFormatException e) { |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7842
diff
changeset
|
204 log.warn("Could not get data " + dataName + " as int", e); |
1967
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
205 return 0; |
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 } |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
208 |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
209 /** Returns database-id of cross-section (from data). */ |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
210 protected int getDBID() { |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
211 return getDataAsIntNull(DATA_DBID); |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
212 } |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
213 |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
214 /** |
6537
f2722602936c
issue1157: Store parents initial km at CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6101
diff
changeset
|
215 * Return position (km) from parent (initial km), 0 if not found. |
f2722602936c
issue1157: Store parents initial km at CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6101
diff
changeset
|
216 */ |
f2722602936c
issue1157: Store parents initial km at CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6101
diff
changeset
|
217 private double getParentKm() { |
9460 | 218 final String val = getDataAsString(PARENT_KM); |
6936
332d2dfa783f
issue1460: prevent NPEs when backstepping and changing Q values for WINFO
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6574
diff
changeset
|
219 if (val == null) { |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7842
diff
changeset
|
220 log.warn("Empty data: " + PARENT_KM); |
6936
332d2dfa783f
issue1460: prevent NPEs when backstepping and changing Q values for WINFO
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6574
diff
changeset
|
221 return 0; |
332d2dfa783f
issue1460: prevent NPEs when backstepping and changing Q values for WINFO
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6574
diff
changeset
|
222 } |
6537
f2722602936c
issue1157: Store parents initial km at CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6101
diff
changeset
|
223 try { |
f2722602936c
issue1157: Store parents initial km at CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6101
diff
changeset
|
224 return Double.valueOf(val); |
f2722602936c
issue1157: Store parents initial km at CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6101
diff
changeset
|
225 } |
9460 | 226 catch (final NumberFormatException e) { |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7842
diff
changeset
|
227 log.warn("Could not get data " + PARENT_KM + " as double", e); |
6537
f2722602936c
issue1157: Store parents initial km at CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6101
diff
changeset
|
228 return 0; |
f2722602936c
issue1157: Store parents initial km at CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6101
diff
changeset
|
229 } |
f2722602936c
issue1157: Store parents initial km at CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6101
diff
changeset
|
230 } |
f2722602936c
issue1157: Store parents initial km at CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6101
diff
changeset
|
231 |
f2722602936c
issue1157: Store parents initial km at CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6101
diff
changeset
|
232 /** |
1967
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
233 * 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
|
234 */ |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
235 protected double getKm() { |
9460 | 236 final String val = getDataAsString(DATA_KM); |
1967
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
237 try { |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
238 return Double.valueOf(val); |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
239 } |
9460 | 240 catch (final NumberFormatException e) { |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7842
diff
changeset
|
241 log.warn("Could not get data " + DATA_KM + " as double", e); |
1967
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
242 return 0; |
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 } |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
245 |
9460 | 246 /** |
247 * Returns true if artifact is set to be a "master" (other facets will | |
248 * refer to this). | |
249 */ | |
1967
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
250 public boolean isMaster() { |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
251 return !getDataAsString(DATA_IS_MASTER).equals("0"); |
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 * 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
|
256 * |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
257 * @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
|
258 * in the form {{x1, x2} {y1, y2}} ). |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
259 */ |
9460 | 260 public double[][] getCrossSectionData() { |
261 log.info("getCrossSectionData() for cross_section.km " + getDataAsString(DATA_KM)); | |
262 final FastCrossSectionLine line = searchCrossSectionLine(); | |
1967
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
263 |
9460 | 264 return line != null ? line.fetchCrossSectionProfile() : null; |
1967
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
265 } |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
266 |
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 * 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
|
269 * "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
|
270 * |
3272
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
271 * 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
|
272 * 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
|
273 * |
2678
d35e37b6a211
Fix issue620: synchron navigation at impossible km.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2153
diff
changeset
|
274 * @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
|
275 * if considered too far. |
1967
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
276 */ |
2120
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
277 public FastCrossSectionLine searchCrossSectionLine() { |
9460 | 278 final double TOO_FAR = 1d; |
279 final CrossSection crossSection = CrossSectionFactory.getCrossSection(getDBID()); | |
2120
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
280 |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7842
diff
changeset
|
281 if (log.isDebugEnabled()) { |
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7842
diff
changeset
|
282 log.debug("dbid " + getDBID() + " : " + crossSection); |
1967
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
283 } |
2120
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
284 |
9460 | 285 final NavigableMap<Double, Integer> kms = CrossSectionKMService.getKms(crossSection.getId()); |
2120
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
286 |
9460 | 287 final Double wishKM = getKm(); |
2120
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
288 |
9460 | 289 final Double floor = kms.floorKey(wishKM); |
290 final Double ceil = kms.ceilingKey(wishKM); | |
2120
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
291 |
3272
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
292 Double nextKm; |
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
293 Double prevKm; |
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
294 |
9460 | 295 final double floorD = floor != null ? Math.abs(floor - wishKM) : Double.MAX_VALUE; |
2120
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
296 |
9460 | 297 final double ceilD = ceil != null ? Math.abs(ceil - wishKM) : Double.MAX_VALUE; |
2120
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
298 |
3272
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
299 double km; |
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
300 if (floorD < ceilD) { |
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
301 km = floor; |
9460 | 302 } else { |
3272
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
303 km = ceil; |
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
304 } |
2120
f021080cb409
Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2040
diff
changeset
|
305 |
2678
d35e37b6a211
Fix issue620: synchron navigation at impossible km.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2153
diff
changeset
|
306 // 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
|
307 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
|
308 return null; |
d35e37b6a211
Fix issue620: synchron navigation at impossible km.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2153
diff
changeset
|
309 } |
d35e37b6a211
Fix issue620: synchron navigation at impossible km.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2153
diff
changeset
|
310 |
3272
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
311 // 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
|
312 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
|
313 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
|
314 |
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
315 if (prevKm == null) { |
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
316 prevKm = -1d; |
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
317 } |
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
318 if (nextKm == null) { |
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
319 nextKm = -1d; |
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 |
31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2763
diff
changeset
|
322 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
|
323 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
|
324 |
9460 | 325 return FastCrossSectionLineFactory.getCrossSectionLine(crossSection, km); |
1967
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1964
diff
changeset
|
326 } |
1964
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
327 } |
85e442933e6d
New CrossSectionArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
328 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |