//
// //
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);