Package org.geotools.coverage.grid.io.imageio.geotiff

Examples of org.geotools.coverage.grid.io.imageio.geotiff.GeoTiffIIOMetadataDecoder


        coverage.dispose(true);
       
        // getting a reader
        reader = new GeoTiffReader(output);

        GeoTiffIIOMetadataDecoder metadata = reader.getMetadata();
        String readSoftware = metadata.getAsciiTIFFTag(Integer.toString(BaselineTIFFTagSet.TAG_SOFTWARE));
        assertTrue(software.equalsIgnoreCase(readSoftware));
        String readCopyright = metadata.getAsciiTIFFTag(Integer.toString(BaselineTIFFTagSet.TAG_COPYRIGHT));
        assertTrue(copyrightInfo.equalsIgnoreCase(readCopyright));
       
        reader.dispose();
    }
View Full Code Here


      if(metadata==null)
        return false;
      //
      // parse metadata and be resilient with CRS
      //
      final GeoTiffIIOMetadataDecoder metadataAdapter = new GeoTiffIIOMetadataDecoder(metadata);
      if(!metadataAdapter.hasGeoKey()&& LOGGER.isLoggable(Level.FINE))
                            LOGGER.fine("Unable to find geokey directory for this tif file");
         
     
      //
      // analyze georeferencing
      //
      // do we have verything as geotiff?
      if(metadataAdapter.hasModelTrasformation()|| (metadataAdapter.hasPixelScales()&&metadataAdapter.hasTiePoints()))
          return true;
     
      // now look for info into a WLD file or TAB file
            MathTransform raster2Model = GeoTiffReader.parseWorldFile(o);
            if (raster2Model == null) {
View Full Code Here

            ////
           
            //
            // Now load geotiff metadata
            //
            final GeoTiffIIOMetadataDecoder decoder = new GeoTiffIIOMetadataDecoder(metadata);
           
            //
            // NO DATA
            // 
            if (decoder.hasNoData())
                noDataValue = decoder.getNoData();
           
            // //
            //
            // CRS INFO
            //
            // //
            GeoTiffMetadata2CRSAdapter gtcs = null;
            final Object tempCRS = this.hints.get(Hints.DEFAULT_COORDINATE_REFERENCE_SYSTEM);
            if (tempCRS != null) {
                crs = (CoordinateReferenceSystem) tempCRS;
                if (LOGGER.isLoggable(Level.FINE))
                    LOGGER.log(Level.FINE, "Using forced coordinate reference system");
            } else {

                // metadata decoder
                gtcs=new GeoTiffMetadata2CRSAdapter(hints);
                // check metadata first
                if (decoder.hasGeoKey()&& gtcs != null)
                    try {
                        crs = gtcs.createCoordinateSystem(decoder);
                    } catch (FactoryException e) {
                       throw new IOException(e);
                    }

                if (crs == null)
                    crs = GeoTiffUtils.getCRS(source.getSource());
            }

            if (crs == null){
                if(LOGGER.isLoggable(Level.WARNING)){
                    LOGGER.warning("Coordinate Reference System is not available");
                }
                crs = AbstractGridFormat.getDefaultCRS();
            }
           
            if (gtcs != null&& metadata!=null&& (decoder.hasModelTrasformation()||(decoder.hasPixelScales()&&decoder.hasTiePoints()))) {
                // TODO I hate all thiese casts
                raster2Model = (AffineTransform) GeoTiffMetadata2CRSAdapter.getRasterToModel(decoder);
            } else {
                // TODO I hate all thiese casts               
                raster2Model = (AffineTransform) GeoTiffUtils.parseWorldFile(source);
View Full Code Here

            //
            // //
            inStream.mark();
            reader.setInput(inStream);
            final IIOMetadata iioMetadata = reader.getImageMetadata(0);
            final GeoTiffIIOMetadataDecoder metadata = new GeoTiffIIOMetadataDecoder(iioMetadata);
            gtcs = new GeoTiffMetadata2CRSAdapter(hints);
           
            // //
            //
            // get the CRS INFO
            //
            // //
            final Object tempCRS = this.hints.get(Hints.DEFAULT_COORDINATE_REFERENCE_SYSTEM);
            if (tempCRS != null) {
                this.crs = (CoordinateReferenceSystem) tempCRS;
                if (LOGGER.isLoggable(Level.FINE))
                    LOGGER.log(Level.FINE, "Using forced coordinate reference system");
            } else {
             
              // check external prj first
              crs = getCRS(source);
                               
              // now, if we did not want to override the inner CRS or we did not have any external PRJ at hand
              // let's look inside the geotiff
                if (!OVERRIDE_INNER_CRS || crs==null){
                  if(metadata.hasGeoKey()&& gtcs != null){
                      crs = gtcs.createCoordinateSystem(metadata);
                  }
                }


            }

            //
            // No data
            //
            if (metadata.hasNoData()){
                noData = metadata.getNoData();
            }
           
            //
            // parse and set layout
            //
            setLayout(reader);
           
            // //
            //
            // get the dimension of the hr image and build the model as well as
            // computing the resolution
            // //
            numOverviews = reader.getNumImages(true) - 1;
            int hrWidth = reader.getWidth(0);
            int hrHeight = reader.getHeight(0);
            final Rectangle actualDim = new Rectangle(0, 0, hrWidth, hrHeight);
            originalGridRange = new GridEnvelope2D(actualDim);

            if (gtcs != null&& metadata!=null&& (metadata.hasModelTrasformation()||(metadata.hasPixelScales()&&metadata.hasTiePoints()))) {
                this.raster2Model = GeoTiffMetadata2CRSAdapter.getRasterToModel(metadata);
            } else {
              // world file
                this.raster2Model = parseWorldFile(source);
               
View Full Code Here

     * Returns the geotiff metadata for this geotiff file.
     *
     * @return the metadata
     */
    public GeoTiffIIOMetadataDecoder getMetadata() {
        GeoTiffIIOMetadataDecoder metadata = null;
        ImageReader reader = null;
        boolean closeMe = true;
        ImageInputStream stream = null;
       
        try {
            if ((source instanceof InputStream)|| (source instanceof ImageInputStream)){
                closeMe = false;
            }
            if (source instanceof ImageInputStream ) {
                    stream =(ImageInputStream) source;
            } else {
                inStreamSPI = ImageIOExt.getImageInputStreamSPI(source);
                if (inStreamSPI == null) {
                    throw new IllegalArgumentException("No input stream for the provided source");
                }
                stream = inStreamSPI.createInputStreamInstance(source, ImageIO.getUseCache(), ImageIO.getCacheDirectory());
            }
            if (stream == null) {
                    throw new IllegalArgumentException("No input stream for the provided source");
            }
            stream.mark();
            reader = READER_SPI.createReaderInstance();
            reader.setInput(stream);
            final IIOMetadata iioMetadata = reader.getImageMetadata(0);
            metadata = new GeoTiffIIOMetadataDecoder(iioMetadata);
        } catch (IOException e) {
            if (LOGGER.isLoggable(Level.SEVERE)) {
                LOGGER.log(Level.SEVERE, e.getMessage(), e);
            }
        } finally {
View Full Code Here

     final ByteArrayInputStream inputStream = new ByteArrayInputStream(uuid.getData());
         final TIFFImageReader tiffreader = (TIFFImageReader) new TIFFImageReaderSpi().createReaderInstance();
         tiffreader.setInput(ImageIO.createImageInputStream(inputStream));
         final IIOMetadata tiffmetadata = tiffreader.getImageMetadata(0);
         try {
            final GeoTiffIIOMetadataDecoder metadataDecoder = new GeoTiffIIOMetadataDecoder(tiffmetadata);
            final GeoTiffMetadata2CRSAdapter adapter = new GeoTiffMetadata2CRSAdapter(hints);
             coordinateReferenceSystem = adapter.createCoordinateSystem(metadataDecoder);
             if (coordinateReferenceSystem != null) {
               if (this.crs == null)
                 this.crs = coordinateReferenceSystem;
View Full Code Here

    // get the METADATA
    //
    // //
    reader.setInput(inStream);
    final IIOMetadata iioMetadata = reader.getImageMetadata(0);
    metadata = new GeoTiffIIOMetadataDecoder(iioMetadata);
    gtcs = (GeoTiffMetadata2CRSAdapter) GeoTiffMetadata2CRSAdapter.get(hints);
    if (metadata.hasNoData())
        noData = metadata.getNoData();
   
View Full Code Here

   * <p>
   * You can check the metadataNames for the set of valid
   * names to use when calling this method.
   */
  public String getMetadataValue(String name) {
    GeoTiffIIOMetadataDecoder decoder = getMetadata();

    return super.getMetadataValue(name);
  }
View Full Code Here

TOP

Related Classes of org.geotools.coverage.grid.io.imageio.geotiff.GeoTiffIIOMetadataDecoder

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.