diff --git a/six/modules/c++/six.sidd/conf/schema/SIDD_V3.0.0_ISM-v13/SIDD_schema_V3.0.0.xsd b/six/modules/c++/six.sidd/conf/schema/SIDD_V3.0.0_ISM-v13/SIDD_schema_V3.0.0.xsd
index b16850464..c772127bd 100644
--- a/six/modules/c++/six.sidd/conf/schema/SIDD_V3.0.0_ISM-v13/SIDD_schema_V3.0.0.xsd
+++ b/six/modules/c++/six.sidd/conf/schema/SIDD_V3.0.0_ISM-v13/SIDD_schema_V3.0.0.xsd
@@ -1442,7 +1442,7 @@
-
+
diff --git a/six/modules/c++/six.sidd/conf/schema/SIDD_V3.0.0_ISM-v201609/SIDD_schema_V3.0.0.xsd b/six/modules/c++/six.sidd/conf/schema/SIDD_V3.0.0_ISM-v201609/SIDD_schema_V3.0.0.xsd
index 3502aafe9..3558e23aa 100644
--- a/six/modules/c++/six.sidd/conf/schema/SIDD_V3.0.0_ISM-v201609/SIDD_schema_V3.0.0.xsd
+++ b/six/modules/c++/six.sidd/conf/schema/SIDD_V3.0.0_ISM-v201609/SIDD_schema_V3.0.0.xsd
@@ -1442,7 +1442,7 @@
-
+
diff --git a/six/modules/c++/six.sidd/include/six/sidd/Compression.h b/six/modules/c++/six.sidd/include/six/sidd/Compression.h
index 27ce2d3a9..b1f5c75c0 100644
--- a/six/modules/c++/six.sidd/include/six/sidd/Compression.h
+++ b/six/modules/c++/six.sidd/include/six/sidd/Compression.h
@@ -15,13 +15,13 @@ struct J2KCompression
{
Layer();
- double bitRate;
+ double bitRate = 0.0;
};
J2KCompression();
- size_t numWaveletLevels;
- size_t numBands;
+ size_t numWaveletLevels = 0;
+ size_t numBands = 0;
std::vector layerInfo;
};
diff --git a/six/modules/c++/six.sidd/include/six/sidd/DerivedXMLParser.h b/six/modules/c++/six.sidd/include/six/sidd/DerivedXMLParser.h
index ffc160e52..4827b0a74 100644
--- a/six/modules/c++/six.sidd/include/six/sidd/DerivedXMLParser.h
+++ b/six/modules/c++/six.sidd/include/six/sidd/DerivedXMLParser.h
@@ -194,10 +194,8 @@ struct DerivedXMLParser : public six::XMLParser
XMLElem parent = nullptr) const = 0;
XMLElem convertAnnotationToXML(const Annotation *a,
XMLElem parent = nullptr) const;
- XMLElem convertCompressionToXML(const Compression *c,
- XMLElem parent = nullptr) const;
- void convertJ2KToXML(const J2KCompression* c, XMLElem& parent) const;
- XMLElem convertSFAGeometryToXML(const SFAGeometry *g,
+ public: virtual void convertJ2KToXML(const J2KCompression&, xml::lite::Element&) const {}
+ protected: XMLElem convertSFAGeometryToXML(const SFAGeometry *g,
XMLElem parent = nullptr) const;
XMLElem convertGeographicCoordinateSystemToXML(
const SFAGeographicCoordinateSystem* geographicCoordinateSystem,
diff --git a/six/modules/c++/six.sidd/include/six/sidd/DerivedXMLParser200.h b/six/modules/c++/six.sidd/include/six/sidd/DerivedXMLParser200.h
index b282d7112..d6ab6347e 100644
--- a/six/modules/c++/six.sidd/include/six/sidd/DerivedXMLParser200.h
+++ b/six/modules/c++/six.sidd/include/six/sidd/DerivedXMLParser200.h
@@ -92,9 +92,6 @@ struct DerivedXMLParser200 final : public DerivedXMLParser
virtual void parseCompressionFromXML(const xml::lite::Element* compressionElem,
Compression& compression) const;
- virtual XMLElem convertCompressionToXML(const Compression& compression,
- XMLElem parent = nullptr) const;
-
virtual XMLElem convertDisplayToXML(const Display& display,
XMLElem parent = nullptr) const override;
@@ -141,8 +138,7 @@ struct DerivedXMLParser200 final : public DerivedXMLParser
static xml::lite::Element& convertFilterToXML(const DerivedXMLParser&,
const std::string& name, const Filter&, xml::lite::Element& parent);
- static void convertJ2KToXML(const DerivedXMLParser&,
- const J2KCompression&, xml::lite::Element& parent);
+ void convertJ2KToXML(const J2KCompression&, xml::lite::Element&) const override;
void parseJ2KCompression(const xml::lite::Element* j2kElem,
J2KCompression& j2k) const;
diff --git a/six/modules/c++/six.sidd/include/six/sidd/DerivedXMLParser300.h b/six/modules/c++/six.sidd/include/six/sidd/DerivedXMLParser300.h
index 9eeeb5ef3..ed6ebc930 100644
--- a/six/modules/c++/six.sidd/include/six/sidd/DerivedXMLParser300.h
+++ b/six/modules/c++/six.sidd/include/six/sidd/DerivedXMLParser300.h
@@ -84,6 +84,7 @@ struct DerivedXMLParser300 final : public DerivedXMLParser
void parseBankFromXML(const xml::lite::Element* bankElem, Filter::Bank&) const;
void parseFilterFromXML(const xml::lite::Element& filterELem, Filter& filter) const;
void parseJ2KCompression(const xml::lite::Element& j2kElem, J2KCompression& j2k) const;
+ void convertJ2KToXML(const J2KCompression&, xml::lite::Element&) const override;
void parseGeoDataFromXML(const xml::lite::Element& elem, GeoDataBase&) const;
void parseDigitalElevationDataFromXML(const xml::lite::Element& elem, DigitalElevationData&) const;
void parseProductGenerationOptionsFromXML(const xml::lite::Element& optionsElem, ProductGenerationOptions&) const;
diff --git a/six/modules/c++/six.sidd/source/Compression.cpp b/six/modules/c++/six.sidd/source/Compression.cpp
index c3f4f6808..af4ec4f59 100644
--- a/six/modules/c++/six.sidd/source/Compression.cpp
+++ b/six/modules/c++/six.sidd/source/Compression.cpp
@@ -4,14 +4,11 @@ namespace six
{
namespace sidd
{
-J2KCompression::Layer::Layer() :
- bitRate(0.0)
+J2KCompression::Layer::Layer()
{
}
-J2KCompression::J2KCompression() :
- numWaveletLevels(0),
- numBands(0)
+J2KCompression::J2KCompression()
{
}
}
diff --git a/six/modules/c++/six.sidd/source/DerivedXMLParser200.cpp b/six/modules/c++/six.sidd/source/DerivedXMLParser200.cpp
index 3bdd6fc3d..48c3cc418 100644
--- a/six/modules/c++/six.sidd/source/DerivedXMLParser200.cpp
+++ b/six/modules/c++/six.sidd/source/DerivedXMLParser200.cpp
@@ -277,7 +277,7 @@ xml::lite::Document* DerivedXMLParser200::toXML(const DerivedData* derived) cons
// optional
if (derived->compression.get())
{
- convertCompressionToXML(*derived->compression, root);
+ convertCompressionToXML(*this, *(derived->compression), *root);
}
// optional
if (derived->digitalElevationData.get())
@@ -1482,32 +1482,26 @@ xml::lite::Element& DerivedXMLParser200::convertFilterToXML(const DerivedXMLPars
return filterElem;
}
-XMLElem DerivedXMLParser200::convertCompressionToXML(
- const Compression& compression,
- XMLElem parent) const
-{
- assert(parent != nullptr);
- return &convertCompressionToXML(*this, compression, *parent);
-}
xml::lite::Element& DerivedXMLParser200::convertCompressionToXML(const DerivedXMLParser& parser,
const Compression& compression, xml::lite::Element& parent)
{
auto& compressionElem = parser.newElement("Compression", parent);
auto& j2kElem = parser.newElement("J2K", compressionElem);
auto& originalElem = parser.newElement("Original", j2kElem);
- convertJ2KToXML(parser, compression.original, originalElem);
+ parser.convertJ2KToXML(compression.original, originalElem);
if (compression.parsed.get())
{
auto& parsedElem = parser.newElement("Parsed", j2kElem);
- convertJ2KToXML(parser, *compression.parsed, parsedElem);
+ parser.convertJ2KToXML(*(compression.parsed), parsedElem);
}
return compressionElem;
}
-void DerivedXMLParser200::convertJ2KToXML(const DerivedXMLParser& parser,
- const J2KCompression& j2k, xml::lite::Element& parent)
+void DerivedXMLParser200::convertJ2KToXML(const J2KCompression& j2k, xml::lite::Element& parent) const
{
+ auto& parser = *this;
+
parser.createInt("NumWaveletLevels", j2k.numWaveletLevels, parent);
parser.createInt("NumBands", j2k.numBands, parent);
@@ -1518,7 +1512,7 @@ void DerivedXMLParser200::convertJ2KToXML(const DerivedXMLParser& parser,
for (size_t ii = 0; ii < numLayers; ++ii)
{
auto& layerElem = parser.newElement("Layer", layerInfoElem);
- parser.setAttribute(layerElem, "index", ii + 1);
+ parser.setAttribute(layerElem, "index", ii + 1); // `positiveInteger` in SIDD 2.0; changed to `nonNegativeInteger` in SIDD 3.0
parser.createDouble("Bitrate", j2k.layerInfo[ii].bitRate, layerElem);
}
}
diff --git a/six/modules/c++/six.sidd/source/DerivedXMLParser300.cpp b/six/modules/c++/six.sidd/source/DerivedXMLParser300.cpp
index c568e410e..db2ec21d4 100644
--- a/six/modules/c++/six.sidd/source/DerivedXMLParser300.cpp
+++ b/six/modules/c++/six.sidd/source/DerivedXMLParser300.cpp
@@ -25,6 +25,7 @@
#include
#include
+#include
#include
@@ -222,7 +223,7 @@ xml::lite::Document* DerivedXMLParser300::toXML(const DerivedData* derived) cons
// optional
if (derived->compression.get())
{
- DerivedXMLParser200::convertCompressionToXML(*this, *derived->compression, *root);
+ DerivedXMLParser200::convertCompressionToXML(*this, *(derived->compression), *root);
}
// optional
if (derived->digitalElevationData.get())
@@ -335,10 +336,42 @@ void DerivedXMLParser300::parseJ2KCompression(const xml::lite::Element& j2kElem,
for (size_t ii = 0; ii < layerElems.size(); ++ii)
{
+ // In SIDD 3.0, the `index` attribute type changed from `positiveInteger` to `nonNegativeInteger`
+ // (matching C-style indexing). Since we had a problem with this, use the opportunity to
+ // validate the `index` value.
+ const auto& attributes = layerElems[ii]->getAttributes();
+ std::string strIndex;
+ if (attributes.getValue("index", strIndex))
+ {
+ // The schema says this is required, but we might not be validating.
+ const size_t index = std::stoi(strIndex);
+ std::ignore = index; // compiler warning
+ assert(ii == index); // again, we might not be validating the XML
+ }
+
parseDouble(getFirstAndOnly(layerElems[ii], "Bitrate"), j2k.layerInfo[ii].bitRate);
}
}
+void DerivedXMLParser300::convertJ2KToXML(const J2KCompression& j2k, xml::lite::Element& parent) const
+{
+ auto& parser = *this;
+
+ parser.createInt("NumWaveletLevels", j2k.numWaveletLevels, parent);
+ parser.createInt("NumBands", j2k.numBands, parent);
+
+ const auto numLayers = j2k.layerInfo.size();
+ auto& layerInfoElem = parser.newElement("LayerInfo", parent);
+ parser.setAttribute(layerInfoElem, "numLayers", numLayers);
+
+ for (size_t ii = 0; ii < numLayers; ++ii)
+ {
+ auto& layerElem = parser.newElement("Layer", layerInfoElem);
+ parser.setAttribute(layerElem, "index", ii); // `ii + 1` in SIDD 2.0, `positiveInteger` is now `nonNegativeInteger`
+ parser.createDouble("Bitrate", j2k.layerInfo[ii].bitRate, layerElem);
+ }
+}
+
void DerivedXMLParser300::parseDisplayFromXML(const xml::lite::Element& displayElem,
Display& display) const
{
diff --git a/six/modules/c++/six.sidd/tests/sample_xml/sidd300.xml b/six/modules/c++/six.sidd/tests/sample_xml/sidd300.xml
index e3a79ebe9..11686c833 100644
--- a/six/modules/c++/six.sidd/tests/sample_xml/sidd300.xml
+++ b/six/modules/c++/six.sidd/tests/sample_xml/sidd300.xml
@@ -504,6 +504,31 @@
0
+
+
+
+ 1
+ 2
+
+
+ 3.14
+
+
+
+
+ 3
+ 4
+
+
+ 3.1415
+
+
+ 3.1415926
+
+
+
+
+
1