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

Pass ISMVersion around a bit more #657

Merged
merged 118 commits into from
Jun 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
118 commits
Select commit Hold shift + click to select a range
69b3cc9
copy six.sidd to six.sidd30
Jan 30, 2023
2eb06d5
six.sidd30 project and unittests
Jan 30, 2023
c8de122
sidd -> sidd30
Jan 30, 2023
822b4ae
more sidd -> sidd30
Jan 30, 2023
0fa02ec
more sidd -> sidd30
Jan 30, 2023
0407911
begin removing SIDD 3.0 support from six.sidd; it is now (or will be)…
Jan 30, 2023
00bea9f
remove more SIDD 3.0 unittest code from six.sidd, it's not just in si…
Jan 30, 2023
757a806
remove last? traces of SIDD3.0 from six.sidd
Jan 30, 2023
a3da393
tweaks from feature/ISM
Jan 30, 2023
0e1c446
latest from coda-oss and nitro
Jan 30, 2023
41a3083
Squashed 'externals/coda-oss/' changes from 1582c6ac9..aabc5818e
Jan 30, 2023
35a73fd
Merge commit '41a30838e1d4dba6472d7211f3e76b671b48450d' into feature/…
Jan 30, 2023
54a36ce
Squashed 'externals/nitro/' changes from e1a64da1f..24ff32863
Jan 30, 2023
9bdb185
latest from coda-oss and nitro
Jan 30, 2023
b3df43d
latest from coda-oss and nitro
Jan 30, 2023
f6faa5b
use common code from six.sidd
Jan 30, 2023
1ea9562
consistent convertDerivedClassificationToXML() API
Jan 30, 2023
79091cb
use common code from six.sidd
Jan 30, 2023
9a0c703
compile SIDD30 Utilities.cpp
Jan 30, 2023
ba63e04
get six.sidd30 unittests working
Jan 30, 2023
1f4ba79
remove files duplicated between six.sidd and six.sidd30
Jan 30, 2023
06d8f23
build with CMake
Jan 31, 2023
5b68012
SIDD_V3.0.0 directory in "schema"
Feb 2, 2023
7446c7f
easy access to test XML files from Visual Studio
Feb 2, 2023
a687c3a
ValidatorXerces can be moved, but not copied
Feb 2, 2023
c37b15a
fix SIDD version bug when generating fake data
Feb 2, 2023
a579efa
set things up for different schema paths for SIDD 3.0 (not yet implem…
Feb 2, 2023
0ea02ca
more detailed output from schema validation failure
Feb 2, 2023
0dec03b
SIDD_V3.0.0
Feb 2, 2023
797d147
SIDD 3.0 schemas are in the SIDD_V3.0.0 directory
Feb 2, 2023
e5daf7f
no ISM-v201609 in this branch
Feb 2, 2023
4c76c9c
Merge branch 'main' into feature/SIDD-3.0
Apr 25, 2023
624f31f
IonoParameters/F2Height is optional
Apr 25, 2023
6b7cf7e
Merge branch 'feature/SIDD-3.0' of github.com:ngageoint/six-library i…
Apr 25, 2023
84ad444
Merge branch 'main' into feature/SIDD-3.0
Apr 25, 2023
47f9f69
remove six.sidd30
Apr 25, 2023
eaeb4e8
remove SIDD_V3.0.0
Apr 25, 2023
c06756b
slam in 'main'
Apr 25, 2023
84a4cf6
Merge branch 'main' into feature/SIDD-3.0
Apr 26, 2023
2d7838a
Merge branch 'main' into feature/SIDD-3.0
May 22, 2023
869666d
Merge branch 'main' into feature/SIDD-3.0
May 22, 2023
ebd7d8d
Merge branch 'feature/SIDD-3.0' of github.com:ngageoint/six-library i…
May 22, 2023
cc06d88
ISMVersion enum for 201609 and 13
May 22, 2023
d5e5577
need to be able to set the ISM version in more places
May 22, 2023
9725e04
start rippling changes for ISMVersion
May 22, 2023
e5fd009
add a "current" to make it easy for developers to switch between V201…
May 22, 2023
b439ab4
change the ISM namespace
May 22, 2023
1723ca3
restore SIDD-3.0_ISM-v13 to a separate directory
May 22, 2023
c710603
Create sidd300_ISM-v13.xml
May 22, 2023
9abfb68
wrap the xml::lite::validator in our own class
May 22, 2023
adfcf4d
pass a XmlLiteValidator instance
May 22, 2023
6367940
xml.lite changes from coda-oss
May 23, 2023
17bf734
despite various checks for a NULL logger, it really can't be NULL
May 23, 2023
401e703
use xml::lite::Validator directly
May 23, 2023
a3563df
move ISMVersion to the a sidd300 namespace to make it clear it's part…
May 23, 2023
eba3d9e
got a scoping issue somewhere :-(
May 23, 2023
f3eba0d
unittest for ISM-v13
May 23, 2023
d5bc547
hack to read ISM-v13 SIDD from unittest code; WIP
May 23, 2023
c357f82
don't need make_ utility, at least right now
May 24, 2023
9b4427d
log_errors_and_throw() utility
May 24, 2023
b5f88f6
prepare for validating a schema-path at a time
May 24, 2023
8245eef
latest xml.lite tweaks from coda-oss
May 24, 2023
54633a8
"new" code does XML validation one path at a time
May 24, 2023
bd431f7
adjust schema paths if ISMVersion is set
May 24, 2023
d2c26e9
automatically prepend the ISM schema path
May 24, 2023
4d74163
remove ISMVersion from DerivedXMLControl
May 24, 2023
8055430
allow the hard-coded "SIDD_V3.0.0_ISM-" name to be changed
May 24, 2023
6bb5937
first pass at finding the corresponding XSD for a XML
May 29, 2023
7f2de53
add a "hook" so that we can intercept validate() in SIDD code
May 29, 2023
18a57e5
provide standard validateXMLImpl() implementation
May 30, 2023
debc9d9
Revert "first pass at finding the corresponding XSD for a XML"
May 30, 2023
bd9238e
move schema finding code to six.sidd
May 30, 2023
aa81b50
new code only needs to work with std::vector<path>
May 30, 2023
7bdcec0
If we found the right XSD, use that directory first.
May 30, 2023
b08a864
Revert "allow the hard-coded "SIDD_V3.0.0_ISM-" name to be changed"
May 30, 2023
29d93c0
always validate one schema-path at a time
May 30, 2023
8c14122
try not to open so many XSDs
May 30, 2023
fb0c56c
getEnvIfSet()
May 30, 2023
e6ec603
look for SICommonTypes_V1.0.xsd to find the schema directory
May 30, 2023
b28f2d1
Merge branch 'main' into feature/SIDD-3.0
May 30, 2023
fd261c0
"hook" for validating created XML
May 30, 2023
6328464
find_SIDD_schema_V_files() utility
May 30, 2023
fd9704b
put the hard-code SIDD schema name in one place
May 30, 2023
37afd61
copy ISM-v201609 files to separate directory
May 30, 2023
0c5978b
There is now a separate directory for each SIDD 3.0 ISM
May 30, 2023
e5c785d
latest from coda-oss
May 30, 2023
e68140d
Merge commit '81533c2ebd8d743a2fd16116e0d365ea92862eb2' into feature/…
May 30, 2023
81533c2
Squashed 'externals/coda-oss/' changes from e87c32b4d..ff4f820ed
May 30, 2023
853b6f7
Squashed 'externals/nitro/' changes from c8ecbe9ae..2fd7a0bfa
May 30, 2023
f6c30df
copy_externals
May 30, 2023
9732f16
Merge branch 'main' into feature/SIDD-3.0
May 31, 2023
56b4497
toXMLImplValidate() isn't needed (at least not right now)
May 31, 2023
8b5a1bd
simplify validation code by converting to std::filesystem::path rathe…
May 31, 2023
1981611
No longer need ScoppedISMVersion to read ISM-v13 XML
May 31, 2023
842100e
comments to indicate the attributes for which we're looking
May 31, 2023
13831f0
be sure SIDD XML is really SIDD
May 31, 2023
b49336a
latest coda-oss from xml.lite branch
May 31, 2023
887b0f2
use std::vector::insert
May 31, 2023
432307c
create a SIDD Version enum rather than using strings
May 31, 2023
0eab307
expose ISMVersion in fromXML() and toXML()
May 31, 2023
9c0f159
don't need old ISM with SIDD 3.0
Jun 1, 2023
06c9115
Merge branch 'main' into feature/SIDD-3.0
Jun 8, 2023
3077749
use six::sidd::Version rather than a string for creating fake data
Jun 8, 2023
5d9d1e2
require ISMVersion for SIDD 3.0.0
Jun 8, 2023
4ebf05b
more use of six::sidd::Version
Jun 8, 2023
cc682ca
save ISMVersion for SIDD 3.0.0
Jun 8, 2023
70ac245
adjust desVersion for ISMVersion
Jun 8, 2023
c863746
use the ISMVersion from the environment, if any
Jun 8, 2023
f42bfa7
still more use of sidd::Version
Jun 8, 2023
7710dfd
still more use of sidd::Version instead of strVersion
Jun 8, 2023
d81dfdb
latest from CODA-OSS and NITRO
Jun 8, 2023
88fca03
Merge branch 'main' into feature/SIDD-3.0
Jun 8, 2023
50dbb92
latest from CODA-OSS
Jun 8, 2023
2d83223
Squashed 'externals/coda-oss/' changes from ff4f820ed..d1244a080
Jun 8, 2023
06ba41f
Merge commit '2d83223fc22d43f7d580b625ef78d2e04f42645c' into feature/…
Jun 8, 2023
2fdb1db
Squashed 'externals/nitro/' changes from 2fd7a0bfa..05dae18a3
Jun 8, 2023
091ca2a
sync_externals
Jun 8, 2023
5121522
latest from CODA-OSS
Jun 8, 2023
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
59 changes: 48 additions & 11 deletions six/modules/c++/six.sidd/include/six/sidd/DerivedData.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
* see <http://www.gnu.org/licenses/>.
*
*/
#pragma once
#ifndef SIX_six_sidd_DerivedData_h_INCLUDED_
#define SIX_six_sidd_DerivedData_h_INCLUDED_
#pragma once

#include <std/filesystem>

Expand All @@ -44,8 +44,42 @@

namespace six
{
// Emphasize that this is for SIDD 3.0.0
namespace sidd300
{
// We have to support two ISM versions with SIDD 3.0 :-(
enum class ISMVersion
{
v201609, // the "newer" version; default
v13, // the "original" version

current = v201609
};
std::string to_string(ISMVersion); // "v201609" or "v13"

ISMVersion get(ISMVersion defaultIfNotSet); // overloaded on ISMVersion
std::optional<ISMVersion> set(ISMVersion); // returns previous value, if any
std::optional<ISMVersion> getISMVersion();
std::optional<ISMVersion> clearISMVersion(); // returns previous value, if any

std::vector<std::filesystem::path> find_SIDD_schema_V_files(const std::vector<std::filesystem::path>& schemaPaths);
}

namespace sidd
{
// six.sidd only currently supports --
// SIDD 1.0.0
// SIDD 2.0.0
// SIDD 3.0.0
enum class Version
{
v100,
v200,
v300,
};
std::string to_string(Version); // "1.0.0", "2.0.0", "3.0.0"
Version normalizeVersion(const std::string&);

/*!
* \class DerivedData
* \brief The implementation of Data for derived products
Expand All @@ -54,7 +88,7 @@ namespace sidd
* Contains the structs that are the model for SIDD products
*
*/
struct DerivedData: public Data
struct DerivedData : public Data
{
/*!
* Information related to processor, classification,
Expand Down Expand Up @@ -142,6 +176,8 @@ struct DerivedData: public Data
* rather than invoking this object directly.
*/
DerivedData();
DerivedData(Version);
DerivedData(Version, six::sidd300::ISMVersion); // SIDD 3.0.0 must use this overload

/*!
* We are dealing with derived data
Expand Down Expand Up @@ -316,15 +352,14 @@ struct DerivedData: public Data
return std::string(VENDOR_ID);
}

virtual std::string getVersion() const
{
return mVersion;
}
virtual std::string getVersion() const;
virtual void setVersion(const std::string&);
void setVersion(const std::string&, six::sidd300::ISMVersion); // SIDD 3.0.0 must use this overload

virtual void setVersion(const std::string& strVersion)
{
mVersion = strVersion;
}
Version getSIDDVersion() const;
void setSIDDVersion(Version);
void setSIDDVersion(Version, six::sidd300::ISMVersion); // SIDD 3.0.0 must use this overload
six::sidd300::ISMVersion getISMVersion() const;

/*
* Convert the output plane pixel location into meters from the reference
Expand All @@ -341,7 +376,9 @@ struct DerivedData: public Data
bool operator_eq(const DerivedData& rhs) const;
static const char VENDOR_ID[];
bool equalTo(const Data& rhs) const override;
std::string mVersion;

Version mVersion = Version::v100; // existing code
six::sidd300::ISMVersion mISMVersion = six::sidd300::ISMVersion::current; // only for SIDD 3.0.0
};
}
}
Expand Down
43 changes: 5 additions & 38 deletions six/modules/c++/six.sidd/include/six/sidd/DerivedXMLControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,55 +19,23 @@
* see <http://www.gnu.org/licenses/>.
*
*/
#ifndef __SIX_DERIVED_XML_CONTROL_H__
#define __SIX_DERIVED_XML_CONTROL_H__
#pragma once
#ifndef SIX_six_sidd_DerivedXMLControl_h_INCLUDED_
#define SIX_six_sidd_DerivedXMLControl_h_INCLUDED_

#include <std/optional>
#include <std/filesystem>

#include <six/XMLControl.h>
#include <six/Enums.h>

#include <six/sidd/DerivedData.h>
#include <six/sidd/DerivedXMLParser.h>

namespace six
{

// Emphasize that this is for SIDD 3.0.0
namespace sidd300
{
// We have to support two ISM versions with SIDD 3.0 :-(
enum class ISMVersion
{
v201609, // the "newer" version; default
v13, // the "original" version

current = v201609
};
std::string to_string(ISMVersion); // "v201609" or "v13"

ISMVersion get(ISMVersion defaultIfNotSet); // overloaded on ISMVersion
std::optional<ISMVersion> set(ISMVersion); // returns previous value, if any
std::optional<ISMVersion> getISMVersion();
std::optional<ISMVersion> clearISMVersion(); // returns previous value, if any

std::vector<std::filesystem::path> find_SIDD_schema_V_files(const std::vector<std::filesystem::path>& schemaPaths);
}

namespace sidd
{
// six.sidd only currently supports --
// SIDD 1.0.0
// SIDD 2.0.0
// SIDD 3.0.0
enum class Version
{
v100,
v200,
v300,
};
std::string to_string(Version); // "v100", "v200", "v300"

/*!
* \class DerivedXMLControl
* \brief Turns an DerivedData object into XML and vice versa
Expand Down Expand Up @@ -117,5 +85,4 @@ struct DerivedXMLControl : public XMLControl
}
}

#endif

#endif // SIX_six_sidd_DerivedXMLControl_h_INCLUDED_
18 changes: 9 additions & 9 deletions six/modules/c++/six.sidd/include/six/sidd/DerivedXMLParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
* see <http://www.gnu.org/licenses/>.
*
*/
#ifndef __SIX_SIDD_DERIVED_XML_PARSER_H__
#define __SIX_SIDD_DERIVED_XML_PARSER_H__
#pragma once
#ifndef SIX_six_sidd_DerivedXMLParser_h_INCLUDED_
#define SIX_six_sidd_DerivedXMLParser_h_INCLUDED_

#include <six/XMLControl.h>
#include <six/sidd/DerivedData.h>
Expand Down Expand Up @@ -58,13 +59,13 @@ struct DerivedXMLParser : public six::XMLParser
XMLElem parent = nullptr) const;

protected:
DerivedXMLParser(const std::string& version,
DerivedXMLParser(Version,
std::unique_ptr<six::SICommonXMLParser>&& comParser,
logging::Logger* log = nullptr, bool ownLog = false);
DerivedXMLParser(const std::string& version,
DerivedXMLParser(Version,
std::unique_ptr<six::SICommonXMLParser>&&,
std::unique_ptr<logging::Logger>&&);
DerivedXMLParser(const std::string& version,
DerivedXMLParser(Version,
std::unique_ptr<six::SICommonXMLParser>&&,
logging::Logger&);

Expand Down Expand Up @@ -235,10 +236,9 @@ struct DerivedXMLParser : public six::XMLParser
XMLElem parsePlaneProjection(const xml::lite::Element* projElem, const Measurement& measurement) const;
XMLElem parseCylindricalProjection(const xml::lite::Element* projElem, const Measurement& measurement) const;

static
std::string versionToURI(const std::string& strVersion)
static std::string versionToURI(Version siddVersion)
{
return ("urn:SIDD:" + strVersion);
return "urn:SIDD:" + to_string(siddVersion);
}

private:
Expand All @@ -247,4 +247,4 @@ struct DerivedXMLParser : public six::XMLParser
}
}

#endif
#endif // SIX_six_sidd_DerivedXMLParser_h_INCLUDED_
12 changes: 7 additions & 5 deletions six/modules/c++/six.sidd/include/six/sidd/Utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
* see <http://www.gnu.org/licenses/>.
*
*/
#ifndef __SIX_SIDD_UTILITIES_H__
#define __SIX_SIDD_UTILITIES_H__
#pragma once
#ifndef SIX_six_sidd_Utilities_h_INCLUDED_
#define SIX_six_sidd_Utilities_h_INCLUDED_

#include <memory>
#include <vector>
Expand All @@ -31,6 +32,7 @@
#include <types/RgAz.h>
#include <six/Utilities.h>
#include <six/sidd/DerivedData.h>
#include <six/sidd/DerivedXMLControl.h>

namespace six
{
Expand Down Expand Up @@ -82,8 +84,8 @@ class Utilities
* \return mock DerivedData object
*/
static std::unique_ptr<DerivedData> createFakeDerivedData();
static std::unique_ptr<DerivedData> createFakeDerivedData(const std::string& strVersion);

static std::unique_ptr<DerivedData> createFakeDerivedData(Version);
static std::unique_ptr<DerivedData> createFakeDerivedData(Version, six::sidd300::ISMVersion); // for SIDD 3.0.0

/*
* Parses the XML in 'xmlStream' and converts it into a DerivedData object.
Expand Down Expand Up @@ -156,4 +158,4 @@ class Utilities
};
}
}
#endif
#endif // SIX_six_sidd_Utilities_h_INCLUDED_
64 changes: 56 additions & 8 deletions six/modules/c++/six.sidd/source/DerivedData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,19 @@ namespace sidd
{
const char DerivedData::VENDOR_ID[] = "MDA-IS";

DerivedData::DerivedData() :
DerivedData::DerivedData(Version siddVersion, six::sidd300::ISMVersion ismVersion) :
productCreation(new ProductCreation),
mVersion("1.0.0")
mVersion(siddVersion), mISMVersion(ismVersion)
{
}
DerivedData::DerivedData(Version siddVersion) : DerivedData(siddVersion, six::sidd300::get(six::sidd300::ISMVersion::current))
{
if (siddVersion == Version::v300)
{
throw std::invalid_argument("Must use ISMVersion overload.");
}
}
DerivedData::DerivedData() : DerivedData(Version::v100) // existing code
{
}

Expand Down Expand Up @@ -89,22 +99,20 @@ DateTime DerivedData::getCollectionStartDateTime() const

const mem::ScopedCopyablePtr<LUT>& DerivedData::getDisplayLUT() const
{
if (mVersion == "1.0.0")
if (mVersion == Version::v100)
{
if (display->remapInformation.get() == nullptr)
{
throw except::Exception(Ctxt("Display.RemapInformation is nullptr"));
}
return display->remapInformation->remapLUT;
}
else if ((mVersion == "2.0.0") || (mVersion == "3.0.0"))
else if ((mVersion == Version::v200) || (mVersion == Version::v300))
{
return nitfLUT;
}
else
{
throw except::Exception(Ctxt("Unknown version. Expected 3.0.0, 2.0.0, or 1.0.0"));
}

throw except::Exception(Ctxt("Unknown version. Expected 3.0.0, 2.0.0, or 1.0.0"));
}
void DerivedData::setDisplayLUT(std::unique_ptr<AmplitudeTable>&& pLUT)
{
Expand Down Expand Up @@ -166,5 +174,45 @@ bool DerivedData::equalTo(const Data& rhs) const
}
return false;
}

Version DerivedData::getSIDDVersion() const
{
return mVersion;
}
std::string DerivedData::getVersion() const
{
return to_string(getSIDDVersion());
}

void DerivedData::setSIDDVersion(Version siddVersion, six::sidd300::ISMVersion ismVersion)
{
mVersion = siddVersion;
mISMVersion = ismVersion;
}
void DerivedData::setSIDDVersion(Version siddVersion)
{
if (siddVersion == Version::v300)
{
throw std::invalid_argument("Must use ISMVersion overload."); // TODO
}
setSIDDVersion(siddVersion, six::sidd300::get(six::sidd300::ISMVersion::current));
}

void DerivedData::setVersion(const std::string& strVersion)
{
// This is an `override` of `six::Data` so there's no way to pass
// as six::sidd300::ISMVersion for SIDD 3.0.0.
setVersion(strVersion, six::sidd300::get(six::sidd300::ISMVersion::current));
}
void DerivedData::setVersion(const std::string& strVersion, six::sidd300::ISMVersion ismVersion)
{
setSIDDVersion(normalizeVersion(strVersion), ismVersion);
}

six::sidd300::ISMVersion DerivedData::getISMVersion() const
{
return mISMVersion;
}

}
}
12 changes: 5 additions & 7 deletions six/modules/c++/six.sidd/source/DerivedXMLControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@
#include <six/sidd/DerivedXMLParser200.h>
#include <six/sidd/DerivedXMLParser300.h>

namespace
{
six::sidd::Version normalizeVersion(const std::string& strVersion)
six::sidd::Version six::sidd::normalizeVersion(const std::string& strVersion)
{
std::vector<std::string> versionParts;
six::XMLControl::splitVersion(strVersion, versionParts);
Expand Down Expand Up @@ -84,19 +82,19 @@ six::sidd::Version normalizeVersion(const std::string& strVersion)

throw except::Exception(Ctxt("Unsupported SIDD Version: " + strVersion));
}
}

namespace six
{
namespace sidd
{
std::string to_string(Version siddVersion)
{
// Match "incoming" SIDD version strings; this is also what the XML expects, see normalizeVersion()
switch (siddVersion)
{
case Version::v100: return "v100";
case Version::v200: return "v200";
case Version::v300: return "v300";
case Version::v100: return "1.0.0";
case Version::v200: return "2.0.0";
case Version::v300: return "3.0.0";
default: break;
}
throw std::logic_error("Unkown 'Version' value.");
Expand Down
Loading