@Test public void testClipEnvelopeReprojection() throws Exception { SimpleFeatureCollection features = fsPolylines.getFeatures(); RectangularClipProcess cp = new RectangularClipProcess(); SimpleFeatureCollection result = cp.execute( features, new ReferencedEnvelope( 0.0, 3339584.7, 0, 3503549.8, CRS.decode("EPSG:3857")), false); assertEquals(4, result.size()); }
@DescribeResult(name = "result", description = "Clipped feature collection") public SimpleFeatureCollection execute( @DescribeParameter(name = "features", description = "Input feature collection") SimpleFeatureCollection features, @DescribeParameter(name = "clip", description = "Bounds of clipping rectangle") ReferencedEnvelope 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 { CoordinateReferenceSystem featuresCRS = features.getSchema().getCoordinateReferenceSystem(); if (featuresCRS != null && clip.getCoordinateReferenceSystem() != null && !CRS.equalsIgnoreMetadata(featuresCRS, clip.getCoordinateReferenceSystem())) { boolean lenient = true; try { clip = clip.transform(featuresCRS, lenient); } catch (TransformException e) { throw new ProcessException(e); } catch (FactoryException e) { throw new ProcessException(e); } } return new ClipProcess().execute(features, JTS.toGeometry(clip), preserveZ); }
RectangularClipProcess 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 = "Bounds of clipping rectangle") ReferencedEnvelope 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 { CoordinateReferenceSystem featuresCRS = features.getSchema().getCoordinateReferenceSystem(); if (featuresCRS != null && clip.getCoordinateReferenceSystem() != null && !CRS.equalsIgnoreMetadata(featuresCRS, clip.getCoordinateReferenceSystem())) { boolean lenient = true; try { clip = clip.transform(featuresCRS, lenient); } catch (TransformException e) { throw new ProcessException(e); } catch (FactoryException e) { throw new ProcessException(e); } } return new ClipProcess().execute(features, JTS.toGeometry(clip), preserveZ); } }
RectangularClipProcess 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 = "Bounds of clipping rectangle") ReferencedEnvelope 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 { CoordinateReferenceSystem featuresCRS = features.getSchema().getCoordinateReferenceSystem(); if (featuresCRS != null && clip.getCoordinateReferenceSystem() != null && !CRS.equalsIgnoreMetadata(featuresCRS, clip.getCoordinateReferenceSystem())) { boolean lenient = true; try { clip = clip.transform(featuresCRS, lenient); } catch (TransformException e) { throw new ProcessException(e); } catch (FactoryException e) { throw new ProcessException(e); } } return new ClipProcess().execute(features, JTS.toGeometry(clip), preserveZ); }  }
RectangularClipProcess 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 = "Bounds of clipping rectangle") ReferencedEnvelope 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 { CoordinateReferenceSystem featuresCRS = features.getSchema().getCoordinateReferenceSystem(); if (featuresCRS != null && clip.getCoordinateReferenceSystem() != null && !CRS.equalsIgnoreMetadata(featuresCRS, clip.getCoordinateReferenceSystem())) { boolean lenient = true; try { clip = clip.transform(featuresCRS, lenient); } catch (TransformException e) { throw new ProcessException(e); } catch (FactoryException e) { throw new ProcessException(e); } } return new ClipProcess().execute(features, JTS.toGeometry(clip), preserveZ); }  @DescribeResult(name = "result", description = "Clipped feature collection") SimpleFeatureCollection execute(
            @DescribeParameter(name = "features", description = "Input feature collection")
                    SimpleFeatureCollection features,
            @DescribeParameter(name = "clip", description = "Bounds of clipping rectangle")
                    ReferencedEnvelope clip,
            @DescribeParameter(
                        name = "preserveZ",
                        min = 0,
                        description =
                                "Attempt to preserve Z values from the original geometry (interpolate value for new points)"
                    )
                    Boolean preserveZ); }
RectangularClipProcess 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 = "Bounds of clipping rectangle") ReferencedEnvelope 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 { CoordinateReferenceSystem featuresCRS = features.getSchema().getCoordinateReferenceSystem(); if (featuresCRS != null && clip.getCoordinateReferenceSystem() != null && !CRS.equalsIgnoreMetadata(featuresCRS, clip.getCoordinateReferenceSystem())) { boolean lenient = true; try { clip = clip.transform(featuresCRS, lenient); } catch (TransformException e) { throw new ProcessException(e); } catch (FactoryException e) { throw new ProcessException(e); } } return new ClipProcess().execute(features, JTS.toGeometry(clip), preserveZ); }  @DescribeResult(name = "result", description = "Clipped feature collection") SimpleFeatureCollection execute(
            @DescribeParameter(name = "features", description = "Input feature collection")
                    SimpleFeatureCollection features,
            @DescribeParameter(name = "clip", description = "Bounds of clipping rectangle")
                    ReferencedEnvelope clip,
            @DescribeParameter(
                        name = "preserveZ",
                        min = 0,
                        description =
                                "Attempt to preserve Z values from the original geometry (interpolate value for new points)"
                    )
                    Boolean preserveZ);  }