Examples of Envelope2D


Examples of org.geotools.geometry.Envelope2D

        assertTrue(CRS.getMapProjection(nad27Tennessee) instanceof LambertConformal1SP);
    }

    public void testTransformWgs84PolarStereographic() throws Exception {
        CoordinateReferenceSystem crs = CRS.decode("EPSG:3031", true);
        Envelope2D envelope = new Envelope2D(DefaultGeographicCRS.WGS84);
        envelope.add(-180, -90);
        envelope.add(180, 0);
        Envelope transformed = CRS.transform(envelope, crs);
        // the result is a square
        assertEquals(transformed.getMaximum(0), transformed.getMaximum(1), 1d);
        assertEquals(transformed.getMinimum(0), transformed.getMinimum(1), 1d);
        assertEquals(Math.abs(transformed.getMinimum(0)), transformed.getMaximum(0), 1d);
View Full Code Here

Examples of org.geotools.geometry.Envelope2D

        assertEquals(transformed.getMaximum(0), 1.236739621845986E7, 1d);
    }

    public void testTransformPolarStereographicWgs84() throws Exception {
        CoordinateReferenceSystem crs = CRS.decode("EPSG:3031", true);
        Envelope2D envelope = new Envelope2D(crs);
        // random bbox that does include the pole
        envelope.add(-4223632.8125, -559082.03125);
        envelope.add(5053710.9375, 3347167.96875);
        Envelope transformed = CRS.transform(envelope, DefaultGeographicCRS.WGS84);
        // check we got the whole range of longitudes, since the original bbox contains the pole
        assertEquals(-180d, transformed.getMinimum(0), 0d);
        assertEquals(180d, transformed.getMaximum(0), 0d);
        // another bbox
        envelope = new Envelope2D(crs);
        // random bbox that does not include the pole, but it's really just slightly off it
        envelope.add(-10718812.640513, -10006238.053703);
        envelope.add(12228504.561708, -344209.75803081);
        transformed = CRS.transform(envelope, DefaultGeographicCRS.WGS84);
        assertEquals(-90, transformed.getMinimum(1), 0.1d);
    }
View Full Code Here

Examples of org.geotools.geometry.Envelope2D

    }

    public void testTransformPolarStereographicWgs84FalseOrigin() throws Exception {
        // this one has false origins at 6000000/6000000
        CoordinateReferenceSystem crs = CRS.decode("EPSG:3032", true);
        Envelope2D envelope = new Envelope2D(crs);
        envelope.add(5900000, 5900000);
        envelope.add(6100000, 6100000);
        Envelope transformed = CRS.transform(envelope, DefaultGeographicCRS.WGS84);
        // check we got the whole range of longitudes, since the original bbox contains the pole
        assertEquals(-180d, transformed.getMinimum(0), 0d);
        assertEquals(180d, transformed.getMaximum(0), 0d);
    }
View Full Code Here

