/** * description: the following TIFFKeys count as indicator if a TIFF-File carries GeoTIFF * information: <br> * ModelPixelScaleTag = 33550 (SoftDesk) <br> * ModelTransformationTag = 34264 (JPL Carto Group) <br> * ModelTiepointTag = 33922 (Intergraph) <br> * GeoKeyDirectoryTag = 34735 (SPOT) <br> * GeoDoubleParamsTag = 34736 (SPOT) <br> * GeoAsciiParamsTag = 34737 (SPOT) */ private boolean isGeoTiff(TIFFImage image) { TIFFDirectory directory = (TIFFDirectory) image.getProperty("tiff_directory"); if (directory.getField(GeoTiffTag.ModelPixelScaleTag) == null && directory.getField(GeoTiffTag.ModelTransformationTag) == null && directory.getField(GeoTiffTag.ModelTiepointTag) == null && directory.getField(GeoTiffTag.GeoKeyDirectoryTag) == null && directory.getField(GeoTiffTag.GeoDoubleParamsTag) == null && directory.getField(GeoTiffTag.GeoAsciiParamsTag) == null) { return false; } return true; }
/** * @param file * @throws FileNotFoundException * @throws IOException * @throws GeoTiffException */ public GeoTiffReader(File file) throws FileNotFoundException, IOException, GeoTiffException { TIFFDecodeParam decodeParam = new TIFFDecodeParam(); int geodirectory = 0; FileInputStream fis = new FileInputStream(file); FileCacheSeekableStream fcss = new FileCacheSeekableStream(fis); this.image = new TIFFImage(fcss, decodeParam, geodirectory); if (!isGeoTiff(this.image)) { throw new GeoTiffException("GeoTiffReader: TIFF is no GeoTIFF image!"); } this.tifdir = (TIFFDirectory) image.getProperty("tiff_directory"); if (this.tifdir.getField(GeoTiffTag.GeoKeyDirectoryTag) != null) { setGeoKeyDirectoryTag(); } fcss.close(); }