Package org.geotools.coverage.grid

Examples of org.geotools.coverage.grid.GridGeometry2D


        tileSize.setValue("128,128");
       
        useMT.setValue(false);
        useJAI.setValue(true);
        final GeneralEnvelope oldEnvelope = reader.getOriginalEnvelope();
        gg.setValue(new GridGeometry2D(reader.getOriginalGridRange(), oldEnvelope));
       
        // //
        //
        // Reading
        //
View Full Code Here


        final ParameterValue<GridGeometry2D> gg = JP2KFormat.READ_GRIDGEOMETRY2D.createValue();
        final ParameterValue<Boolean> useJAI = JP2KFormat.USE_JAI_IMAGEREAD.createValue();
        useJAI.setValue(false);
        final GeneralEnvelope oldEnvelope = reader.getOriginalEnvelope();
        checkReader(reader);
        gg.setValue(new GridGeometry2D(reader.getOriginalGridRange(), oldEnvelope));
        GridCoverage2D gc = (GridCoverage2D) reader.read(new GeneralParameterValue[] { gg, useJAI});
        assertNotNull(gc);
        forceDataLoading(gc);
       
        // //
        //
        // Testing simple imageRead
        //
        // //

        useJAI.setValue(true);
        final Envelope wgs84Envelope = CRS.transform(oldEnvelope, DefaultGeographicCRS.WGS84);
        gg.setValue(new GridGeometry2D(reader.getOriginalGridRange(), wgs84Envelope));
        gc = (GridCoverage2D) reader.read(new GeneralParameterValue[] {gg, useJAI});
        assertNotNull(gc);
        forceDataLoading(gc);
    }
