@Test public void testClipExtractSeparateBitsLowLine() throws Exception { SimpleFeatureCollection features = fsLines.getFeatures(); ClipProcess cp = new ClipProcess(); SimpleFeatureCollection result = cp.execute( features, new WKTReader() .read( "POLYGON((1000 -10, 1000 10, 9000 10, 9000 -10, 8000 -10, 8000 5, 2000 5, 2000 -10, 1000 -10))"), true); assertEquals(1, result.size()); SimpleFeatureIterator fi = result.features(); SimpleFeature f = fi.next(); fi.close(); MultiLineString ml = (MultiLineString) f.getDefaultGeometry(); assertEquals(2, ml.getNumGeometries()); LineString ls = (LineString) ml.getGeometryN(0); CoordinateSequence cs = ls.getCoordinateSequence(); assertEquals(2, cs.size()); assertOrdinates(1000, 0, 0.1, cs, 0); assertOrdinates(2000, 0, 0.2, cs, 1); ls = (LineString) ml.getGeometryN(1); cs = ls.getCoordinateSequence(); assertEquals(2, cs.size()); assertOrdinates(8000, 0, 0.8, cs, 0); assertOrdinates(9000, 0, 0.9, cs, 1); }
@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);  }