comparison src/main/java/de/mpiwg/itgroup/annotations/restlet/AnnotatorResourceImpl.java @ 85:ed51eadc82c5

add polyline annotation shape.
author casties
date Mon, 26 Jan 2015 18:51:28 +0100
parents 6bf38b5e30a8
children e3f0613b2f2d
comparison
equal deleted inserted replaced
84:6bf38b5e30a8 85:ed51eadc82c5
462 if (i < numCoords-1) { 462 if (i < numCoords-1) {
463 coords.append(", "); 463 coords.append(", ");
464 } 464 }
465 } 465 }
466 // TODO: add units/crs to wkt 466 // TODO: add units/crs to wkt
467 // assume polygon with outer ring
467 fragment = String.format("wkt=POLYGON((%s))", coords); 468 fragment = String.format("wkt=POLYGON((%s))", coords);
469 } else if (type.equalsIgnoreCase("linestring")) {
470 // linestring (polyline) shape
471 JSONArray coordArray = geom.getJSONArray("coordinates");
472 StringBuilder coords = new StringBuilder();
473 int numCoords = coordArray.length();
474 for (int i = 0; i < numCoords; ++i) {
475 JSONArray coordPair = coordArray.getJSONArray(i);
476 coords.append(coordPair.getString(0));
477 coords.append(" ");
478 coords.append(coordPair.getString(1));
479 if (i < numCoords-1) {
480 coords.append(", ");
481 }
482 }
483 // TODO: add units/crs to wkt
484 fragment = String.format("wkt=LINESTRING(%s)", coords);
468 } else { 485 } else {
469 logger.severe("Unable to parse this shape: " + shape); 486 logger.severe("Unable to parse this shape: " + shape);
470 } 487 }
471 return fragment; 488 return fragment;
472 } 489 }