private String convertToWKT(Geometry g, boolean isFormatted) { if (g == null) return ""; if (!isFormatted) return g.toString(); WKTWriter writer = new WKTWriter(); writer.setFormatted(isFormatted); writer.setMaxCoordinatesPerLine(5); return writer.write(g); }
public String toString() { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); pw.print("GEOMETRYCOLLECTION("); boolean firstGeometry = true; for (Geometry geometry : geometries) { if (firstGeometry) { firstGeometry = false; } else { pw.print(","); } pw.print(geometry.toString()); } pw.print(")"); pw.flush(); return sw.toString(); }