Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pick up non-SICD/SIDD DES when reading #291

Merged
merged 2 commits into from
Dec 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) :
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we using mem::SharedPtr here to match an existing interface? If not we should use std::shared_ptr

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically, yes. There's a whole call hierarchy of mem::SharedPtr going on here. I think doing a separate PR that's kind of a general C++11 update pass (or at least just the smart pointers) would make more sense than making piecemeal changes.

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