@Test public void testExecute1() throws Exception { SimpleFeatureTypeBuilder tb = new SimpleFeatureTypeBuilder(); tb.setName("featureType"); tb.add("geometry", Geometry.class); tb.add("integer", Integer.class); GeometryFactory gf = new GeometryFactory(); SimpleFeatureBuilder b = new SimpleFeatureBuilder(tb.buildFeatureType()); DefaultFeatureCollection features = new DefaultFeatureCollection(null, b.getFeatureType()); DefaultFeatureCollection secondFeatures = new DefaultFeatureCollection(null, b.getFeatureType()); Coordinate firstArray[] = new Coordinate[5]; for (int numFeatures = 0; numFeatures < 1; numFeatures++) { firstArray[0] = new Coordinate(0, 0); firstArray[1] = new Coordinate(1, 0); firstArray[2] = new Coordinate(1, 1); firstArray[3] = new Coordinate(0, 1); firstArray[4] = new Coordinate(0, 0); LinearRing shell = gf.createLinearRing(firstArray); b.add(gf.createPolygon(shell, null)); b.add(0); secondFeatures.add(b.buildFeature(numFeatures + "")); } Coordinate centre = ((Polygon) secondFeatures.features().next().getDefaultGeometry()) .getCentroid() .getCoordinate(); Point p = gf.createPoint(centre); b.add(p); b.add(0); features.add(b.buildFeature(0 + "")); InclusionFeatureCollection process = new InclusionFeatureCollection(); SimpleFeatureCollection output = process.execute(features, secondFeatures); assertEquals(1, output.size()); SimpleFeatureIterator iterator = output.features(); Geometry expected = (Geometry) features.features().next().getDefaultGeometry(); SimpleFeature sf = iterator.next(); assertTrue(expected.equals((Geometry) sf.getDefaultGeometry())); }
@DescribeResult(description = "Output feature collection") public SimpleFeatureCollection execute( @DescribeParameter(name = "first", description = "First feature collection") SimpleFeatureCollection firstFeatures, @DescribeParameter(name = "second", description = "Second feature collection") SimpleFeatureCollection secondFeatures) { return new IncludedFeatureCollection(firstFeatures, secondFeatures); }
InclusionFeatureCollection implements VectorProcess { @DescribeResult(description = "Output feature collection") public SimpleFeatureCollection execute( @DescribeParameter(name = "first", description = "First feature collection") SimpleFeatureCollection firstFeatures, @DescribeParameter(name = "second", description = "Second feature collection") SimpleFeatureCollection secondFeatures) { return new IncludedFeatureCollection(firstFeatures, secondFeatures); } }
InclusionFeatureCollection implements VectorProcess { @DescribeResult(description = "Output feature collection") public SimpleFeatureCollection execute( @DescribeParameter(name = "first", description = "First feature collection") SimpleFeatureCollection firstFeatures, @DescribeParameter(name = "second", description = "Second feature collection") SimpleFeatureCollection secondFeatures) { return new IncludedFeatureCollection(firstFeatures, secondFeatures); }  }
InclusionFeatureCollection implements VectorProcess { @DescribeResult(description = "Output feature collection") public SimpleFeatureCollection execute( @DescribeParameter(name = "first", description = "First feature collection") SimpleFeatureCollection firstFeatures, @DescribeParameter(name = "second", description = "Second feature collection") SimpleFeatureCollection secondFeatures) { return new IncludedFeatureCollection(firstFeatures, secondFeatures); }  @DescribeResult(description = "Output feature collection") SimpleFeatureCollection execute(
            @DescribeParameter(name = "first", description = "First feature collection")
                    SimpleFeatureCollection firstFeatures,
            @DescribeParameter(name = "second", description = "Second feature collection")
                    SimpleFeatureCollection secondFeatures); }
InclusionFeatureCollection implements VectorProcess { @DescribeResult(description = "Output feature collection") public SimpleFeatureCollection execute( @DescribeParameter(name = "first", description = "First feature collection") SimpleFeatureCollection firstFeatures, @DescribeParameter(name = "second", description = "Second feature collection") SimpleFeatureCollection secondFeatures) { return new IncludedFeatureCollection(firstFeatures, secondFeatures); }  @DescribeResult(description = "Output feature collection") SimpleFeatureCollection execute(
            @DescribeParameter(name = "first", description = "First feature collection")
                    SimpleFeatureCollection firstFeatures,
            @DescribeParameter(name = "second", description = "Second feature collection")
                    SimpleFeatureCollection secondFeatures);  }