Package org.geotools.coverage.grid

Examples of org.geotools.coverage.grid.GeneralGridEnvelope


      //
      // Reading the coverage
      //
      // /////////////////////////////////////////////////////////
      parameters.put(AbstractGridFormat.READ_GRIDGEOMETRY2D.getName().toString(),
          new GridGeometry2D(new GeneralGridEnvelope(destinationSize), destinationEnvelopeInSourceCRS));
 
      final GridCoverage coverage = coverageReader.read(CoverageUtils.getParameters(
                  coverageReader.getFormat().getReadParameters(), parameters, true));
 
      if ((coverage == null) || !(coverage instanceof GridCoverage2D)) {
          throw new IOException("The requested coverage could not be found.");
      }
 
      /**
       * Band Select
       */
      /*
      Coverage bandSelectedCoverage = null;
 
      bandSelectedCoverage = WCSUtils.bandSelect(request.getParameters(), coverage);
    */
      /**
       * Crop
       */
      final GridCoverage2D croppedGridCoverage = WCSUtils.crop(coverage,
              (GeneralEnvelope) coverage.getEnvelope(), cvCRS, destinationEnvelopeInSourceCRS,
              Boolean.TRUE);
 
      /**
       * Scale/Resampling (if necessary)
       */
      GridCoverage2D subCoverage = croppedGridCoverage;
      final GeneralGridEnvelope newGridrange = new GeneralGridEnvelope(destinationSize);
 
      /*if (!newGridrange.equals(croppedGridCoverage.getGridGeometry()
                      .getGridRange())) {*/
      subCoverage = WCSUtils.scale(croppedGridCoverage, newGridrange, croppedGridCoverage, cvCRS,
              destinationEnvelopeInSourceCRS);
View Full Code Here


                    new SingleValueConverterWrapper( new SRSConverter() ));
                reader.moveUp();
            }
           
            // new grid range
            GeneralGridEnvelope gridRange = new GeneralGridEnvelope(low, high);
           
           
            GridGeometry2D gg = new GridGeometry2D( gridRange, gridToCRS, crs );
            return serializationMethodInvoker.callReadResolve(gg);
        }
View Full Code Here

        //
        // Reading the coverage
        //
        // /////////////////////////////////////////////////////////
        parameters.put(AbstractGridFormat.READ_GRIDGEOMETRY2D.getName().toString(),
            new GridGeometry2D(new GeneralGridEnvelope(destinationSize), destinationEnvelopeInSourceCRS));

        final GridCoverage coverage = coverageReader.read(CoverageUtils.getParameters(
                    coverageReader.getFormat().getReadParameters(), parameters, true));

        if ((coverage == null) || !(coverage instanceof GridCoverage2D)) {
            throw new IOException("The requested coverage could not be found.");
        }

        /**
         * Band Select
         */
        Coverage bandSelectedCoverage = null;

        bandSelectedCoverage = WCSUtils.bandSelect(request.getParameters(), coverage);

        /**
         * Crop
         */
        final GridCoverage2D croppedGridCoverage = WCSUtils.crop(bandSelectedCoverage,
                (GeneralEnvelope) coverage.getEnvelope(), cvCRS, destinationEnvelopeInSourceCRS,
                Boolean.TRUE);

        /**
         * Scale/Resampling (if necessary)
         */
        GridCoverage2D subCoverage = croppedGridCoverage;
        final GeneralGridEnvelope newGridrange = new GeneralGridEnvelope(destinationSize);

        /*if (!newGridrange.equals(croppedGridCoverage.getGridGeometry()
                        .getGridRange())) {*/
        subCoverage = WCSUtils.scale(croppedGridCoverage, newGridrange, croppedGridCoverage, cvCRS,
                destinationEnvelopeInSourceCRS);
View Full Code Here

        Map grid = cInfoReader.grid();
        if ( grid != null ) {
            int[] low = (int[]) grid.get( "low" );
            int[] high = (int[]) grid.get( "high" );
           
            GeneralGridEnvelope range = new GeneralGridEnvelope(low, high);
           
            Map<String,Double> tx = (Map<String, Double>) grid.get( "geoTransform" );
            if ( tx != null ) {
                double[] matrix = new double[3 * 3];
                matrix[0] = tx.get( "scaleX") != null ? tx.get( "scaleX") : matrix[0];
                matrix[1] = tx.get( "shearX") != null ? tx.get( "shearX") : matrix[1];
                matrix[2] = tx.get( "translateX") != null ? tx.get( "translateX") : matrix[2];
                matrix[3] = tx.get( "shearY") != null ? tx.get( "shearY") : matrix[3];
                matrix[4] = tx.get( "scaleY") != null ? tx.get( "scaleY") : matrix[4];
                matrix[5] = tx.get( "translateY") != null ? tx.get( "translateY") : matrix[5];
                matrix[8] = 1.0;
               
                MathTransform gridToCRS = new DefaultMathTransformFactory()
                    .createAffineTransform( new GeneralMatrix(3,3,matrix));
                coverage.setGrid( new GridGeometry2D(range,gridToCRS,crs) );
            }
            else {
                coverage.setGrid( new GridGeometry2D( range, gridEnvelope ) );
            }
        }
        else {
            // new grid range
            GeneralGridEnvelope range = new GeneralGridEnvelope(new int[] { 0,
                    0 }, new int[] { 1, 1 });
            coverage.setGrid( new GridGeometry2D(range, gridEnvelope) );
        }
       
        for ( Iterator x = cInfoReader.coverageDimensions().iterator(); x   .hasNext(); ) {
View Full Code Here

                maxy = Math.max(maxy, (int) Math.ceil(rasterGridRangeInDataSet.getMaximum(1)));
            }
            int width = maxx - minx;
            int height = maxy - miny;
            Rectangle range = new Rectangle(0, 0, width, height);
            originalGridRange = new GeneralGridEnvelope(range, 2);
        }
        return originalGridRange;
    }
