35 static ossimTrace traceDebug(
"ossimRpfToc:debug");
39 return data.
print(out);
57 static const char MODULE[] =
"ossimRpfToc::parseFile";
81 << MODULE <<
" leaving with no nitf header found....." << std::endl;
89 if(traceDebug() && (info.
getTagName() ==
"RPFHDR") )
92 << MODULE <<
" nitf file header print\n";
96 if ( !keepFileHeader )
123 << MODULE <<
" DEBUG: Found RPF HEADER tag\n";
133 <<
"ossimRpfToc::parseFile: Leaving No RPFHDR tag found" <<
"\n";
151 <<
"ossimRpfToc::parseFile: Leaving no RPFHDR " << __LINE__ <<
"\n";
159 <<
"ossimRpfToc::parseFile: Returning with OK." << std::endl;
168 static const char MODULE[] =
"ossimRpfToc::createTocAndCopyFrames";
173 << MODULE <<
" entered..." 174 <<
"\ndot rpf file: " << dotRpfFile
175 <<
"\noutput directory: " << outputDir
183 std::string e = MODULE;
184 e +=
" ERROR:\nCould not create directory: ";
185 e+= outputDir.
c_str();
192 dotRpfStr->open(dotRpfFile.
c_str(), ios_base::in);
193 if ( !dotRpfStr->good() )
198 std::string e = MODULE;
199 e +=
" ERROR:\nCould not open: ";
200 e += dotRpfFile.
c_str();
205 if ( sourceADotTocFile.
empty() )
210 std::string e = MODULE;
211 e +=
" ERROR:\nCould not deduce source a.toc file!";
222 std::string e = MODULE;
223 e +=
" ERROR:\nCould not open: ";
224 e += sourceADotTocFile.
c_str();
229 if ( !sourceNitfFileHdr.
valid() )
234 std::string e = MODULE;
235 e +=
" ERROR:\nCould not get nitf file header from: ";
236 e += sourceADotTocFile.
c_str();
241 if ( !sourceRpfHdr.
valid() )
246 std::string e = MODULE;
247 e +=
" ERROR:\nCould not get rpf header from: ";
248 e += sourceADotTocFile.
c_str();
255 if ( !boundaryRectSectionSubheader.
valid() )
260 std::string e = MODULE;
261 e +=
" ERROR:\nCould not pull boundary rect sub header from source file: ";
262 e += sourceADotTocFile.
c_str();
269 if ( !boundaryRectTable.
valid() )
274 std::string e = MODULE;
275 e +=
" ERROR:\nCould not pull boundary rect table from source file: ";
276 e += sourceADotTocFile.
c_str();
283 if ( !frameFileSubHeader.
valid() )
288 std::string e = MODULE;
289 e +=
" ERROR:\nCould not pull frame file sub header from source file: ";
290 e += sourceADotTocFile.
c_str();
297 if ( !frameFileSubSection.
valid() )
302 std::string e = MODULE;
303 e +=
" ERROR:\nCould not pull frame file sub section from source file: ";
304 e += sourceADotTocFile.
c_str();
312 dotTocStr->open( dotTocFile.
c_str(), ios::out|ios::binary );
313 if ( !dotTocStr->good() )
320 std::string e = MODULE;
321 e +=
" ERROR:\nCould not open: ";
322 e += dotTocFile.
c_str();
375 fileHdr->
addTag(rpfHdrInfo);
388 std::streampos pos = dotTocStr->tellp();
389 std::streamoff locationSectionOffset = pos;
392 fileHdr->
setHeaderLength( static_cast<ossim_uint64>(locationSectionOffset) );
437 if ( fileHdr->
getTag(rpfHdrInfo,
"RPFHDR") )
512 dotTocStr->seekp(0, ios::beg);
515 dotTocStr->seekp(boundaryRectPosition, ios::beg);
523 <<
"writing boundaryRectSectionSubheader:\n" << *(boundaryRectSectionSubheader.
get())
531 boundaryRectSectionSubheader->
writeStream(*dotTocStr);
536 <<
"Original boundaryRectTable:\n" << *(boundaryRectTable.
get()) <<
"\n";
543 if ( boundaryRectTable->
getEntry( entry, boundaryRectRecord) )
548 <<
"writing boundaryRectTable:\n" << boundaryRectRecord <<
"\n";
555 std::string e = MODULE;
556 e +=
" ERROR:\nCould not get bounding rect record for entry: ";
563 std::string e = MODULE;
564 e +=
" ERROR:\nCould not deduce entry from frame list!";
576 <<
"writing frameFileSubHeader:\n" << *(frameFileSubHeader.
get()) <<
"\n";
585 std::streamoff frameFileIndexSectionStartPos = dotTocStr->tellp();
589 std::streamoff endOfFilePos = dotTocStr->tellp();
593 static_cast<ossim_uint32>(endOfFilePos - frameFileIndexSectionStartPos);
600 fileHdr->
setFileLength(static_cast<ossim_uint64>(endOfFilePos));
601 dotTocStr->seekp(0, ios::beg);
617 const std::string& prefix,
618 bool printOverviews)
const 635 const std::string& prefix )
const 646 const std::string& prefix,
647 bool printOverviews )
const 654 tocEntry->
print(out, prefix);
660 if ( (scale.
contains(
"OVERVIEW") ==
false) || printOverviews )
663 entryPrefix +=
"image";
666 REC.
print(out, entryPrefix);
681 rpfFrame.
print(out, entryPrefix);
731 if ( pEntry != NULL )
742 if ( pEntry != NULL )
755 if ( pEntry != NULL )
757 return pEntry->
getEntry( row, col, result );
768 if ( bResult ==
true )
790 std::vector< ossimRpfTocEntry*>::iterator tocEntry =
809 <<
"ossimRpfToc::buildTocEntryList: entered.....\n";
818 <<
"ossimRpfToc::buildTocEntryList: invalid input leaving..... " << std::endl;
840 std::streamoff current = in.tellg();
849 in.seekg(current, ios::beg);
863 long offsetToIndexSubsection = in.tellg();
864 if(frameFileIndexHead)
876 std::streamoff currentPosition = in.tellg();
903 in.seekg(currentPosition, ios::beg);
907 delete frameFileIndexHead;
908 frameFileIndexHead = 0;
917 <<
"ossimRpfToc::buildTocEntryList: leaving....." << std::endl;
927 for(
ossim_uint32 index = 0; index < numberOfEntries; index++)
948 bool foundEntry =
false;
953 rpfTocEntry->
getEntry(v, h, frameEntry);
972 static const char MODULE[] =
"ossimRpfToc::writeFrameFileIndexSection";
981 ossim_uint32 pathnameRecordOffset = FRAME_FILE_INDEX_RECORD_LENGTH * frames;
988 if ( !dotRpfStr.good() )
994 dotRpfStr.seekg(0, ios_base::beg);
1004 while( dotRpfStr.good() )
1008 if ( dotRpfStr.good() )
1042 <<
"frames written: " << framesWritten
1043 <<
"\nwrote record:\n" << pathRecord
1048 dotRpfStr.seekg(0, ios_base::beg);
1058 static const char MODULE[] =
"ossimRpfToc::copyFrames";
1072 if ( !dotRpfStr.good() )
1078 dotRpfStr.seekg(0, ios_base::beg);
1095 destinationFile = outputDir;
1096 subDir = file.
path();
1097 subDir = subDir.
file();
1098 destinationFile = destinationFile.
dirCat( subDir );
1101 if ( !destinationFile.
exists() )
1108 if ( !dotRpfStr.good() )
1113 dotRpfStr.seekg(0, ios_base::beg);
1118 while( dotRpfStr.good() )
1122 if ( dotRpfStr.good() )
1126 destinationFile = outputDir;
1127 subDir = file.
path();
1128 subDir = subDir.
file();
1129 destinationFile = destinationFile.
dirCat( subDir );
1130 destinationFile = destinationFile.
dirCat( file.
file() );
1147 dotRpfStr.seekg(0, ios_base::beg);
1159 if ( !dotRpfStr.good() )
1165 dotRpfStr.seekg(0, ios_base::beg);
1171 while( dotRpfStr.good() )
1175 if ( dotRpfStr.good() )
1182 dotRpfStr.seekg(0, ios_base::beg);
1191 if ( !dotRpfStr.good() )
1196 dotRpfStr.seekg(0, ios_base::beg);
1210 tocFile = subDir.
dirCat(
"a.toc");
1213 tocFile = subDir.
dirCat(
"A.TOC");
1216 subDir = subDir.
path();
1217 tocFile = subDir.
dirCat(
"a.toc");
1220 tocFile = subDir.
dirCat(
"A.TOC");
1230 if ( !dotRpfStr.good() )
1234 dotRpfStr.seekg(0, ios_base::beg);
1248 bool result =
false;
1250 if ( !dotRpfStr.good() )
1256 dotRpfStr.seekg(0, ios_base::beg);
1276 if ( !dotRpfStr.good() )
1281 dotRpfStr.seekg(0, ios_base::beg);
1293 bool result =
false;
1297 std::vector<ossimString> lineArray;
1298 os.
split(lineArray,
"|");
1299 if ( lineArray.size() )
1301 file = lineArray[0];
void clear()
Erases the entire container.
void addComponentRecord(const ossimRpfComponentLocationRecord &record)
Method to add a component location record.
ossim_int32 ossimErrorCode
bool getFrameFileIndexRecordFromFile(const ossimFilename &file, ossimRpfFrameFileIndexRecord &record) const
Gets the record matching file.
ossimErrorCode parseStream(std::istream &in, ossimByteOrder byteOrder)
ossim_uint32 getNumberOfEntries() const
bool getCorespondingEntry(ossimRpfFrameFileIndexSubsection *frameFileSubSection, std::ifstream &dotRpfStr, ossim_uint32 &entry) const
Gets the zero based entry number for the first file in the dot rpf file.
ossimFilename getFilename() const
ossimFilename getSourceTocFile(std::ifstream &dotRpfStr) const
Get a.toc file from the dot rpf file.
std::ostream & operator<<(std::ostream &out, const ossimRpfToc &data)
ossim_uint32 getNumberOfFrames(std::ifstream &dotRpfStr) const
Get the number of frames from the dot rpf file.
std::ostream & print(std::ostream &out, const std::string &prefix=std::string()) const
print method that outputs a key/value type format adding prefix to keys.
static const ossimErrorCode OSSIM_OK
std::basic_ifstream< char > ifstream
Class for char input file streams.
ossimFilename expand() const
Method to do file name expansion.
std::ostream & print(std::ostream &out, const std::string &prefix=std::string(), bool printOverviews=false) const
print method that outputs a key/value type format adding prefix to keys.
ossim_uint32 getNumberOfFramesVertical() const
bool contains(char aChar) const
const ossimString getRelativeFramePath(ossim_uint32 entryIdx, ossim_uint32 row, ossim_uint32 col) const
For the given entry index, frame row, and frame column, this routine returns the corresponding name o...
ossimString getScale() const
static ossimString toString(bool aValue)
Numeric to string methods.
ossim_uint32 m_componentLength
std::vector< ossimRpfTocEntry * > m_tocEntryList
void allocateTocEntryList(ossim_uint32 numberOfEntries)
void split(std::vector< ossimString > &result, const ossimString &separatorList, bool skipBlankFields=false) const
Splits this string into a vector of strings (fields) using the delimiter list specified.
ossimRefPtr< const ossimNitfFileHeader > m_nitfFileHeader
static const ossimErrorCode OSSIM_ERROR
std::istream & getline(std::istream &is, ossimString &str, char delim)
const ossimRpfHeader * getRpfHeader() const
unsigned short ossim_uint16
ossim_uint32 getNumberOfFramesHorizontal(ossim_uint32 idx) const
For the given entry index, this routine returns the number of frames that exist in the horizontal dir...
const ossimRpfBoundaryRectRecord & getBoundaryInformation() const
void setLocationSectionLength(ossim_uint16 length)
ossimErrorCode parseStream(std::istream &in, ossimByteOrder byteOrder)
const ossimString getPathToFrameFileFromRoot() const
bool copyFileTo(const ossimFilename &outputFile) const
Copies this file to output file.
std::vector< ossimRpfComponentLocationRecord > & getLocationRecordList()
Brief Direct access to the list of records.
void setPathnameRecordOffset(ossim_uint32 offset)
void setLocationRecordLength(ossim_uint16 length)
ossim_uint16 getLocationColNumber() const
void deleteTocEntryList()
void writeStream(std::ostream &out)
Write method.
ossim_uint32 m_componentLocation
std::ostream & print(std::ostream &out, const std::string &prefix=std::string()) const
print method that outputs a key/value type format adding prefix to keys.
void writeFrameFileIndexSection(ossimRpfFrameFileIndexSubsection *frameFileSubSection, std::ifstream &dotRpfStr, std::ofstream &dotTocStr)
Writes the frame file sub section of an a.toc.
const ossimNitfFileHeader * getHeader() const
unsigned int ossim_uint32
void setComponentAggregateLength(ossim_uint32 length)
bool getEntry(ossim_uint32 entry, ossimRpfBoundaryRectRecord &record) const
Gets record for entry.
const ossimRpfTocEntry * getTocEntry(ossim_uint32 index) const
ossim_uint16 m_componentId
std::ostream & print(std::ostream &out, const std::string &prefix=std::string()) const
print method that outputs a key/value type format adding prefix to keys.
void setBoundaryRecNumber(ossim_uint16 entry)
Sets the zero based entry number.
ossimErrorCode parseFile(const ossimFilename &fileName, bool keepFileHeader=false)
Parses a.toc file.
ossimRefPtr< ossimRpfHeader > m_rpfHeader
bool getRpfFrameEntry(ossim_uint32 entryIdx, ossim_uint32 row, ossim_uint32 col, ossimRpfFrameEntry &result) const
For the given entry index, frame row, and frame column, this routine returns the corresponding ossimR...
void createTocAndCopyFrames(const ossimFilename &dotRpfFile, const ossimFilename &outputDir)
Creates a new a.toc file from list of rpf frames in output directory.
ossim_uint32 getNumberOfFramesHorizontal() const
ossimErrorCode parseFile(const ossimFilename &filename, bool minimalParse=false)
void getRootDirectory(ossimFilename &dir) const
Method to get the root directory from the a.toc file name.
ossimString getPathname() const
void copyFrames(std::ifstream &dotRpfStr, const ossimFilename &outputDir)
Copies frame to output directory.
ossim_uint32 getPathnameRecordOffset() const
void writeStream(std::ostream &out)
Write method.
ossim_uint16 getBoundaryRecNumber() const
const ossimNitfFileHeader * getNitfFileHeader() const
Get the nitf file header.
ossimFilename dirCat(const ossimFilename &file) const
void setPathName(const ossimString &path)
Set the pathname and length from string size.
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string's contents...
void buildTocEntryList(ossimRpfHeader *rpfHeader)
ossimFilename file() const
bool parseFile(const ossimFilename &file)
std::basic_ofstream< char > ofstream
Class for char output file streams.
bool getEntry(long row, long col, ossimRpfFrameEntry &result) const
void setLocationTableOffset(ossim_uint32 offset)
bool getFile(const std::string &line, ossimFilename &file) const
Gets the filename from line in.
ossim_uint32 getNumberOfFramesVertical(ossim_uint32 idx) const
For the given entry index, this routine returns the number of frames that exist in the vertical direc...
std::ostream & printHeader(std::ostream &out, const std::string &prefix=std::string()) const
print method that outputs a key/value type format adding prefix to keys.
bool createDirectory(bool recurseFlag=true, int perm=0775) const
ossim_int32 getTocEntryIndex(const ossimRpfTocEntry *entry)
Returns -1 if not found.
ossimFilename path() const
const ossimFilename & getFullPath() const
void writeStream(std::ostream &out)
Write method.
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
void getFirstEntry(const ossimRpfTocEntry *rpfTocEntry, ossimRpfFrameEntry &frameEntry) const
Walks through frames to find the first entry that exists...
void clearFields()
Clears records and fields.
std::basic_ostream< char > ostream
Base class for char output streams.
ossim_uint16 getLocationRowNumber() const
void setNumberOfComponentLocationRecords(ossim_uint16 count)
std::ostream & printTocEntry(std::ostream &out, ossim_uint32 entryIndex, const std::string &prefix=std::string(), bool printOverviews=false) const
print method that outputs a key/value type format adding prefix to keys.
std::ostream & print(std::ostream &out, ossimString prefix) const
prints to out.