Tudat/JsonInterface/Environment/rotationModel.cpp
//! Create a `json` object from a shared pointer to a `RotationModelSettings` object.
Create a `json` object from a shared pointer to a `RotationModelSettings` object.
Create a ` json ` object from a shared pointer to a ` RotationModelSettings ` object .
void to_json( nlohmann::json& jsonObject, const std::shared_ptr< RotationModelSettings >& rotationModelSettings )
{
    if ( ! rotationModelSettings )
    {
        return;
    }
    using namespace json_interface;
    using K = Keys::Body::RotationModel;
    const RotationModelType rotationModelType = rotationModelSettings->getRotationType( );
    jsonObject[ K::type ] = rotationModelType;
    jsonObject[ K::originalFrame ] = rotationModelSettings->getOriginalFrame( );
    jsonObject[ K::targetFrame ] = rotationModelSettings->getTargetFrame( );
    switch ( rotationModelType )
    {
    case simple_rotation_model:
    {
        std::shared_ptr< SimpleRotationModelSettings > simpleRotationModelSettings =
                std::dynamic_pointer_cast< SimpleRotationModelSettings >( rotationModelSettings );
        assertNonnullptrPointer( simpleRotationModelSettings );
        jsonObject[ K::initialOrientation ] = simpleRotationModelSettings->getInitialOrientation( );
        jsonObject[ K::initialTime ] = simpleRotationModelSettings->getInitialTime( );
        jsonObject[ K::rotationRate ] = simpleRotationModelSettings->getRotationRate( );
        return;
    }
    case spice_rotation_model:
        return;
    case gcrs_to_itrs_rotation_model:
    {
        std::cerr<<"Warning when writing GCRS to ITRS rotation model to JSON, only precession-nutation theory and base frame are saved, rest is kept at default values"<<std::endl;
        std::shared_ptr< GcrsToItrsRotationModelSettings > simpleRotationModelSettings =
                std::dynamic_pointer_cast< GcrsToItrsRotationModelSettings >( rotationModelSettings );
        assertNonnullptrPointer( simpleRotationModelSettings );
        jsonObject[ K::precessionNutationTheory ] = simpleRotationModelSettings->getNutationTheory( );
        return;
    }
    default:
        handleUnimplementedEnumValue( rotationModelType, rotationModelTypes, unsupportedRotationModelTypes );
    }
}
void to_json ( nlohmann :: json & jsonObject , const std :: shared_ptr < RotationModelSettings > & rotationModelSettings ) { if ( ! rotationModelSettings ) { return ; } using namespace json_interface ; using K = Keys :: Body :: RotationModel ; const RotationModelType rotationModelType = rotationModelSettings -> getRotationType ( ) ; jsonObject [ K :: type ] = rotationModelType ; jsonObject [ K :: originalFrame ] = rotationModelSettings -> getOriginalFrame ( ) ; jsonObject [ K :: targetFrame ] = rotationModelSettings -> getTargetFrame ( ) ; switch ( rotationModelType ) { case simple_rotation_model : { std :: shared_ptr < SimpleRotationModelSettings > simpleRotationModelSettings = std :: dynamic_pointer_cast < SimpleRotationModelSettings > ( rotationModelSettings ) ; assertNonnullptrPointer ( simpleRotationModelSettings ) ; jsonObject [ K :: initialOrientation ] = simpleRotationModelSettings -> getInitialOrientation ( ) ; jsonObject [ K :: initialTime ] = simpleRotationModelSettings -> getInitialTime ( ) ; jsonObject [ K :: rotationRate ] = simpleRotationModelSettings -> getRotationRate ( ) ; return ; } case spice_rotation_model : return ; case gcrs_to_itrs_rotation_model : { std :: cerr << " " << std :: endl ; std :: shared_ptr < GcrsToItrsRotationModelSettings > simpleRotationModelSettings = std :: dynamic_pointer_cast < GcrsToItrsRotationModelSettings > ( rotationModelSettings ) ; assertNonnullptrPointer ( simpleRotationModelSettings ) ; jsonObject [ K :: precessionNutationTheory ] = simpleRotationModelSettings -> getNutationTheory ( ) ; return ; } default : handleUnimplementedEnumValue ( rotationModelType , rotationModelTypes , unsupportedRotationModelTypes ) ; } }
Create a `json` object from a shared pointer to a `RotationModelSettings` object.
Create a ` json ` object from a shared pointer to a ` RotationModelSettings ` object .