@Test public void testFeatureCollection() throws Exception { Geometry poly = new WKTReader().read("POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))"); CoordinateReferenceSystem utm32n = CRS.decode("EPSG:32632"); poly.setUserData(utm32n); SimpleFeatureCollection fc = new FeatureProcess().execute(poly, null, "testft"); assertNotNull(fc); assertEquals(1, fc.size()); SimpleFeatureType schema = fc.getSchema(); assertEquals("testft", schema.getTypeName()); assertEquals(1, schema.getAttributeCount()); GeometryDescriptor ad = (GeometryDescriptor) schema.getDescriptor("geom"); assertEquals(Polygon.class, ad.getType().getBinding()); assertEquals(utm32n, ad.getCoordinateReferenceSystem()); SimpleFeature sf = fc.features().next(); assertEquals(poly, sf.getDefaultGeometry()); }
@DescribeResult(name = "result", description = "Output feature collection") public SimpleFeatureCollection execute( @DescribeParameter(name = "geometry", description = "Input geometry", min = 1) Geometry geometry, @DescribeParameter( name = "crs", description = "Coordinate reference system of the input geometry (if not provided in the geometry)" ) CoordinateReferenceSystem crs, @DescribeParameter( name = "typeName", description = "Feauturetype name for the feature collection", min = 1 ) String name) { if (crs == null) { try { crs = (CoordinateReferenceSystem) geometry.getUserData(); } catch (Exception e) { } } if (crs == null && geometry.getSRID() > 0) { try { crs = CRS.decode("EPSG:" + geometry.getSRID()); } catch (Exception e) { } } SimpleFeatureTypeBuilder tb = new SimpleFeatureTypeBuilder(); tb.setName(name); tb.add("geom", geometry.getClass(), crs); SimpleFeatureType schema = tb.buildFeatureType(); SimpleFeature sf = SimpleFeatureBuilder.build(schema, new Object[] {geometry}, null); ListFeatureCollection result = new ListFeatureCollection(schema); result.add(sf); return result; }
FeatureProcess implements VectorProcess { @DescribeResult(name = "result", description = "Output feature collection") public SimpleFeatureCollection execute( @DescribeParameter(name = "geometry", description = "Input geometry", min = 1) Geometry geometry, @DescribeParameter( name = "crs", description = "Coordinate reference system of the input geometry (if not provided in the geometry)" ) CoordinateReferenceSystem crs, @DescribeParameter( name = "typeName", description = "Feauturetype name for the feature collection", min = 1 ) String name) { if (crs == null) { try { crs = (CoordinateReferenceSystem) geometry.getUserData(); } catch (Exception e) { } } if (crs == null && geometry.getSRID() > 0) { try { crs = CRS.decode("EPSG:" + geometry.getSRID()); } catch (Exception e) { } } SimpleFeatureTypeBuilder tb = new SimpleFeatureTypeBuilder(); tb.setName(name); tb.add("geom", geometry.getClass(), crs); SimpleFeatureType schema = tb.buildFeatureType(); SimpleFeature sf = SimpleFeatureBuilder.build(schema, new Object[] {geometry}, null); ListFeatureCollection result = new ListFeatureCollection(schema); result.add(sf); return result; } }
FeatureProcess implements VectorProcess { @DescribeResult(name = "result", description = "Output feature collection") public SimpleFeatureCollection execute( @DescribeParameter(name = "geometry", description = "Input geometry", min = 1) Geometry geometry, @DescribeParameter( name = "crs", description = "Coordinate reference system of the input geometry (if not provided in the geometry)" ) CoordinateReferenceSystem crs, @DescribeParameter( name = "typeName", description = "Feauturetype name for the feature collection", min = 1 ) String name) { if (crs == null) { try { crs = (CoordinateReferenceSystem) geometry.getUserData(); } catch (Exception e) { } } if (crs == null && geometry.getSRID() > 0) { try { crs = CRS.decode("EPSG:" + geometry.getSRID()); } catch (Exception e) { } } SimpleFeatureTypeBuilder tb = new SimpleFeatureTypeBuilder(); tb.setName(name); tb.add("geom", geometry.getClass(), crs); SimpleFeatureType schema = tb.buildFeatureType(); SimpleFeature sf = SimpleFeatureBuilder.build(schema, new Object[] {geometry}, null); ListFeatureCollection result = new ListFeatureCollection(schema); result.add(sf); return result; }  }
FeatureProcess implements VectorProcess { @DescribeResult(name = "result", description = "Output feature collection") public SimpleFeatureCollection execute( @DescribeParameter(name = "geometry", description = "Input geometry", min = 1) Geometry geometry, @DescribeParameter( name = "crs", description = "Coordinate reference system of the input geometry (if not provided in the geometry)" ) CoordinateReferenceSystem crs, @DescribeParameter( name = "typeName", description = "Feauturetype name for the feature collection", min = 1 ) String name) { if (crs == null) { try { crs = (CoordinateReferenceSystem) geometry.getUserData(); } catch (Exception e) { } } if (crs == null && geometry.getSRID() > 0) { try { crs = CRS.decode("EPSG:" + geometry.getSRID()); } catch (Exception e) { } } SimpleFeatureTypeBuilder tb = new SimpleFeatureTypeBuilder(); tb.setName(name); tb.add("geom", geometry.getClass(), crs); SimpleFeatureType schema = tb.buildFeatureType(); SimpleFeature sf = SimpleFeatureBuilder.build(schema, new Object[] {geometry}, null); ListFeatureCollection result = new ListFeatureCollection(schema); result.add(sf); return result; }  @DescribeResult(name = "result", description = "Output feature collection") SimpleFeatureCollection execute(
            @DescribeParameter(name = "geometry", description = "Input geometry", min = 1)
                    Geometry geometry,
            @DescribeParameter(
                        name = "crs",
                        description =
                                "Coordinate reference system of the input geometry (if not provided in the geometry)"
                    )
                    CoordinateReferenceSystem crs,
            @DescribeParameter(
                        name = "typeName",
                        description = "Feauturetype name for the feature collection",
                        min = 1
                    )
                    String name); }
