diff gnv-artifacts/src/main/java/de/intevation/gnv/utils/WKTUtils.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 2402173a1490
children 7ba4c7222265
line wrap: on
line diff
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/utils/WKTUtils.java	Mon Dec 28 16:24:05 2009 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/utils/WKTUtils.java	Mon Dec 28 17:13:12 2009 +0000
@@ -10,13 +10,12 @@
 import de.intevation.gnv.geobackend.base.query.QueryExecutor;
 import de.intevation.gnv.geobackend.base.query.QueryExecutorFactory;
 import de.intevation.gnv.geobackend.base.query.exception.QueryException;
+
 import de.intevation.gnv.math.LinearFunction;
-import de.intevation.gnv.state.InputData;
 
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
-import java.util.Map;
 
 import org.apache.commons.math.optimization.OptimizationException;
 import org.apache.commons.math.optimization.fitting.CurveFitter;
@@ -84,20 +83,17 @@
 
 
     public static String worldCoordinatesToIndex(
-        Collection<Result>     result,
-        Map<String, InputData> inputData,
-        String                 ijkQueryID
-    ) throws ParseException, QueryException
+		Coordinate []       coords,
+        Collection<Result>  result,
+		String              meshid,
+        String              ijkQueryID
+    )
+	throws QueryException
     {
         // 1. IJK Anfragen für Stuetzpunkte im Netz ausführen.
-        LineString ls = (LineString)new WKTReader().read(
-            inputData.get("mesh_linestring").getValue());
-
-        Coordinate[] coords = ls.getCoordinates();
 
         List<java.awt.Point> points = new ArrayList<java.awt.Point>(coords.length);
 
-        String meshid = inputData.get("meshid").getValue();
         QueryExecutor queryExecutor = QueryExecutorFactory
                                         .getInstance()
                                         .getQueryExecutor();
@@ -189,4 +185,18 @@
 
         return additionWhere;
     }
+
+	public static Coordinate [] toCoordinates(String wkt) {
+		try {
+			LineString ls = (LineString)new WKTReader().read(wkt);
+			return ls.getCoordinates();
+		}
+		catch (ParseException pe) {
+			log.error("cannot read WKT line string", pe);
+		}
+		catch (ClassCastException cce) {
+			log.error("cannot read WKT line string", cce);
+		}
+		return null;
+	}
 }

http://dive4elements.wald.intevation.org