Skip to content

Commit

Permalink
Revert "make sure we'll always be able to uniquely identify versions"
Browse files Browse the repository at this point in the history
This reverts commit 6ca4581.
  • Loading branch information
Dan Smith committed Aug 7, 2023
1 parent a7f8f5a commit 13e47b4
Show file tree
Hide file tree
Showing 12 changed files with 50 additions and 50 deletions.
6 changes: 3 additions & 3 deletions six/modules/c++/cphd/include/cphd/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ typedef six::MatchInformation MatchInformation;

enum class Version
{
v1_0_0, // {"1.0.0", xml::lite::Uri("urn:CPHD:1.0.0")},
v1_0_1, // {"1.0.1", xml::lite::Uri("http://api.nsgreg.nga.mil/schema/cphd/1.0.1")},
v1_1_0, // {"1.1.0", xml::lite::Uri("http://api.nsgreg.nga.mil/schema/cphd/1.1.0")}
v100, // {"1.0.0", xml::lite::Uri("urn:CPHD:1.0.0")},
v101, // {"1.0.1", xml::lite::Uri("http://api.nsgreg.nga.mil/schema/cphd/1.0.1")},
v110, // {"1.1.0", xml::lite::Uri("http://api.nsgreg.nga.mil/schema/cphd/1.1.0")}
};
std::string to_string(Version); // "1.0.0", "1.0.1", "1.1.0"

Expand Down
12 changes: 6 additions & 6 deletions six/modules/c++/cphd/source/CPHDXMLControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ std::unordered_map<std::string, xml::lite::Uri> CPHDXMLControl::getVersionUriMap
static std::map<Version, xml::lite::Uri> getVersionUriMap_()
{
static const std::map<Version, xml::lite::Uri> retval = {
{Version::v1_0_0, xml::lite::Uri("urn:CPHD:1.0.0")},
{Version::v1_0_1, xml::lite::Uri("http://api.nsgreg.nga.mil/schema/cphd/1.0.1")},
{Version::v1_1_0, xml::lite::Uri("http://api.nsgreg.nga.mil/schema/cphd/1.1.0")}
{Version::v100, xml::lite::Uri("urn:CPHD:1.0.0")},
{Version::v101, xml::lite::Uri("http://api.nsgreg.nga.mil/schema/cphd/1.0.1")},
{Version::v110, xml::lite::Uri("http://api.nsgreg.nga.mil/schema/cphd/1.1.0")}
};
return retval;
}
Expand Down Expand Up @@ -231,9 +231,9 @@ std::string cphd::to_string(Version siddVersion)
// Match existing version strings, see CPHDXMLControl::getVersionUriMap
switch (siddVersion)
{
case Version::v1_0_0: return "1.0.0";
case Version::v1_0_1: return "1.0.1";
case Version::v1_1_0: return "1.1.0";
case Version::v100: return "1.0.0";
case Version::v101: return "1.0.1";
case Version::v110: return "1.1.0";
default: break;
}
throw std::logic_error("Unkown 'Version' value.");
Expand Down
2 changes: 1 addition & 1 deletion six/modules/c++/cphd/source/FileHeader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace cphd

