Mercurial > dive4elements > gnv-client
comparison gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/verticalcrosssection/VerticalCrossSectionOutputState.java @ 440:eb2ac62e853a
Cleaned up messy code a bit in "Horizontales Schnittprofil" and "Profilschnitt".
gnv-artifacts/trunk@488 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Mon, 28 Dec 2009 17:13:12 +0000 |
parents | 8975de9d7483 |
children | f42ed4f10b79 |
comparison
equal
deleted
inserted
replaced
439:8975de9d7483 | 440:eb2ac62e853a |
---|---|
12 import java.util.HashMap; | 12 import java.util.HashMap; |
13 import java.util.Iterator; | 13 import java.util.Iterator; |
14 import java.util.Locale; | 14 import java.util.Locale; |
15 import java.util.Map; | 15 import java.util.Map; |
16 import java.util.ArrayList; | 16 import java.util.ArrayList; |
17 import java.util.Arrays; | |
18 import java.util.List; | |
17 | 19 |
18 import org.apache.log4j.Logger; | 20 import org.apache.log4j.Logger; |
19 | 21 |
20 import org.jfree.chart.ChartTheme; | 22 import org.jfree.chart.ChartTheme; |
21 | 23 |
23 | 25 |
24 import au.com.bytecode.opencsv.CSVWriter; | 26 import au.com.bytecode.opencsv.CSVWriter; |
25 | 27 |
26 import com.vividsolutions.jts.geom.Point; | 28 import com.vividsolutions.jts.geom.Point; |
27 import com.vividsolutions.jts.geom.Coordinate; | 29 import com.vividsolutions.jts.geom.Coordinate; |
28 import com.vividsolutions.jts.geom.LineString; | |
29 import com.vividsolutions.jts.io.ParseException; | |
30 import com.vividsolutions.jts.io.WKTReader; | |
31 | 30 |
32 import de.intevation.artifacts.CallContext; | 31 import de.intevation.artifacts.CallContext; |
33 | 32 |
34 import de.intevation.gnv.artifacts.cache.CacheFactory; | 33 import de.intevation.gnv.artifacts.cache.CacheFactory; |
35 | 34 |
48 | 47 |
49 import de.intevation.gnv.math.AttributedXYColumns; | 48 import de.intevation.gnv.math.AttributedXYColumns; |
50 import de.intevation.gnv.math.HeightValue; | 49 import de.intevation.gnv.math.HeightValue; |
51 import de.intevation.gnv.math.XYColumn; | 50 import de.intevation.gnv.math.XYColumn; |
52 import de.intevation.gnv.math.IJKey; | 51 import de.intevation.gnv.math.IJKey; |
52 | |
53 import de.intevation.gnv.state.InputData; | |
53 | 54 |
54 import de.intevation.gnv.state.describedata.KeyValueDescibeData; | 55 import de.intevation.gnv.state.describedata.KeyValueDescibeData; |
55 import de.intevation.gnv.state.exception.StateException; | 56 import de.intevation.gnv.state.exception.StateException; |
56 import de.intevation.gnv.state.timeseries.TimeSeriesOutputState; | 57 import de.intevation.gnv.state.timeseries.TimeSeriesOutputState; |
57 | 58 |
104 Element element = CacheFactory.getInstance().getCache().get(key); | 105 Element element = CacheFactory.getInstance().getCache().get(key); |
105 if (element != null) | 106 if (element != null) |
106 return element.getObjectValue(); | 107 return element.getObjectValue(); |
107 | 108 |
108 log.debug("No results in cache yet."); | 109 log.debug("No results in cache yet."); |
109 if (inputData.containsKey("mesh_linestring")) { | 110 |
110 | 111 InputData meshLine = inputData.get("mesh_linestring"); |
111 try { | 112 InputData meshId = inputData.get("meshid"); |
112 LineString ls = (LineString) new WKTReader().read( | 113 |
113 inputData.get("mesh_linestring").getValue()); | 114 if (meshLine == null) { |
114 | 115 log.error("mesh_linestring is not defined"); |
115 Coordinate[] coords = ls.getCoordinates(); | 116 throw new IllegalStateException("missing mesh_linestring"); |
116 | 117 } |
117 String additionWhere = WKTUtils.worldCoordinatesToIndex( | 118 |
118 result, | 119 if (meshId == null) { |
119 inputData, | 120 log.error("meshid is not defined"); |
120 ijkQueryID | 121 throw new IllegalStateException("missing meshid"); |
121 ); | 122 } |
122 | 123 |
123 | 124 Coordinate [] coords = WKTUtils.toCoordinates( |
124 String[] filterValues = | 125 meshLine.getValue()); |
125 generateFilterValuesFromInputData(); | 126 |
126 String[] addedFilterValues = | 127 if (coords == null) { |
127 new String[filterValues.length + 1]; | 128 throw new IllegalStateException("cannot read coordinates"); |
128 | 129 } |
129 System.arraycopy( | 130 |
130 filterValues, 0, | 131 try { |
131 addedFilterValues, 0, | 132 String additionWhere = WKTUtils.worldCoordinatesToIndex( |
132 filterValues.length | 133 coords, |
133 ); | 134 result, |
134 addedFilterValues[filterValues.length] = additionWhere; | 135 meshId.getValue(), |
135 | 136 ijkQueryID); |
136 QueryExecutor exec = QueryExecutorFactory | 137 |
137 .getInstance() | 138 String[] addedFilterValues = StringUtils.append( |
138 .getQueryExecutor(); | 139 generateFilterValuesFromInputData(), |
139 | 140 additionWhere); |
140 result = exec.executeQuery(queryID, addedFilterValues); | 141 |
141 } | 142 QueryExecutor exec = QueryExecutorFactory |
142 catch (ParseException pe) { | 143 .getInstance() |
143 log.error(pe, pe); | 144 .getQueryExecutor(); |
144 } | 145 |
145 catch (QueryException qe) { | 146 result = exec.executeQuery(queryID, addedFilterValues); |
146 log.error(qe, qe); | 147 } |
147 } | 148 catch (QueryException qe) { |
148 } | 149 log.error(qe, qe); |
149 else { | 150 } |
150 // TODO What should happen if there is no linestring? | 151 |
151 log.warn("No linestring in inputData."); | 152 Object obj = process( |
152 } | 153 Arrays.asList(coords), |
153 | 154 preProcess(result), |
154 Object obj = process(preProcess(result)); | 155 callContext); |
156 | |
155 CacheFactory.getInstance().getCache().put(new Element(key, obj)); | 157 CacheFactory.getInstance().getCache().put(new Element(key, obj)); |
156 | 158 |
157 return obj; | 159 return obj; |
158 } | 160 } |
159 | 161 |
160 | 162 |
161 protected Object process(AttributedXYColumns columns) { | 163 protected Object process( |
164 List<Coordinate> path, | |
165 AttributedXYColumns columns, | |
166 CallContext callContext | |
167 ) { | |
162 | 168 |
163 // TODO Implement me | 169 // TODO Implement me |
164 return null; | 170 return null; |
165 } | 171 } |
166 | 172 |
225 | 231 |
226 ArrayList<XYColumn> cols = new ArrayList<XYColumn>(map.values()); | 232 ArrayList<XYColumn> cols = new ArrayList<XYColumn>(map.values()); |
227 attColumns.setXYColumns(cols); | 233 attColumns.setXYColumns(cols); |
228 | 234 |
229 return attColumns; | 235 return attColumns; |
230 } | |
231 | |
232 | |
233 protected boolean attributeInList(String name) { | |
234 for (int i = 0; i < ATTRIBUTE_LIST.length; i++) { | |
235 if (name.equals(ATTRIBUTE_LIST[i])) | |
236 return true; | |
237 } | |
238 | |
239 return false; | |
240 } | 236 } |
241 | 237 |
242 | 238 |
243 @Override | 239 @Override |
244 protected Chart getChart( | 240 protected Chart getChart( |