diff gnv-artifacts/src/main/java/de/intevation/gnv/transition/CoordinateSelectionTransition.java @ 173:1b2fc94766c9

Added real Coordinate-Query to TimeSeries-Mesh gnv-artifacts/trunk@212 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Tue, 13 Oct 2009 09:11:23 +0000
parents
children 72bd41ba548d
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/transition/CoordinateSelectionTransition.java	Tue Oct 13 09:11:23 2009 +0000
@@ -0,0 +1,88 @@
+/**
+ *
+ */
+package de.intevation.gnv.transition;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.apache.log4j.Logger;
+
+import com.vividsolutions.jts.geom.Point;
+
+import de.intevation.gnv.geobackend.base.Result;
+import de.intevation.gnv.transition.describedata.KeyValueDescibeData;
+import de.intevation.gnv.transition.describedata.NamedCollection;
+import de.intevation.gnv.utils.InputValidator;
+import de.intevation.gnv.utils.exception.ValidationException;
+
+/**
+ * @author Tim Englich <tim.englich@intevation.de>
+ *
+ */
+public class CoordinateSelectionTransition extends TransitionBase {
+
+    /**
+     * the logger, used to log exceptions and additonaly information
+     */
+    private static Logger log = Logger.getLogger(CoordinateSelectionTransition.class);
+    
+    /**
+     * The UID of this Class
+     */
+    private static final long serialVersionUID = 6318923553625195063L;
+
+    /**
+     * Constructor
+     */
+    public CoordinateSelectionTransition() {
+        super();
+    }
+
+    /**
+     * @see de.intevation.gnv.transition.Transition#validate()
+     */
+    public boolean validate() {
+        return true;
+    }
+
+    @Override
+    protected void purifyResult(Collection<Result> result, String uuid) {
+        log.debug("CoordinateSelectionTransition.purifyResult");
+        if (this.descibeData == null) {
+            this.descibeData = new ArrayList<Object>();
+        }
+        NamedCollection<KeyValueDescibeData> keyValueDescibeData = this
+                .extractKVP(result, "FEATUREID", "SHAPE");
+        this.descibeData.add(keyValueDescibeData);
+    }
+    
+    @Override
+    protected String prepareInputData4RegionDBQuery(String value) {
+        log.debug("CoordinateSelectionTransition.prepareInputData4RegionDBQuery");
+        double distance=0.;
+        String returnValue = null;
+        try {
+            Point center = new InputValidator().getPointValue(value);
+            String meshIDValue = super.inputData.get("meshid").getValue();
+            int segments = 97;
+            int meshid = new Integer(meshIDValue);
+            if (meshid == 3 || meshid == 5){ // TODO nicht hier festbrennen.
+                distance = 0.15; //nord-ostsee 6nm // 97 Stützpunkte
+            }else if (meshid == 1 || meshid == 4){
+                distance = 0.03; //Kuestenmodell 1 nm
+            }else if (meshid == 2 || meshid == 321){
+                distance = 0.3; //SST Karten ca 20km
+            }else if (meshid == 641){
+                distance = 0.3; //Eisdaten Klima
+            }
+            returnValue = center.buffer(distance,segments).toText();
+        } catch (NumberFormatException e) {
+            log.error(e,e);
+        } catch (ValidationException e) {
+            log.error(e,e);
+        }
+        return returnValue;
+        
+    }
+}

http://dive4elements.wald.intevation.org