# HG changeset patch # User Tim Englich # Date 1255680107 0 # Node ID 72bd41ba548d0965b4de3d0411ccaccd546b4ea3 # Parent f2c76f35da5aa1a27231f40f09e3e6fcfdf16c00 Added Transformation from WKT-Coordinate Reperesentation to BSH-Coordinate Representation. issue38 gnv-artifacts/trunk@224 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r f2c76f35da5a -r 72bd41ba548d gnv-artifacts/ChangeLog --- a/gnv-artifacts/ChangeLog Thu Oct 15 15:38:15 2009 +0000 +++ b/gnv-artifacts/ChangeLog Fri Oct 16 08:01:47 2009 +0000 @@ -1,3 +1,8 @@ +2009-10-16 Tim Englich + + * src/main/java/de/intevation/gnv/transition/CoordinateSelectionTransition.java (convert2DisplayCoordinate): + Added Transformation from WKT-Coordinate Reperesentation to BSH-Coordinate Representation. issue38 + 2009-10-15 Tim Englich * src/main/java/de/intevation/gnv/chart/HorizontalProfileChartFactory.java, diff -r f2c76f35da5a -r 72bd41ba548d gnv-artifacts/src/main/java/de/intevation/gnv/transition/CoordinateSelectionTransition.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/transition/CoordinateSelectionTransition.java Thu Oct 15 15:38:15 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/transition/CoordinateSelectionTransition.java Fri Oct 16 08:01:47 2009 +0000 @@ -5,13 +5,18 @@ import java.util.ArrayList; import java.util.Collection; +import java.util.Iterator; import org.apache.log4j.Logger; import com.vividsolutions.jts.geom.Point; +import com.vividsolutions.jts.io.ParseException; +import com.vividsolutions.jts.io.WKTReader; import de.intevation.gnv.geobackend.base.Result; +import de.intevation.gnv.transition.describedata.DefaultKeyValueDescribeData; import de.intevation.gnv.transition.describedata.KeyValueDescibeData; +import de.intevation.gnv.transition.describedata.NamedArrayList; import de.intevation.gnv.transition.describedata.NamedCollection; import de.intevation.gnv.utils.InputValidator; import de.intevation.gnv.utils.exception.ValidationException; @@ -85,4 +90,43 @@ return returnValue; } + + /** + * @see de.intevation.gnv.transition.TransitionBase#extractKVP(java.util.Collection, java.lang.String, java.lang.String) + */ + @Override + protected NamedCollection extractKVP( + Collection result, + String keyid, + String valueid) { + Iterator rit = result.iterator(); + NamedCollection keyValueDescibeData = new NamedArrayList( + this.dataName, result.size()); + keyValueDescibeData.setMultiSelect(this.dataMultiSelect); + while (rit.hasNext()) { + Result resultValue = rit.next(); + keyValueDescibeData.add(new DefaultKeyValueDescribeData(resultValue + .getString(keyid), this.convert2DisplayCoordinate(resultValue.getString(valueid)))); + } + return keyValueDescibeData; + } + + protected String convert2DisplayCoordinate(String wkt){ + String formattedCoordinate = null; + try { + Point p = (Point)new WKTReader().read(wkt); + double lat = p.getY(); + double lon =p.getX(); + String nord="N"; + String ost="E"; + if (lat <0 ){nord="S"; lat=-lat;} + if (lon <0 ){ost="W"; lon=-lon;} + formattedCoordinate = String.format("%1$02d°%2$1S %3$05.2f' %4$03d°%5$1S %6$05.2f'", + (int)lat, nord,60.*(lat-((int)lat)),(int)lon,ost,60.*(lon-((int)lon))); + } catch (ParseException e) { + log.error(e,e); + } + + return formattedCoordinate; + } }