View Full Code Here

    private void initInputCoverageProperties() throws IOException {
        VariableAdapter.UnidataSpatialDomain spatialDomain = (org.geotools.imageio.netcdf.VariableAdapter.UnidataSpatialDomain) (source.getSpatialDomain());

        // Getting spatial context
        final Set<? extends RasterLayout> rasterElements = spatialDomain.getRasterElements(false, null);
        final GridGeometry2D gridGeometry2D = spatialDomain.getGridGeometry();
        final AffineTransform gridToCRS = (AffineTransform) gridGeometry2D.getGridToCRS();
        final double[] coverageFullResolution = CoverageUtilities.getResolution(gridToCRS);
        final MathTransform raster2Model = gridGeometry2D.getGridToCRS();
        final ReferencedEnvelope bbox = spatialDomain.getReferencedEnvelope();
        final ReferencedEnvelope referencedEnvelope = new ReferencedEnvelope(bbox);
        final CoordinateReferenceSystem spatialReferenceSystem2D = spatialDomain.getCoordinateReferenceSystem2D();
        rasterArea = rasterElements.iterator().next().toRectangle();
View Full Code Here

        final GeneralEnvelope envelope = reader.getOriginalEnvelope();
        final RasterManager manager = new RasterManager(reader);
        final ParameterValue<GridGeometry2D> gg = JP2KFormat.READ_GRIDGEOMETRY2D.createValue();
        final ParameterValue<Boolean> useJAI = JP2KFormat.USE_JAI_IMAGEREAD.createValue();
        useJAI.setValue(false);
        gg.setValue(new GridGeometry2D(reader.getOriginalGridRange(), envelope));
        final GeneralParameterValue[] params = new GeneralParameterValue[] { gg, useJAI};
        final RasterLayerRequest request = new RasterLayerRequest(params, manager);
        final Rectangle area = request.getDestinationRasterArea();
        assertEquals(area.width, 400);
        assertEquals(area.height, 200);
View Full Code Here

        //
        // Requested GridGeometry2D parameter
        //
        // //
        if (name.equals(AbstractGridFormat.READ_GRIDGEOMETRY2D.getName())) {
            final GridGeometry2D gg = (GridGeometry2D) param.getValue();
            if (gg == null) {
                return;
            }

            requestedBBox = new ReferencedEnvelope((Envelope) gg.getEnvelope2D());
            requestedRasterArea = gg.getGridRange2D().getBounds();
            return;
        }

        // //
        //
View Full Code Here

            MathTransform2D mt = coverages.get(0).getGridGeometry().getCRSToGrid2D();
            Rectangle rasterSpaceEnvelope;
            rasterSpaceEnvelope = CRS.transform(mt, targetEnvelope).toRectangle2D().getBounds();
            GridEnvelope2D gridRange = new GridEnvelope2D(rasterSpaceEnvelope);
            GridGeometry2D gridGeometry = new GridGeometry2D(gridRange, targetEnvelope);

            // mosaic
            final ParameterValueGroup param = MOSAIC_PARAMS.clone();
            param.parameter("sources").setValue(coverages);
            param.parameter("geometry").setValue(gridGeometry);
View Full Code Here

        }
   
        return coverageFactory.create(
                rasterManager.getCoverageIdentifier(),
                image,
                new GridGeometry2D(
                        new GridEnvelope2D(PlanarImage.wrapRenderedImage(image).getBounds()),
                        PixelInCell.CELL_CORNER,
                        finalGridToWorldCorner,
                        this.rasterManager.getCoverageCRS(),
                        hints),
View Full Code Here

      // we have at least two sources, let's merge them
      //
      // /////////////////////////////////////////////////////////////////////
      final Iterator<CoverageProcessingNode> it = sources.iterator();
      RenderedImage op = null;
      GridGeometry2D gridGeometry = null;
      ImageLayout layout = null;
      final Hints hints = getHints();
      final List<GridCoverage2D> sourceGridCoverages= new ArrayList<GridCoverage2D>();
      do {
        // //
        //
        // Get the source image and do the merge
        //
        // //
        final CoverageProcessingNode currentSourceNode = (CoverageProcessingNode) it.next();
        final GridCoverage2D currentSourceCoverage = (GridCoverage2D) currentSourceNode.getOutput();
        sourceGridCoverages.add(currentSourceCoverage);
        final GridGeometry2D gg = (GridGeometry2D) currentSourceCoverage.getGridGeometry();
        if (gridGeometry == null) {
          // get the envelope for the first source.
          gridGeometry = gg;

          // color model
          final ComponentColorModel cm = new ComponentColorModel(
              ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB),
              false, false, Transparency.OPAQUE,
              currentSourceCoverage.getRenderedImage()
                  .getSampleModel().getDataType());
          layout = new ImageLayout();
          layout.setColorModel(cm);
        } else if (!gg.equals(gridGeometry))
          throw new IllegalArgumentException(Errors.format(
              ErrorKeys.MUST_SHARE_GRIDGEOMETRY_$1, "BandMerge"));

        // //
        //
View Full Code Here

                        uniform, mapArea, destinationCrs, sourceCrs, screenSize,
                        geometryAttribute, at, hasTransformation);
                Query definitionQuery = getDefinitionQuery(currLayer, featureSource, sourceCrs);
                if(hasTransformation) {
                    // prepare the stage for the raster transformations
                    GridGeometry2D gridGeometry = getRasterGridGeometry(destinationCrs, sourceCrs);
                    // vector transformation wise, we have to account for two separate queries,
                    // the one attached to the layer and then one coming from SLD.
                    // The first source attributes, the latter talks tx output attributes
                    // so they have to be applied before and after the transformation respectively
                   
View Full Code Here

     * @return
     * @throws NoninvertibleTransformException
     */
    GridGeometry2D getRasterGridGeometry(CoordinateReferenceSystem destinationCrs,
            CoordinateReferenceSystem sourceCRS) throws NoninvertibleTransformException {
        GridGeometry2D readGG;
        if (sourceCRS == null || destinationCrs == null ||
                CRS.equalsIgnoreMetadata(destinationCrs, sourceCRS)) {
            readGG = new GridGeometry2D(new GridEnvelope2D(screenSize),
                    originalMapExtent);
        } else {
            // reprojection involved, read a bit more pixels to account for rotation
            Rectangle bufferedTargetArea = (Rectangle) screenSize.clone();
            bufferedTargetArea.add( // exand top/right
                    screenSize.x + screenSize.width + REPROJECTION_RASTER_GUTTER,
                    screenSize.y + screenSize.height + REPROJECTION_RASTER_GUTTER);
            bufferedTargetArea.add( // exand bottom/left
                    screenSize.x - REPROJECTION_RASTER_GUTTER,
                    screenSize.y - REPROJECTION_RASTER_GUTTER);

            // now create the final envelope accordingly
            readGG = new GridGeometry2D(new GridEnvelope2D(bufferedTargetArea),
                    PixelInCell.CELL_CORNER, new AffineTransform2D(
                            worldToScreenTransform.createInverse()),
                    originalMapExtent.getCoordinateReferenceSystem(), null);
        }
        return readGG;
View Full Code Here

TOP

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

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.