Mercurial > dive4elements > gnv-client
comparison gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/horizontal/HorizontalProfileMeshCrossOutputState.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 | da21c256a0ba |
comparison
equal
deleted
inserted
replaced
439:8975de9d7483 | 440:eb2ac62e853a |
---|---|
9 import java.util.List; | 9 import java.util.List; |
10 import java.util.Locale; | 10 import java.util.Locale; |
11 | 11 |
12 import org.apache.log4j.Logger; | 12 import org.apache.log4j.Logger; |
13 import org.w3c.dom.Node; | 13 import org.w3c.dom.Node; |
14 | |
15 import com.vividsolutions.jts.io.ParseException; | |
16 | 14 |
17 import de.intevation.artifactdatabase.Config; | 15 import de.intevation.artifactdatabase.Config; |
18 | 16 |
19 import de.intevation.gnv.artifacts.cache.CacheFactory; | 17 import de.intevation.gnv.artifacts.cache.CacheFactory; |
20 | 18 |
30 import de.intevation.gnv.math.Point2d; | 28 import de.intevation.gnv.math.Point2d; |
31 import de.intevation.gnv.chart.Chart; | 29 import de.intevation.gnv.chart.Chart; |
32 import de.intevation.gnv.chart.ChartLabels; | 30 import de.intevation.gnv.chart.ChartLabels; |
33 import de.intevation.gnv.chart.HorizontalCrossProfileChart; | 31 import de.intevation.gnv.chart.HorizontalCrossProfileChart; |
34 | 32 |
33 import de.intevation.gnv.state.InputData; | |
34 | |
35 import de.intevation.gnv.utils.DistanceCalculator; | 35 import de.intevation.gnv.utils.DistanceCalculator; |
36 import de.intevation.gnv.utils.WKTUtils; | 36 import de.intevation.gnv.utils.WKTUtils; |
37 import de.intevation.gnv.utils.StringUtils; | 37 import de.intevation.gnv.utils.StringUtils; |
38 | 38 |
39 import de.intevation.artifacts.CallContext; | 39 import de.intevation.artifacts.CallContext; |
40 | 40 |
41 import org.jfree.chart.ChartTheme; | 41 import org.jfree.chart.ChartTheme; |
42 | 42 |
43 import com.vividsolutions.jts.geom.Coordinate; | 43 import com.vividsolutions.jts.geom.Coordinate; |
44 import com.vividsolutions.jts.geom.LineString; | |
45 import com.vividsolutions.jts.io.WKTReader; | |
46 | 44 |
47 /** | 45 /** |
48 * @author Tim Englich <tim.englich@intevation.de> | 46 * @author Tim Englich <tim.englich@intevation.de> |
49 * | 47 * |
50 */ | 48 */ |
139 net.sf.ehcache.Element value = CacheFactory.getInstance().getCache().get(key); | 137 net.sf.ehcache.Element value = CacheFactory.getInstance().getCache().get(key); |
140 if (value != null) { | 138 if (value != null) { |
141 result = (Collection<Result>) (value.getObjectValue()); | 139 result = (Collection<Result>) (value.getObjectValue()); |
142 }else{ | 140 }else{ |
143 | 141 |
144 if (this.inputData.containsKey("mesh_linestring")){ | 142 InputData meshLine = inputData.get("mesh_linestring"); |
145 | 143 InputData meshId = inputData.get("meshid"); |
146 try { | 144 |
147 LineString ls = (LineString)new WKTReader().read( | 145 if (meshLine == null) { |
148 inputData.get("mesh_linestring").getValue()); | 146 log.error("mesh_linestring is not defined"); |
149 | 147 throw new IllegalStateException("missing mesh_linestring"); |
150 Coordinate[] coords = ls.getCoordinates(); | 148 } |
151 | 149 |
152 String additionWhere = | 150 if (meshId == null) { |
153 WKTUtils.worldCoordinatesToIndex( | 151 log.error("meshid is not defined"); |
154 result, | 152 throw new IllegalStateException("missing meshid"); |
155 inputData, | 153 } |
156 ijkQueryID | 154 |
157 ); | 155 Coordinate [] coords = WKTUtils.toCoordinates( |
158 | 156 meshLine.getValue()); |
159 String[] filterValues = | 157 |
160 generateFilterValuesFromInputData(); | 158 if (coords == null) { |
161 String[] addedFilterValues = | 159 throw new IllegalStateException("cannot read coordinates"); |
162 new String[filterValues.length+1]; | 160 } |
163 System.arraycopy( | 161 |
164 filterValues, 0, | 162 try { |
165 addedFilterValues, 0, | 163 String additionWhere = |
166 filterValues.length); | 164 WKTUtils.worldCoordinatesToIndex( |
167 addedFilterValues[filterValues.length] = additionWhere; | 165 coords, |
168 | 166 result, |
169 QueryExecutor queryExecutor = QueryExecutorFactory | 167 meshId.getValue(), |
170 .getInstance() | 168 ijkQueryID); |
171 .getQueryExecutor(); | 169 |
172 | 170 String[] addedFilterValues = StringUtils.append( |
173 result = process( | 171 generateFilterValuesFromInputData(), |
174 Arrays.asList(coords), | 172 additionWhere); |
175 queryExecutor.executeQuery( | 173 |
176 queryID, | 174 QueryExecutor queryExecutor = QueryExecutorFactory |
177 addedFilterValues) | 175 .getInstance() |
178 ); | 176 .getQueryExecutor(); |
179 } catch (ParseException e) { | 177 |
180 log.error(e,e); | 178 result = process( |
181 }catch (QueryException e) { | 179 Arrays.asList(coords), |
182 log.error(e,e); | 180 queryExecutor.executeQuery( |
183 } | 181 queryID, |
184 }else{ | 182 addedFilterValues)); |
185 // TODO: definieren was passiert wenn kein linestring vorhanden ist. | 183 } |
184 catch (QueryException e) { | |
185 log.error(e,e); | |
186 } | 186 } |
187 | 187 |
188 if (CacheFactory.getInstance().isInitialized()) { | 188 if (CacheFactory.getInstance().isInitialized()) { |
189 CacheFactory.getInstance().getCache().put(new net.sf.ehcache.Element(key, result)); | 189 CacheFactory.getInstance().getCache().put(new net.sf.ehcache.Element(key, result)); |
190 } | 190 } |