@Test public void rasterizePoints() throws Exception { ReferencedEnvelope bounds = new ReferencedEnvelope(-10, 10, -20, 20, DefaultEngineeringCRS.GENERIC_2D); Dimension gridDim = new Dimension(100, 100); SimpleFeatureCollection features = createPoints(bounds, gridDim); String covName = "Test"; ProgressListener monitor = null; GridCoverage2D cov = VectorToRasterProcess.process(features, "value", gridDim, bounds, covName, monitor); SimpleFeatureIterator iter = features.features(); int[] covValues = new int[1]; try { while (iter.hasNext()) { SimpleFeature feature = iter.next(); Coordinate coord = ((Geometry) feature.getDefaultGeometry()).getCoordinate(); Point2D worldPos = new Point2D.Double(coord.x, coord.y); int value = (Integer) feature.getAttribute("value"); cov.evaluate(worldPos, covValues); assertEquals(value, covValues[0]); } } finally { iter.close(); } }
public static GridCoverage2D process( SimpleFeatureCollection features, Object attribute, Dimension gridDim, Envelope bounds, String covName, ProgressListener monitor) throws VectorToRasterException { VectorToRasterProcess process = new VectorToRasterProcess(); return process.convert(features, attribute, gridDim, bounds, covName, monitor); }
VectorToRasterProcess implements VectorProcess { public static GridCoverage2D process( SimpleFeatureCollection features, Object attribute, Dimension gridDim, Envelope bounds, String covName, ProgressListener monitor) throws VectorToRasterException { VectorToRasterProcess process = new VectorToRasterProcess(); return process.convert(features, attribute, gridDim, bounds, covName, monitor); } }
VectorToRasterProcess implements VectorProcess { public static GridCoverage2D process( SimpleFeatureCollection features, Object attribute, Dimension gridDim, Envelope bounds, String covName, ProgressListener monitor) throws VectorToRasterException { VectorToRasterProcess process = new VectorToRasterProcess(); return process.convert(features, attribute, gridDim, bounds, covName, monitor); }  }
VectorToRasterProcess implements VectorProcess { public static GridCoverage2D process( SimpleFeatureCollection features, Object attribute, Dimension gridDim, Envelope bounds, String covName, ProgressListener monitor) throws VectorToRasterException { VectorToRasterProcess process = new VectorToRasterProcess(); return process.convert(features, attribute, gridDim, bounds, covName, monitor); }  static GridCoverage2D process(
            SimpleFeatureCollection features,
            Object attribute,
            Dimension gridDim,
            Envelope bounds,
            String covName,
            ProgressListener monitor); @DescribeResult(name = "result", description = "Rasterized grid") GridCoverage2D execute(
            @DescribeParameter(
                        name = "features",
                        description = "Features to process",
                        min = 1,
                        max = 1
                    )
                    SimpleFeatureCollection features,
            @DescribeParameter(
                        name = "rasterWidth",
                        description = "Width of the output grid in pixels",
                        min = 1,
                        max = 1,
                        minValue = 1
                    )
                    Integer rasterWidth,
            @DescribeParameter(
                        name = "rasterHeight",
                        description = "Height of the output grid in pixels",
                        min = 1,
                        max = 1,
                        minValue = 1
                    )
                    Integer rasterHeight,
            @DescribeParameter(
                        name = "title",
                        description = "Title to use for the output grid",
                        min = 0,
                        max = 1,
                        defaultValue = "raster"
                    )
                    String title,
            @DescribeParameter(
                        name = "attribute",
                        description = "Attribute name to use for the raster cell values",
                        min = 1,
                        max = 1
                    )
                    String attribute,
            @DescribeParameter(
                        name = "bounds",
                        description = "Bounding box of the area to rasterize",
                        min = 0,
                        max = 1
                    )
                    Envelope bounds,
            ProgressListener progressListener); }
VectorToRasterProcess implements VectorProcess { public static GridCoverage2D process( SimpleFeatureCollection features, Object attribute, Dimension gridDim, Envelope bounds, String covName, ProgressListener monitor) throws VectorToRasterException { VectorToRasterProcess process = new VectorToRasterProcess(); return process.convert(features, attribute, gridDim, bounds, covName, monitor); }  static GridCoverage2D process(
            SimpleFeatureCollection features,
            Object attribute,
            Dimension gridDim,
            Envelope bounds,
            String covName,
            ProgressListener monitor); @DescribeResult(name = "result", description = "Rasterized grid") GridCoverage2D execute(
            @DescribeParameter(
                        name = "features",
                        description = "Features to process",
                        min = 1,
                        max = 1
                    )
                    SimpleFeatureCollection features,
            @DescribeParameter(
                        name = "rasterWidth",
                        description = "Width of the output grid in pixels",
                        min = 1,
                        max = 1,
                        minValue = 1
                    )
                    Integer rasterWidth,
            @DescribeParameter(
                        name = "rasterHeight",
                        description = "Height of the output grid in pixels",
                        min = 1,
                        max = 1,
                        minValue = 1
                    )
                    Integer rasterHeight,
            @DescribeParameter(
                        name = "title",
                        description = "Title to use for the output grid",
                        min = 0,
                        max = 1,
                        defaultValue = "raster"
                    )
                    String title,
            @DescribeParameter(
                        name = "attribute",
                        description = "Attribute name to use for the raster cell values",
                        min = 1,
                        max = 1
                    )
                    String attribute,
            @DescribeParameter(
                        name = "bounds",
                        description = "Bounding box of the area to rasterize",
                        min = 0,
                        max = 1
                    )
                    Envelope bounds,
            ProgressListener progressListener);  }