Tudat/JsonInterface/Environment/rotationModel.cpp
//! Create a shared pointer to a `RotationModelSettings` object from a `json` object.
Create a shared pointer to a `RotationModelSettings` object from a `json` object.
Create a shared pointer to a ` RotationModelSettings ` object from a ` json ` object .
void from_json( const nlohmann::json& jsonObject, std::shared_ptr< RotationModelSettings >& rotationModelSettings )
{
    using namespace json_interface;
    using K = Keys::Body::RotationModel;
    const RotationModelType rotationModelType = getValue< RotationModelType >( jsonObject, K::type );
    const std::string originalFrame = getValue< std::string >( jsonObject, K::originalFrame );
    std::string targetFrame = "";
    if( rotationModelType != gcrs_to_itrs_rotation_model )
    {
        targetFrame = getValue< std::string >( jsonObject, K::targetFrame );
    }
    else
    {
       targetFrame = "GCRS";
    }
    switch ( rotationModelType ) {
    case simple_rotation_model:
    {
        const double initialTime = getValue< double >( jsonObject, K::initialTime );
        nlohmann::json jsonInitialOrientation;
        if ( isDefined( jsonObject, K::initialOrientation ) )
        {
            jsonInitialOrientation = getValue< nlohmann::json >( jsonObject, K::initialOrientation );
        }
        else
        {
            jsonInitialOrientation[ K::originalFrame ] = originalFrame;
            jsonInitialOrientation[ K::targetFrame ] = targetFrame;
            jsonInitialOrientation[ K::initialTime ] = initialTime;
        }
        rotationModelSettings = std::make_shared< SimpleRotationModelSettings >(
                    originalFrame,
                    targetFrame,
                    getAs< Eigen::Quaterniond >( jsonInitialOrientation ),
                    initialTime,
                    getValue< double >( jsonObject, K::rotationRate ) );
        return;
    }
    case spice_rotation_model:
    {
        rotationModelSettings = std::make_shared< RotationModelSettings >(
                    rotationModelType, originalFrame, targetFrame );
        return;
    }
    case gcrs_to_itrs_rotation_model:
    {
        rotationModelSettings = std::make_shared< GcrsToItrsRotationModelSettings >(
                     getValue< basic_astrodynamics::IAUConventions >(
                        jsonObject, K::precessionNutationTheory, basic_astrodynamics::iau_2006 ),
                    originalFrame );
        return;
    }
    default:
        handleUnimplementedEnumValue( rotationModelType, rotationModelTypes, unsupportedRotationModelTypes );
    }
}
void from_json ( const nlohmann :: json & jsonObject , std :: shared_ptr < RotationModelSettings > & rotationModelSettings ) { using namespace json_interface ; using K = Keys :: Body :: RotationModel ; const RotationModelType rotationModelType = getValue < RotationModelType > ( jsonObject , K :: type ) ; const std :: string originalFrame = getValue < std :: string > ( jsonObject , K :: originalFrame ) ; std :: string targetFrame = " " ; if ( rotationModelType != gcrs_to_itrs_rotation_model ) { targetFrame = getValue < std :: string > ( jsonObject , K :: targetFrame ) ; } else { targetFrame = " " ; } switch ( rotationModelType ) { case simple_rotation_model : { const double initialTime = getValue < double > ( jsonObject , K :: initialTime ) ; nlohmann :: json jsonInitialOrientation ; if ( isDefined ( jsonObject , K :: initialOrientation ) ) { jsonInitialOrientation = getValue < nlohmann :: json > ( jsonObject , K :: initialOrientation ) ; } else { jsonInitialOrientation [ K :: originalFrame ] = originalFrame ; jsonInitialOrientation [ K :: targetFrame ] = targetFrame ; jsonInitialOrientation [ K :: initialTime ] = initialTime ; } rotationModelSettings = std :: make_shared < SimpleRotationModelSettings > ( originalFrame , targetFrame , getAs < Eigen :: Quaterniond > ( jsonInitialOrientation ) , initialTime , getValue < double > ( jsonObject , K :: rotationRate ) ) ; return ; } case spice_rotation_model : { rotationModelSettings = std :: make_shared < RotationModelSettings > ( rotationModelType , originalFrame , targetFrame ) ; return ; } case gcrs_to_itrs_rotation_model : { rotationModelSettings = std :: make_shared < GcrsToItrsRotationModelSettings > ( getValue < basic_astrodynamics :: IAUConventions > ( jsonObject , K :: precessionNutationTheory , basic_astrodynamics :: iau_2006 ) , originalFrame ) ; return ; } default : handleUnimplementedEnumValue ( rotationModelType , rotationModelTypes , unsupportedRotationModelTypes ) ; } }
Create a shared pointer to a `RotationModelSettings` object from a `json` object.
Create a shared pointer to a ` RotationModelSettings ` object from a ` json ` object .
// Base class settings // Get JSON object for initialOrientation (or create it if not defined)