Examples of org.geotools.geometry.Envelope2D

    }

    public void testTransformPolarStereographicToOther() throws Exception {
        CoordinateReferenceSystem antarcticPs = CRS.decode("EPSG:3031", true);
        CoordinateReferenceSystem australianPs = CRS.decode("EPSG:3032", true);
        Envelope2D envelope = new Envelope2D(antarcticPs);
        envelope.add(-4223632.8125, -559082.03125);
        envelope.add(5053710.9375, 3347167.96875);
        Envelope transformed = CRS.transform(envelope, australianPs);
        // has a false easting and northing, we can only check the spans are equal
        assertEquals(transformed.getSpan(0), transformed.getSpan(1), 1d);

        assertEquals(transformed.getMaximum(0), 1.2309982175378662E7, 1d);
View Full Code Here

Examples of org.geotools.geometry.Envelope2D

            /*
             * the pixel space region that will be extracted. Since the origin
             * is always 0,0, we can continue to see this in world view.
             */
            sourceRegion = new Rectangle(xmin, ymin, (xmax - xmin), ymax - ymin);
            requestedRegionEnvelope = new Envelope2D(crs, requestedWest, requestedSouth, requestedEast - requestedWest,
                    requestedNorth - requestedSouth);

            /*
             * the real world deltas
             */
            xDeltaW = requestedWest - fileWest;
            yDeltaS = requestedSouth - fileSouth;
            xDeltaE = requestedEast - fileEast;
            yDeltaN = requestedNorth - fileNorth;
            // yDelta = requestedNorth - north;

            /*
             * the real world envelope covering the read map part.
             */
            tmpDxW = xDeltaW > 0.0 ? 0.0 : xDeltaW;
            tmpDyS = yDeltaS > 0.0 ? 0.0 : yDeltaS;
            tmpDyN = yDeltaN < 0.0 ? 0.0 : yDeltaN;
            tmpDxE = xDeltaE < 0.0 ? 0.0 : xDeltaE;
            // set the region to the requestedRegion, this value is passed to
            // the coverage to
            // transform the JAI space into the real space.

            /*
             * define the subsampling values. This done starting from the
             * original's image resolution.
             */
            if (!useSubSamplingAsRequestedColsRows) {
                /*
                 * in this case we respect the original subsampling contract.
                 */
                JGrassRegion tmpRegion = new JGrassRegion(region);
                tmpRegion.setWEResolution((fileEast - fileWest) / (double) fileCols);
                tmpRegion.setNSResolution((fileNorth - fileSouth) / (double) fileRows);
                subSamplingX = (int) Math.floor((double) tmpRegion.getCols() / (double) requestedCols);
                subSamplingY = (int) Math.floor((double) tmpRegion.getRows() / (double) requestedRows);
                if (subSamplingX == 0)
                    subSamplingX = 1;
                if (subSamplingY == 0)
                    subSamplingY = 1;
                if (subSamplingX != subSamplingY) {
                    if (subSamplingX < subSamplingY) {
                        subSamplingY = subSamplingX;
                    } else {
                        subSamplingX = subSamplingY;
                    }
                }
            } else {
                /*
                 * in this case the subsampling values are interpreted as
                 * columns and row numbers to be used to calculate the
                 * resolution from the given boundaries.
                 */

                double sourceCols = (requestedEast - requestedWest) / (1 + (xPaddingSx / (xmax - xmin))) / requestedXres;
                double sourceRows = (requestedNorth - requestedSouth) / (1 + (yPaddingTop / (ymax - ymin))) / requestedYres;
                /*
                 * the padding has to be removed since inside the reader
                 * the padding is ignored and non present in the sourceRegion that
                 * is passed.
                 */
                sourceCols = sourceCols + xPaddingSx;
                sourceRows = sourceRows + yPaddingTop;
                subSamplingX = (int) Math.round(sourceCols);
                subSamplingY = (int) Math.round(sourceRows);

                if (subSamplingX < 1) {
                    subSamplingX = 1;
                }
                if (subSamplingY < 1) {
                    subSamplingY = 1;
                }
            }

        } else {
            /*
             * if no region has been requested, the source and requested region
             * are the same, i.e. the whole raster is read and passed.
             */
            requestedRows = fileRows;
            requestedCols = fileCols;
            requestedWest = fileWest;
            requestedEast = fileEast;
            requestedSouth = fileSouth;
            requestedNorth = fileNorth;
            double scaleX = fileCols / (fileEast - fileWest);
            double scaleY = fileRows / (fileNorth - fileSouth);
            double EPS = 1E-6;
            int xmin = (int) Math.floor((requestedWest - fileWest) * scaleX + EPS);
            int xmax = (int) Math.ceil((requestedEast - fileWest) * scaleX - EPS);
            int ymin = (int) Math.floor((fileNorth - requestedNorth) * scaleY + EPS);
            int ymax = (int) Math.ceil((fileNorth - requestedSouth) * scaleY - EPS);
            sourceRegion = new Rectangle(xmin, ymin, (xmax - xmin), ymax - ymin);
            requestedRegionEnvelope = new Envelope2D(crs, requestedWest, requestedSouth, requestedEast - requestedWest,
                    requestedNorth - requestedSouth);

            /*
             * define the subsampling values. This done starting from the
             * original's image resolution.
View Full Code Here

Examples of org.geotools.geometry.Envelope2D

        final BoundingBox bb = sd.getHorizontalExtent();
        boundingBoxesMap.put(coverageName, bb);
        final GeneralEnvelope coverageEnvelope2D = new GeneralEnvelope(bb);
        coverageEnvelope2DMap.put(coverageName, coverageEnvelope2D);
        spatialReferenceSystem2DMap.put(coverageName, coverageEnvelope2D.getCoordinateReferenceSystem());
        final Envelope2D wgs84BaseEnvelope2D = (Envelope2D) Utilities.getEnvelopeAsWGS84(coverageEnvelope2D, true);
        wgs84BaseEnvelope2DMap.put(coverageName, wgs84BaseEnvelope2D);
        baseEnvelope2DMap.put(coverageName, new Envelope2D(coverageEnvelope2D));
    }
View Full Code Here

Examples of org.geotools.geometry.Envelope2D

        // Selection of the first coverage
        GridCoverage2D coverage = sourceCollection.iterator().next();
        // CRS to use. The first CRS is used
        final CoordinateReferenceSystem crs = coverage.getCoordinateReferenceSystem2D();
        // Global bounding Box to use
        Envelope2D globalBbox = new Envelope2D();
        // Transformation choice string parameter
        String transChoice = (String) parameters.parameter(TRANSFORM_CHOICE).getValue();
        // The TransformList object is initilaized to FIRST in order to take the first element.
        TransformList choice = TransformList.FIRST;
        // Setting of the correct TransformList object to use if the parameter is present
        if (transChoice != null && !transChoice.isEmpty()) {
            choice = TransformList.getTransformList(transChoice);
        }

        // Source number
        int size = sourceCollection.size();

        // GridGeometry List for all the sources
        List<GridGeometry2D> gg2D = new ArrayList<GridGeometry2D>(size);

        // Loop through the
        for (GridCoverage2D source : sourceCollection) {
            if (source == null) {
                size--;
                continue;
            }
            // Expand the BBOX for containing all the input Coverages
            globalBbox.include(source.getEnvelope2D());
            // Add the gridGeometry associated to the coverage
            gg2D.add(source.getGridGeometry());
        }

        // Creation of the list of the transformations to use.
View Full Code Here

Examples of org.geotools.geometry.Envelope2D

         */
        RenderingHints hints = ImageUtilities.getRenderingHints(parameters.getSource());
        ImageLayout layout = (hints != null) ? (ImageLayout) hints.get(JAI.KEY_IMAGE_LAYOUT) : null;

        // Selection of the Bounding Box to use if present
        Envelope2D bbox = parameters.bbox;

        if (layout != null) {
            // If BBOX is present the it is added to the layout
            if (bbox != null) {
                updateLayout(parameters, layout, bbox);
View Full Code Here

Examples of org.geotools.geometry.Envelope2D

                cov[i][j] = random.nextFloat();
            }
        }

        DefaultEngineeringCRS b;
        Envelope2D env = new Envelope2D(DefaultEngineeringCRS.CARTESIAN_2D, 1000, 5000, 300, 300);

        return (new GridCoverageFactory()).create("Example", cov, env);
    
    }
View Full Code Here

Examples of org.geotools.geometry.Envelope2D

     *
     */
    public void testIDWWarpGridBuilder() {
        try {
              // Envelope 20*20 km 00
              Envelope env = new Envelope2D(crs, -50, -50, 400000, 200000);
             
              // Generates 15 MappedPositions of approximately 2 m differences
              List<MappedPosition> mp = generateMappedPositions(env, 6, 2, crs);

              WarpGridBuilder builder = new IDWGridBuilder(mp, 5000, 5000, env);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.