FeatureProcess implements VectorProcess { @DescribeResult(name = "result", description = "Output feature collection") public SimpleFeatureCollection execute( @DescribeParameter(name = "geometry", description = "Input geometry", min = 1) Geometry geometry, @DescribeParameter( name = "crs", description = "Coordinate reference system of the input geometry (if not provided in the geometry)" ) CoordinateReferenceSystem crs, @DescribeParameter( name = "typeName", description = "Feauturetype name for the feature collection", min = 1 ) String name) { if (crs == null) { try { crs = (CoordinateReferenceSystem) geometry.getUserData(); } catch (Exception e) { } } if (crs == null && geometry.getSRID() > 0) { try { crs = CRS.decode("EPSG:" + geometry.getSRID()); } catch (Exception e) { } } SimpleFeatureTypeBuilder tb = new SimpleFeatureTypeBuilder(); tb.setName(name); tb.add("geom", geometry.getClass(), crs); SimpleFeatureType schema = tb.buildFeatureType(); SimpleFeature sf = SimpleFeatureBuilder.build(schema, new Object[] {geometry}, null); ListFeatureCollection result = new ListFeatureCollection(schema); result.add(sf); return result; }  @DescribeResult(name = "result", description = "Output feature collection") SimpleFeatureCollection execute(
            @DescribeParameter(name = "geometry", description = "Input geometry", min = 1)
                    Geometry geometry,
            @DescribeParameter(
                        name = "crs",
                        description =
                                "Coordinate reference system of the input geometry (if not provided in the geometry)"
                    )
                    CoordinateReferenceSystem crs,
            @DescribeParameter(
                        name = "typeName",
                        description = "Feauturetype name for the feature collection",
                        min = 1
                    )
                    String name);  }