Package org.geotools.geometry

Examples of org.geotools.geometry.Envelope2D


        param.parameter(Mosaic.POLICY).setValue("fine");
        // Mosaic
        GridCoverage2D mosaic = (GridCoverage2D) processor.doOperation(param);

        // Check that the final GridCoverage BoundingBox is equal to the union of the separate coverages bounding box
        Envelope2D expected = coverage1.getEnvelope2D();
        expected.include(resampled.getEnvelope2D());
        // Mosaic Envelope
        Envelope2D actual = mosaic.getEnvelope2D();

        // Check the same Bounding Box
        assertEqualBBOX(expected, actual);

        // Check that the final Coverage resolution is equal to that of the second coverage
        double initialRes = calculateResolution(resampled);
        double finalRes = calculateResolution(mosaic);
        double percentual = Math.abs(initialRes - finalRes) / initialRes;
        Assert.assertTrue(percentual < TOLERANCE);

        // Check that on the center of the image there are nodata
        DirectPosition point = new DirectPosition2D(mosaic.getCoordinateReferenceSystem(),
                actual.getCenterX(), actual.getCenterY());
        double nodata = CoverageUtilities.getBackgroundValues(coverage1)[0];
        double result = ((int[]) mosaic.evaluate(point))[0];
        Assert.assertEquals(nodata, result, TOLERANCE);

        // Check that on the Upper Left border pixel there is valid data
        point = new DirectPosition2D(mosaic.getCoordinateReferenceSystem(), actual.getMinX()
                + finalRes, actual.getMinY() + finalRes);
        result = ((int[]) mosaic.evaluate(point))[0];
        Assert.assertNotEquals(nodata, result, TOLERANCE);

        // Coverage and RenderedImage disposal
        mosaic.dispose(true);
View Full Code Here


        // Mosaic operation
        GridCoverage2D mosaic = mosaic(sortCoverages(Arrays.asList(c1, shifted)),
                new GeneralEnvelope(reUnion), new Hints());

        // Ensure the mosaic Bounding box is equal to that expected
        Envelope2D expected = new Envelope2D(reUnion);
        assertEqualBBOX(expected, mosaic.getEnvelope2D());

        // Check that the final Coverage resolution is equal to that of the first coverage
        double finalRes = calculateResolution(mosaic);

        // Check that on the center of the image there is valid data
        DirectPosition point = new DirectPosition2D(mosaic.getCoordinateReferenceSystem(),
                expected.getCenterX(), expected.getCenterY());
        double nodata = 0;
        double result = ((byte[]) mosaic.evaluate(point))[0];
        Assert.assertNotEquals(nodata, result, TOLERANCE);

        // Check that on the Upper Left border pixel there is valid data
        point = new DirectPosition2D(mosaic.getCoordinateReferenceSystem(), expected.getMinX()
                + finalRes, expected.getMinY() + finalRes);
        result = ((byte[]) mosaic.evaluate(point))[0];
        Assert.assertNotEquals(nodata, result, TOLERANCE);

        // Check that on the Upper Right border pixel there is valid data
        point = new DirectPosition2D(mosaic.getCoordinateReferenceSystem(), expected.getMaxX()
                - finalRes, expected.getMinY() + finalRes);
        result = ((byte[]) mosaic.evaluate(point))[0];
        Assert.assertNotEquals(nodata, result, TOLERANCE);

        // Coverage and RenderedImage disposal
        mosaic.dispose(true);
View Full Code Here

                DefaultGeographicCRS.WGS84);
        List<GridCoverage2D> sorted = sortCoverages(Arrays.asList(c4, c2, c, c3));
        GridCoverage2D mosaic = mosaic(sorted, new GeneralEnvelope(reUnion), new Hints());

        // Ensure the mosaic Bounding box is equal to that expected
        Envelope2D expected = new Envelope2D(reUnion);
        assertEqualBBOX(expected, mosaic.getEnvelope2D());

        // Calculate the mosaic resolution
        double res = calculateResolution(mosaic);
View Full Code Here

                // We exploit the clamping capabilities of the sample model.
                raster.setSample(x, y, 0, x + y);
            }
        }
        final CoordinateReferenceSystem crs = DefaultGeographicCRS.WGS84;
        final Envelope envelope = new Envelope2D(crs, 0, 0, 30, 30);
        final GridCoverageFactory factory = CoverageFactoryFinder.getGridCoverageFactory(null);
        return factory.create("My grayscale float coverage", raster, envelope);
    }