static const char* getDefaultVersion()
{
static const auto defaultVersion = to_string(Version::v1_0_1);
static const auto defaultVersion = to_string(Version::v101);
return defaultVersion.c_str();
}
const char* FileHeader::DEFAULT_VERSION = getDefaultVersion();
Expand Down
6 changes: 3 additions & 3 deletions six/modules/c++/cphd/source/Metadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@ void Metadata::setVersion(const std::string& version)
{
if (version == "1.0.0")
{
setVersion(Version::v1_0_0);
setVersion(Version::v100);
}
else if (version == "1.0.1")
{
setVersion(Version::v1_0_1);
setVersion(Version::v101);
}
else if (version == "1.1.0")
{
setVersion(Version::v1_1_0);
setVersion(Version::v110);
}
else
{
Expand Down
8 changes: 4 additions & 4 deletions six/modules/c++/six.sidd/include/six/sidd/DerivedData.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ namespace sidd
// SIDD 3.0.0
enum class Version
{
v1_0_0,
v2_0_0,
v3_0_0,
v100,
v200,
v300,
};
std::string to_string(Version); // "1.0.0", "2.0.0", "3.0.0"
Version normalizeVersion(const std::string&);
Expand Down Expand Up @@ -377,7 +377,7 @@ struct DerivedData : public Data
static const char VENDOR_ID[];
bool equalTo(const Data& rhs) const override;

Version mVersion = Version::v1_0_0; // existing code
Version mVersion = Version::v100; // existing code
six::sidd300::ISMVersion mISMVersion = six::sidd300::ISMVersion::current; // only for SIDD 3.0.0
};
}
Expand Down
10 changes: 5 additions & 5 deletions six/modules/c++/six.sidd/source/DerivedData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ DerivedData::DerivedData(Version siddVersion, six::sidd300::ISMVersion ismVersio
}
DerivedData::DerivedData(Version siddVersion) : DerivedData(siddVersion, six::sidd300::get(six::sidd300::ISMVersion::current))
{
if (siddVersion == Version::v3_0_0)
if (siddVersion == Version::v300)
{
throw std::invalid_argument("Must use ISMVersion overload.");
}
}
DerivedData::DerivedData() : DerivedData(Version::v1_0_0) // existing code
DerivedData::DerivedData() : DerivedData(Version::v100) // existing code
{
}

Expand Down Expand Up @@ -99,15 +99,15 @@ DateTime DerivedData::getCollectionStartDateTime() const

