Changeset 85:ed51eadc82c5 in AnnotationManagerN4J


Ignore:
Timestamp:
Jan 26, 2015, 5:51:28 PM (9 years ago)
Author:
casties
Branch:
default
Message:

add polyline annotation shape.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/de/mpiwg/itgroup/annotations/restlet/AnnotatorResourceImpl.java

    r84 r85  
    465465                }
    466466                // TODO: add units/crs to wkt
     467                // assume polygon with outer ring
    467468            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);
    468485        } else {
    469486            logger.severe("Unable to parse this shape: " + shape);
Note: See TracChangeset for help on using the changeset viewer.