Skip to content

Commit

Permalink
Merge pull request #291 from ngageoint/read_extra_des
Browse files Browse the repository at this point in the history
Pick up non-SICD/SIDD DES when reading
  • Loading branch information
clydestanfield authored Dec 5, 2019
2 parents cdc9a78 + c75e627 commit c94650b
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 30 deletions.
19 changes: 17 additions & 2 deletions six/modules/c++/six/include/six/Container.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ namespace six
class Container
{
public:
/*!
/*!
* The data class is either COMPLEX or DERIVED
* This just tells us what kind of container. Note that, in
* This just tells us what kind of container. Note that, in
* the case of DERIVED, one or more Data*'s DataType will
* be DERIVED.
*
Expand Down Expand Up @@ -147,6 +147,20 @@ class Container
*/
void removeData(const Data* data);

/*!
* Add segment source for a DES other than the
* SICD/SIDD DES.
* \param source SegmentSource to add
*/
void addDESSource(const nitf::SegmentSource& source);

/*!
* Get all added DES sources for DES other than the
* SICD/SIDD DES.
* \return The DES sources
*/
const std::vector<nitf::SegmentSource>& getDESSources() const;

protected:
typedef std::pair<mem::ScopedCloneablePtr<Data>,
mem::ScopedCopyablePtr<Legend> > DataPair;
Expand All @@ -155,6 +169,7 @@ class Container

DataType mDataType;
DataVec mData;
std::vector<nitf::SegmentSource> mDESSources;

private:
static
Expand Down
10 changes: 10 additions & 0 deletions six/modules/c++/six/source/Container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,14 @@ Data* Container::getData(const std::string& iid, size_t numImages)

return getData(dataID);
}

void Container::addDESSource(const nitf::SegmentSource& source)
{
mDESSources.push_back(source);
}

const std::vector<nitf::SegmentSource>& Container::getDESSources() const
{
return mDESSources;
}
}
13 changes: 10 additions & 3 deletions six/modules/c++/six/source/NITFHeaderCreator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ const char NITFHeaderCreator::OPT_NUM_ROWS_PER_BLOCK[] = "NumRowsPerBlock";
const char NITFHeaderCreator::OPT_NUM_COLS_PER_BLOCK[] = "NumColsPerBlock";
const size_t NITFHeaderCreator::DEFAULT_BUFFER_SIZE = 8 * 1024 * 1024;

NITFHeaderCreator::NITFHeaderCreator() :
NITFHeaderCreator::NITFHeaderCreator() :
mRecord(NITF_VER_21),
mXMLRegistry(NULL),
mLog(NULL),
Expand All @@ -108,7 +108,7 @@ NITFHeaderCreator::NITFHeaderCreator() :
loadXmlDataContentHandler();
}

NITFHeaderCreator::NITFHeaderCreator(mem::SharedPtr<Container> container) :
NITFHeaderCreator::NITFHeaderCreator(mem::SharedPtr<Container> container) :
mRecord(NITF_VER_21),
mXMLRegistry(NULL),
mLog(NULL),
Expand All @@ -119,7 +119,7 @@ NITFHeaderCreator::NITFHeaderCreator(mem::SharedPtr<Container> container) :
}

NITFHeaderCreator::NITFHeaderCreator(const six::Options& options,
mem::SharedPtr<Container> container) :
mem::SharedPtr<Container> container) :
mRecord(NITF_VER_21),
mXMLRegistry(NULL),
mLog(NULL),
Expand Down Expand Up @@ -909,6 +909,13 @@ void NITFHeaderCreator::initialize(mem::SharedPtr<Container> container)
setDESecurity(data.getClassification(), subheader);
}

for (auto desSource : container->getDESSources())
{
std::shared_ptr<nitf::SegmentWriter> desWriter(
new nitf::SegmentWriter(desSource));
mSegmentWriters.push_back(desWriter);
}

updateFileHeaderSecurity();
}

Expand Down
51 changes: 26 additions & 25 deletions six/modules/c++/six/source/NITFReadControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,39 +274,40 @@ void NITFReadControl::load(mem::SharedPtr<nitf::IOInterface> ioInterface,
{
nitf::DESegment segment = (nitf::DESegment) *desIter;
nitf::DESubheader subheader = segment.getSubheader();
nitf::SegmentReader deReader = mReader.newDEReader(i);

//Skip over any non-SICD/SIDD DESs
if (getDataType(segment) == DataType::NOT_SET)
{
continue;
mContainer->addDESSource(nitf::SegmentReaderSource(deReader));
}

nitf::SegmentReader deReader = mReader.newDEReader(i);
SegmentInputStreamAdapter ioAdapter(deReader);
std::auto_ptr<Data> data(parseData(*mXMLRegistry,
ioAdapter,
dataType,
schemaPaths,
*mLog));
if (data.get() == NULL)
else
{
throw except::Exception(Ctxt("Unable to transform XML DES"));
}
SegmentInputStreamAdapter ioAdapter(deReader);
std::auto_ptr<Data> data(parseData(*mXMLRegistry,
ioAdapter,
dataType,
schemaPaths,
*mLog));
if (data.get() == NULL)
{
throw except::Exception(Ctxt("Unable to transform XML DES"));
}

// Note that DE override data never should clash, there
// is one DES per data, so it's safe to do this
addDEClassOptions(subheader, data->getClassification());
// Note that DE override data never should clash, there
// is one DES per data, so it's safe to do this
addDEClassOptions(subheader, data->getClassification());

if (data->getDataType() == six::DataType::DERIVED)
{
mContainer->addData(data, findLegend(productNum));
}
else
{
mContainer->addData(data);
}
if (data->getDataType() == six::DataType::DERIVED)
{
mContainer->addData(data, findLegend(productNum));
}
else
{
mContainer->addData(data);
}

++productNum;
++productNum;
}
}

// Get the total number of images in the NITF
Expand Down

0 comments on commit c94650b

Please sign in to comment.