public void saveBoundary(JSONObject feature, MultiPolygon geometry) { if(writer != null) { JSONObject properties = feature.getJSONObject(GeoJsonWriter.PROPERTIES); String btype = "boundary:" + StringUtils.stripToEmpty(properties.optString("admin_level")); if(fallbackTypes.contains(btype)) { String id = StringUtils.split(feature.getString("id"), '-')[2]; String wkt = geometry.toString(); writer.println(id + "\t" + StringUtils.removeEnd(GeoJsonWriter.getNowTimestampString(), "Z") + "\t" + wkt); } } }
return "SRID=4326;" + polygon.toString();
/** * * @param payload * @return */ public Shape parseShape(SimpleFeature payload) throws ParseWKTException { int attIndexPlotPoly = payload.getFeatureType().indexOf(AreaFieldPreference.SHAPE_ATT_POLYGON.getValue()); int attIndexPlotName = payload.getFeatureType().indexOf(AreaFieldPreference.SHAPE_ATT_NAME.getValue()); MultiPolygon polygon = null; if (attIndexPlotPoly >= 0) { polygon = (MultiPolygon) payload.getAttribute(attIndexPlotPoly); } String shapeName = DEFAULT_SHAPE_NAME; if (attIndexPlotName >= 0) { shapeName = (String) payload.getAttribute(attIndexPlotName); } try { Shape shape = new Shape(polygon.toString()); shape.setName(shapeName); shape.setType(Shape.ShapeType.SKIP); return shape; } catch (ParseException ex) { Exceptions.printStackTrace(ex); LOG.error(LOGKEY_PROCESSING_PARSE_ERROR, shapeFile.getName()); throw new ParseWKTException("Failed creating shape from multipolygon: " + polygon.toString(), ex); } }