use of org.locationtech.jts.operation.polygonize.Polygonizer in project Universal-G-Code-Sender by winder.
the class ToolPathUtils method convertAreaToGeometry.
public static Geometry convertAreaToGeometry(final Area area, final GeometryFactory factory) {
PathIterator iter = area.getPathIterator(null, FLATNESS_PRECISION);
PrecisionModel precisionModel = factory.getPrecisionModel();
Polygonizer polygonizer = new Polygonizer(true);
List<Coordinate[]> coords = ShapeReader.toCoordinates(iter);
List<Geometry> geometries = new ArrayList<>();
for (Coordinate[] array : coords) {
for (Coordinate c : array) precisionModel.makePrecise(c);
LineString lineString = factory.createLineString(array);
geometries.add(lineString);
}
polygonizer.add(factory.buildGeometry(geometries).union());
return polygonizer.getGeometry();
}
Aggregations