USGSCSM Astro Plugin Class

class UsgsAstroPlugin : public csm::Plugin
#include <UsgsAstroPlugin.h>

Copyright © 2017-2022 BAE Systems Information and Electronic Systems Integration Inc.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

  3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Public Functions

UsgsAstroPlugin()
~UsgsAstroPlugin()
virtual std::string getStateFromISD(csm::Isd imageSupportData) const

Retrieves a model state from ISD. @description Extracts and returns a model state string from the provided ISD by first loading any associated image support data and then converting that data into a state string that represents the sensor model identified within the ISD.

Parameters:

imageSupportData – The ISD object from which to derive the model state.

Returns:

A string representing the model state derived from the provided ISD.

virtual std::string getPluginName() const

Retrieves the name of the plugin. @description This function returns the name of the plugin, identifying it within the CSM (Community Sensor Model) framework.

Returns:

A string containing the plugin’s name.

virtual std::string getManufacturer() const

Retrieves the manufacturer’s name. @description This function returns the name of the manufacturer of the plugin.

Returns:

A string containing the name of the manufacturer.

virtual std::string getReleaseDate() const

Retrieves the release date of the plugin. @description This function returns the release date of the plugin, indicating when this version of the plugin was made available.

Returns:

A string containing the release date of the plugin.

virtual csm::Version getCsmVersion() const

Retrieves the version of the CSM API the plugin conforms to. @description This function returns the version of the Community Sensor Model (CSM) API that this plugin is designed to work with.

Returns:

A csm::Version object representing the CSM API version.

virtual size_t getNumModels() const

Retrieves the number of sensor models supported by the plugin. @description This function returns the total number of distinct sensor models provided by the plugin.

Returns:

The number of sensor models supported by the plugin as a size_t.

virtual std::string getModelName(size_t modelIndex) const

Retrieves the name of a specific sensor model supported by the plugin. @description This function returns the name of a sensor model identified by its index.

Parameters:

modelIndex – The index of the sensor model, within the range of models supported by the plugin.

Returns:

A string containing the name of the specified sensor model.

virtual std::string getModelFamily(size_t modelIndex) const

Retrieves the model family for a specific sensor model. @description This function returns the family type of the sensor model identified by the provided model index.

Parameters:

modelIndex – The index of the sensor model within the plugin’s supported models.

Returns:

A string identifying the model’s family. For this plugin, all models belong to the CSM_RASTER_FAMILY.

virtual csm::Version getModelVersion(const std::string &modelName) const

Retrieves the version of a specific sensor model supported by the plugin. @description This function returns the version of the sensor model identified by its name.

Parameters:

modelName – The name of the sensor model for which to retrieve the version.

Returns:

A csm::Version object representing the version of the specified sensor model.

virtual bool canModelBeConstructedFromState(const std::string &modelName, const std::string &modelState, csm::WarningList *warnings = NULL) const

Determines if a sensor model can be constructed from a given state string. @description This function checks if a sensor model with the specified name can be accurately constructed from a provided state string.

Parameters:
  • modelName – The name of the sensor model to be constructed.

  • modelState – A string representing the state from which the model should be constructed.

  • warnings – A pointer to a csm::WarningList for logging any warnings that occur during the model construction check. This can include warnings about mismatches between the intended model and the constructed model or other issues.

Returns:

A boolean value indicating whether the model can be constructed from the provided state. Returns true if the model can be constructed, false otherwise.

virtual bool canModelBeConstructedFromISD(const csm::Isd &imageSupportData, const std::string &modelName, csm::WarningList *warnings = NULL) const

Checks if a sensor model can be constructed from ISD. @description Determines whether a sensor model specified by modelName can be accurately constructed from a given ISD (Imaging Support Data).

Parameters:
  • imageSupportData – The ISD object containing imaging support data necessary for constructing the model.

  • modelName – The name of the sensor model to be constructed.

  • warnings – A pointer to a csm::WarningList for logging any warnings that occur during the model construction check. This includes any issues encountered while attempting to construct the model from the ISD.

Returns:

A boolean value indicating whether the model can be constructed from the provided ISD. Returns true if construction is possible, false otherwise.

virtual csm::Model *constructModelFromState(const std::string &modelState, csm::WarningList *warnings = NULL) const

