# HG changeset patch # User Tim Englich # Date 1255514505 0 # Node ID 71b2f263f0365997340140f3f1b7bc744bfbe0bd # Parent 000e00592ba58b5983e0347f8803f6bf0183912b Add WKT-Syntaxt to Shape ReturnValue geo-backend/trunk@218 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 000e00592ba5 -r 71b2f263f036 geo-backend/ChangeLog --- a/geo-backend/ChangeLog Wed Oct 14 09:28:18 2009 +0000 +++ b/geo-backend/ChangeLog Wed Oct 14 10:01:45 2009 +0000 @@ -1,5 +1,7 @@ 2009-10-14 Tim Englich + * src/main/java/de/intevation/gnv/geobackend/sde/datasources/Row.java (getPosValue): + Add WKT-Syntaxt to Shape ReturnValue * src/test/ressources/QueryExecutorTestCase.properties: Changed Test-Query-Statement for Spatial-Queries with INNERJOINS and ORDER BY * src/test/java/de/intevation/gnv/geobackend/base/query/QueryExecutorTestCase.java (testSpatialQueryWithoutIntersects): diff -r 000e00592ba5 -r 71b2f263f036 geo-backend/src/main/java/de/intevation/gnv/geobackend/sde/datasources/Row.java --- a/geo-backend/src/main/java/de/intevation/gnv/geobackend/sde/datasources/Row.java Wed Oct 14 09:28:18 2009 +0000 +++ b/geo-backend/src/main/java/de/intevation/gnv/geobackend/sde/datasources/Row.java Wed Oct 14 10:01:45 2009 +0000 @@ -237,26 +237,39 @@ * @see #getValue(int) */ public String getPosValue(int pPos)throws TechnicalException{ - SeShape val; - ArrayList aList; - SDEPoint mPoint[]; - double lat,lon; - try { - val = (SeShape) this.mObjects[pPos]; - aList = val.getAllPoints(0,false); - mPoint = (SDEPoint[])aList.get(0); - lat = mPoint[0].getY(); - lon = mPoint[0].getX(); - String nord="N"; - String ost="E"; - if (lat <0 ){nord="S"; lat=-lat;} - if (lon <0 ){ost="W"; lon=-lon;} - return 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 (SeException e) { - throw new TechnicalException("Could not cast this value to the Float Type. Object is of value type: " + getValue(pPos).getClass().getName()); + SeShape val; + ArrayList aList; + SDEPoint mPoint[]; + StringBuffer returnValue = new StringBuffer(); + synchronized (returnValue) { + + try { + val = (SeShape) this.mObjects[pPos]; + aList = val.getAllPoints(0,false); + mPoint = (SDEPoint[])aList.get(0); + + if (mPoint.length == 1){ // PUNKT + returnValue.append("POINT(").append(mPoint[0].getX()).append(" ").append(mPoint[0].getY()).append(")"); + }else{ + returnValue.append("LINESTRING("); + for (int i = 0; i< mPoint.length;i++){ + returnValue.append(mPoint[0].getX()).append(" ").append(mPoint[0].getY()); + if (i < mPoint.length-1){ + returnValue.append(" , "); + } + } + returnValue.append(")"); + } + // String nord="N"; + // String ost="E"; + // if (lat <0 ){nord="S"; lat=-lat;} + // if (lon <0 ){ost="W"; lon=-lon;} + // return 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 (SeException e) { + throw new TechnicalException("Could not cast this value to the Float Type. Object is of value type: " + getValue(pPos).getClass().getName()); + } } + return returnValue.toString(); } }