comparison geo-backend/src/main/java/de/intevation/gnv/geobackend/sde/datasources/Row.java @ 273:69ddef25e822

Polygon and 3D Support was added to the WKT-Representation. geo-backend/trunk@277 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Fri, 30 Oct 2009 11:11:55 +0000
parents 71b2f263f036
children 9063c5fcebf7
comparison
equal deleted inserted replaced
272:05912f0304ac 273:69ddef25e822
42 42
43 /** 43 /**
44 * Default Logging instance 44 * Default Logging instance
45 */ 45 */
46 private static Logger sLogger = Logger.getLogger(Row.class); 46 private static Logger sLogger = Logger.getLogger(Row.class);
47 private static boolean sDebug = sLogger.isDebugEnabled();
48 47
49 /** 48 /**
50 * Data container. 49 * Data container.
51 */ 50 */
52 private Object[] mObjects; 51 private Object[] mObjects;
67 */ 66 */
68 public Row (String[] ArrayStr){ 67 public Row (String[] ArrayStr){
69 this (ArrayStr.length); 68 this (ArrayStr.length);
70 int nLength = ArrayStr.length; 69 int nLength = ArrayStr.length;
71 for (int i=0; i < nLength; i++){ 70 for (int i=0; i < nLength; i++){
72 //if (sDebug)
73 // sLogger.debug(" ArrayStr["+i+" ]=" + ArrayStr[i]);
74 addObject(ArrayStr[i], i); 71 addObject(ArrayStr[i], i);
75 72
76 } 73 }
77 74
78 } 75 }
240 SeShape val; 237 SeShape val;
241 ArrayList aList; 238 ArrayList aList;
242 SDEPoint mPoint[]; 239 SDEPoint mPoint[];
243 StringBuffer returnValue = new StringBuffer(); 240 StringBuffer returnValue = new StringBuffer();
244 synchronized (returnValue) { 241 synchronized (returnValue) {
245
246 try { 242 try {
247 val = (SeShape) this.mObjects[pPos]; 243 val = (SeShape) this.mObjects[pPos];
248 aList = val.getAllPoints(0,false); 244 aList = val.getAllPoints(0,false);
249 mPoint = (SDEPoint[])aList.get(0); 245 mPoint = (SDEPoint[])aList.get(0);
250 246 if (val.isPoint()){
251 if (mPoint.length == 1){ // PUNKT 247 returnValue.append("POINT(")
252 returnValue.append("POINT(").append(mPoint[0].getX()).append(" ").append(mPoint[0].getY()).append(")"); 248 .append(mPoint[0].getX())
253 }else{ 249 .append(" ")
250 .append(mPoint[0].getY())
251 .append(" ")
252 .append(mPoint[0].getZ())
253 .append(")");
254 }else if (val.isLine()){
254 returnValue.append("LINESTRING("); 255 returnValue.append("LINESTRING(");
255 for (int i = 0; i< mPoint.length;i++){ 256 for (int i = 0; i< mPoint.length;i++){
256 returnValue.append(mPoint[0].getX()).append(" ").append(mPoint[0].getY()); 257 returnValue.append(mPoint[i].getX())
258 .append(" ")
259 .append(mPoint[i].getY())
260 .append(" ")
261 .append(mPoint[i].getZ());
257 if (i < mPoint.length-1){ 262 if (i < mPoint.length-1){
258 returnValue.append(" , "); 263 returnValue.append(" , ");
259 } 264 }
260 } 265 }
261 returnValue.append(")"); 266 returnValue.append(")");
267 } else if (val.isPolygon()){
268 returnValue.append("POLYGON((");
269 for (int i = 0; i< mPoint.length;i++){
270 returnValue.append(mPoint[i].getX())
271 .append(" ")
272 .append(mPoint[i].getY())
273 .append(" ")
274 .append(mPoint[i].getZ());
275 if (i < mPoint.length-1){
276 returnValue.append(" , ");
277 }
278 }
279 returnValue.append(")");
280 // TODO Wie werden innere Ringe unterstützt.
281 // for (int i =1 ; i < aList.size(); i++){
282 // returnValue.append("(");
283 // mPoint = (SDEPoint[])aList.get(i);
284 // for (int j = 0; j < mPoint.length;j++){
285 // returnValue.append(mPoint[j].getX())
286 // .append(" ")
287 // .append(mPoint[j].getY())
288 // .append(" ")
289 // .append(mPoint[i].getZ());
290 // if (i < mPoint.length-1){
291 // returnValue.append(" , ");
292 // }
293 // }
294 // returnValue.append(")");
295 // }
296 returnValue.append(")");
262 } 297 }
263 // String nord="N";
264 // String ost="E";
265 // if (lat <0 ){nord="S"; lat=-lat;}
266 // if (lon <0 ){ost="W"; lon=-lon;}
267 // return String.format("%1$02d°%2$1S %3$05.2f' %4$03d°%5$1S %6$05.2f'",
268 // (int)lat, nord,60.*(lat-((int)lat)),(int)lon,ost,60.*(lon-((int)lon)));
269 } catch (SeException e) { 298 } catch (SeException e) {
270 throw new TechnicalException("Could not cast this value to the Float Type. Object is of value type: " + getValue(pPos).getClass().getName()); 299 throw new TechnicalException("Could not cast this value to the Float Type. Object is of value type: " + getValue(pPos).getClass().getName());
271 } 300 }
272 } 301 }
273 return returnValue.toString(); 302 return returnValue.toString();

http://dive4elements.wald.intevation.org