View Full Code Here

        /*
         * Create the ROI as a JTS polygon.
         */
        final PrecisionModel   pm = new PrecisionModel();
        final GeometryFactory  gf = new GeometryFactory(pm, 0);
        final Envelope2D envelope = sampleFloatCoverage.getEnvelope2D();
        final double minX = envelope.getMinX();
        final double minY = envelope.getMinY();
        final double maxX = envelope.getCenterX();
        final double maxY = envelope.getCenterY();
        final Coordinate[] corners = new Coordinate[] {
                new Coordinate(minX, minY),
                new Coordinate(maxX, minY),
                new Coordinate(maxX, maxY),
                new Coordinate(minX, maxY),
View Full Code Here

        /*
         * Create the ROI as a JTS polygon.
         */
        final PrecisionModel   pm = new PrecisionModel();
        final GeometryFactory  gf = new GeometryFactory(pm, 0);
        final Envelope2D envelope = sampleByteCoverage.getEnvelope2D();
        final double minX = envelope.getMinX();
        final double maxY = envelope.getMaxY();
        final double minY = maxY - envelope.getHeight() / 16;
        final double maxX = minX + envelope.getWidth()  / 16;
        final Coordinate[] coord = new Coordinate[] {
                new Coordinate(minX, maxY),
                new Coordinate(maxX, maxY),
                new Coordinate(maxX, minY),
                new Coordinate(minX, minY),
View Full Code Here

        hints.put(JAI.KEY_IMAGE_LAYOUT, il);
        // Mosaic operation
        GridCoverage2D mosaic = (GridCoverage2D) processor.doOperation(param, hints);

        // Check that the final GridCoverage BoundingBox is equal to the union of the separate coverages bounding box
        Envelope2D expected = coverage1.getEnvelope2D();
        expected.include(coverage2.getEnvelope2D());
        // Mosaic Envelope
        Envelope2D actual = mosaic.getEnvelope2D();

        // Check the same Bounding Box
        assertEqualBBOX(expected, actual);

        // Check that the final Coverage resolution is equal to that of the first coverage
        double initialRes = calculateResolution(coverage1);
        double finalRes = calculateResolution(mosaic);
        double percentual = Math.abs(initialRes - finalRes) / initialRes;
        Assert.assertTrue(percentual < TOLERANCE);

        // Check that on the center of the image there are nodata
        DirectPosition point = new DirectPosition2D(mosaic.getCoordinateReferenceSystem(),
                actual.getCenterX(), actual.getCenterY());
        double nodata = CoverageUtilities.getBackgroundValues(coverage1)[0];
        double result = ((int[]) mosaic.evaluate(point))[0];
        Assert.assertEquals(nodata, result, TOLERANCE);

        // Check that on the Upper Left border pixel there is valid data
        point = new DirectPosition2D(mosaic.getCoordinateReferenceSystem(), actual.getMinX()
                + finalRes, actual.getMinY() + finalRes);
        result = ((int[]) mosaic.evaluate(point))[0];
        Assert.assertNotEquals(nodata, result, TOLERANCE);

        // Ensure the Layout is already present after the mosaic
        Assert.assertTrue(hints.containsKey(JAI.KEY_IMAGE_LAYOUT));
View Full Code Here

        param.parameter(Mosaic.OUTNODATA_NAME).setValue(new double[] { nodata });
        // Mosaic
        GridCoverage2D mosaic = (GridCoverage2D) processor.doOperation(param);

        // Check that the final GridCoverage BoundingBox is equal to the union of the separate coverages bounding box
        Envelope2D expected = coverage1.getEnvelope2D();
        expected.include(coverage2.getEnvelope2D());
        // Mosaic Envelope
        Envelope2D actual = mosaic.getEnvelope2D();

        // Check the same Bounding Box
        assertEqualBBOX(expected, actual);

        // Check that the final Coverage resolution is equal to that of the first coverage
        double initialRes = calculateResolution(coverage1);
        double finalRes = calculateResolution(mosaic);
        double percentual = Math.abs(initialRes - finalRes) / initialRes;
        Assert.assertTrue(percentual < TOLERANCE);

        // Check that on the center of the image there are nodata
        DirectPosition point = new DirectPosition2D(mosaic.getCoordinateReferenceSystem(),
                actual.getCenterX(), actual.getCenterY());
        double result = ((int[]) mosaic.evaluate(point))[0];
        Assert.assertEquals(nodata, result, TOLERANCE);

        // Check that on the Upper Left border pixel there is valid data
        point = new DirectPosition2D(mosaic.getCoordinateReferenceSystem(), actual.getMinX()
                + finalRes, actual.getMinY() + finalRes);
        result = ((int[]) mosaic.evaluate(point))[0];
        Assert.assertNotEquals(nodata, result, TOLERANCE);

        // Coverage and RenderedImage disposal
        mosaic.dispose(true);
View Full Code Here

        // Check that the final Coverage Bands are 2
        Assert.assertEquals(2, mosaic.getNumSampleDimensions());

        // Check that the final GridCoverage BoundingBox is equal to the union of the separate coverages bounding box
        Envelope2D expected = coverage3.getEnvelope2D();
        expected.include(coverage4.getEnvelope2D());
        // Mosaic Envelope
        Envelope2D actual = mosaic.getEnvelope2D();

        // Check the same Bounding Box
        assertEqualBBOX(expected, actual);

        // Check that the final Coverage resolution is equal to that of the first coverage
        double initialRes = calculateResolution(coverage3);
        double finalRes = calculateResolution(mosaic);
        double percentual = Math.abs(initialRes - finalRes) / initialRes;
        Assert.assertTrue(percentual < TOLERANCE);

        // Check that on the center of the image there are nodata
        DirectPosition point = new DirectPosition2D(mosaic.getCoordinateReferenceSystem(),
                actual.getCenterX(), actual.getCenterY());
        double nodata = CoverageUtilities.getBackgroundValues(coverage1)[0];
        double result = ((int[]) mosaic.evaluate(point))[0];
        Assert.assertEquals(nodata, result, TOLERANCE);

        // Check that on the Upper Left border pixel there is valid data
        point = new DirectPosition2D(mosaic.getCoordinateReferenceSystem(), actual.getMinX()
                + finalRes, actual.getMinY() + finalRes);
        result = ((int[]) mosaic.evaluate(point))[0];
        Assert.assertNotEquals(nodata, result, TOLERANCE);

        // Coverage and RenderedImage disposal
        mosaic.dispose(true);
View Full Code Here

        sources.add(coverage2);
        // Setting of the sources
        param.parameter("Sources").setValue(sources);

        // Initial Bounding box
        Envelope2D startBBOX = coverage1.getEnvelope2D();
        startBBOX.include(coverage2.getEnvelope2D());
        Envelope2D expected = new Envelope2D(startBBOX);
        Point2D pt = new Point2D.Double(startBBOX.getMaxX() + 1, startBBOX.getMaxY() + 1);
        expected.add(pt);
        // External GridGeometry
        GridGeometry2D ggStart = new GridGeometry2D(PixelInCell.CELL_CORNER, coverage1
                .getGridGeometry().getGridToCRS2D(PixelOrientation.UPPER_LEFT), expected,
                GeoTools.getDefaultHints());

        param.parameter("geometry").setValue(ggStart);
        // Mosaic
        GridCoverage2D mosaic = (GridCoverage2D) processor.doOperation(param);

        // Check that the final GridCoverage BoundingBox is equal to the bounding box provided in input

        // Mosaic Envelope
        Envelope2D actual = mosaic.getEnvelope2D();

        // Check the same Bounding Box
        assertEqualBBOX(expected, actual);

        // Check that the final Coverage resolution is equal to that of the first coverage
        double initialRes = calculateResolution(coverage1);
        double finalRes = calculateResolution(mosaic);
        Assert.assertEquals(initialRes, finalRes, TOLERANCE);

        // Check that on the Upper Right pixel of the image there are nodata
        DirectPosition point = new DirectPosition2D(mosaic.getCoordinateReferenceSystem(),
                actual.getMinX() + finalRes, actual.getMaxY() - finalRes);
        double nodata = CoverageUtilities.getBackgroundValues(coverage1)[0];
        double result = ((int[]) mosaic.evaluate(point))[0];
        Assert.assertEquals(nodata, result, TOLERANCE);

        // Check that on the Upper Left border pixel there is valid data
        point = new DirectPosition2D(mosaic.getCoordinateReferenceSystem(), actual.getMinX()
                + finalRes, actual.getMinY() + finalRes);
        result = ((int[]) mosaic.evaluate(point))[0];
        Assert.assertNotEquals(nodata, result, TOLERANCE);

        // Coverage and RenderedImage disposal
        mosaic.dispose(true);
View Full Code Here

TOP

Related Classes of org.geotools.geometry.Envelope2D

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.