Skip to content
Snippets Groups Projects
Commit 1e981d2c authored by jlaura's avatar jlaura Committed by Jesse Mapel
Browse files

Merging dev into master for release (#158)

* Updated ISD and tests  (#87)

* updated tests + RIP TestyMcTestFace

* keys updated

* Probably should not hard code .cpps in the CMakeLists.txt for GTest

* updated specs to mimic synthetic json

* appveyor assumed broken from standup, disabling until fixed

* eulers are now quats

* merge from jay's changes

* merge markers

* renamed quats as per Jessie's reccomendation

* only appends sensor_orientation to missing params

* stupid markers

* updated test ISD

* changes as per some comments

* updated as per comments

* defaults are all 0

* #pragma once to C style header guard

* stragler change

* missed some params

* missed another

* moving things around

* patched segfault error + added detector center as defined in json schema (#94)

* patched segfault error + added detector center as defined in the swagger schema

* verbose travi

* Fixed optical distortion and pixel to focal transforms. (#115)

* Update to use quaternions in test to match new ISD

* Fixes #121

* Fix 1 remaining failing omega rotation test

* Updates token to be in quotes

* Still trying to get the builds working.

* Updates to force upload

* Adds newline

* Update for formatting

* Trying to force travis to deploy with labels

I am editing this on the repo in order to get Travis to do its thing - I can not do this via a PR.

* Update .travis.yml

* Update meta.yaml

to try and force a dev tag on the builds to get labels to work.

* Update meta.yaml

* Update .travis.yml

* test x scaling for reset model state

* test FL500 conversion

* test FL500 conversion

* Add tests to include

* commit to force run of tests on mac with debug output

* switch to using tolerances from dev

* 0.5 pixel offset

* try moving set of filename into setup

* initialize differently test

* more debug output

* Add matrix to debug output

* Even more debug output from matrix calculation

* Add missing quaternion component to state string

* cleanup debug output now that problem is fixed

* fix added spacing

* Adds in check for PR for upload

* echo to check travis env

* fixes equality check for PR

* Clean up some spacing (non-functional) in UsgsAstroFrameModel

* Fixed canModelBeConstructedFromISD throwing an exception when the metadata file doesn't exist. (#134)

* fixed can be converted error

* Added not constructible test for frame plugin

* Removed old LS ISD header (#137)

* Update some of the tests that set a new state value to use a function in the fixture, rather than repeating code

* Windows Build (#139)

* adds win build

* Windows build

* Updates submodules

* Refactoring to move to one plugin and removed unused classes.  (#138)

* merge

* changed varrs

* reset test

* First iteration

* it compiles, although renaming this is still neccessary

* added source

* cleaned up, tests still need to pass

* post merge clean up

* validation updated, validation tests are now passing

* Addressed comments from Jesse

* last Jesse comment, convertISDToModelState doesn't check if pointer is invalid anymore as the sensor model should except

* model_name -> m_modelName for frame getState

* copy paste error in FrameSensorModel

* Resolve merge conflicts with FrameIsdTest vs. SimpleFrameIsdTest names

* Fix hopefully last merge problem

* Conda build on win (#143)

* Conda build on win

* Trying a straight build first

* Unneeded csmapi

* Now trying to upload build

* Trying a build and upload

* Trying syntax change

* trying ps

* Update .appveyor.yml

* Update .appveyor.yml

* Update .appveyor.yml

* Update .appveyor.yml

* Update .appveyor.yml

* Update .appveyor.yml

* Update .appveyor.yml

* Update .appveyor.yml

* Update .appveyor.yml

* Update .appveyor.yml

* Update .appveyor.yml

* Update meta.yaml

* Update bld.bat

This is a test to see where appveyor is failing.

* Update bld.bat

* Update bld.bat

* Update meta.yaml

* Update .appveyor.yml

* Update .appveyor.yml

* Update .appveyor.yml

* Update .appveyor.yml

* Adds if/else into appveyor (#146)

* Adds if/else into appveyor

* Update .appveyor.yml

* Updates to use gcc7

* Update .travis.yml

* Update .appveyor.yml

* Fixed Line Scan construction and condensed plugin tests (#145)

* First pass at test LS ISD

* Initial LS plugin test base

* fixed a test in frame plugin tests

* Initial LS plugin test suite

* Moved to single plugin test file

* Added some new plugin tests

* Fixed LS construction

* Re-updated submodules

* Reverted gtest

* removed debuf prints left in and made getModelName functional (#148)

* Changed line scan sensor model to new ISD spec (#149)

* Changed line scan sensor model to new ISD spec

* Updated LS to the proper spec

* Changed model_name to name_model

* Updated tests to use new name_ format in ISD

* Updated LS test data to new spec

* Fixed typo in ls test ISD

* Moved framer to new ISD format. Added bad debug statements.

* Updated LS to new spec

* Fixed focal length epsilon name

* Added model state test for framer (#152)

* fixed nan issue (#153)

* fixed nan issue

* left in for loop

* Removed switch statement for ls distortion: (#150)
parent 55181f74
No related branches found
Tags 1.0.0
No related merge requests found
Showing
with 1752 additions and 2934 deletions
...@@ -7,17 +7,41 @@ platform: ...@@ -7,17 +7,41 @@ platform:
configuration: configuration:
- Release - Release
- Debug
environment:
CSM_LIBRARY_PATH: C:\\Miniconda36-x64\lib
CSM_INCLUDE_PATH: C:\\Miniconda36-x64\include
install: install:
- git submodule update --init --recursive - git submodule update --init --recursive
# This pulls csm from conda - call C:\\Miniconda36-x64\Scripts\activate.bat
- cmd: call C:\\Miniconda36-x64\Scripts\activate.bat - conda config --set always_yes yes --set changeps1 no
- cmd: conda install -y -c usgs-astrogeology libcsm - conda update -q conda
- cmake . - conda install conda-build anaconda-client
- conda config --add channels usgs-astrogeology
before_build:
- mkdir build
- cd build
build_script: build_script:
- cmake --build . -- %MSBUILD_ARGS% - cmake -G "Visual Studio 15 2017 Win64" -DBUILD_TESTS=OFF ..
- cmake --build . --target ALL_BUILD --config Release
artifacts:
- path: build\Release\usgscsm.dll
name: usgscsm.dll
on_success:
- cd ../
- conda build -q recipe/
- ps:
if ($env:APPVEYOR_PULL_REQUEST_NUMBER -eq "") {
$tar_glob = conda build recipe --output;
Write-Host "tar_glob $tar_glob";
if ($env:APPVEYOR_REPO_BRANCH -eq "dev") {
$anaconda_label = "dev"
} else {
$anaconda_label = "main"
};
Write-Host "anaconda_label $anaconda_label";
$parameters = '-t', "$env:CONDA_UPLOAD_TOKEN", 'upload', "$tar_glob", '-l',
"$anaconda_label", '--force', '--no-progress';
& cmd /c 'anaconda 2>&1' $parameters;
};
...@@ -14,15 +14,16 @@ matrix: ...@@ -14,15 +14,16 @@ matrix:
sources: sources:
- ubuntu-toolchain-r-test - ubuntu-toolchain-r-test
packages: packages:
- g++-6 - g++-7
env: env:
- MATRIX_EVAL="CXX=g++-6 && CC=gcc-6" - MATRIX_EVAL="CXX=g++-7 && CC=gcc-7"
- os: osx - os: osx
osx_image: xcode9.4 osx_image: xcode9.4
env: env:
- MATRIX_EVAL="CXX=clang++ && CC=clang" - MATRIX_EVAL="CXX=clang++ && CC=clang"
before_install: before_install:
- echo "$TRAVIS_PULL_REQUEST"
- eval "${MATRIX_EVAL}" - eval "${MATRIX_EVAL}"
- | - |
if [ "$TRAVIS_OS_NAME" == "linux" ]; then if [ "$TRAVIS_OS_NAME" == "linux" ]; then
...@@ -58,8 +59,8 @@ after_success: ...@@ -58,8 +59,8 @@ after_success:
- builddir=(`conda build recipe --output`) - builddir=(`conda build recipe --output`)
# Label based on the branch and upload to anaconda.org # Label based on the branch and upload to anaconda.org
- | - |
if [ "$TRAVIS_BRANCH" == "master" ]; then if [ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
anaconda -t="$CONDA_UPLOAD_TOKEN" upload $builddir; anaconda -t="$CONDA_UPLOAD_TOKEN" upload $builddir;
elif [ "$TRAVIS_BRANCH" == "dev" ]; then elif [ "$TRAVIS_BRANCH" == "dev" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
anaconda -t="$CONDA_UPLOAD_TOKEN" upload $builddir --label dev; anaconda -t="$CONDA_UPLOAD_TOKEN" upload $builddir --label dev --force;
fi fi
...@@ -18,14 +18,15 @@ else() ...@@ -18,14 +18,15 @@ else()
PATH_SUFFIXES "csm" PATH_SUFFIXES "csm"
PATHS $ENV{CONDA_PREFIX}/include/) PATHS $ENV{CONDA_PREFIX}/include/)
find_library(CSM_LIBRARY csmapi PATHS $ENV{CONDA_PREFIX}/lib) find_library(CSM_LIBRARY csmapi PATHS $ENV{CONDA_PREFIX}/lib)
message("--Found CSM Library: ${CSM_LIBRARY}")
message("--Found CSM Include Directory: ${CSM_INCLUDE_DIR}")
endif(BUILD_CSM) endif(BUILD_CSM)
add_library(usgscsm SHARED add_library(usgscsm SHARED
src/UsgsAstroFramePlugin.cpp src/UsgsAstroPlugin.cpp
src/UsgsAstroFrameSensorModel.cpp src/UsgsAstroFrameSensorModel.cpp
src/UsgsAstroLsPlugin.cpp src/UsgsAstroLsSensorModel.cpp)
src/UsgsAstroLsSensorModel.cpp
src/UsgsAstroLsStateData.cpp)
set_target_properties(usgscsm PROPERTIES set_target_properties(usgscsm PROPERTIES
VERSION ${PROJECT_VERSION} VERSION ${PROJECT_VERSION}
...@@ -42,7 +43,6 @@ target_include_directories(usgscsm ...@@ -42,7 +43,6 @@ target_include_directories(usgscsm
) )
# Setup for GoogleTest # Setup for GoogleTest
find_package (Threads) find_package (Threads)
target_link_libraries(usgscsm target_link_libraries(usgscsm
...@@ -50,16 +50,11 @@ target_link_libraries(usgscsm ...@@ -50,16 +50,11 @@ target_link_libraries(usgscsm
gtest ${CMAKE_THREAD_LIBS_INIT}) gtest ${CMAKE_THREAD_LIBS_INIT})
if(WIN32) if(WIN32)
option(CMAKE_USE_WIN32_THREADS_INIT "using WIN32 threads" ON) install(TARGETS usgscsm RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR})
option(gtest_disable_pthreads "Disable uses of pthreads in gtest." ON)
install(TARGETS usgscsm
RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(DIRECTORY ${USGSCSM_INCLUDE_DIRS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
else() else()
install(TARGETS usgscsm install(TARGETS usgscsm LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(DIRECTORY ${USGSCSM_INCLUDE_DIRS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
endif() endif()
install(DIRECTORY ${USGSCSM_INCLUDE_DIRS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
# Optional build or link against CSM # Optional build or link against CSM
......
Subproject commit ea22180f46f86f4c95ade84ab81eb4477bdd8dd6 Subproject commit c78dbba3731432249a75db9fdd7415b292d46715
Subproject commit e5e2ef7cd27cc089c1d8302a11970ef870554294 Subproject commit 2fe3bd994b3189899d93f1d5a881e725e046fdc2
...@@ -9,6 +9,10 @@ ...@@ -9,6 +9,10 @@
#include "RasterGM.h" #include "RasterGM.h"
#include "CorrelationModel.h" #include "CorrelationModel.h"
#include <json.hpp>
using json = nlohmann::json;
class UsgsAstroFrameSensorModel : public csm::RasterGM { class UsgsAstroFrameSensorModel : public csm::RasterGM {
// UsgsAstroFramePlugin needs to access private members // UsgsAstroFramePlugin needs to access private members
friend class UsgsAstroFramePlugin; friend class UsgsAstroFramePlugin;
...@@ -17,11 +21,19 @@ class UsgsAstroFrameSensorModel : public csm::RasterGM { ...@@ -17,11 +21,19 @@ class UsgsAstroFrameSensorModel : public csm::RasterGM {
UsgsAstroFrameSensorModel(); UsgsAstroFrameSensorModel();
~UsgsAstroFrameSensorModel(); ~UsgsAstroFrameSensorModel();
bool isValidModelState(const std::string& stringState, csm::WarningList *warnings);
bool isValidIsd(const std::string& stringIsd, csm::WarningList *warnings);
virtual csm::ImageCoord groundToImage(const csm::EcefCoord &groundPt, virtual csm::ImageCoord groundToImage(const csm::EcefCoord &groundPt,
double desiredPrecision=0.001, double desiredPrecision=0.001,
double *achievedPrecision=NULL, double *achievedPrecision=NULL,
csm::WarningList *warnings=NULL) const; csm::WarningList *warnings=NULL) const;
std::string constructStateFromIsd(const std::string& jsonIsd, csm::WarningList *warnings);
void reset();
virtual csm::ImageCoordCovar groundToImage(const csm::EcefCoordCovar &groundPt, virtual csm::ImageCoordCovar groundToImage(const csm::EcefCoordCovar &groundPt,
double desiredPrecision=0.001, double desiredPrecision=0.001,
double *achievedPrecision=NULL, double *achievedPrecision=NULL,
...@@ -301,12 +313,12 @@ class UsgsAstroFrameSensorModel : public csm::RasterGM { ...@@ -301,12 +313,12 @@ class UsgsAstroFrameSensorModel : public csm::RasterGM {
protected: protected:
FRIEND_TEST(FramerParameterizedTest,JacobianTest); FRIEND_TEST(FramerParameterizedTest,JacobianTest);
FRIEND_TEST(FrameIsdTest, setFocalPlane1); FRIEND_TEST(FrameSensorModel, setFocalPlane1);
FRIEND_TEST(FrameIsdTest, Jacobian1); FRIEND_TEST(FrameSensorModel, Jacobian1);
FRIEND_TEST(FrameIsdTest, setFocalPlane_AllCoefficientsOne); FRIEND_TEST(FrameSensorModel, setFocalPlane_AllCoefficientsOne);
FRIEND_TEST(FrameIsdTest, distortMe_AllCoefficientsOne); FRIEND_TEST(FrameSensorModel, distortMe_AllCoefficientsOne);
FRIEND_TEST(FrameIsdTest, setFocalPlane_AlternatingOnes); FRIEND_TEST(FrameSensorModel, setFocalPlane_AlternatingOnes);
FRIEND_TEST(FrameIsdTest, distortMe_AlternatingOnes); FRIEND_TEST(FrameSensorModel, distortMe_AlternatingOnes);
virtual bool setFocalPlane(double dx,double dy,double &undistortedX,double &undistortedY) const; virtual bool setFocalPlane(double dx,double dy,double &undistortedX,double &undistortedY) const;
virtual void distortionFunction(double ux, double uy, double &dx, double &dy) const; virtual void distortionFunction(double ux, double uy, double &dx, double &dy) const;
...@@ -316,7 +328,6 @@ protected: ...@@ -316,7 +328,6 @@ protected:
private: private:
// Input parameters // Input parameters
static const int m_numParameters; static const int m_numParameters;
static const std::string m_parameterName[]; static const std::string m_parameterName[];
...@@ -326,40 +337,43 @@ protected: ...@@ -326,40 +337,43 @@ protected:
std::vector<double> m_noAdjustments; std::vector<double> m_noAdjustments;
std::vector<double> m_odtX; std::vector<double> m_odtX;
std::vector<double> m_odtY; std::vector<double> m_odtY;
std::vector<double> m_transX;
static const int _NUM_STATE_KEYWORDS; std::vector<double> m_transY;
static const std::string _STATE_KEYWORD[]; std::vector<double> m_spacecraftVelocity;
std::vector<double> m_sunPosition;
double m_transX[3]; std::vector<double> m_ccdCenter;
double m_transY[3]; std::vector<double> m_iTransS;
std::vector<double> m_iTransL;
std::vector<double> m_boresight;
double m_majorAxis; double m_majorAxis;
double m_minorAxis; double m_minorAxis;
double m_focalLength; double m_focalLength;
double m_spacecraftVelocity[3];
double m_sunPosition[3];
double m_ccdCenter[2];
double m_minElevation; double m_minElevation;
double m_maxElevation; double m_maxElevation;
double m_line_pp; double m_linePp;
double m_sample_pp; double m_samplePp;
double m_startingDetectorSample; double m_startingDetectorSample;
double m_startingDetectorLine; double m_startingDetectorLine;
std::string m_targetName; std::string m_targetName;
std::string m_modelName;
double m_ifov; double m_ifov;
std::string m_instrumentID; std::string m_instrumentID;
double m_focalLengthEpsilon; double m_focalLengthEpsilon;
double m_originalHalfLines; double m_originalHalfLines;
std::string m_spacecraftName; std::string m_spacecraftName;
double m_pixelPitch; double m_pixelPitch;
double m_iTransS[3];
double m_iTransL[3];
double m_ephemerisTime; double m_ephemerisTime;
double m_originalHalfSamples; double m_originalHalfSamples;
double m_boresight[3];
int m_nLines; int m_nLines;
int m_nSamples; int m_nSamples;
int m_nParameters; int m_nParameters;
json _state;
static const int _NUM_STATE_KEYWORDS;
static const int NUM_PARAMETERS;
static const std::string _STATE_KEYWORD[];
csm::NoCorrelationModel _no_corr_model; csm::NoCorrelationModel _no_corr_model;
double getValue(int index,const std::vector<double> &adjustments) const; double getValue(int index,const std::vector<double> &adjustments) const;
...@@ -371,6 +385,7 @@ protected: ...@@ -371,6 +385,7 @@ protected:
double xl, double yl, double xl, double yl,
double zl, double zl,
double& x,double& y, double& z) const; double& x,double& y, double& z) const;
}; };
#endif #endif
//----------------------------------------------------------------------------
//
// UNCLASSIFIED
//
// Copyright © 1989-2017 BAE Systems Information and Electronic Systems Integration Inc.
// ALL RIGHTS RESERVED
// Use of this software product is governed by the terms of a license
// agreement. The license agreement is found in the installation directory.
//
// For support, please visit http://www.baesystems.com/gxp
//
// FILENAME: UsgsAstroLsISD.h
//
// DESCRIPTION:
//
// Image Support Data (ISD) to build the Astro Line Scanner sensor model.
// The ISD format is defined by the imagery provider. A few common formats
// include name/value pairs, XML, NITF TREs, and GeoTiff tags.
//
// This ISD is formatted as a list of name/value pairs. The order of the
// list generally does not matter, except that the length of a vector needs
// to be read in before the vector itself. Extra data in the support data
// file will be ignored.
//
// There is data describing the ellipsoid that can optionally be in a
// seperate file. This is to support legacy data, but is not encouraged.
//
// For the Astro LS sensor model there is a close relationship between the
// ISD and the State data. This is not always the case. So, it is best to
// seperate the ISD parsing (done here), the translation of ISD to state
// data (done in the plugin), and the instantiation of the sensor model
// from state data (done in the sensor model).
//
// SOFTWARE HISTORY:
//
// Date Author Comment
// ----------- ---------- -------
// 16-Oct-2017 BAE Systems Initial Release
//
//#############################################################################
#ifndef __USGS_ASTRO_LINE_SCANNER_ISD_H
#define __USGS_ASTRO_LINE_SCANNER_ISD_H
#include <vector>
#include <string>
#include <csm.h>
#include <Isd.h>
#include <SettableEllipsoid.h>
class UsgsAstroLsISD
{
public:
UsgsAstroLsISD()
{
reset();
}
UsgsAstroLsISD(
const std::string& lis_file_name,
const std::string& ell_file_name)
{
reset();
setISD(lis_file_name, ell_file_name);
}
virtual ~UsgsAstroLsISD() {}
// Formats the support data as a string
// This is mainly used to check that the
// support data is read in correctly.
std::string toString() const;
// Initializes the class from ISD as formatted by the image provider.
//
// Note that if the ellipsoid data is found in the main ISD file,
// the ellipsoid data file is not needed.
void setISD(
const std::string& lis_file_name,
const std::string& ell_file_name);
//--------------------------------------------------------------------------
// Helper Routines
//--------------------------------------------------------------------------
// Initial check that support data file exists and looks like Astro LS ISD.
static bool checkFileValidity(
const csm::Isd& image_support_data,
std::string& lis_file_name,
std::string& ell_file_name,
std::string& img_rel_name);
// ISD elements;
// The support data is defined by USGS. See the documentation at
// http://htmlpreview.github.io/?https://github.com/USGS-Astrogeology/socet_set/blob/master/SS4HiRISE/Tutorials/ISD_keyword_examples/AstroLineScanner_ISD_Keywords.ls.htm
// Even for fields that do not change, it is best to include them in
// the support data rather than hard code values in the sensor model.
// Since this is not always done, some fields are optional.
std::string m_sensor_type;
int m_total_lines;
int m_total_samples;
int m_platform;
int m_aberr;
int m_atmref;
double m_int_time;
double m_starting_ephemeris_time;
double m_center_ephemeris_time;
double m_detector_sample_summing;
double m_starting_sample;
int m_ikcode;
double m_focal;
double m_isis_z_direction;
double m_optical_dist_coef[3];
double m_itranss[3];
double m_itransl[3];
double m_detector_sample_origin;
double m_detector_line_origin;
double m_detector_line_offset;
double m_mounting_angles[3];
double m_dt_ephem;
double m_t0_ephem;
double m_dt_quat;
double m_t0_quat;
int m_number_of_ephem;
int m_number_of_quaternions;
std::vector<double> m_ephem_pts;
std::vector<double> m_ephem_rates;
std::vector<double> m_quaternions;
std::vector<double> m_tri_parameters;
double m_semi_major_axis;
double m_eccentricity;
// Optional fields
double m_ref_height;
double m_min_valid_ht;
double m_max_valid_ht;
std::string m_image_id;
std::string m_sensor_id;
std::string m_platform_id;
std::string m_traj_id;
std::string m_coll_id;
std::string m_ref_date_time;
static const std::string mISD_KEYWORDS[];
protected:
// Set to default values
void reset();
};
#endif
//----------------------------------------------------------------------------
//
// UNCLASSIFIED
//
// Copyright © 1989-2017 BAE Systems Information and Electronic Systems Integration Inc.
// ALL RIGHTS RESERVED
// Use of this software product is governed by the terms of a license
// agreement. The license agreement is found in the installation directory.
//
// For support, please visit http://www.baesystems.com/gxp
//
// Description:
// This class creates instances of the Astro Line Scanner sensor model. The
// sensor model can be created from either image support data or sensor model
// state data. This plugin is an implementation of the CSM 3.0.3 CSM plugin
// class. It supports ISD specified by image file name. It is expected that
// a support data file exist in the same directory with the images file name
// with "_keywords.lis" appended instead of the original extension. An optional
// file containing ellipsoid data (ellipsoid.ell) can also be placed in this
// directory. Otherwise, the ellipsoid data is found in the .lis file.
//
// Revision History:
// Date Name Description
// ----------- --------- -----------------------------------------------
// 30-APR-2017 BAE Systems Initial Implementation based on CSM 2.0 code
// 16-OCT-2017 BAE Systems Update for CSM 3.0.3
//-----------------------------------------------------------------------------
#ifndef __USGS_ASTRO_LINE_SCANNER_PLUGIN_H
#define __USGS_ASTRO_LINE_SCANNER_PLUGIN_H
#include <string>
#include <Plugin.h>
class UsgsAstroLsPlugin : public csm::Plugin
{
public:
//---
// The public interface is inherited from the csm::Plugin class.
//---
//--------------------------------------------------------------------------
// Plugin Interface
//--------------------------------------------------------------------------
virtual std::string getPluginName() const;
//> This method returns the character std::string that identifies the
// plugin.
//<
//---
// CSM Plugin Descriptors
//---
virtual std::string getManufacturer() const;
//> This method returns name of the organization that created the plugin.
//<
virtual std::string getReleaseDate() const;
//> This method returns release date of the plugin.
// The returned string follows the ISO 8601 standard.
//
//- Precision Format Example
//- year yyyy "1961"
//- month yyyymm "196104"
//- day yyyymmdd "19610420"
//<
virtual csm::Version getCsmVersion() const;
//> This method returns the CSM API version that the plugin conforms to.
//<
//---
// Model Availability
//---
virtual size_t getNumModels() const;
//> This method returns the number of types of models that this plugin
// can create.
//<
virtual std::string getModelName(size_t modelIndex) const;
//> This method returns the name of the model for the given modelIndex.
// The order does not matter - the index is only used to cycle through
// all of the model names.
//
// The model index must be less than getNumModels(), or an exception
// will be thrown.
//<
virtual std::string getModelFamily(size_t modelIndex) const;
//> This method returns the model "family" for the model for the given
// modelIndex. This should be the same as what is returned from
// csm::Model::getFamily() for the model.
//
// SETs can use this information to exclude models when searching for a
// model to create.
//
// The model index must be less than getNumModels(), or an exception
// will be thrown.
//<
//---
// Model Descriptors
//---
virtual csm::Version getModelVersion(const std::string& modelName) const;
//> This method returns the version of the code for the model given
// by modelIndex. The Version object can be compared to other Version
// objects with its comparison operators. Not to be confused with the
// CSM API version.
//<
//---
// Model Construction
//---
virtual bool canModelBeConstructedFromState(
const std::string& modelName,
const std::string& modelState,
csm::WarningList* warnings = NULL) const;
//> This method returns a boolean indicating whether or not a model of the
// given modelName can be constructed from the given modelState.
//
// If a non-NULL warnings argument is received, it will be populated
// as applicable.
//<
virtual bool canModelBeConstructedFromISD(
const csm::Isd& imageSupportData,
const std::string& modelName,
csm::WarningList* warnings = NULL) const;
//> This method returns a boolean indicating whether or not a model of the
// given modelName can be constructed from the given imageSupportData.
//
// If a non-NULL warnings argument is received, it will be populated
// as applicable.
//<
virtual csm::Model* constructModelFromState(
const std::string& modelState,
csm::WarningList* warnings = NULL) const;
//> This method allocates and initializes an object of the appropriate
// derived Model class with the given modelState and returns a pointer to
// the Model base class. The object is allocated by this method using
// new; it is the responsibility of the calling application to delete it.
//
// If a non-NULL warnings argument is received, it will be populated
// as applicable.
//<
virtual csm::Model* constructModelFromISD(
const csm::Isd& imageSupportData,
const std::string& modelName,
csm::WarningList* warnings = NULL) const;
//> This method allocates and initializes an object of the appropriate
// derived Model class with the given imageSupportData and returns a
// pointer to the Model base class. The object is allocated by this
// method using new; it is the responsibility of the calling
// application to delete it.
//
// If a non-NULL warnings argument is received, it will be populated
// as applicable.
//<
virtual std::string getModelNameFromModelState(
const std::string& modelState,
csm::WarningList* warnings = NULL) const;
// This method returns the model name for which the given modelState
// is applicable.
//
// If a non-NULL warnings argument is received, it will be populated
// as applicable.
//<
//---
// Image Support Data Conversions
//---
virtual bool canISDBeConvertedToModelState(
const csm::Isd& imageSupportData,
const std::string& modelName,
csm::WarningList* warnings = NULL) const;
//> This method returns a boolean indicating whether or not a model state
// of the given modelName can be constructed from the given
// imageSupportData.
//
// If a non-NULL warnings argument is received, it will be populated
// as applicable.
//<
virtual std::string convertISDToModelState(
const csm::Isd& imageSupportData,
const std::string& modelName,
csm::WarningList* warnings = NULL) const;
//> This method returns a model state string for the given modelName,
// constructed from the given imageSupportData.
//
// If a non-NULL warnings argument is received, it will be populated
// as applicable.
//<
//private:
//--------------------------------------------------------------------------
// Constructors/Destructor
//--------------------------------------------------------------------------
UsgsAstroLsPlugin();
~UsgsAstroLsPlugin();
private:
//--------------------------------------------------------------------------
// Data Members
//--------------------------------------------------------------------------
// This is needed to allow the plugin to be registered.
static const UsgsAstroLsPlugin _theRegisteringObject;
static const std::string mISD_KEYWORDS[];
static const std::string mSTATE_KEYWORDS[];
}; // UsgsAstroLsPlugin
#endif // __USGS_ASTRO_LINE_SCANNER_PLUGIN_H
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
#ifndef __USGS_ASTRO_LINE_SCANNER_SENSORMODEL_H #ifndef __USGS_ASTRO_LINE_SCANNER_SENSORMODEL_H
#define __USGS_ASTRO_LINE_SCANNER_SENSORMODEL_H #define __USGS_ASTRO_LINE_SCANNER_SENSORMODEL_H
#include "UsgsAstroLsStateData.h"
#include <RasterGM.h> #include <RasterGM.h>
#include <SettableEllipsoid.h> #include <SettableEllipsoid.h>
#include <CorrelationModel.h> #include <CorrelationModel.h>
...@@ -37,6 +36,102 @@ class UsgsAstroLsSensorModel : public csm::RasterGM, virtual public csm::Settabl ...@@ -37,6 +36,102 @@ class UsgsAstroLsSensorModel : public csm::RasterGM, virtual public csm::Settabl
{ {
public: public:
// Initializes the class from state data as formatted
// in a string by the toString() method
void setState(const std::string &state);
virtual void replaceModelState(const std::string& argState);
//> This method attempts to initialize the current model with the state
// given by argState. The argState argument can be a string previously
// retrieved from the getModelState method.
//
// If argState contains a valid state for the current model,
// the internal state of the model is updated.
//
// If the model cannot be updated to the given state, a csm::Error is
// thrown and the internal state of the model is undefined.
//
// If the argument state string is empty, the model remains unchanged.
//<
// This method checks to see if the model name is recognized
// in the input state string.
static std::string getModelNameFromModelState(
const std::string& model_state);
std::string constructStateFromIsd(const std::string imageSupportData, csm::WarningList *list) const;
// State data elements;
std::string m_imageIdentifier; // 1
std::string m_sensorType; // 2
int m_totalLines; // 3
int m_totalSamples; // 4
double m_offsetLines; // 5
double m_offsetSamples; // 6
int m_platformFlag; // 7
int m_aberrFlag; // 8
int m_atmRefFlag; // 9
std::vector<double> m_intTimeLines;
std::vector<double> m_intTimeStartTimes;
std::vector<double> m_intTimes;
double m_startingEphemerisTime; // 11
double m_centerEphemerisTime; // 12
double m_detectorSampleSumming; // 13
double m_startingSample; // 14
int m_ikCode; // 15
double m_focal; // 16
double m_isisZDirection; // 17
double m_opticalDistCoef[3]; // 18
double m_iTransS[3]; // 19
double m_iTransL[3]; // 20
double m_detectorSampleOrigin; // 21
double m_detectorLineOrigin; // 22
double m_detectorLineOffset; // 23
double m_mountingMatrix[9]; // 24
double m_semiMajorAxis; // 25
double m_semiMinorAxis; // 26
std::string m_referenceDateAndTime; // 27
std::string m_platformIdentifier; // 28
std::string m_sensorIdentifier; // 29
std::string m_trajectoryIdentifier; // 30
std::string m_collectionIdentifier; // 31
double m_refElevation; // 32
double m_minElevation; // 33
double m_maxElevation; // 34
double m_dtEphem; // 35
double m_t0Ephem; // 36
double m_dtQuat; // 37
double m_t0Quat; // 38
int m_numEphem; // 39
int m_numQuaternions; // 40
std::vector<double> m_ephemPts; // 41
std::vector<double> m_ephemRates; // 42
std::vector<double> m_quaternions; // 43
std::vector<double> m_parameterVals; // 44
std::vector<csm::param::Type> m_parameterType; // 45
csm::EcefCoord m_referencePointXyz; // 46
double m_gsd; // 47
double m_flyingHeight; // 48
double m_halfSwath; // 49
double m_halfTime; // 50
std::vector<double> m_covariance; // 51
int m_imageFlipFlag; // 52
// Hardcoded
static const std::string _SENSOR_MODEL_NAME; // state date element 0
static const std::string _STATE_KEYWORD[];
static const int NUM_PARAM_TYPES;
static const std::string PARAM_STRING_ALL[];
static const csm::param::Type PARAM_CHAR_ALL[];
static const int NUM_PARAMETERS;
static const std::string PARAMETER_NAME[];
// Set to default values
void reset();
//-------------------------------------------------------------- //--------------------------------------------------------------
// Constructors/Destructor // Constructors/Destructor
//-------------------------------------------------------------- //--------------------------------------------------------------
...@@ -44,8 +139,11 @@ public: ...@@ -44,8 +139,11 @@ public:
UsgsAstroLsSensorModel(); UsgsAstroLsSensorModel();
~UsgsAstroLsSensorModel(); ~UsgsAstroLsSensorModel();
virtual std::string getModelState() const;
// Set the sensor model based on the input state data // Set the sensor model based on the input state data
void set( const UsgsAstroLsStateData &state_data ); void set( const std::string &state_data );
//---------------------------------------------------------------- //----------------------------------------------------------------
...@@ -775,7 +873,7 @@ public: ...@@ -775,7 +873,7 @@ public:
//--- //---
// Sensor Model State // Sensor Model State
//--- //---
virtual std::string getModelState() const; // virtual std::string setModelState(std::string stateString) const;
//> This method returns a string containing the data to exactly recreate //> This method returns a string containing the data to exactly recreate
// the current model. It can be used to restore this model to a // the current model. It can be used to restore this model to a
// previous state with the replaceModelState method or create a new // previous state with the replaceModelState method or create a new
...@@ -785,20 +883,6 @@ public: ...@@ -785,20 +883,6 @@ public:
// current state. // current state.
//< //<
virtual void replaceModelState(const std::string& argState);
//> This method attempts to initialize the current model with the state
// given by argState. The argState argument can be a string previously
// retrieved from the getModelState method.
//
// If argState contains a valid state for the current model,
// the internal state of the model is updated.
//
// If the model cannot be updated to the given state, a csm::Error is
// thrown and the internal state of the model is undefined.
//
// If the argument state string is empty, the model remains unchanged.
//<
virtual csm::Ellipsoid getEllipsoid() const; virtual csm::Ellipsoid getEllipsoid() const;
//> This method returns the planetary ellipsoid. //> This method returns the planetary ellipsoid.
//< //<
...@@ -951,7 +1035,6 @@ private: ...@@ -951,7 +1035,6 @@ private:
double determinant3x3(double mat[9]) const; double determinant3x3(double mat[9]) const;
UsgsAstroLsStateData _data; // Holds the state data
csm::NoCorrelationModel _no_corr_model; // A way to report no correlation between images is supported csm::NoCorrelationModel _no_corr_model; // A way to report no correlation between images is supported
std::vector<double> _no_adjustment; // A vector of zeros indicating no internal adjustment std::vector<double> _no_adjustment; // A vector of zeros indicating no internal adjustment
......
//----------------------------------------------------------------------------
//
// UNCLASSIFIED
//
// Copyright © 1989-2017 BAE Systems Information and Electronic Systems Integration Inc.
// ALL RIGHTS RESERVED
// Use of this software product is governed by the terms of a license
// agreement. The license agreement is found in the installation directory.
//
// For support, please visit http://www.baesystems.com/gxp
//
// DESCRIPTION:
//
// Holds State data that runs the Astro Line Scanner Sensor Model.
// The format of the state data is determined by the sensor model
// developer. The CSM plugin converts ISD to state data and the
// CSM sensor model is instantiated based on the state data.
//
// By CSM convention, the sensor model name is the first element in
// the state data. The rest of the state data is order independent
// with the exception that the length of vectors must come before
// the vector data.
//
// For the Astro Line Scanner sensor model, the state data closely
// follows the support data. This is not always the case. For this
// model, the state data is a list name/value pairs.
//
//
// SOFTWARE HISTORY:
//
// Date Author Comment
// ----------- ---------- -------
// 13-OCT-2017 BAE Systems Initial Release
//
//#############################################################################
#ifndef __USGS_ASTRO_LINE_SCANNER_STATE_DATA_H
#define __USGS_ASTRO_LINE_SCANNER_STATE_DATA_H
#include <vector>
#include <string>
#include <csm.h>
#include <SettableEllipsoid.h>
class UsgsAstroLsStateData
{
public:
UsgsAstroLsStateData()
{
reset();
}
UsgsAstroLsStateData(const std::string &state)
{
reset();
setState(state);
}
~UsgsAstroLsStateData() {}
// Formats the state data as a string.
// This is the format that is used to instantiate a sensor model.
std::string toString() const;
// Formats the sate data as a JSON string.
std::string toJson() const;
// Initializes the class from state data as formatted
// in a string by the toString() method
void setState(const std::string &state);
// This method checks to see if the model name is recognized
// in the input state string.
static std::string getModelNameFromModelState(
const std::string& model_state);
// State data elements;
std::string m_ImageIdentifier; // 1
std::string m_SensorType; // 2
int m_TotalLines; // 3
int m_TotalSamples; // 4
double m_OffsetLines; // 5
double m_OffsetSamples; // 6
int m_PlatformFlag; // 7
int m_AberrFlag; // 8
int m_AtmRefFlag; // 9
std::vector<double> m_IntTimeLines;
std::vector<double> m_IntTimeStartTimes;
std::vector<double> m_IntTimes;
double m_StartingEphemerisTime; // 11
double m_CenterEphemerisTime; // 12
double m_DetectorSampleSumming; // 13
double m_StartingSample; // 14
int m_IkCode; // 15
double m_Focal; // 16
double m_IsisZDirection; // 17
double m_OpticalDistCoef[3]; // 18
double m_ITransS[3]; // 19
double m_ITransL[3]; // 20
double m_DetectorSampleOrigin; // 21
double m_DetectorLineOrigin; // 22
double m_DetectorLineOffset; // 23
double m_MountingMatrix[9]; // 24
double m_SemiMajorAxis; // 25
double m_SemiMinorAxis; // 26
std::string m_ReferenceDateAndTime; // 27
std::string m_PlatformIdentifier; // 28
std::string m_SensorIdentifier; // 29
std::string m_TrajectoryIdentifier; // 30
std::string m_CollectionIdentifier; // 31
double m_RefElevation; // 32
double m_MinElevation; // 33
double m_MaxElevation; // 34
double m_DtEphem; // 35
double m_T0Ephem; // 36
double m_DtQuat; // 37
double m_T0Quat; // 38
int m_NumEphem; // 39
int m_NumQuaternions; // 40
std::vector<double> m_EphemPts; // 41
std::vector<double> m_EphemRates; // 42
std::vector<double> m_Quaternions; // 43
std::vector<double> m_ParameterVals; // 44
std::vector<csm::param::Type> m_ParameterType; // 45
csm::EcefCoord m_ReferencePointXyz; // 46
double m_Gsd; // 47
double m_FlyingHeight; // 48
double m_HalfSwath; // 49
double m_HalfTime; // 50
std::vector<double> m_Covariance; // 51
int m_ImageFlipFlag; // 52
// Hardcoded
static const std::string SENSOR_MODEL_NAME; // state date element 0
static const std::string STATE_KEYWORD[];
static const int NUM_PARAM_TYPES;
static const std::string PARAM_STRING_ALL[];
static const csm::param::Type PARAM_CHAR_ALL[];
static const int NUM_PARAMETERS;
static const std::string PARAMETER_NAME[];
enum
{
STA_SENSOR_MODEL_NAME,
STA_IMAGE_IDENTIFIER,
STA_SENSOR_TYPE,
STA_TOTAL_LINES,
STA_TOTAL_SAMPLES,
STA_OFFSET_LINES,
STA_OFFSET_SAMPLES,
STA_PLATFORM_FLAG,
STA_ABERR_FLAG,
STA_ATMREF_FLAG,
STA_INT_TIME_LINES,
STA_INT_TIME_START_TIMES,
STA_INT_TIMES,
STA_STARTING_EPHEMERIS_TIME,
STA_CENTER_EPHEMERIS_TIME,
STA_DETECTOR_SAMPLE_SUMMING,
STA_STARTING_SAMPLE,
STA_IK_CODE,
STA_FOCAL,
STA_ISIS_Z_DIRECTION,
STA_OPTICAL_DIST_COEF,
STA_I_TRANS_S,
STA_I_TRANS_L,
STA_DETECTOR_SAMPLE_ORIGIN,
STA_DETECTOR_LINE_ORIGIN,
STA_DETECTOR_LINE_OFFSET,
STA_MOUNTING_MATRIX,
STA_SEMI_MAJOR_AXIS,
STA_SEMI_MINOR_AXIS,
STA_REFERENCE_DATE_AND_TIME,
STA_PLATFORM_IDENTIFIER,
STA_SENSOR_IDENTIFIER,
STA_TRAJECTORY_IDENTIFIER,
STA_COLLECTION_IDENTIFIER,
STA_REF_ELEVATION,
STA_MIN_ELEVATION,
STA_MAX_ELEVATION,
STA_DT_EPHEM,
STA_T0_EPHEM,
STA_DT_QUAT,
STA_T0_QUAT,
STA_NUM_EPHEM,
STA_NUM_QUATERNIONS,
STA_EPHEM_PTS,
STA_EPHEM_RATES,
STA_QUATERNIONS,
STA_PARAMETER_VALS,
STA_PARAMETER_TYPE,
STA_REFERENCE_POINT_XYZ,
STA_GSD,
STA_FLYING_HEIGHT,
STA_HALF_SWATH,
STA_HALF_TIME,
STA_COVARIANCE,
STA_IMAGE_FLIP_FLAG,
_NUM_STATE_KEYWORDS
};
// Set to default values
void reset();
};
#endif
#ifndef UsgsAstroFramePlugin_h #ifndef UsgsAstroPlugin_h
#define UsgsAstroFramePlugin_h #define UsgsAstroPlugin_h
#include <string> #include <string>
...@@ -7,13 +7,16 @@ ...@@ -7,13 +7,16 @@
#include <Plugin.h> #include <Plugin.h>
#include <Version.h> #include <Version.h>
#include <json.hpp>
using json = nlohmann::json;
class UsgsAstroFramePlugin : public csm::Plugin { class UsgsAstroPlugin : public csm::Plugin {
public: public:
UsgsAstroFramePlugin(); UsgsAstroPlugin();
~UsgsAstroFramePlugin(); ~UsgsAstroPlugin();
virtual std::string getStateFromISD(csm::Isd imageSupportData) const;
virtual std::string getPluginName() const; virtual std::string getPluginName() const;
virtual std::string getManufacturer() const; virtual std::string getManufacturer() const;
virtual std::string getReleaseDate() const; virtual std::string getReleaseDate() const;
...@@ -42,12 +45,12 @@ class UsgsAstroFramePlugin : public csm::Plugin { ...@@ -42,12 +45,12 @@ class UsgsAstroFramePlugin : public csm::Plugin {
const std::string &modelName, const std::string &modelName,
csm::WarningList *warnings = NULL) const; csm::WarningList *warnings = NULL) const;
std::string loadImageSupportData(const csm::Isd &imageSupportDataOriginal) const;
// TODO when implementing, add any other necessary members. // TODO when implementing, add any other necessary members.
private: private:
csm::Isd loadImageSupportData(const csm::Isd &imageSupportData) const; static const UsgsAstroPlugin m_registeredPlugin;
static const UsgsAstroFramePlugin m_registeredPlugin;
static const std::string _PLUGIN_NAME; static const std::string _PLUGIN_NAME;
static const std::string _MANUFACTURER_NAME; static const std::string _MANUFACTURER_NAME;
static const std::string _RELEASE_DATE; static const std::string _RELEASE_DATE;
...@@ -56,6 +59,10 @@ private: ...@@ -56,6 +59,10 @@ private:
static const std::string _ISD_KEYWORD[]; static const std::string _ISD_KEYWORD[];
static const int _NUM_STATE_KEYWORDS; static const int _NUM_STATE_KEYWORDS;
static const std::string _STATE_KEYWORD[]; static const std::string _STATE_KEYWORD[];
static const json MODEL_KEYWORDS;
typedef csm::Model* (*sensorConstructor)(void);
static std::map<std::string, sensorConstructor> MODELS;
}; };
#endif #endif
mkdir build
cd build
cmake -G "Visual Studio 15 2017 Win64" -DBUILD_TESTS=OFF ..
cmake --build . --target ALL_BUILD --config Release
copy Release\usgscsm.dll %LIBRARY_BIN%
if errorlevel 1 exit 1
package: package:
name: usgscam name: usgscsm
version: "0.1.0" version: "0.1.0"
source: source:
git_url: https://github.com/USGS-Astrogeology/CSM-CameraModel.git git_url: https://github.com/USGS-Astrogeology/CSM-CameraModel.git
build:
string: dev
requirements: requirements:
build: build:
- {{ compiler('cxx') }} # [linux] - {{ compiler('cxx') }} # [linux]
- vc 14 # [win]
- cmake >=3.10 - cmake >=3.10
- libcsm - libcsm
- vc 14 # [win]
run:
- vc # [win]
test: test:
commands: commands:
- test -e $PREFIX/lib/libusgscsm.so # [linux] - test -e $PREFIX/lib/libusgscsm.so # [linux]
- test -e $PREFIX/lib/libusgscsm.dylib # [osx] - test -e $PREFIX/lib/libusgscsm.dylib # [osx]
- if not exist %LIBRARY_BIN%\usgscsm.dll exit 1 # [win]
about: about:
home: https://github.com/USGS-Astrogeology/CSM-CameraModels home: https://github.com/USGS-Astrogeology/CSM-CameraModels
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
#include "UsgsAstroPlugin.h"
#include "UsgsAstroFrameSensorModel.h"
#include "UsgsAstroLsSensorModel.h"
#include <algorithm>
#include <cstdlib>
#include <string>
#include <fstream>
#include <math.h>
#include <csm.h>
#include <Error.h>
#include <Plugin.h>
#include <Warning.h>
#include <Version.h>
#include <json.hpp>
using json = nlohmann::json;
#ifdef _WIN32
# define DIR_DELIMITER_STR "\\"
#else
# define DIR_DELIMITER_STR "/"
#endif
// Declaration of static variables
const std::string UsgsAstroPlugin::_PLUGIN_NAME = "UsgsAstroPluginCSM";
const std::string UsgsAstroPlugin::_MANUFACTURER_NAME = "UsgsAstrogeology";
const std::string UsgsAstroPlugin::_RELEASE_DATE = "20170425";
const int UsgsAstroPlugin::_N_SENSOR_MODELS = 2;
const int UsgsAstroPlugin::_NUM_ISD_KEYWORDS = 21;
const std::string UsgsAstroPlugin::_ISD_KEYWORD[] =
{
"name_model",
"center_ephemeris_time",
"dt_ephemeris",
"focal2pixel_lines",
"focal2pixel_samples",
"focal_length_model",
"image_lines",
"image_samples",
"interpolation_method",
"number_of_ephemerides",
"optical_distortion",
"radii",
"reference_height",
"sensor_location_unit",
"sensor_location",
"sensor_orientation",
"sensor_velocity",
"detector_center",
"starting_detector_line",
"starting_detector_sample",
"starting_ephemeris_time",
"sun_position"
};
// const json UsgsAstroPlugin::MODEL_KEYWORDS = {
// {UsgsAstroFrameSensorModel::_SENSOR_MODEL_NAME, UsgsAstroFrameSensorModel::_STATE_KEYWORD},
// {UsgsAstroLsSensorModel::_SENSOR_MODEL_NAME, UsgsAstroLsSensorModel::_STATE_KEYWORD}
// };
// Static Instance of itself
const UsgsAstroPlugin UsgsAstroPlugin::m_registeredPlugin;
UsgsAstroPlugin::UsgsAstroPlugin() {
}
UsgsAstroPlugin::~UsgsAstroPlugin() {
}
std::string UsgsAstroPlugin::getPluginName() const {
return _PLUGIN_NAME;
}
std::string UsgsAstroPlugin::getManufacturer() const {
return _MANUFACTURER_NAME;
}
std::string UsgsAstroPlugin::getReleaseDate() const {
return _RELEASE_DATE;
}
csm::Version UsgsAstroPlugin::getCsmVersion() const {
return CURRENT_CSM_VERSION;
}
size_t UsgsAstroPlugin::getNumModels() const {
return _N_SENSOR_MODELS;
}
std::string UsgsAstroPlugin::getModelName(size_t modelIndex) const {
std::vector<std::string> supportedModelNames = {
UsgsAstroFrameSensorModel::_SENSOR_MODEL_NAME,
UsgsAstroLsSensorModel::_SENSOR_MODEL_NAME
};
return supportedModelNames[modelIndex];
}
std::string UsgsAstroPlugin::getModelFamily(size_t modelIndex) const {
return CSM_RASTER_FAMILY;
}
csm::Version UsgsAstroPlugin::getModelVersion(const std::string &modelName) const {
return csm::Version(1, 0, 0);
}
bool UsgsAstroPlugin::canModelBeConstructedFromState(const std::string &modelName,
const std::string &modelState,
csm::WarningList *warnings) const {
try {
csm::Model* model = constructModelFromState(modelState, warnings);
return (bool)model;
}
catch(...) {
return false;
}
}
bool UsgsAstroPlugin::canModelBeConstructedFromISD(const csm::Isd &imageSupportData,
const std::string &modelName,
csm::WarningList *warnings) const {
try {
csm::Model* model = constructModelFromISD(imageSupportData, modelName, warnings);
return (bool)model;
}
catch(...) {
return false;
}
}
// This function takes a csm::Isd which only has the image filename set. It uses this filename to
// find a metadata json file located alongside the image file and returns a json
// encoded string.
std::string UsgsAstroPlugin::loadImageSupportData(const csm::Isd &imageSupportDataOriginal) const {
// Get image location from the input csm::Isd:
std::string imageFilename = imageSupportDataOriginal.filename();
size_t lastIndex = imageFilename.find_last_of(".");
std::string baseName = imageFilename.substr(0, lastIndex);
std::string isdFilename = baseName.append(".json");
try {
std::ifstream isd_sidecar(isdFilename);
json jsonisd;
isd_sidecar >> jsonisd;
return jsonisd.dump();
} catch (...) {
std::string errorMessage = "Could not read metadata file associated with image: ";
errorMessage.append(isdFilename);
throw csm::Error(csm::Error::FILE_READ, errorMessage,
"UsgsAstroPlugin::loadImageSupportData");
}
}
std::string UsgsAstroPlugin::getModelNameFromModelState(const std::string &modelState,
csm::WarningList *warnings) const {
auto state = json::parse(modelState);
std::string name = state.value<std::string>("name_model", "");
if (name == "") {
csm::Error::ErrorType aErrorType = csm::Error::INVALID_SENSOR_MODEL_STATE;
std::string aMessage = "No 'name_model' key in the model state object.";
std::string aFunction = "UsgsAstroPlugin::getModelNameFromModelState";
csm::Error csmErr(aErrorType, aMessage, aFunction);
throw(csmErr);
}
return name;
}
bool UsgsAstroPlugin::canISDBeConvertedToModelState(const csm::Isd &imageSupportData,
const std::string &modelName,
csm::WarningList *warnings) const {
try {
convertISDToModelState(imageSupportData, modelName, warnings);
}
catch(...) {
return false;
}
return true;
}
std::string UsgsAstroPlugin::getStateFromISD(csm::Isd imageSupportData) const {
std::string stringIsd = loadImageSupportData(imageSupportData);
json jsonIsd = json::parse(stringIsd);
return convertISDToModelState(imageSupportData, jsonIsd.at("modelName"));
}
std::string UsgsAstroPlugin::convertISDToModelState(const csm::Isd &imageSupportData,
const std::string &modelName,
csm::WarningList *warnings) const {
csm::Model* sensor_model = constructModelFromISD(imageSupportData, modelName, warnings);
return sensor_model->getModelState();
}
csm::Model *UsgsAstroPlugin::constructModelFromISD(const csm::Isd &imageSupportDataOriginal,
const std::string &modelName,
csm::WarningList *warnings) const {
std::string stringIsd = loadImageSupportData(imageSupportDataOriginal);
if (modelName == UsgsAstroFrameSensorModel::_SENSOR_MODEL_NAME) {
UsgsAstroFrameSensorModel *model = new UsgsAstroFrameSensorModel();
try {
model->replaceModelState(model->constructStateFromIsd(stringIsd, warnings));
}
catch (...) {
csm::Error::ErrorType aErrorType = csm::Error::SENSOR_MODEL_NOT_CONSTRUCTIBLE;
std::string aMessage = "Invalid ISD for Model " + modelName + ": ";
std::string aFunction = "UsgsAstroPlugin::constructModelFromISD()";
throw csm::Error(aErrorType, aMessage, aFunction);
}
return model;
}
else if (modelName == UsgsAstroLsSensorModel::_SENSOR_MODEL_NAME) {
UsgsAstroLsSensorModel *model = new UsgsAstroLsSensorModel();
try {
model->replaceModelState(model->constructStateFromIsd(stringIsd, warnings));
}
catch (...) {
csm::Error::ErrorType aErrorType = csm::Error::SENSOR_MODEL_NOT_CONSTRUCTIBLE;
std::string aMessage = "Invalid ISD for Model " + modelName + ": ";
std::string aFunction = "UsgsAstroPlugin::constructModelFromISD()";
throw csm::Error(aErrorType, aMessage, aFunction);
}
return model;
}
else {
csm::Error::ErrorType aErrorType = csm::Error::SENSOR_MODEL_NOT_SUPPORTED;
std::string aMessage = "Model" + modelName + " not supported: ";
std::string aFunction = "UsgsAstroPlugin::constructModelFromISD()";
throw csm::Error(aErrorType, aMessage, aFunction);
}
}
csm::Model *UsgsAstroPlugin::constructModelFromState(const std::string& modelState,
csm::WarningList *warnings) const {
json state = json::parse(modelState);
std::string modelName = state["modelName"];
if (modelName == UsgsAstroFrameSensorModel::_SENSOR_MODEL_NAME) {
UsgsAstroFrameSensorModel* model = new UsgsAstroFrameSensorModel();
model->replaceModelState(modelState);
return model;
}
else if (modelName == UsgsAstroLsSensorModel::_SENSOR_MODEL_NAME) {
UsgsAstroLsSensorModel* model = new UsgsAstroLsSensorModel();
model->replaceModelState(modelState);
return model;
}
else {
csm::Error::ErrorType aErrorType = csm::Error::ISD_NOT_SUPPORTED;
std::string aMessage = "Model" + modelName + " not supported: ";
std::string aFunction = "UsgsAstroPlugin::constructModelFromState()";
throw csm::Error(aErrorType, aMessage, aFunction);
}
}
cmake_minimum_required(VERSION 3.10) cmake_minimum_required(VERSION 3.10)
# Link runCSMCameraModelTests with what we want to test and the GTest and pthread library # Link runCSMCameraModelTests with what we want to test and the GTest and pthread library
add_executable(runCSMCameraModelTests TestyMcTestFace.cpp FrameCameraTests.cpp) add_executable(runCSMCameraModelTests
PluginTests.cpp
FrameCameraTests.cpp)
if(WIN32)
option(CMAKE_USE_WIN32_THREADS_INIT "using WIN32 threads" ON)
option(gtest_disable_pthreads "Disable uses of pthreads in gtest." ON)
target_link_libraries(runCSMCameraModelTests usgscsm ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES})
else()
target_link_libraries(runCSMCameraModelTests usgscsm ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES} pthread) target_link_libraries(runCSMCameraModelTests usgscsm ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES} pthread)
endif()
gtest_discover_tests(runCSMCameraModelTests WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests) gtest_discover_tests(runCSMCameraModelTests WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment