class GeometryFunctions {

    @DescribeProcess(title = "Split Polygon", description = "Splits a polygon by a linestring")
    @DescribeResult(description = "The collection of split polygons")
    static public Geometry splitPolygon(
            @DescribeParameter(name = "polygon", description = "Polygon to split") Geometry polygon,
            @DescribeParameter(name = "line", description = "Linestring to split by") LineString line) {
        Geometry nodedLinework = polygon.getBoundary().union(line);
        Geometry polys = polygonize(nodedLinework);

        // Only keep polygons which are inside the input
        List<Polygon> output = new ArrayList<Polygon>();
        for (int i = 0; i < polys.getNumGeometries(); i++) {
            Polygon candpoly = (Polygon) polys.getGeometryN(i);
            // use interior point to test for inclusion in parent
            if (polygon.contains(candpoly.getInteriorPoint())) {
                output.add(candpoly);
            }
        }
        return polygon.getFactory().createGeometryCollection(
                GeometryFactory.toGeometryArray(output));
    }

}