45 "ossimTiffOverviewBuilder",
48 static ossimTrace traceDebug(
"ossimTiffOverviewBuilder:debug");
51 static const char COPY_ALL_KW[] =
"copy_all_flag";
52 static const char TEMP_EXTENSION[] =
"temp_extension";
53 static const char INTERNAL_OVERVIEWS_KW[] =
"internal_overviews_flag";
55 #ifdef OSSIM_ID_ENABLED 56 static const char OSSIM_ID[] =
"$Id: ossimTiffOverviewBuilder.cpp 22362 2013-08-07 20:23:22Z dburken $";
75 m_jpegCompressQuality(DEFAULT_COMPRESS_QUALITY),
79 m_outputTileSizeSetFlag(false),
80 m_internalOverviewsFlag(false)
85 <<
"ossimTiffOverviewBuilder::ossimTiffOverviewBuilder DEBUG:\n";
86 #ifdef OSSIM_ID_ENABLED 93 <<
"overview stop dimension: " << m_overviewStopDimension
113 <<
"ossimTiffOverviewBuilder::buildOverview DEBUG:" 114 <<
"\noverview file: " << overview_file.
c_str()
115 <<
"\ncopy_all flag: " << (copy_all?
"true":
"false")
129 static const char MODULE[] =
"ossimTiffOverviewBuilder::execute";
134 << MODULE <<
" ERROR:" 135 <<
"\nError status has been previously set! Returning..." 156 <<
"Source image file and overview file cannot be the same!" 172 outputFileTemp +=
".tmp";
189 <<
"\nCurrent number of reduced res sets: " 191 <<
"\nNumber of required reduced res sets: " << requiedResLevels
192 <<
"\nStarting reduced res set: " << startingResLevel
197 if ( startingResLevel >= requiedResLevels )
200 << MODULE <<
" NOTICE:" 201 <<
"\nImage has required reduced resolution data sets.\nReturning..." 248 << __FILE__ <<
" " << __LINE__ <<
" " << MODULE
249 <<
"\nCannot open file: " << outputFileTemp << std::endl;
264 if (startingResLevel == 0)
271 << __FILE__ <<
" " << __LINE__
272 <<
"\nError copying image!" << std::endl;
275 if (progressListener)
278 delete progressListener;
279 progressListener = 0;
295 if (progressListener)
298 delete progressListener;
299 progressListener = 0;
308 for (
ossim_uint32 i = startingResLevel; i < requiedResLevels; ++i)
324 if ( !
copyR0() && (i <= m_imageHandler->getNumberOfDecimationLevels()) )
332 if ( ih->
open(outputFileTemp) == false )
339 << __FILE__ <<
" " << __LINE__ <<
" " << MODULE
340 <<
"\nCannot open file: " << outputFileTemp << std::endl;
369 << __FILE__ <<
" " << __LINE__ <<
" " << MODULE
370 <<
"\nError creating reduced res set: " << i << std::endl;
380 if (progressListener)
383 delete progressListener;
384 progressListener = 0;
404 if (progressListener)
407 delete progressListener;
408 progressListener = 0;
437 if (progressListener)
440 delete progressListener;
441 progressListener = 0;
465 static const char MODULE[] =
"ossimTiffOverviewBuilder::writeR0";
485 << MODULE <<
" NOTICE: geotiff tags not set." << std::endl;
502 <<
"ossimTiffOverviewBuilder::writeR0 DEBUG:" 503 <<
"\nsamples: " << samples
504 <<
"\nlines: " << lines
505 <<
"\ntilesWide: " << tilesWide
506 <<
"\ntilesHigh: " << tilesHigh
507 <<
"\nnumberOfTiles: " << numberOfTiles
516 for(
int i = 0; i < tilesHigh; ++i)
538 << MODULE <<
" ERROR: reading tile: " << i << std::endl;
558 data =
static_cast<tdata_t
>(t->
getBuf(band));
566 int bytesWritten = 0;
567 bytesWritten = TIFFWriteTile(tif,
577 << MODULE <<
" ERROR:" 578 <<
"Error returned writing tiff tile: " << i
580 <<
"\nBytes written: " << bytesWritten
600 double numTiles = numberOfTiles;
609 if (!TIFFWriteDirectory(tif))
612 << MODULE <<
" Error writing directory!" << std::endl;
631 TIFFCreateDirectory( tif );
714 static const char MODULE[] =
"ossimTiffOverviewBuilder::writeRn";
717 os <<
"creating r" << resLevel <<
"...";
728 if (!
setTags(tif, rect, resLevel))
751 << MODULE <<
" NOTICE: geotiff tags not set." << std::endl;
764 <<
"ossimTiffOverviewBuilder::writeRn DEBUG:" 765 <<
"\noutputTilesWide: " << outputTilesWide
766 <<
"\noutputTilesHigh: " << outputTilesHigh
767 <<
"\nnumberOfTiles: " << numberOfTiles
788 << MODULE <<
" ERROR: reading tile: " << i << std::endl;
798 int bytesWritten = 0;
799 bytesWritten = TIFFWriteTile(tif,
809 << MODULE <<
" ERROR:" 810 <<
"Error returned writing tiff tile: " << i
812 <<
"\nBytes written: " << bytesWritten
833 double numTiles = numberOfTiles;
848 << MODULE <<
" Error writing to TIF file!" << std::endl;
899 TIFFSetField( tif, TIFFTAG_SUBFILETYPE, FILETYPE_REDUCEDIMAGE );
905 <<
"ossimTiffOverviewBuilder::setTags DEBUG:" 906 <<
"\nrrds_level: " << resLevel
907 <<
"\nimageWidth: " << imageWidth
908 <<
"\nimageHeight: " << imageHeight
909 <<
"\nminSampleValue: " << minSampleValue
910 <<
"\nmaxSampleValue: " << maxSampleValue
914 TIFFSetField( tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_SEPARATE );
915 TIFFSetField( tif, TIFFTAG_IMAGEWIDTH, imageWidth);
916 TIFFSetField( tif, TIFFTAG_IMAGELENGTH, imageHeight);
919 TIFFSetField( tif, TIFFTAG_SAMPLESPERPIXEL, samplesPerPixel );
922 TIFFSetField( tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB );
924 TIFFSetField( tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK );
926 TIFFSetField( tif, TIFFTAG_TILEWIDTH,
m_tileWidth );
952 <<
"ossimTiffOverviewBuilder::setTags WARNING:\n" 953 <<
"Compression not set for this data type:\n" 970 TIFFSetField( tif, TIFFTAG_SMINSAMPLEVALUE, minSampleValue );
971 TIFFSetField( tif, TIFFTAG_SMAXSAMPLEVALUE, maxSampleValue );
983 TIFFSetField( tif, TIFFTAG_MINSAMPLEVALUE,
984 static_cast<int>(minSampleValue) );
985 TIFFSetField( tif, TIFFTAG_MAXSAMPLEVALUE,
986 static_cast<int>(maxSampleValue) );
1038 static_cast<ossim_uint64>(1024)*
1040 static_cast<ossim_uint64>(4));
1044 static_cast<ossim_uint64>(bounds.
height())*
1047 getOutputScalarType())));
1049 if((byteCheck*static_cast<ossim_uint64>(2))>fourGigs)
1071 return XTIFFOpen( filename.
c_str(), openMode.
c_str() );
1081 switch (compression_type)
1083 case COMPRESSION_JPEG:
1084 case COMPRESSION_LZW:
1085 case COMPRESSION_DEFLATE:
1086 case COMPRESSION_PACKBITS:
1094 << __FILE__ <<
" " << __LINE__
1095 <<
"\nossimTiffOverviewBuilder::setCompressionType Unsupported compression type: " 1096 << compression_type <<
"\nDefaulting to none." 1105 if (quality > 1 && quality < 101)
1114 <<
"ossimTiffOverviewBuilder::setJpegCompressionQuality\n" 1115 <<
"\nCompression quality of " << quality <<
" is out of range!" 1116 <<
"\nRange is 100 to 1. Current quality set to default of 75." 1176 getFilenameWithThisExtension(
ossimString(
"ovr"), usePrefix);
1192 static const char MODULE[] =
"ossimTiffOverviewBuilder::initializeFromHandler";
1211 <<
"\nSource image is tiled: " 1213 <<
"\nm_imageHandler->getTileWidth(): " 1215 <<
"\nm_imageHandler->getTileHeight(): " 1217 <<
"\nm_imageHandler->getImageTileWidth(): " 1219 <<
"\nm_imageHandler->getImageTileHeight(): " 1278 << MODULE <<
" ERROR:" 1279 <<
"\nUnknow pixel type: " 1305 << MODULE <<
" ERROR:" 1306 <<
"\nSetting image handler as input failed!" 1317 if (type ==
"ossim_tiff_nearest")
1322 else if (type ==
"ossim_tiff_box")
1338 type =
"ossim_tiff_nearest";
1342 type =
"ossim_tiff_box";
1348 std::vector<ossimString>& typeList)
const 1350 typeList.push_back(
ossimString(
"ossim_tiff_box"));
1351 typeList.push_back(
ossimString(
"ossim_tiff_nearest"));
1356 if ( property.
valid() )
1370 else if(value ==
"lzw")
1375 else if(value ==
"deflate")
1379 else if(value ==
"packbits")
1388 else if(property->
getName() == COPY_ALL_KW)
1392 else if(property->
getName() == TEMP_EXTENSION)
1396 else if( property->
getName() == INTERNAL_OVERVIEWS_KW )
1419 propertyNames.push_back(COPY_ALL_KW);
1420 propertyNames.push_back(INTERNAL_OVERVIEWS_KW);
1422 propertyNames.push_back(TEMP_EXTENSION);
1429 if ( (index == 0) &&
1440 bool result =
false;
1450 <<
"Internal overviews opton not supported for class: " 16 bit unsigned integer (15 bits used)
virtual bool open()=0
Pure virtual open.
virtual void valueToString(ossimString &valueResult) const =0
virtual ossimRefPtr< ossimConnectableObject > disconnectMyInput(ossim_int32 inputIndex, bool disconnectOutputFlag=true, bool createEventFlag=true)
Will disconnect the object at the given input index and generate a connection event.
virtual bool addListener(ossimListener *listener)
ossim_int32 m_currentTiffDir
virtual ossimObject * dup() const =0
void setScanForMinMaxNull(bool flag)
Turn on/off scan for min, max, null flag.
ossim_uint32 getRequiredResLevels(const ossimImageHandler *ih) const
Gets the required number of res levels.
ossim_uint32 getNumberOfTilesHorizontal() const
std::basic_ostringstream< char > ostringstream
Class for char output memory streams.
virtual ossim_uint32 getNumberOfBands() const
virtual bool execute()
Calls buildOverview.
static const ossimFilename NIL
This was taken from Wx widgets for performing touch and access date stamps.
bool getCopyAllFlag() const
Method to return copy all flag.
virtual void getTypeNameList(std::vector< ossimString > &typeList) const
Method to populate class supported types.
virtual void disconnect(ossimConnectableObject *object=0)
Will disconnect the object passed in.
bool needsAborting() const
bool getScanForMinMaxNull() const
void barrier()
MPI Barrier method.
virtual ossim_uint32 getNumberOfOutputBands() const
Returns the number of bands in a tile returned from this TileSource.
static const char * OUTPUT_TILE_SIZE_KW
virtual ~ossimTiffOverviewBuilder()
virtual destructor
std::list< ossimListener * > theListenerList
virtual ossimString getEntryString(ossim_int32 entry_number) const
virtual bool setInputSource(ossimImageHandler *imageSource)
Sets the input to the builder.
virtual ossim_uint32 getNumberOfLines(ossim_uint32 resLevel=0) const =0
Pure virtual, derived classes must implement.
bool writeR0(TIFF *tif)
Copy the full resolution image data to the output tif image.
ossim_uint32 height() const
bool buildInternalOverviews() const
ossimString m_tempExtension
void setOutputTileSize(const ossimIpt &tileSize)
virtual ossim_uint32 getTileHeight() const
Returns the default processing tile height.
void setCopyAllFlag(bool flag)
Sets theCopyAllFlag.
virtual void getOutputImageRectangle(ossimIrect &rect) const
Gets the zero-based image rectangle for the output reduced resolution data set (rrds).
OSSIM_DLL void defaultTileSize(ossimIpt &tileSize)
virtual void setPercentComplete(double percentComplete)
bool writeRn(ossimImageHandler *imageHandler, TIFF *tif, ossim_uint32 resLevel, bool firstResLevel)
Write reduced resolution data set to the tif file.
virtual ossimDataObjectStatus getDataObjectStatus() const
ossim_uint32 getNumberOfTilesVertical() const
16 bit unsigned integer (14 bits used)
static const ossimErrorCode OSSIM_ERROR
ossim_uint32 getNumberOfTiles() const
virtual ossimString getClassName() const
16 bit unsigned integer (13 bits used)
virtual ossimString getOverviewType() const
Gets the overview type.
unsigned short ossim_uint16
virtual bool loadState(const ossimKeywordlist &spec, const char *prefix=0)
Computes and writes the mask file according to the specification in the KWL.
virtual void setProcessStatus(ossimProcessStatus processStatus)
virtual void applyScale(const ossimDpt &scale, bool recenterTiePoint)
Applies scale to theDeltaLonPerPixel, theDeltaLatPerPixel and theMetersPerPixel data members (eg: the...
ossim_int32 m_sampleFormat
virtual ossim_uint32 getTileWidth() const
Returns the default processing tile width.
virtual ossim_uint32 getNumberOfDecimationLevels() const
This returns the total number of decimation levels.
virtual double getMinPixelValue(ossim_uint32 band=0) const
Retuns the min pixel value.
void setJpegCompressionQuality(ossim_int32 quality)
Sets the compression quality for use when using a compression type of COMPRESSION_JPEG.
static ossimScalarTypeLut * instance()
Returns the static instance of an ossimScalarTypeLut object.
ossim_int32 m_bytesPerPixel
ossimFilename m_outputFile
void writeHistogram()
Write histogram method.
bool hasModelTransform() const
virtual bool setInputSource(ossimImageHandler *imageSource)
Sets the input to the builder.
ossimKeywordlist m_bitMaskSpec
virtual ossimRefPtr< ossimImageGeometry > getImageGeometry()
Returns the image geometry object associated with this tile source or NULL if non defined...
void setTileSize(const ossimIpt &pt)
updated the tile size.
virtual const ossimFilename & getFilename() const
Returns the filename.
std::string::size_type size() const
TIFF * openTiff(const ossimString &filename) const
static const char * COMPRESSION_TYPE_KW
virtual ossim_uint32 getImageTileHeight() const =0
Returns the tile width of the image or 0 if the image is not tiled.
virtual bool setOutputToInputBandList()
If the image handler "isBandSeletor()" then the band selection of the output are set to input or iden...
unsigned long long ossim_uint64
ossimRefPtr< ossimBitMaskWriter > m_maskWriter
unsigned int ossim_uint32
virtual bool setOverviewType(const ossimString &type)
Sets the overview output type.
bool getInternalOverviewsFlag() const
This is the image handler for providing mask pixels to an ossimMaskFilter object. ...
void setAssociatedMaskWriter(ossimBitMaskWriter *maskWriter)
This class can be used during overview generation, in which case there will be a simultaneous mask wr...
ossimFilterResampler::ossimFilterResamplerType m_resampleType
OSSIM_DLL ossim_uint32 scalarSizeInBytes(ossimScalarType scalarType)
ossimHistogramMode getHistogramMode() const
Gets the histogram accumulation mode.
virtual ossimRefPtr< ossimImageData > getNextTile()
Will allow you to get the next tile in the sequence.
virtual void setProperty(ossimRefPtr< ossimProperty > property)
Method to set properties.
static ossimString downcase(const ossimString &aString)
Class for computing a mask from an input image source and writing the mask file to disk...
virtual ossimIrect getImageRectangle(ossim_uint32 resLevel=0) const
Returns zero-based bounding rectangle of the image.
void setCompressionType(ossim_uint16 compression_type)
Sets the compression type to use when building overviews.
virtual ossim_int32 connectMyInputTo(ossimConnectableObject *inputObject, bool makeOutputConnection=true, bool createEventFlag=true)
Will try to connect this objects input to the passed in object.
virtual ossim_uint32 getNumberOfEntries() const
ossim_uint32 width() const
ossimErrorCode theErrorStatus
void toPoint(const std::string &s)
Initializes this point from string.
ossim_int32 m_jpegCompressQuality
Container class that holds both 2D transform and 3D projection information for an image Only one inst...
ossimRefPtr< ossimImageHandler > m_imageHandler
ossim_int32 m_bitsPerSample
void closeTiff(TIFF *tif)
void setImageHandler(ossimImageHandler *input)
Sets the input source or connection.
ossim_uint16 m_tiffCompressType
virtual bool canConnectMyInputTo(ossim_int32 index, const ossimConnectableObject *obj) const
void generateMask(ossimRefPtr< ossimImageData > tile, ossim_uint32 rLevel)
Given a source's tile, derives the alpha mask and saves it in buffer for later writing to disk...
void setInternalOverviewsFlag(bool flag)
Sets internal overviews flag.
virtual void setOutputFile(const ossimFilename &file)
Sets the output filename.
virtual ossim_uint32 getImageTileWidth() const =0
Returns the tile width of the image or 0 if the image is not tiled.
64 bit normalized floating point
const ossimProjection * getProjection() const
Access methods for projection (may be NULL pointer).
16 bit unsigned integer (11 bits used)
virtual void finalize()
Finalize method.
bool setTags(TIFF *tif, const ossimIrect &outputRect, ossim_int32 resLevel) const
Set the tiff tags for the appropriate resLevel.
virtual bool isImageTiled() const
Indicates whether or not the image is tiled internally.
ossimRefPtr< ossimMaskFilter > m_maskFilter
void setStartingResLevel(ossim_uint32 level)
virtual ossimScalarType getOutputScalarType() const
This will be used to query the output pixel type of the tile source.
This class defines an abstract Handler which all image handlers(loaders) should derive from...
std::vector< ossim_uint8 > m_nullDataBuffer
void setCurrentMessage(const ossimString &message)
ossim_uint32 getStartingResLevel() const
virtual ossim_int32 connectMyInputTo(ossimConnectableObject *inputObject, bool makeOutputConnection=true, bool createEventFlag=true)
Will try to connect this objects input to the passed in object.
virtual const void * getBuf() const
virtual void setErrorStatus() const
void setScanForMinMax(bool flag)
Turn on/off scan for min max flag.
static const char * COMPRESSION_QUALITY_KW
virtual ossimObject * getObject()
void setSourceLevel(ossim_uint32 level)
Sets the input source resolution to decimate from.
virtual void slaveProcessTiles()
This implementation does nothing.
ossim_uint32 getSize() const
bool getScanForMinMax() const
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string's contents...
bool m_outputTileSizeSetFlag
virtual void close()
Writes the mask file to path specified. Returns TRUE if successful.
bool setGeotiffTags(const ossimImageGeometry *geom, const ossimDrect &boundingRect, ossim_uint32 resLevel, TIFF *tif)
Writes geotiff tags.
virtual ossim_uint32 getNumberOfSamples(ossim_uint32 resLevel=0) const =0
Pure virtual, derived classes must implement.
void setHistogramMode(ossimHistogramMode mode)
Sets the histogram accumulation mode.
virtual ossimIrect getBoundingRect(ossim_uint32 resLevel=0) const
Returns zero-based bounding rectangle of the image.
virtual double getMaxPixelValue(ossim_uint32 band=0) const
Returns the max pixel of the band.
#define RTTI_DEF1(cls, name, b1)
bool writeOmdFile(const std::string &file)
Writes an ossim metadata(omd) file with min, max, null values.
bool buildOverview(const ossimFilename &overview_file, bool copy_all=false)
Builds overview file and sets "theOutputFile" to that of the overview_file.
virtual void disconnectAllInputs()
Will disconnect all of the input objects.
void setBitMaskObjects(ossimBitMaskWriter *mask_writer, ossimMaskFilter *mask_filter)
Enabled the generation of an alpha (bit) mask such that any full or partial null pixels will be maske...
virtual ossim_uint32 getNumberOfInputBands() const =0
static const char * OVERVIEW_STOP_DIMENSION_KW
void setResampleType(ossimFilterResampler::ossimFilterResamplerType resampleType)
Supports BOX or NEAREST NEIGHBOR.
ossimFilename & setExtension(const ossimString &e)
Sets the extension of a file name.
static bool writeTags(TIFF *tiffOut, const ossimRefPtr< ossimMapProjectionInfo > projectionInfo, bool imagineNad27Flag=false)
virtual void getPropertyNames(std::vector< ossimString > &propertyNames) const
Method to populate the list of property names.
void setStartingResLevel(ossim_uint32 res_level)
Sets the starting resolution level for the mask.
virtual ossimFilename getOutputFile() const
Gets the output file name.
static ossimMpi * instance()
bool m_internalOverviewsFlag
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
void setResampleType(ossimFilterResampler::ossimFilterResamplerType resampleType)
Sets the resampling type.
virtual void initialize()
This must be called.
bool rename(const ossimFilename &destFile, bool overwriteDestinationFlag=true) const
ossim_uint32 m_overviewStopDimension
const ossimString & getName() const
virtual ossimRefPtr< ossimImageData > getTile(const ossimIpt &origin, ossim_uint32 resLevel=0)
void setMaskSource(ossimImageSource *maskSource)
This set method is necessary when this object is being added to an ossimImageChain because ossimImage...
16 bit unsigned integer (12 bits used)
ossimTiffOverviewBuilder()
default constructor
virtual bool removeListener(ossimListener *listener)
ossim_int32 m_tileSizeInBytes