- Polygon p = (Polygon) feature.getDefaultGeometry();
- Point centroid = p.getCentroid();
- String code = "AUTO:42001," + centroid.getX() + "," + centroid.getY();
- CoordinateReferenceSystem auto = CRS.decode(code);
-
- MathTransform transform = CRS.findMathTransform(DefaultGeographicCRS.WGS84, auto);
-
- Polygon projed = (Polygon) JTS.transform(p, transform);
-
- for (Coordinate coord : projed.getCoordinates()) {
- double x = coord.x;
- if (x < minX)
- minX = x;
- if (x > maxX)
- maxX = x;
- double y = -coord.y;
- if (y < minY)
- minY = y;
- if (y > maxY)
- maxY = y;
- sb.append(x + "," + y + " ");
+ if (geometry instanceof Polygon p) {
+ Point centroid = p.getCentroid();
+ String code = "AUTO:42001," + centroid.getX() + "," + centroid.getY();
+ CoordinateReferenceSystem auto = CRS.decode(code);
+
+ MathTransform transform = CRS.findMathTransform(DefaultGeographicCRS.WGS84, auto);
+
+ Polygon projed = (Polygon) JTS.transform(p, transform);
+
+ for (Coordinate coord : projed.getCoordinates()) {
+ double x = coord.x;
+ if (x < minX)
+ minX = x;
+ if (x > maxX)
+ maxX = x;
+ double y = -coord.y;
+ if (y < minY)
+ minY = y;
+ if (y > maxY)
+ maxY = y;
+ sb.append(x + "," + y + " ");
+ }
+ sb.append("\">");
+ sb.append("</polyline>\n");
+ shapes.add(sb.toString());
+ } else {
+ throw new IllegalArgumentException("Unsuppported geometry type " + geometry.getClass().getName());