Constructs a sensor model from a model state string. @description Instantiates a sensor model using a given state string that encapsulates the model’s configuration.

Parameters:
  • modelState – A JSON-encoded string representing the state of the sensor model.

  • warnings – A pointer to a csm::WarningList for logging any warnings that occur during model construction from state.

Throws:

csm::Error – If the model cannot be constructed due to an unsupported model name or any other issues, an error is thrown with details of the failure.

Returns:

A pointer to the reconstructed csm::Model.

virtual csm::Model *constructModelFromISD(const csm::Isd &imageSupportData, const std::string &modelName, csm::WarningList *warnings = NULL) const

Constructs a sensor model from ISD. @description Creates a sensor model based on the given ISD (Imaging Support Data) and the specified model name.

Parameters:
  • imageSupportDataOriginal – The ISD containing imaging support data necessary for model construction.

  • modelName – The name of the sensor model to be constructed.

  • warnings – A pointer to a csm::WarningList for logging any warnings that occur during model construction.

Throws:

csm::Error – If the model cannot be constructed from the given ISD, an error is thrown detailing the reason for failure.

Returns:

A pointer to the constructed csm::Model.

virtual std::string getModelNameFromModelState(const std::string &modelState, csm::WarningList *warnings = NULL) const

Retrieves the model name from a given model state. @description Extracts the sensor model name from a JSON-encoded string representing the model’s state.

Parameters:
  • modelState – A JSON-encoded string representing the state of a sensor model.

  • warnings – A pointer to a csm::WarningList for logging any warnings that occur during the extraction of the model name from the state.

Throws:

csm::Error – If the ‘name_model’ key is missing from the model state, indicating an invalid or incomplete state representation.

Returns:

The name of the sensor model extracted from the model state.

virtual bool canISDBeConvertedToModelState(const csm::Isd &imageSupportData, const std::string &modelName, csm::WarningList *warnings = NULL) const

Checks if ISD can be converted to a model state for a specific model. @description Determines whether the provided ISD (Imaging Support Data) can be successfully converted into a model state string for the sensor model specified by modelName.

Parameters:
  • imageSupportData – The ISD object containing imaging support data.

  • modelName – The name of the sensor model for which the ISD is to be converted.

  • warnings – A pointer to a csm::WarningList for logging any warnings that occur during the ISD conversion check. This can include issues encountered while attempting to convert the ISD to a model state.

Returns:

A boolean value indicating whether the ISD can be converted to a model state for the specified model. Returns true if conversion is possible, false otherwise.

virtual std::string convertISDToModelState(const csm::Isd &imageSupportData, const std::string &modelName, csm::WarningList *warnings = NULL) const

Converts ISD to a model state for a specific sensor model. @description Converts the provided ISD (Imaging Support Data) into a model state string specifically for the sensor model named modelName.

Parameters:
  • imageSupportData – The ISD object containing imaging support data.

  • modelName – The name of the sensor model for which the ISD is to be converted.

  • warnings – A pointer to a csm::WarningList for logging any warnings that occur during the ISD to model state conversion. This might include issues with the ISD content or format that could affect the conversion process.

Returns:

A string representing the state of the sensor model as derived from the provided ISD.

std::string loadImageSupportData(const csm::Isd &imageSupportDataOriginal) const

Loads image support data from a metadata file. @description Given a csm::Isd object that includes only the image filename, this function locates a corresponding metadata JSON file in the same directory, reads it, and returns its content as a JSON-encoded string. The function appends the image identifier to the JSON object before returning.

Parameters:

imageSupportDataOriginal – A csm::Isd object containing the filename of the image for which support data is to be loaded.

Throws:

csm::Error – If there is an issue reading the metadata file, an error is thrown with details of the failure.

Returns:

A string containing the JSON-encoded image support data.

Private Types

typedef csm::Model *(*sensorConstructor)(void)

Private Members

std::shared_ptr<spdlog::logger> m_logger

Private Static Attributes

static const UsgsAstroPlugin m_registeredPlugin
static const std::string _PLUGIN_NAME = "UsgsAstroPluginCSM"
static const std::string _MANUFACTURER_NAME = "UsgsAstrogeology"
static const std::string _RELEASE_DATE = "20190222"
static const int _N_SENSOR_MODELS = 5
static std::map<std::string, sensorConstructor> MODELS