@Test public void testClipPoly3DNewVertices() throws Exception { SimpleFeatureCollection features = fsMeters.getFeatures(); ClipProcess cp = new ClipProcess(); SimpleFeatureCollection result = cp.execute( features, new WKTReader() .read( "POLYGON((0 5000, 0 10000, 10000 10000, 10000 5000, 0 5000))"), true); assertEquals(1, result.size()); SimpleFeatureIterator fi = result.features(); SimpleFeature f = fi.next(); MultiPolygon mp = (MultiPolygon) f.getDefaultGeometry(); assertEquals(1, mp.getNumGeometries()); Polygon p = (Polygon) mp.getGeometryN(0); assertEquals(0, p.getNumInteriorRing()); LineString shell = p.getExteriorRing(); CoordinateSequence cs = shell.getCoordinateSequence(); assertEquals(5, cs.size()); assertOrdinates(0, 5000, 1, cs, 0); assertOrdinates(0, 10000, 2, cs, 1); assertOrdinates(10000, 10000, 2, cs, 2); assertOrdinates(10000, 5000, 1, cs, 3); assertOrdinates(0, 5000, 1, cs, 4); assertFalse(fi.hasNext()); fi.close(); }
@DescribeResult(name = "result", description = "Clipped feature collection") public SimpleFeatureCollection execute( @DescribeParameter(name = "features", description = "Input feature collection") SimpleFeatureCollection features, @DescribeParameter( name = "clip", description = "Geometry to use for clipping (in same CRS as input features)" ) Geometry clip, @DescribeParameter( name = "preserveZ", min = 0, description = "Attempt to preserve Z values from the original geometry (interpolate value for new points)" ) Boolean preserveZ) throws ProcessException { Envelope box = clip.getEnvelopeInternal(); String srs = null; if (features.getSchema().getCoordinateReferenceSystem() != null) { srs = CRS.toSRS(features.getSchema().getCoordinateReferenceSystem()); } BBOX bboxFilter = ff.bbox("", box.getMinX(), box.getMinY(), box.getMaxX(), box.getMaxY(), srs); if (preserveZ == null) { preserveZ = false; } return new ClippingFeatureCollection(features.subCollection(bboxFilter), clip, preserveZ); }
ClipProcess implements VectorProcess { @DescribeResult(name = "result", description = "Clipped feature collection") public SimpleFeatureCollection execute( @DescribeParameter(name = "features", description = "Input feature collection") SimpleFeatureCollection features, @DescribeParameter( name = "clip", description = "Geometry to use for clipping (in same CRS as input features)" ) Geometry clip, @DescribeParameter( name = "preserveZ", min = 0, description = "Attempt to preserve Z values from the original geometry (interpolate value for new points)" ) Boolean preserveZ) throws ProcessException { Envelope box = clip.getEnvelopeInternal(); String srs = null; if (features.getSchema().getCoordinateReferenceSystem() != null) { srs = CRS.toSRS(features.getSchema().getCoordinateReferenceSystem()); } BBOX bboxFilter = ff.bbox("", box.getMinX(), box.getMinY(), box.getMaxX(), box.getMaxY(), srs); if (preserveZ == null) { preserveZ = false; } return new ClippingFeatureCollection(features.subCollection(bboxFilter), clip, preserveZ); } }
ClipProcess implements VectorProcess { @DescribeResult(name = "result", description = "Clipped feature collection") public SimpleFeatureCollection execute( @DescribeParameter(name = "features", description = "Input feature collection") SimpleFeatureCollection features, @DescribeParameter( name = "clip", description = "Geometry to use for clipping (in same CRS as input features)" ) Geometry clip, @DescribeParameter( name = "preserveZ", min = 0, description = "Attempt to preserve Z values from the original geometry (interpolate value for new points)" ) Boolean preserveZ) throws ProcessException { Envelope box = clip.getEnvelopeInternal(); String srs = null; if (features.getSchema().getCoordinateReferenceSystem() != null) { srs = CRS.toSRS(features.getSchema().getCoordinateReferenceSystem()); } BBOX bboxFilter = ff.bbox("", box.getMinX(), box.getMinY(), box.getMaxX(), box.getMaxY(), srs); if (preserveZ == null) { preserveZ = false; } return new ClippingFeatureCollection(features.subCollection(bboxFilter), clip, preserveZ); }  }
ClipProcess implements VectorProcess { @DescribeResult(name = "result", description = "Clipped feature collection") public SimpleFeatureCollection execute( @DescribeParameter(name = "features", description = "Input feature collection") SimpleFeatureCollection features, @DescribeParameter( name = "clip", description = "Geometry to use for clipping (in same CRS as input features)" ) Geometry clip, @DescribeParameter( name = "preserveZ", min = 0, description = "Attempt to preserve Z values from the original geometry (interpolate value for new points)" ) Boolean preserveZ) throws ProcessException { Envelope box = clip.getEnvelopeInternal(); String srs = null; if (features.getSchema().getCoordinateReferenceSystem() != null) { srs = CRS.toSRS(features.getSchema().getCoordinateReferenceSystem()); } BBOX bboxFilter = ff.bbox("", box.getMinX(), box.getMinY(), box.getMaxX(), box.getMaxY(), srs); if (preserveZ == null) { preserveZ = false; } return new ClippingFeatureCollection(features.subCollection(bboxFilter), clip, preserveZ); }  @DescribeResult(name = "result", description = "Clipped feature collection") SimpleFeatureCollection execute(
            @DescribeParameter(name = "features", description = "Input feature collection")
                    SimpleFeatureCollection features,
            @DescribeParameter(
                        name = "clip",
                        description = "Geometry to use for clipping (in same CRS as input features)"
                    )
                    Geometry clip,
            @DescribeParameter(
                        name = "preserveZ",
                        min = 0,
                        description =
                                "Attempt to preserve Z values from the original geometry (interpolate value for new points)"
                    )
                    Boolean preserveZ); }
ClipProcess implements VectorProcess { @DescribeResult(name = "result", description = "Clipped feature collection") public SimpleFeatureCollection execute( @DescribeParameter(name = "features", description = "Input feature collection") SimpleFeatureCollection features, @DescribeParameter( name = "clip", description = "Geometry to use for clipping (in same CRS as input features)" ) Geometry clip, @DescribeParameter( name = "preserveZ", min = 0, description = "Attempt to preserve Z values from the original geometry (interpolate value for new points)" ) Boolean preserveZ) throws ProcessException { Envelope box = clip.getEnvelopeInternal(); String srs = null; if (features.getSchema().getCoordinateReferenceSystem() != null) { srs = CRS.toSRS(features.getSchema().getCoordinateReferenceSystem()); } BBOX bboxFilter = ff.bbox("", box.getMinX(), box.getMinY(), box.getMaxX(), box.getMaxY(), srs); if (preserveZ == null) { preserveZ = false; } return new ClippingFeatureCollection(features.subCollection(bboxFilter), clip, preserveZ); }  @DescribeResult(name = "result", description = "Clipped feature collection") SimpleFeatureCollection execute(
            @DescribeParameter(name = "features", description = "Input feature collection")
                    SimpleFeatureCollection features,
            @DescribeParameter(
                        name = "clip",
                        description = "Geometry to use for clipping (in same CRS as input features)"
                    )
                    Geometry clip,
            @DescribeParameter(
                        name = "preserveZ",
                        min = 0,
                        description =
                                "Attempt to preserve Z values from the original geometry (interpolate value for new points)"
                    )
                    Boolean preserveZ);  }