View Full Code Here

            grid.setSrsName(node.getAttributeValue("srsName").toString());
        }
       
        grid.setDimension((BigInteger) node.getAttribute("dimension").getValue());

        GeneralGridEnvelope limitsEnvelope = (GeneralGridEnvelope) node.getChildValue("limits");
       
//        GridLimitsType limits = Gml4wcsFactory.eINSTANCE.createGridLimitsType();
//        GridEnvelopeType gridEnelope = Gml4wcsFactory.eINSTANCE.createGridEnvelopeType();
//        List l = new ArrayList();
//             l.add(limitsEnvelope.getLow(0));
//             l.add(limitsEnvelope.getLow(1));
//        List h = new ArrayList();
//             h.add(limitsEnvelope.getHigh(0));
//             h.add(limitsEnvelope.getHigh(1));

        grid.setDimension(BigInteger.valueOf(2));
        grid.setLimits(new GridEnvelope2D(
                (int)limitsEnvelope.getLow(0), (int)limitsEnvelope.getLow(1),
                (int)limitsEnvelope.getHigh(0), (int)limitsEnvelope.getHigh(1))
        );
       
        List<Node> axisNames = node.getChildren("axisName");
        if (axisNames != null && !axisNames.isEmpty()) {
            for (Node axisName : axisNames) {
View Full Code Here

            throws Exception {
        if (node.getChild("low") != null) {
            int[] l = (int[]) node.getChildValue("low");
            int[] h = (int[]) node.getChildValue("high");

            GridEnvelope envelope = new GeneralGridEnvelope(l, h, true);
            return envelope;
        }

        return null;
    }
View Full Code Here

      _Ny = H / dx;
      Ny = (int) (_Ny + 0.5);
    }

    // new grid range
    final GeneralGridEnvelope newGridrange = new GeneralGridEnvelope(new int[] {0, 0 }, new int[] { Nx, Ny });
    final GridGeometry2D newGridGeometry = new GridGeometry2D(newGridrange,new GeneralEnvelope(gc.getEnvelope()));

    // /////////////////////////////////////////////////////////////////////
    //
    // Reshaping using the resample operation for having best precision.
View Full Code Here

            if (!needsReprojection) {

                // now get the requested bbox which have been already adjusted and project it back
                // to raster space
                computedRasterArea = new GeneralGridEnvelope(CRS.transform(requestedWorldToGrid,
                        new GeneralEnvelope(computedBBox)), PixelInCell.CELL_CORNER, false)
                        .toRectangle();

            } else {
                //
                // reproject the crop bbox back in the requested crs and then crop, notice that we
                // are imposing
                // the same raster area somehow
                //

                final GeneralEnvelope cropBBOXInRequestCRS = CRS
                        .transform(computedBBox, requestCRS);
                // make sure it falls within the requested envelope
                cropBBOXInRequestCRS.intersect(requestedBBox);

                // now go back to raster space
                computedRasterArea = new GeneralGridEnvelope(CRS.transform(requestedWorldToGrid,
                        cropBBOXInRequestCRS), PixelInCell.CELL_CORNER, false).toRectangle();
                // intersect with the original requested raster space to be sure that we stay within
                // the requested raster area
                XRectangle2D.intersect(computedRasterArea, requestedRasterArea, computedRasterArea);
View Full Code Here

        if (destinationToSourceTransform == null || destinationToSourceTransform.isIdentity()) {

            // now get the requested bbox which have been already adjusted and project it back to
            // raster space
            try {
                destinationRasterArea = new GeneralGridEnvelope(CRS.transform(requestedWorldToGrid,
                        new GeneralEnvelope(cropBBox)), PixelInCell.CELL_CORNER, false)
                        .toRectangle();
            } catch (IllegalStateException e) {
                throw new DataSourceException(e);
            } catch (TransformException e) {
                throw new DataSourceException(e);
            }
        } else {
            //
            // reproject the crop bbox back and then crop, notice that we are imposing
            //
            try {
                final GeneralEnvelope cropBBOXInRequestCRS = new GeneralEnvelope(CRS.transform(
                        cropBBox, requestCRS));
                cropBBOXInRequestCRS.setCoordinateReferenceSystem(requestedBBox
                        .getCoordinateReferenceSystem());
                // make sure it falls within the requested envelope
                cropBBOXInRequestCRS.intersect(requestedBBox);

                // now go back to raster space
                destinationRasterArea = new GeneralGridEnvelope(CRS.transform(requestedWorldToGrid,
                        cropBBOXInRequestCRS), PixelInCell.CELL_CORNER, false).toRectangle();
                // intersect with the original requested raster space to be sure that we stay within
                // the requested raster area
                XRectangle2D.intersect(destinationRasterArea, requestedRasterArea,
                        destinationRasterArea);
View Full Code Here

TOP

Related Classes of org.geotools.coverage.grid.GeneralGridEnvelope

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.