50 static ossimTrace traceDebug(
"ossimImageFileWriter:debug");
51 static const ossimString AUTO_CREATE_DIRECTORY_KW(
"auto_create_directory");
54 static const char OSSIM_ID[] =
"$Id: ossimImageFileWriter.cpp 23068 2015-01-07 23:08:29Z okramer $";
58 "ossimImageFileWriter",
63 static const char SCALE_TO_EIGHT_BIT_KW[] =
"scale_to_eight_bit";
75 theViewController(NULL),
76 theProgressListener(NULL),
79 theWriteImageFlag(
true),
80 theWriteOverviewFlag(false),
81 theWriteHistogramFlag(false),
82 theScaleToEightBitFlag(false),
84 theOverviewJpegCompressQuality(75),
85 theWriteEnviHeaderFlag(false),
86 theWriteErsHeaderFlag(false),
87 theWriteExternalGeometryFlag(false),
88 theWriteFgdcFlag(false),
89 theWriteJpegWorldFileFlag(false),
90 theWriteReadmeFlag(false),
91 theWriteTiffWorldFileFlag(false),
92 theWriteWorldFileFlag(false),
93 theAutoCreateDirectoryFlag(
true),
100 <<
"ossimImageFileWriter::ossimImageFileWriter entered..." 102 #ifdef OSSIM_ID_ENABLED 104 <<
"OSSIM_ID: " << OSSIM_ID << std::endl;
170 const char* prefix)
const 203 "create_jpeg_world_file",
213 "create_tiff_world_file",
238 SCALE_TO_EIGHT_BIT_KW,
242 AUTO_CREATE_DIRECTORY_KW,
275 kwl.
add(prefix,
"linear_units", os,
true);
312 if(
ossimString(lookup).downcase().contains(
"area"))
322 lookup = kwl.
find(prefix,
"linear_units");
326 getEntryNumber(lookup,
true);
342 lookup = kwl.
find(prefix,
"create_envi_hdr");
349 lookup = kwl.
find(prefix,
"create_ers_hdr");
356 lookup = kwl.
find(prefix,
"create_fgdc");
363 lookup = kwl.
find(prefix,
"create_jpeg_world_file");
370 lookup = kwl.
find(prefix,
"create_readme");
377 lookup = kwl.
find(prefix,
"create_tiff_world_file");
384 lookup = kwl.
find(prefix,
"create_world_file");
412 lookup = kwl.
find(prefix, SCALE_TO_EIGHT_BIT_KW);
419 lookup = kwl.
find(prefix, AUTO_CREATE_DIRECTORY_KW);
465 if (ih.
valid() ==
false)
632 outputFile +=
"_readme.txt";
674 <<
"Write of envi header file failed!" << endl;
685 <<
"Write of ers header file failed!" << endl;
697 <<
"Write of geometry file failed!" << endl;
709 <<
"Write of fgdc file failed!" << endl;
721 <<
"Write of jpeg world file failed!" << endl;
734 <<
"Write of readme file failed!" << endl;
746 <<
"Write of tiff world file failed!" << endl;
759 <<
"Write of world file failed!" << endl;
772 <<
"Write of histogram file failed!" << endl;
809 writer = 0; histoSource = 0; handler = 0;
1018 static const char MODULE[] =
"ossimImageFileWriter::execute";
1025 << MODULE <<
" DEBUG:\ntheInputConnection is NULL!" << endl;
1035 << MODULE <<
" DEBUG:\ntheFilename is empty!" << endl;
1057 << MODULE <<
" ERROR: Area of interest has nans!" 1058 <<
"Area of interest: " 1060 <<
"\nReturning..." << endl;
1069 << MODULE <<
" DEBUG:\n" 1093 bool wroteFile =
true;
1119 <<
"Write of overview file failed!" << endl;
1136 <<
"Write of metadata file failed!" << endl;
1145 if(savedInput.
valid())
1257 if(!property)
return;
1263 else if (property->
getName() ==
"create_envi_hdr")
1267 else if (property->
getName() ==
"create_ers_hdr")
1271 else if (property->
getName() ==
1276 else if (property->
getName() ==
"create_fgdc")
1280 else if (property->
getName() ==
"create_jpeg_world_file")
1284 else if (property->
getName() ==
"create_readme")
1288 else if (property->
getName() ==
"create_tiff_world_file")
1292 else if (property->
getName() ==
"create_world_file")
1308 else if (property->
getName() == SCALE_TO_EIGHT_BIT_KW)
1312 else if(property->
getName() == AUTO_CREATE_DIRECTORY_KW)
1316 else if (property->
getName() ==
"linear_units")
1352 return filenameProp;
1357 std::vector<ossimString> typeList;
1359 if(typeList.size() > 1)
1371 else if(name == AUTO_CREATE_DIRECTORY_KW)
1375 else if (name ==
"create_envi_hdr")
1379 else if (name ==
"create_ers_hdr")
1387 else if (name ==
"create_fgdc")
1391 else if (name ==
"create_jpeg_world_file")
1395 else if (name ==
"create_readme")
1399 else if (name ==
"create_tiff_world_file")
1403 else if (name ==
"create_world_file")
1419 else if (name == SCALE_TO_EIGHT_BIT_KW)
1423 else if (name ==
"linear_units")
1435 if (value ==
"unknown")
1441 vector<ossimString> constraintList;
1445 constraintList.push_back(
ossimString(
"us_survey_feet"));
1473 propertyNames.push_back(
ossimString(
"create_envi_hdr"));
1475 propertyNames.push_back(
ossimString(
"create_fgdc"));
1476 propertyNames.push_back(
ossimString(
"create_jpeg_world_file"));
1477 propertyNames.push_back(
ossimString(
"create_readme"));
1478 propertyNames.push_back(
ossimString(
"create_tiff_world_file"));
1479 propertyNames.push_back(
ossimString(
"create_world_file"));
1483 propertyNames.push_back(
ossimString(AUTO_CREATE_DIRECTORY_KW));
1484 propertyNames.push_back(
ossimString(SCALE_TO_EIGHT_BIT_KW));
1485 propertyNames.push_back(
ossimString(
"linear_units"));
1506 std::vector<ossimString> imageTypeList;
1509 std::vector<ossimString>::const_iterator i = imageTypeList.begin();
1511 while (i != imageTypeList.end())
1513 if ( (*i) == imageType )
1551 else if (s ==
"area")
1584 bool result =
false;
1594 if ( ( ext ==
"tif" ) || ( ext ==
"tiff" ) )
1598 else if ( ( ext ==
"jpg" ) || ( ext ==
"jpeg" ) )
1602 else if ( ext ==
"png" )
1606 else if ( ext ==
"sid" )
1620 <<
"Could not derive world file extension for: " <<
theFilename <<
"\n";
1627 <<
"Write of world file failed!\n";
virtual bool writeHistogramFile()
Returns true on success, false on error.
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)
virtual void setOutputImageType(ossim_int32 type)
virtual ossim_uint16 getOverviewCompressType() const
virtual void setWriteImageFlag(bool flag)
bool theScaleToEightBitFlag
virtual ossimObject * getObject()
ossimFilename noExtension() const
virtual bool writeErsHeaderFile()
Will write an ER Mapper header file.
virtual bool writeWorldFile()
Will write a world file.
virtual void setWriteJpegWorldFile(bool flag)
virtual void setProperty(ossimRefPtr< ossimProperty > property)
virtual bool execute()
Calls buildOverview.
virtual ossimImageHandler * open(const ossimFilename &fileName, bool trySuffixFirst=true, bool openOverview=true) const
open that takes a filename.
virtual void disconnect(ossimConnectableObject *object=0)
Will disconnect the object passed in.
ossimString theOutputImageType
bool needsAborting() const
static const char * CREATE_HISTOGRAM_KW
Represents serializable keyword/value map.
virtual ossimString getExtension() const
Returns a 3-letter extension from the image type descriptor (theOutputImageType) that can be used for...
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
virtual void setWriteErsHeaderFlag(bool flag)
virtual void setWriteTiffWorldFile(bool flag)
virtual void setScaleToEightBitFlag(bool flag)
virtual bool getOutputHasInternalOverviews(void) const
Examples of writers that always generate internal overviews are ossim_kakadu_jp2 and ossim_kakadu_nit...
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
ossimRefPtr< ossimViewController > theViewController
virtual void setPixelType(ossimPixelType type)
If "point" the coordinate tie points are relative to the center of the pixel.
const char * find(const char *key) const
virtual bool addListener(ossimListener *listener)
Overrides base "addListener" this will capture the pointer and then call the base class "addListener"...
virtual void setOverviewJpegCompressQuality(ossim_int32 quality)
ossimUnitType theLinearUnits
If not a geographic projection this allows the user to set the linear units of the output tag to be: ...
virtual ossimString getEntryString(ossim_int32 entry_number) const
virtual bool writeFile()=0
Write out the file.
virtual void disconnectInputEvent(ossimConnectionEvent &event)
static const char * OVERVIEW_COMPRESSION_TYPE_KW
virtual void getPropertyNames(std::vector< ossimString > &propertyNames) const
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
virtual bool writeReadmeFile()
Will write a readme file.
Class to write out meta data in a Federal Geographic Data Committe (FGDC) format. ...
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
ossimIrect theAreaOfInterest
void setCopyAllFlag(bool flag)
Sets theCopyAllFlag.
void setChangeType(int type, bool on=true)
virtual bool getWriteTiffWorldFileFlag() const
virtual void setTileSize(const ossimIpt &tileSize)
Sets the output image tiling size if supported by the writer.
virtual void setPercentComplete(double percentComplete)
virtual ossimString getClassName() const
static const char * FILEPATH_KW
virtual bool getWriteErsHeaderFlag() const
ossim_uint32 toUInt32() const
virtual bool writeTiffWorldFile()
Will write a world file.
OSSIM_DLL ossimStdOutProgress theStdOutProgress
virtual void setReadOnlyFlag(bool flag)
void addConstraint(const ossimString &value)
Pure virtual base class for image file writers.
virtual bool canConnectMyInputTo(ossim_int32 inputIndex, const ossimConnectableObject *object) const
required to be overriden by derived classes
virtual void connectInputEvent(ossimConnectionEvent &event)
unsigned short ossim_uint16
virtual void getPropertyNames(std::vector< ossimString > &propertyNames) const
virtual void setProcessStatus(ossimProcessStatus processStatus)
bool theWriteHistogramFlag
virtual void fireEvent(ossimEvent &event)
virtual bool setOutputStream(ossimRefPtr< ossimOStream > stream)
Sets the output stream to write to.
virtual bool getScaleToEightBitFlag() const
virtual ossimImageSourceSequencer * getSequencer()
static const char * TYPE_KW
virtual bool writeMetaDataFiles()
Convenience method that calls meta data write methods that are flagged to be called.
virtual ossim_int32 getOverviewJpegCompressQuality() const
bool theWriteOverviewFlag
virtual ossimRefPtr< ossimProperty > getProperty(const ossimString &name) const
ossimImageFileWriter(const ossimFilename &filename=ossimFilename(), ossimImageSource *inputSource=0, ossimObject *owner=0)
The writer will own the sequencer.
virtual void setOutputName(const ossimString &outputName)
bool theWriteEnviHeaderFlag
External meta data writer flags.
virtual ossim_int32 getEntryNumber(const char *entry_string, bool case_insensitive=true) const
virtual void getImageTypeList(std::vector< ossimString > &imageTypeList) const =0
void getImageTypeList(std::vector<ossimString>& imageTypeList)const
ossimConnectableObject * getInput(ossim_uint32 index=0)
returns the object at the specified index.
ossim_int32 toInt32() const
virtual bool getWriteJpegWorldFileFlag() const
void push_back(char c)
Equivalent to insert(end(), c).
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
void setJpegCompressionQuality(ossim_int32 quality)
Sets the compression quality for use when using a compression type of COMPRESSION_JPEG.
virtual bool writeOverviewFile(ossim_uint16 tiff_compress_type=1, ossim_int32 jpeg_compress_quality=75, bool includeR0=false)
Write out an ossim overview file from the source_file.
virtual void setAreaOfInterest(const ossimIrect &areaOfInterest)
virtual ossimScalarType getOutputScalarType() const
This will be used to query the output pixel type of the tile source.
bool theWriteTiffWorldFileFlag
Class for writing a "ERS" style header.
virtual void getPixelTypeString(ossimString &type) const
virtual bool setInputSource(ossimImageHandler *imageSource)
Sets the input to the builder.
std::string::size_type size() const
ossimRefPtr< ossimImageSourceSequencer > theInputConnection
bool theWriteErsHeaderFlag
virtual bool getWriteEnviHeaderFlag() const
static const char * CREATE_OVERVIEW_KW
ossimFilename theFilename
bool toBool() const
String to numeric methods.
virtual ossimIrect getBoundingRect(ossim_uint32 resLevel=0) const
This will return the bounding rect of the source.
virtual bool writeStream()
Method to write the image to a stream.
unsigned int ossim_uint32
bool theWriteJpegWorldFileFlag
virtual void setWriteWorldFile(bool flag)
bool theWriteExternalGeometryFlag
virtual void enableSource()
virtual bool getWriteWorldFileFlag() const
bool theAutoCreateDirectoryFlag
virtual ossimPixelType getPixelType() const
static ossimString downcase(const ossimString &aString)
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 void setWriteReadme(bool flag)
virtual void initialize()
virtual ~ossimImageFileWriter()
virtual void setAreaOfInterest(const ossimIrect &inputAreaOfInterest)
virtual ossimRefPtr< ossimProperty > getProperty(const ossimString &name) const
virtual void setOutputName(const ossimString &outputName)
virtual bool hasImageType(const ossimString &imageType) const
bool hasImageType(const ossimString& imageType) const
static const char * CREATE_EXTERNAL_GEOMETRY_KW
virtual bool getWriteHistogramFlag() const
virtual bool getWriteOverviewFlag() const
virtual bool getWriteFgdcFlag() const
virtual ossimString getOutputImageTypeString() const
virtual void setFilename(const ossimFilename &file)
ossimPixelType thePixelType
OSSIM_PIXEL_IS_POINT = 0, OSSIM_PIXEL_IS_AREA = 1.
virtual void setOutputFile(const ossimFilename &file)
Sets the output filename.
virtual void setWriteEnviHeaderFlag(bool flag)
virtual void setOverviewCompressType(ossim_uint16 type)
void setLinearUnits(ossimUnitType units)
Sets the linear units of the output file to either feet, us_survey_feet, or meters.
virtual bool writeFgdcFile()
Will write an fgdc file.
ossim_int32 theOverviewJpegCompressQuality
virtual bool writeExternalGeometryFile()
Will write an external geometry file.
virtual bool writeJpegWorldFile()
Will write a jpeg world file.
ConnectableObjectList theInputObjectList
Holds a list of input objects.
virtual const ossimFilename & getFilename() const
static const char * CREATE_IMAGE_KW
ossim_uint16 theOverviewCompressType
virtual void setProperty(ossimRefPtr< ossimProperty > property)
virtual void initialize()
Initialize method.
virtual void setWriteExternalGeometryFlag(bool flag)
virtual bool getWriteExternalGeometryFlag() const
virtual void setWriteFgdcFlag(bool flag)
void setIoType(ossimFilenamePropertyIoType ioType)
static const char * PIXEL_TYPE_KW
virtual void setAreaOfInterest(const ossimIrect &inputRect)
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string's contents...
virtual bool writeEnviHeaderFile()
Will write an envi header file.
bool theInputListIsFixedFlag
Indicates whether the theInputObjectList is fixed.
virtual bool getWriteImageFlag() const
Control flags...
virtual ossimRefPtr< ossimOStream > getOutputStream() const
Method to return the stream attached to output.
virtual void changeSequencer(ossimImageSourceSequencer *sequencer)
Sets the sequencer and connects it to the input of this.
virtual bool getWriteReadmeFlag() const
virtual void setMaxNumberOfRLevels(ossim_uint32 number)
const ossimIrect & getAreaOfInterest() const
static ossimImageHandlerRegistry * instance()
RTTI_DEF3(ossimImageFileWriter, "ossimImageFileWriter", ossimImageWriter, ossimProcessInterface, ossimConnectableObjectListener) static const char SCALE_TO_EIGHT_BIT_KW[]
bool theOutputListIsFixedFlag
Indicates whether the theOutputObjectList is fixed.
static const char * IMAGE_TYPE_KW
static const char * OVERVIEW_COMPRESSION_QUALITY_KW
virtual void setPercentComplete(double percentComplete)
virtual void setWriteHistogramFlag(bool flag)
virtual ossim_int32 getOutputImageType() const
virtual void setFilename(const ossimFilename &filename)
ossimFilename & setExtension(const ossimString &e)
Sets the extension of a file name.
virtual void setTileSize(const ossimIpt &tileSize)
virtual bool removeListener(ossimListener *listener)
Overrides base "removeListener".
bool createDirectory(bool recurseFlag=true, int perm=0775) const
static ossimUnitTypeLut * instance()
Returns the static instance of an ossimUnitTypeLut object.
virtual void propertyEvent(ossimPropertyEvent &event)
static const char * FILENAME_KW
ossimFilename path() const
virtual void setWriteOverviewFlag(bool flag)
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
std::basic_ostream< char > ostream
Base class for char output streams.
virtual bool execute()
Calls: writeFile() writeMetaDataFiles()
void setConstraints(const std::vector< ossimString > &constraintList)
const ossimString & getName() const
ossimListener * theProgressListener
virtual void valueToString(ossimString &valueResult) const
virtual bool removeListener(ossimListener *listener)
bool theWriteWorldFileFlag