Package org.opengis.geometry

Examples of org.opengis.geometry.Envelope


        }
       
        if (tempBBox != null) {
            GeneralEnvelope env;
            try {
                Envelope fixed = CRS.transform( tempBBox, crs );
                env = new GeneralEnvelope( fixed );
            } catch (TransformException e) {
                env = new GeneralEnvelope(new double[] { tempBBox.getMinX(),tempBBox.getMinY() },
                        new double[] { tempBBox.getMaxX(), tempBBox.getMaxY() });
                env.setCoordinateReferenceSystem(crs);
View Full Code Here


     */
    public final Envelope getEnvelope() {
        com.vividsolutions.jts.geom.Geometry jtsGeom = getJTSGeometry();
        com.vividsolutions.jts.geom.Envelope jtsEnv = jtsGeom.getEnvelopeInternal();
        CoordinateReferenceSystem crs = getCoordinateReferenceSystem();
        Envelope result = new EnvelopeImpl(
                new DirectPositionImpl(crs,
                        new double [] { jtsEnv.getMinX(), jtsEnv.getMinY() }),
                new DirectPositionImpl(crs,
                        new double [] { jtsEnv.getMaxX(), jtsEnv.getMaxY() })
        );
View Full Code Here

    /**
     * @inheritDoc
     * @see java.lang.Object#equals(java.lang.Object)
     */
    public boolean equals(final Object obj) {
        final Envelope that = (Envelope) obj;
        return GeometryUtils.equals(this, that);
    }
View Full Code Here

        return location.getOrdinate(0) >= getMinX() && location.getOrdinate(0) <= getMaxX()
                && location.getOrdinate(1) >= getMinY() && location.getOrdinate(1) <= getMaxY();
    }

    public BoundingBox toBounds(CoordinateReferenceSystem targetCRS) throws TransformException {
        Envelope transformed = new GeneralEnvelope((BoundingBox) this);
        transformed = CRS.transform(transformed, targetCRS);
        return new Envelope2D(transformed);
    }
View Full Code Here

        double[] buffer = null;
        final BorderExtender be =  BorderExtender.createInstance(BorderExtender.BORDER_COPY);
        Rectangle  rectangle = PlanarImage.wrapRenderedImage(coverage.getRenderedImage()).getBounds();
        rectangle       = new Rectangle(rectangle.x,rectangle.y,rectangle.width+interpolation.getWidth(), rectangle.height+interpolation.getHeight());
        final Raster          data = PlanarImage.wrapRenderedImage(coverage.getRenderedImage()).getExtendedData(rectangle,be);
        final Envelope    envelope = coverage.getEnvelope();
        final GridEnvelope   range = coverage.getGridGeometry().getGridRange();
        final double          left = envelope.getMinimum(0);
        final double         upper = envelope.getMaximum(1);
        final Point2D.Double point = new Point2D.Double(); // Will maps to pixel upper-left corner
        for (int j=range.getSpan(1); j>=0;--j) {
            for (int i=range.getSpan(0); i>=0;--i) {
                point.x  = left  + PIXEL_SIZE*i;
                point.y  = upper - PIXEL_SIZE*j;
 
View Full Code Here

        final CoverageProcessor processor = CoverageProcessor.getInstance();
        /*
         * Get the source coverage and build the cropped envelope.
         */
        final GridCoverage2D source = coverage.view(ViewType.NATIVE);
        final Envelope oldEnvelope = source.getEnvelope();
        final GeneralEnvelope cropEnvelope = new GeneralEnvelope(new double[] {
                oldEnvelope.getMinimum(0) + oldEnvelope.getSpan(0) * 3 / 8,
                oldEnvelope.getMinimum(1) + oldEnvelope.getSpan(1) * 3 / 8
        }, new double[] {
                oldEnvelope.getMinimum(0) + oldEnvelope.getSpan(0) * 5 / 8,
                oldEnvelope.getMinimum(1) + oldEnvelope.getSpan(1) * 5 / 8
        });
        cropEnvelope.setCoordinateReferenceSystem(oldEnvelope.getCoordinateReferenceSystem());
        /*
         * Do the crop without conserving the envelope.
         */
        ParameterValueGroup param = processor.getOperation("CoverageCrop").getParameters();
        param.parameter("Source").setValue(source);
View Full Code Here

        final CoverageProcessor processor = CoverageProcessor.getInstance();
        /*
         * Get the source coverage and build the cropped envelope.
         */
        final GridCoverage2D source = coverage.view(ViewType.NATIVE);
        final Envelope oldEnvelope = source.getEnvelope();
        final GeneralEnvelope cropEnvelope = new GeneralEnvelope(new double[] {
                oldEnvelope.getMinimum(0) + oldEnvelope.getSpan(0) * 3 / 8,
                oldEnvelope.getMinimum(1) + oldEnvelope.getSpan(1) * 3 / 8
        }, new double[] {
                oldEnvelope.getMinimum(0) + oldEnvelope.getSpan(0) * 5 / 8,
                oldEnvelope.getMinimum(1) + oldEnvelope.getSpan(1) * 5 / 8
        });
        cropEnvelope.setCoordinateReferenceSystem(oldEnvelope.getCoordinateReferenceSystem());
        Envelope2D env2D = new Envelope2D(cropEnvelope);
       
        /*
         * Do the crop without conserving the envelope.
         */
 
View Full Code Here

         * Preparing the crop. We want to get a rectangle that is locate at the
         * center of this coverage envelope that is large 1/4 f the original
         * width and tall 1/4 of the original height.
         */
        final CoverageProcessor processor = CoverageProcessor.getInstance();
        final Envelope oldEnvelope = rotated.getEnvelope();
        final GeneralEnvelope cropEnvelope = new GeneralEnvelope(new double[] {
                oldEnvelope.getMinimum(0) + oldEnvelope.getSpan(0) * 3 / 8,
                oldEnvelope.getMinimum(1) + oldEnvelope.getSpan(1) * 3 / 8
        }, new double[] {
                oldEnvelope.getMinimum(0) + oldEnvelope.getSpan(0) * 5 / 8,
                oldEnvelope.getMinimum(1) + oldEnvelope.getSpan(1) * 5 / 8
        });
        cropEnvelope.setCoordinateReferenceSystem(oldEnvelope.getCoordinateReferenceSystem());
        /*
         * Do the crop without trying to conserve the envelope.
         */
        ParameterValueGroup param = processor.getOperation("CoverageCrop").getParameters();
        param.parameter("Source").setValue(rotated);
View Full Code Here

        /*
         * Get the source coverage and build the cropped envelope.
         */
        final GridCoverage2D source = coverage.view(ViewType.NATIVE);
        final Envelope oldEnvelope = source.getEnvelope();
        final GeneralEnvelope cropEnvelope = new GeneralEnvelope(new double[] {
                oldEnvelope.getMinimum(0) /*+ oldEnvelope.getSpan(0) * 3 / 8*/,
                oldEnvelope.getMinimum(1) /*+ oldEnvelope.getSpan(1) * 3 / 8*/
        }, new double[] {
                oldEnvelope.getMinimum(0) + oldEnvelope.getSpan(0) * 5 / 8,
                oldEnvelope.getMinimum(1) + oldEnvelope.getSpan(1) * 5 / 8
        });
        cropEnvelope.setCoordinateReferenceSystem(oldEnvelope.getCoordinateReferenceSystem());


        GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory( JTSFactoryFinder.EMPTY_HINTS );

        double mid0 = oldEnvelope.getMinimum(0) + oldEnvelope.getSpan(0)/2;
        double mid1 = oldEnvelope.getMinimum(1) + oldEnvelope.getSpan(1)* 4/10;
        double qspan0 = oldEnvelope.getSpan(0) * 2/16;
        double qspan1 = oldEnvelope.getSpan(1) * 2/16;

        double half0 = oldEnvelope.getSpan(0) * 1/10;
        double half1 = oldEnvelope.getSpan(1) * 1/10;

        // overlapping square #1 - rotated by 45deg
        CoordinateSequence cs1 = new CoordinateArraySequence(5);
        cs1.setOrdinate(0, 0, mid0);
        cs1.setOrdinate(0, 1, mid1 + qspan1);
        cs1.setOrdinate(1, 0, mid0 + qspan0);
        cs1.setOrdinate(1, 1, mid1);
        cs1.setOrdinate(2, 0, mid0);
        cs1.setOrdinate(2, 1, mid1 - qspan1);
        cs1.setOrdinate(3, 0, mid0 - qspan0);
        cs1.setOrdinate(3, 1, mid1);
        cs1.setOrdinate(4, 0, mid0);
        cs1.setOrdinate(4, 1, mid1 + qspan1);

        LinearRing shape1 = geometryFactory.createLinearRing(cs1);
        com.vividsolutions.jts.geom.Polygon poly1 = geometryFactory.createPolygon(shape1, null);

        // overlapping square #2
        CoordinateSequence cs2 = new CoordinateArraySequence(5);
        cs2.setOrdinate(0, 0, mid0 + half0);
        cs2.setOrdinate(0, 1, mid1 + half1);
        cs2.setOrdinate(1, 0, mid0 + half0);
        cs2.setOrdinate(1, 1, mid1 - half1);
        cs2.setOrdinate(2, 0, mid0 - half0);
        cs2.setOrdinate(2, 1, mid1 - half1);
        cs2.setOrdinate(3, 0, mid0 - half0);
        cs2.setOrdinate(3, 1, mid1 + half1);
        cs2.setOrdinate(4, 0, mid0 + half0);
        cs2.setOrdinate(4, 1, mid1 + half1);

        LinearRing shape2 = geometryFactory.createLinearRing(cs2);
        com.vividsolutions.jts.geom.Polygon poly2 = geometryFactory.createPolygon(shape2, null);

        // Disjuncted square lower left -- will be included
        CoordinateSequence cs3 = new CoordinateArraySequence(5);
        cs3.setOrdinate(0, 0, oldEnvelope.getMinimum(0));
        cs3.setOrdinate(0, 1, oldEnvelope.getMinimum(1));
        cs3.setOrdinate(1, 0, oldEnvelope.getMinimum(0) + oldEnvelope.getSpan(0) / 8);
        cs3.setOrdinate(1, 1, oldEnvelope.getMinimum(1));
        cs3.setOrdinate(2, 0, oldEnvelope.getMinimum(0) + oldEnvelope.getSpan(0) / 8);
        cs3.setOrdinate(2, 1, oldEnvelope.getMinimum(1) + oldEnvelope.getSpan(1) / 8);
        cs3.setOrdinate(3, 0, oldEnvelope.getMinimum(0) );
        cs3.setOrdinate(3, 1, oldEnvelope.getMinimum(1) + oldEnvelope.getSpan(1) / 8);
        cs3.setOrdinate(4, 0, oldEnvelope.getMinimum(0));
        cs3.setOrdinate(4, 1, oldEnvelope.getMinimum(1));

        LinearRing shape3 = geometryFactory.createLinearRing(cs3);
        com.vividsolutions.jts.geom.Polygon poly3 = geometryFactory.createPolygon(shape3, null);

        // Disjuncted square lower right -- will be excluded by Envelope
        CoordinateSequence cs4 = new CoordinateArraySequence(5);
        cs4.setOrdinate(0, 0, oldEnvelope.getMaximum(0));
        cs4.setOrdinate(0, 1, oldEnvelope.getMinimum(1));
        cs4.setOrdinate(1, 0, oldEnvelope.getMaximum(0) - oldEnvelope.getSpan(0) / 8);
        cs4.setOrdinate(1, 1, oldEnvelope.getMinimum(1));
        cs4.setOrdinate(2, 0, oldEnvelope.getMaximum(0) - oldEnvelope.getSpan(0) / 8);
        cs4.setOrdinate(2, 1, oldEnvelope.getMinimum(1) + oldEnvelope.getSpan(1) / 8);
        cs4.setOrdinate(3, 0, oldEnvelope.getMaximum(0) );
        cs4.setOrdinate(3, 1, oldEnvelope.getMinimum(1) + oldEnvelope.getSpan(1) / 8);
        cs4.setOrdinate(4, 0, oldEnvelope.getMaximum(0));
        cs4.setOrdinate(4, 1, oldEnvelope.getMinimum(1));

        LinearRing shape4 = geometryFactory.createLinearRing(cs4);
        com.vividsolutions.jts.geom.Polygon poly4 = geometryFactory.createPolygon(shape4, null);

        Geometry mpoly = geometryFactory.createMultiPolygon(new com.vividsolutions.jts.geom.Polygon[]{poly1, poly2});
View Full Code Here

        if (env != null) {
            // Try to get a valid extent for the CRS and use this to
            // determine num coordinate digits
            CoordinateReferenceSystem crs = env.getCoordinateReferenceSystem();
            if (crs != null) {
                Envelope validExtent = CRS.getEnvelope(crs);
                if (validExtent != null) {
                    len = getMaxIntegerLen(validExtent);
                }
            }
View Full Code Here

TOP

Related Classes of org.opengis.geometry.Envelope

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.