const mem::ScopedCopyablePtr<LUT>& DerivedData::getDisplayLUT() const
{
if (mVersion == Version::v1_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 == Version::v2_0_0) || (mVersion == Version::v3_0_0))
else if ((mVersion == Version::v200) || (mVersion == Version::v300))
{
return nitfLUT;
}
Expand Down Expand Up @@ -191,7 +191,7 @@ void DerivedData::setSIDDVersion(Version siddVersion, six::sidd300::ISMVersion i
}
void DerivedData::setSIDDVersion(Version siddVersion)
{
if (siddVersion == Version::v3_0_0)
if (siddVersion == Version::v300)
{
throw std::invalid_argument("Must use ISMVersion overload."); // TODO
}
Expand Down
18 changes: 9 additions & 9 deletions six/modules/c++/six.sidd/source/DerivedXMLControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ six::sidd::Version six::sidd::normalizeVersion(const std::string& strVersion)
// SIDD 3.0.0
if (normalizedVersion == "100")
{
return six::sidd::Version::v1_0_0;
return six::sidd::Version::v100;
}
if (normalizedVersion == "200")
{
return six::sidd::Version::v2_0_0;
return six::sidd::Version::v200;
}
if (normalizedVersion == "300")
{
return six::sidd::Version::v3_0_0;
return six::sidd::Version::v300;
}

if (normalizedVersion == "110")
Expand All @@ -92,9 +92,9 @@ namespace sidd
// Match "incoming" SIDD version strings; this is also what the XML expects, see normalizeVersion()
switch (siddVersion)
{
case Version::v1_0_0: return "1.0.0";
case Version::v2_0_0: return "2.0.0";
case Version::v3_0_0: return "3.0.0";
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 Expand Up @@ -330,15 +330,15 @@ DerivedXMLControl::getParser(Version normalizedVersion, std::optional<six::sidd3
// SIDD 1.0.0
// SIDD 2.0.0
// SIDD 3.0.0
if (normalizedVersion == Version::v1_0_0)
if (normalizedVersion == Version::v100)
{
return std::make_unique<DerivedXMLParser100>(mLog);
}
if (normalizedVersion == Version::v2_0_0)
if (normalizedVersion == Version::v200)
{
return std::make_unique<DerivedXMLParser200>(mLog);
}
if (normalizedVersion == Version::v3_0_0)
if (normalizedVersion == Version::v300)
{
if (!ismVersion.has_value())
{
Expand Down
2 changes: 1 addition & 1 deletion six/modules/c++/six.sidd/source/DerivedXMLParser100.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace six
{
namespace sidd
{
constexpr Version VERSION = Version::v1_0_0;
constexpr Version VERSION = Version::v100;
const char SI_COMMON_URI[] = "urn:SICommon:0.1";
const char ISM_URI[] = "urn:us:gov:ic:ism";
inline static xml::lite::Uri getISMUri()
Expand Down
2 changes: 1 addition & 1 deletion six/modules/c++/six.sidd/source/DerivedXMLParser200.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ ProjectionType DerivedXMLParser200::getProjectionType(const xml::lite::Element&
}


constexpr Version VERSION = Version::v2_0_0;
constexpr Version VERSION = Version::v200;
const char SI_COMMON_URI[] = "urn:SICommon:1.0";
inline static xml::lite::Uri getISMUri()
{
Expand Down
2 changes: 1 addition & 1 deletion six/modules/c++/six.sidd/source/DerivedXMLParser300.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace six
{
namespace sidd
{
constexpr Version VERSION = Version::v3_0_0;
constexpr Version VERSION = Version::v300;
static const char SI_COMMON_URI[] = "urn:SICommon:1.0";

// There is a need to support two different versions of ISM with SIDD 3.0 :-(
Expand Down
18 changes: 9 additions & 9 deletions six/modules/c++/six.sidd/source/Utilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ static void initProductCreation(six::sidd::ProductCreation& productCreation, Ver
productCreation.productCreationExtensions.push_back(parameter);

productCreation.classification.securityExtensions.push_back(parameter);
if (siddVersion != Version::v3_0_0)
if (siddVersion != Version::v300)
{
productCreation.classification.desVersion = 234; // existing code
}
Expand All @@ -701,7 +701,7 @@ static void initProductCreation(six::sidd::ProductCreation& productCreation, Ver
productCreation.classification.createDate = six::DateTime();
productCreation.classification.classification = "U";

if (siddVersion == Version::v1_0_0)
if (siddVersion == Version::v100)
{
productCreation.classification.compliesWith.push_back("ICD-710");
}
Expand Down Expand Up @@ -939,7 +939,7 @@ static void initExploitationFeatures(six::sidd::ExploitationFeatures& exFeatures
polarization->txPolarization = six::PolarizationSequenceType::V;
polarization->rcvPolarization = six::PolarizationSequenceType::OTHER;
polarization->rcvPolarizationOffset = 1.37;
if (siddVersion == Version::v1_0_0)
if (siddVersion == Version::v100)
{
polarization->processed = six::BooleanType::IS_TRUE;
}
Expand All @@ -957,7 +957,7 @@ static void initExploitationFeatures(six::sidd::ExploitationFeatures& exFeatures
collection.geometry->extensions.push_back(param);

collection.phenomenology.reset(new six::sidd::Phenomenology());
if (siddVersion != Version::v3_0_0)
if (siddVersion != Version::v300)
{
// [-180, 180) before SIDD 3.0
collection.phenomenology->shadow = six::AngleMagnitude(-1.5, 3.7);
Expand All @@ -979,7 +979,7 @@ static void initExploitationFeatures(six::sidd::ExploitationFeatures& exFeatures
exFeatures.product[0].north = 58.332;
exFeatures.product[0].extensions.push_back(param);

if (siddVersion == Version::v2_0_0)
if (siddVersion == Version::v200)
{
exFeatures.product[0].ellipticity = 12.0;
exFeatures.product[0].polarization.resize(1);
Expand Down Expand Up @@ -1125,7 +1125,7 @@ static void populateData(six::sidd::DerivedData& siddData, const std::string& lu
constexpr bool smallImage = true;
const auto elementSize = static_cast<size_t>(lutType == "Mono" ? 2 : 3);

if ((siddVersion == Version::v2_0_0) || (siddVersion == Version::v3_0_0))
if ((siddVersion == Version::v200) || (siddVersion == Version::v300))
{
// This will naturally get constructed in the course of 1.0.0
// Separate field in 2.0.0
Expand Down Expand Up @@ -1391,19 +1391,19 @@ static std::unique_ptr<DerivedData> createFakeDerivedData_(const Version* pSiddV
}
std::unique_ptr<DerivedData> Utilities::createFakeDerivedData(Version siddVersion)
{
if (siddVersion == Version::v3_0_0)
if (siddVersion == Version::v300)
{
throw std::invalid_argument("Must use ISMVersion overload.");
}
if (siddVersion == Version::v2_0_0)
if (siddVersion == Version::v200)
{
return createFakeDerivedData_(&siddVersion);
}
throw std::invalid_argument("SIDD version = '" + to_string(siddVersion) + "' is not supported.");
}
std::unique_ptr<DerivedData> Utilities::createFakeDerivedData(Version siddVersion, six::sidd300::ISMVersion ismVersion)
{
if (siddVersion != Version::v3_0_0)
if (siddVersion != Version::v300)
{
return createFakeDerivedData(siddVersion);
}
Expand Down
14 changes: 7 additions & 7 deletions six/modules/c++/six.sidd/unittests/test_valid_sixsidd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ static std::unique_ptr<six::sidd::DerivedData> test_assert_round_trip(const std:

inline static const six::UnmodeledS* get_Unmodeled(const six::sidd::DerivedData& derivedData, six::sidd::Version siddVersion)
{
if (siddVersion != six::sidd::Version::v3_0_0) // Unmodeled added in SIDD 3.0
if (siddVersion != six::sidd::Version::v300) // Unmodeled added in SIDD 3.0
{
return nullptr;
}
Expand All @@ -108,17 +108,17 @@ static void test_createFakeDerivedData_(const std::string& testName, bool valida
}
TEST_CASE(test_createFakeDerivedData)
{
test_createFakeDerivedData_(testName, false /*validate*/, six::sidd::Version::v2_0_0, six::sidd300::get(six::sidd300::ISMVersion::current));
test_createFakeDerivedData_(testName, false /*validate*/, six::sidd::Version::v200, six::sidd300::get(six::sidd300::ISMVersion::current));

test_createFakeDerivedData_(testName, false /*validate*/, six::sidd::Version::v3_0_0, six::sidd300::ISMVersion::v13);
test_createFakeDerivedData_(testName, false /*validate*/, six::sidd::Version::v3_0_0, six::sidd300::ISMVersion::v201609);
test_createFakeDerivedData_(testName, false /*validate*/, six::sidd::Version::v300, six::sidd300::ISMVersion::v13);
test_createFakeDerivedData_(testName, false /*validate*/, six::sidd::Version::v300, six::sidd300::ISMVersion::v201609);
}
TEST_CASE(test_createFakeDerivedData_validate)
{
test_createFakeDerivedData_(testName, true /*validate*/, six::sidd::Version::v2_0_0, six::sidd300::get(six::sidd300::ISMVersion::current));
test_createFakeDerivedData_(testName, true /*validate*/, six::sidd::Version::v200, six::sidd300::get(six::sidd300::ISMVersion::current));

test_createFakeDerivedData_(testName, true /*validate*/, six::sidd::Version::v3_0_0, six::sidd300::ISMVersion::v13);
test_createFakeDerivedData_(testName, true /*validate*/, six::sidd::Version::v3_0_0, six::sidd300::ISMVersion::v201609);
test_createFakeDerivedData_(testName, true /*validate*/, six::sidd::Version::v300, six::sidd300::ISMVersion::v13);
test_createFakeDerivedData_(testName, true /*validate*/, six::sidd::Version::v300, six::sidd300::ISMVersion::v201609);
}

TEST_CASE(test_read_sidd200_no_LUT)
Expand Down

0 comments on commit 13e47b4

Please sign in to comment.