Commit ecb84407 authored by Dipl.-Ing. Jonas Stienen's avatar Dipl.-Ing. Jonas Stienen

Merge branch 'develop' of https://git.rwth-aachen.de/ita/ITAGeo into develop

parents ee2bebce 759746af
......@@ -33,18 +33,6 @@
#include <memory>
// ---Forward Declarations---
// ---for friend functions---
namespace ITAGeo { class CStratifiedAtmosphere; }
namespace ITAGeo {
namespace Utils {
namespace JSON {
ITA_GEO_API std::stringstream Encode(const CStratifiedAtmosphere&);
ITA_GEO_API void Decode(CStratifiedAtmosphere& iProfile, const std::string& sContent);
}
}
};
namespace ITAGeo
{
//! Base class for stratified atmospheres
......@@ -56,23 +44,18 @@ namespace ITAGeo
{
public:
CStratifiedAtmosphere(std::unique_ptr<TemperatureProfiles::ITemperatureProfile>, std::unique_ptr<WindProfiles::IWindProfile>, std::unique_ptr<HumidityProfiles::IHumidityProfile> humidity);
//! Move-constructor must be defined since this class holds unique_ptr(s) which are moved into this class
inline CStratifiedAtmosphere(CStratifiedAtmosphere&& oOther)
{
pHumidityProfile = std::move(oOther.pHumidityProfile);
pTemperatureProfile = std::move(oOther.pTemperatureProfile);
pWindProfile = std::move(oOther.pWindProfile);
}
//! Move-operator must be defined since this class holds unique_ptr(s) which are moved into this class
inline CStratifiedAtmosphere& operator=(CStratifiedAtmosphere&& oOther)
{
pHumidityProfile = std::move(oOther.pHumidityProfile);
pTemperatureProfile = std::move(oOther.pTemperatureProfile);
pWindProfile = std::move(oOther.pWindProfile);
return *this;
}
CStratifiedAtmosphere();
CStratifiedAtmosphere(std::shared_ptr<TemperatureProfiles::ITemperatureProfile>, std::shared_ptr<WindProfiles::IWindProfile>, std::shared_ptr<HumidityProfiles::IHumidityProfile> humidity);
//Set and Get
public:
inline const std::shared_ptr<HumidityProfiles::IHumidityProfile> HumidityProfile() const { return pHumidityProfile; };
inline const std::shared_ptr<TemperatureProfiles::ITemperatureProfile> TemperatureProfile() const { return pTemperatureProfile; };
inline const std::shared_ptr<WindProfiles::IWindProfile> WindProfile() const { return pWindProfile; };
inline void SetHumidityProfile(std::shared_ptr<HumidityProfiles::IHumidityProfile> pProfile) { pHumidityProfile = pProfile; };
inline void SetTemperatureProfile(std::shared_ptr<TemperatureProfiles::ITemperatureProfile> pProfile) { pTemperatureProfile = pProfile; };
inline void SetWindProfile(std::shared_ptr<WindProfiles::IWindProfile> pProfile) { pWindProfile = pProfile; };
public:
double RelativeHumidity(double altitude) const;
......@@ -92,23 +75,6 @@ namespace ITAGeo
VistaVector3D WindVector(double altitude) const;
VistaVector3D WindVectorGradient(double altitude) const;
//! Defined in ITAGeo/Utils/JSON/Atmosphere.h
friend std::stringstream ITAGeo::Utils::JSON::Encode(const CStratifiedAtmosphere&);
//! Defined in ITAGeo/Utils/JSON/Atmosphere.h
friend void ITAGeo::Utils::JSON::Decode(CStratifiedAtmosphere& iProfile, const std::string& sContent);
//! Stores path to file (*.xml or *.json, if supported)
/**
* Will throw @CITAException on error
*/
void Store(const std::string& sFilePath, bool bOverwrite = true) const;
//! Loads path from file (*.xml or *.json, if supported)
/**
* Will throw @CITAException on error
*/
void Load(const std::string& sFilePath);
// Source for speed of sound formula and constants:
// M. A. Garces, R. A. Hansen, and K. G. Lindquist. Traveltimes for infrasonic waves propagating in a stratified atmosphere. Geophysical Journal International, 135(1) : 255263, 1998.
protected:
......@@ -119,9 +85,9 @@ namespace ITAGeo
*/
const double airGasConstant_times_ratioSpecificHeats = 402.8;
std::unique_ptr<HumidityProfiles::IHumidityProfile> pHumidityProfile;
std::unique_ptr <TemperatureProfiles::ITemperatureProfile> pTemperatureProfile;
std::unique_ptr<WindProfiles::IWindProfile> pWindProfile;
std::shared_ptr<HumidityProfiles::IHumidityProfile> pHumidityProfile;
std::shared_ptr <TemperatureProfiles::ITemperatureProfile> pTemperatureProfile;
std::shared_ptr<WindProfiles::IWindProfile> pWindProfile;
};
}
......
......@@ -213,7 +213,7 @@ namespace ITAGeo
{
public:
VistaVector3D v3MirrorNormal; //<! If normal is zero vector, image is invalid / was not reflected
VistaVector3D v3MirrorNormal; //!< If normal is zero vector, image is invalid / was not reflected
const VistaVector3D& v3MirrorPosition; //!< Mirror image position (alias for interaction point)
int iPolygonIndex; //!< Polygon index helper (for recursive audibility test)
int iOrder;
......
......@@ -22,6 +22,7 @@
#include <ITAGeo/Definitions.h>
#include <ITAGeo/Atmosphere/StratifiedAtmosphere.h>
#include <memory>
#include <string>
#include <sstream>
......@@ -48,15 +49,15 @@ namespace ITAGeo
//! Create JSON formatted string from given humidity profile interface
ITA_GEO_API std::stringstream FromHumidityProfile(const HumidityProfiles::IHumidityProfile& iProfile);
//! Factory function for humidity profiles based on a JSON formatted string
ITA_GEO_API HumidityProfiles::IHumidityProfile* ToHumidityProfile(const std::string& sContent);
ITA_GEO_API std::shared_ptr<HumidityProfiles::IHumidityProfile> ToHumidityProfile(const std::string& sContent);
//! Create JSON formatted string from given temperature profile interface
ITA_GEO_API std::stringstream FromTemperatureProfile(const TemperatureProfiles::ITemperatureProfile& iProfile);
//! Factory function for temperature profiles based on a JSON formatted string
ITA_GEO_API TemperatureProfiles::ITemperatureProfile* ToTemperatureProfile(const std::string& sContent);
ITA_GEO_API std::shared_ptr<TemperatureProfiles::ITemperatureProfile> ToTemperatureProfile(const std::string& sContent);
//! Create JSON formatted string from given wind profile interface
ITA_GEO_API std::stringstream FromWindProfile(const WindProfiles::IWindProfile&);
//! Factory function for wind profiles based on a JSON formatted string
ITA_GEO_API WindProfiles::IWindProfile* ToWindProfile(const std::string& sContent);
ITA_GEO_API std::shared_ptr<WindProfiles::IWindProfile> ToWindProfile(const std::string& sContent);
//---WEATHER PROFILE ENCODING/DECODING---
......
......@@ -10,11 +10,20 @@
using namespace ITAGeo::WeatherProfileBase;
ITAGeo::CStratifiedAtmosphere::CStratifiedAtmosphere()
{
pHumidityProfile = std::make_shared<HumidityProfiles::CConstant>(50);
pTemperatureProfile = std::make_shared<TemperatureProfiles::CISA>();
pWindProfile = std::make_shared<WindProfiles::CLog>(0.6, 0.1, VistaVector3D(1, 0, 0));
}
ITAGeo::CStratifiedAtmosphere::CStratifiedAtmosphere(
std::unique_ptr<TemperatureProfiles::ITemperatureProfile> temperature,
std::unique_ptr<WindProfiles::IWindProfile> wind,
std::unique_ptr<HumidityProfiles::IHumidityProfile> humidity)
: pTemperatureProfile(std::move(temperature)), pWindProfile(std::move(wind)), pHumidityProfile(std::move(humidity)) {}
std::shared_ptr<TemperatureProfiles::ITemperatureProfile> temperature,
std::shared_ptr<WindProfiles::IWindProfile> wind,
std::shared_ptr<HumidityProfiles::IHumidityProfile> humidity)
: pTemperatureProfile(temperature), pWindProfile(wind), pHumidityProfile(humidity)
{
}
double ITAGeo::CStratifiedAtmosphere::RelativeHumidity(double altitude) const
{
......
#include <ITAGeo/Utils/JSON/Atmosphere.h>
#include "VistaVector3D.h"
#include "VistaJSON.h"
#include <ITAException.h>
......@@ -8,7 +8,7 @@
#include <libjson.h>
#include <fstream>
#include <memory>
//#include <memory>
#pragma region ATMOSPHERE - EXPORT/IMPORT
void ITAGeo::Utils::JSON::Export( const CStratifiedAtmosphere& cAtmosphere, const std::string& sTargetFilePath, bool bOverwrite /* = false*/ )
......@@ -40,9 +40,16 @@ std::stringstream ITAGeo::Utils::JSON::Encode(const CStratifiedAtmosphere& cAtmo
{
JSONNode jnRoot(JSON_NODE);
JSONNode jnHumidity = libjson::parse( FromHumidityProfile(*cAtmosphere.pHumidityProfile).str() );
JSONNode jnTemperature = libjson::parse( FromTemperatureProfile(*cAtmosphere.pTemperatureProfile).str() );
JSONNode jnWind = libjson::parse( FromWindProfile(*cAtmosphere.pWindProfile).str() );
if(!cAtmosphere.HumidityProfile())
ITA_EXCEPT_INVALID_PARAMETER("Humidity Profile is not defined");
if (!cAtmosphere.TemperatureProfile())
ITA_EXCEPT_INVALID_PARAMETER("Temperature Profile is not defined");
if (!cAtmosphere.WindProfile())
ITA_EXCEPT_INVALID_PARAMETER("Wind Profile is not defined");
JSONNode jnHumidity = libjson::parse( FromHumidityProfile(*cAtmosphere.HumidityProfile()).str() );
JSONNode jnTemperature = libjson::parse( FromTemperatureProfile(*cAtmosphere.TemperatureProfile()).str() );
JSONNode jnWind = libjson::parse( FromWindProfile(*cAtmosphere.WindProfile()).str() );
jnHumidity.set_name(ITA_HUMIDITY_PROFILE_STR);
jnTemperature.set_name(ITA_TEMPERATURE_PROFILE_STR);
......@@ -56,18 +63,18 @@ std::stringstream ITAGeo::Utils::JSON::Encode(const CStratifiedAtmosphere& cAtmo
ss << jnRoot.write_formatted();
return ss;
}
void ITAGeo::Utils::JSON::Decode(CStratifiedAtmosphere& cAtmosphere, const std::string& sContent)
void ITAGeo::Utils::JSON::Decode(CStratifiedAtmosphere& oAtmosphere, const std::string& sContent)
{
JSONNode jnRoot = libjson::parse(sContent);
JSONNode jnHumidity = jnRoot.at(ITA_HUMIDITY_PROFILE_STR);
cAtmosphere.pHumidityProfile = std::unique_ptr<HumidityProfiles::IHumidityProfile>( ToHumidityProfile(jnHumidity.write()) );
oAtmosphere.SetHumidityProfile( ToHumidityProfile(jnHumidity.write()) );
JSONNode jnTemperature = jnRoot.at(ITA_TEMPERATURE_PROFILE_STR);
cAtmosphere.pTemperatureProfile = std::unique_ptr<TemperatureProfiles::ITemperatureProfile>( ToTemperatureProfile(jnTemperature.write()) );
oAtmosphere.SetTemperatureProfile( ToTemperatureProfile(jnTemperature.write()) );
JSONNode jnWind = jnRoot.at(ITA_WIND_PROFILE_STR);
cAtmosphere.pWindProfile = std::unique_ptr<WindProfiles::IWindProfile>( ToWindProfile(jnWind.write()) );
oAtmosphere.SetWindProfile( ToWindProfile(jnWind.write()) );
}
#pragma endregion
......@@ -88,7 +95,7 @@ ITA_GEO_API std::stringstream ITAGeo::Utils::JSON::FromHumidityProfile(const Hum
}
ITA_EXCEPT_INVALID_PARAMETER("Cannot conver humidity profile to JSON string. No valid class type found.");
}
ITAGeo::HumidityProfiles::IHumidityProfile* ITAGeo::Utils::JSON::ToHumidityProfile(const std::string& sContent)
std::shared_ptr<ITAGeo::HumidityProfiles::IHumidityProfile> ITAGeo::Utils::JSON::ToHumidityProfile(const std::string& sContent)
{
JSONNode jnRoot = libjson::parse(sContent);
WeatherProfileBase::EClassType classType = WeatherProfileBase::IWeatherProfile::ParseProfileClassType(jnRoot.at("class").as_string());
......@@ -97,7 +104,7 @@ ITAGeo::HumidityProfiles::IHumidityProfile* ITAGeo::Utils::JSON::ToHumidityProfi
{
case WeatherProfileBase::CONSTANT:
{
auto cProfile = new HumidityProfiles::CConstant();
auto cProfile = std::make_shared<HumidityProfiles::CConstant>();
Decode(*cProfile, sContent);
return cProfile;
}
......@@ -133,7 +140,7 @@ ITA_GEO_API std::stringstream ITAGeo::Utils::JSON::FromTemperatureProfile(const
}
ITA_EXCEPT_INVALID_PARAMETER("Cannot conver humidity Profile to JSON string. No valid class type found.");
}
ITAGeo::TemperatureProfiles::ITemperatureProfile* ITAGeo::Utils::JSON::ToTemperatureProfile(const std::string& sContent)
std::shared_ptr<ITAGeo::TemperatureProfiles::ITemperatureProfile> ITAGeo::Utils::JSON::ToTemperatureProfile(const std::string& sContent)
{
JSONNode jnRoot = libjson::parse(sContent);
WeatherProfileBase::EClassType classType = WeatherProfileBase::IWeatherProfile::ParseProfileClassType(jnRoot.at("class").as_string());
......@@ -142,20 +149,20 @@ ITAGeo::TemperatureProfiles::ITemperatureProfile* ITAGeo::Utils::JSON::ToTempera
{
case WeatherProfileBase::CONSTANT:
{
auto cProfile = new TemperatureProfiles::CConstant(0, 0);
auto cProfile = std::make_shared<TemperatureProfiles::CConstant>(0, 0);
Decode(*cProfile, sContent);
return cProfile;
}
case WeatherProfileBase::ROOM:
{
auto cProfile = new TemperatureProfiles::CRoom();
auto cProfile = std::make_shared<TemperatureProfiles::CRoom>();
Decode(*cProfile, sContent);
return cProfile;
}
break;
case WeatherProfileBase::ISA:
{
auto cProfile = new TemperatureProfiles::CISA();
auto cProfile = std::make_shared<TemperatureProfiles::CISA>();
Decode(*cProfile, sContent);
return cProfile;
}
......@@ -192,7 +199,7 @@ std::stringstream ITAGeo::Utils::JSON::FromWindProfile(const WindProfiles::IWind
}
ITA_EXCEPT_INVALID_PARAMETER("Cannot conver wind profile to JSON string. No valid class type found.");
}
ITAGeo::WindProfiles::IWindProfile* ITAGeo::Utils::JSON::ToWindProfile(const std::string& sContent)
std::shared_ptr<ITAGeo::WindProfiles::IWindProfile> ITAGeo::Utils::JSON::ToWindProfile(const std::string& sContent)
{
JSONNode jnRoot = libjson::parse(sContent);
WeatherProfileBase::EClassType classType = WeatherProfileBase::IWeatherProfile::ParseProfileClassType(jnRoot.at("class").as_string());
......@@ -201,19 +208,19 @@ ITAGeo::WindProfiles::IWindProfile* ITAGeo::Utils::JSON::ToWindProfile(const std
{
case WeatherProfileBase::CONSTANT:
{
auto cProfile = new WindProfiles::CConstant(0, VistaVector3D(1, 0, 0));
auto cProfile = std::make_shared<WindProfiles::CConstant>(0, VistaVector3D(1, 0, 0));
Decode(*cProfile, sContent);
return cProfile;
}
case WeatherProfileBase::ZERO:
{
auto cProfile = new WindProfiles::CZero();
auto cProfile = std::make_shared<WindProfiles::CZero>();
Decode(*cProfile, sContent);
return cProfile;
}
case WeatherProfileBase::LOG:
{
auto cProfile = new WindProfiles::CLog(0, 0, VistaVector3D(1, 0, 0));
auto cProfile = std::make_shared<WindProfiles::CLog>(0, 0, VistaVector3D(1, 0, 0));
Decode(*cProfile, sContent);
return cProfile;
}
......
#include "PropagationPath_Impl.h"
#include "VistaVector3D.h"
#include "VistaQuaternion.h"
#include "VistaJSON.h"
#include <ITAException.h>
// STD
//#include <memory>
#include <cmath>
......@@ -245,8 +244,12 @@ JSONNode JSON::CreateNode(const CSensorInhomogeneous& anchor, std::shared_ptr<CR
{
JSONNode jnRoot = CreateNode( (CPropagationAnchor&)(anchor) );
ExtendNode( (CInhomogeneousAnchorExtension&)(anchor), jnRoot );
if (anchor.dSpreadingLoss >= 0)
jnRoot.push_back(JSONNode("spreading_loss", anchor.dSpreadingLoss));
if (anchor.dSpreadingLoss > 0)
{
//Unfortunately, the smallest value libjson will parse is 0.000001. Thus, we store it in dB.
jnRoot.push_back( JSONNode( "spreading_loss_db", 20*std::log10(anchor.dSpreadingLoss) ) );
//jnRoot.push_back(JSONNode("spreading_loss", anchor.dSpreadingLoss));
}
return jnRoot;
}
......@@ -256,6 +259,8 @@ void JSON::Decode(CSensorInhomogeneous& anchor, const JSONNode& jnRoot, std::sha
Decode( (CInhomogeneousAnchorExtension&)(anchor), jnRoot );
if (jnRoot.find("spreading_loss") != jnRoot.end())
anchor.dSpreadingLoss = jnRoot.at("spreading_loss").as_float();
else if (jnRoot.find("spreading_loss_db") != jnRoot.end())
anchor.dSpreadingLoss = std::pow( 10, jnRoot.at("spreading_loss_db").as_float()/20 );
}
JSONNode JSON::CreateNode(const CSpecularReflectionInhomogeneous& anchor, std::shared_ptr<CResourceManager> pResourceManager)
......@@ -333,6 +338,7 @@ JSONNode JSON::CreateNode(const CPropagationPath& path, std::shared_ptr< CResour
JSONNode jnAnchorArray(JSON_ARRAY);
jnAnchorArray.set_name("propagation_anchors");
jnAnchorArray.reserve( path.size() );
for each (auto pAnchor in path)
{
......@@ -419,6 +425,7 @@ void JSON::Decode(CPropagationPath& path, const JSONNode& jnRoot, std::shared_pt
JSONNode jnPropagationAnchors = jnRoot.at("propagation_anchors").as_array();
path.reserve(jnPropagationAnchors.size());
for each (JSONNode jnAnchor in jnPropagationAnchors)
{
CPropagationAnchor::EAnchorType eAnchorType = CPropagationAnchor::ParseAnchorType(jnAnchor.at("anchor_type").as_string());
......@@ -522,6 +529,7 @@ JSONNode JSON::CreateNode(const CPropagationPathList& pathList, std::shared_ptr<
JSONNode jnPathArray(JSON_ARRAY);
jnPathArray.set_name("propagation_paths");
jnPathArray.reserve( pathList.size() );
for each (const CPropagationPath & pPath in pathList)
jnPathArray.push_back( JSON::CreateNode(pPath, pResourceManager) );
......@@ -538,6 +546,7 @@ void JSON::Decode(CPropagationPathList& pathList, const JSONNode& jnRoot, std::s
//Get the propagation anchors of the path
JSONNode jnPropagationPaths = jnRoot.at("propagation_paths").as_array();
pathList.reserve( jnPropagationPaths.size() );
for each (JSONNode jnPath in jnPropagationPaths)
{
//Initialization of the emitter as a shared pointer
......
......@@ -16,11 +16,12 @@
*
*/
#ifndef IW_ITA_GEO_UTILS_JSON_VISTAVECTOR3D
#define IW_ITA_GEO_UTILS_JSON_VISTAVECTOR3D
#ifndef IW_ITA_GEO_UTILS_JSON_VISTA
#define IW_ITA_GEO_UTILS_JSON_VISTA
#include <ITAGeo/Definitions.h>
#include <VistaBase/VistaVector3D.h>
#include <VistaBase/VistaQuaternion.h>
//#include <string>
#include <libjson.h>
......@@ -36,27 +37,27 @@ namespace ITAGeo
//! Create JSONNode from given Vista3DVector
/**
* @param[in] v3Vector Vector to be encoded
* @param[in] encodeW If disabled, the fourth parameter of the VistaVector3D (W) is not encoded (default = true)
* @param[in] encodeW If enabled, the fourth parameter of the VistaVector3D (W) is encoded (default), otherwise not
*/
inline JSONNode CreateNode(const VistaVector3D& v3Vector, bool encodeW = true)
{
JSONNode jnVector3DArray(JSON_ARRAY);
double dX, dY, dZ, dW;
v3Vector.GetValues(dX, dY, dZ, dW);
JSONNode jnPosX("x", dX);
JSONNode jnPosY("y", dY);
JSONNode jnPosZ("z", dZ);
JSONNode jnPosW("w", dW);
jnVector3DArray.push_back(jnPosX);
jnVector3DArray.push_back(jnPosY);
jnVector3DArray.push_back(jnPosZ);
if (encodeW)
jnVector3DArray.push_back(jnPosW);
return jnVector3DArray;
}
inline JSONNode CreateNode(const VistaVector3D& v3Vector, bool encodeW = true)
{
JSONNode jnVector3DArray(JSON_ARRAY);
double dX, dY, dZ, dW;
v3Vector.GetValues(dX, dY, dZ, dW);
JSONNode jnPosX("x", dX);
JSONNode jnPosY("y", dY);
JSONNode jnPosZ("z", dZ);
JSONNode jnPosW("w", dW);
jnVector3DArray.push_back(jnPosX);
jnVector3DArray.push_back(jnPosY);
jnVector3DArray.push_back(jnPosZ);
if (encodeW)
jnVector3DArray.push_back(jnPosW);
return jnVector3DArray;
};
//! Parse properties from JSON node to given Vista3DVector
/**
......@@ -64,20 +65,63 @@ namespace ITAGeo
* @param[in] jsonNode JSONNode with data to be decoded
* If the fourth variable (W) did not get encoded, it is set to the default value of 1.
*/
inline void Decode(VistaVector3D& v3Vector, const JSONNode& jsonNode)
{
JSONNode jsonArray = jsonNode.as_array();
double dX = jsonArray.at(0).as_float();
double dY = jsonArray.at(1).as_float();
double dZ = jsonArray.at(2).as_float();
double dW = 1;
if (jsonArray.size() > 3)
dW = jsonArray.at(3).as_float();
v3Vector.SetValues(dX, dY, dZ, dW);
}
inline void Decode(VistaVector3D& v3Vector, const JSONNode& jsonNode)
{
JSONNode jsonArray = jsonNode.as_array();
double dX = jsonArray.at(0).as_float();
double dY = jsonArray.at(1).as_float();
double dZ = jsonArray.at(2).as_float();
double dW = 1;
if (jsonArray.size() > 3)
dW = jsonArray.at(3).as_float();
v3Vector.SetValues(dX, dY, dZ, dW);
};
//! Create JSONNode from given VistaQuaternion
/**
* @param[in] qQuat VistaQuaternion to be encoded
*/
inline JSONNode CreateNode(const VistaQuaternion& qQuat)
{
JSONNode jnQuaternionArray(JSON_ARRAY);
double dOrient[4];
qQuat.GetValues(dOrient);
JSONNode jnOrientX("x", dOrient[0]);
JSONNode jnOrientY("y", dOrient[1]);
JSONNode jnOrientZ("z", dOrient[2]);
JSONNode jnOrientW("w", dOrient[3]);
jnQuaternionArray.push_back(jnOrientX);
jnQuaternionArray.push_back(jnOrientY);
jnQuaternionArray.push_back(jnOrientZ);
jnQuaternionArray.push_back(jnOrientW);
return jnQuaternionArray;
};
//! Parse properties from JSON node to given VistaQuaternion
/**
* @param[in] qQuat Target quaternion for decoding
* @param[in] jsonNode JSONNode with data to be decoded
*/
inline void Decode(VistaQuaternion& qQuat, const JSONNode& jsonNode)
{
double dQuatData[4];
JSONNode jsonArray = jsonNode.as_array();
dQuatData[0] = jsonArray.at(0).as_float();
dQuatData[1] = jsonArray.at(1).as_float();
dQuatData[2] = jsonArray.at(2).as_float();
dQuatData[3] = jsonArray.at(3).as_float();
qQuat.SetValues(dQuatData);
};
}
}
}
#endif // IW_ITA_GEO_UTILS_JSON_VISTAVECTOR3D
#endif // IW_ITA_GEO_UTILS_JSON_VISTA
/*
* ----------------------------------------------------------------
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2019
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
*/
#ifndef IW_ITA_GEO_UTILS_JSON_VISTAQUATERNION
#define IW_ITA_GEO_UTILS_JSON_VISTAQUATERNION
#include <ITAGeo/Definitions.h>
#include <VistaBase/VistaQuaternion.h>
#include <libjson.h>
namespace ITAGeo
{
namespace Utils
{
namespace JSON
{
//! Create JSONNode from given VistaQuaternion
/**
* @param[in] qQuat VistaQuaternion to be encoded
*/
inline JSONNode CreateNode(const VistaQuaternion& qQuat)
{
JSONNode jnQuaternionArray(JSON_ARRAY);
double dOrient[4];
qQuat.GetValues(dOrient);
JSONNode jnOrientX("x", dOrient[0]);
JSONNode jnOrientY("y", dOrient[1]);
JSONNode jnOrientZ("z", dOrient[2]);
JSONNode jnOrientW("w", dOrient[3]);
jnQuaternionArray.push_back(jnOrientX);
jnQuaternionArray.push_back(jnOrientY);
jnQuaternionArray.push_back(jnOrientZ);
jnQuaternionArray.push_back(jnOrientW);
return jnQuaternionArray;
}
//! Parse properties from JSON node to given VistaQuaternion
/**
* @param[in] qQuat Target quaternion for decoding
* @param[in] jsonNode JSONNode with data to be decoded
*/
void Decode(VistaQuaternion& qQuat, const JSONNode& jsonNode)
{
double dQuatData[4];
JSONNode jsonArray = jsonNode.as_array();
dQuatData[0] = jsonArray.at(0).as_float();
dQuatData[1] = jsonArray.at(1).as_float();
dQuatData[2] = jsonArray.at(2).as_float();
dQuatData[3] = jsonArray.at(3).as_float();
qQuat.SetValues(dQuatData);
}
}
}
}
#endif // IW_ITA_GEO_UTILS_JSON_VISTAQUATERNION
......@@ -11,8 +11,7 @@ if( ITA_GEO_WITH_JSON_SUPPORT )
PropagationPath.cpp
PropagationPath_Impl.h
PropagationPath_Impl.cpp
VistaVector3D.h
VistaQuaternion.h
VistaJSON.h
)
set( DirFiles_SourceGroup "${RelativeSourceGroup}" )
......
......@@ -88,15 +88,15 @@ void exportAtmosphere(const CStratifiedAtmosphere& atmos, const vector<double>&
void exportTestParameters()
{
auto humidProfile = std::make_unique<HumidityProfiles::CConstant>(50);
auto tempProfile = std::make_unique<TemperatureProfiles::CRoom>();
auto windProfile = std::make_unique<WindProfiles::CZero>();
auto homogeneousAtmosphere = CStratifiedAtmosphere(std::move(tempProfile), std::move(windProfile), std::move(humidProfile));
auto humidProfile2 = std::make_unique<HumidityProfiles::CConstant>(50);
auto tempProfile2 = std::make_unique<TemperatureProfiles::CISA>();
auto windProfile2 = std::make_unique<WindProfiles::CLog>(0.6, 0.1, VistaVector3D(1, 0, 0));
auto inhomogeneousAtmosphere = CStratifiedAtmosphere(std::move(tempProfile2), std::move(windProfile2), std::move(humidProfile2));
auto humidProfile = std::make_shared<HumidityProfiles::CConstant>(50);
auto tempProfile = std::make_shared<TemperatureProfiles::CRoom>();
auto windProfile = std::make_shared<WindProfiles::CZero>();
auto homogeneousAtmosphere = CStratifiedAtmosphere(tempProfile, windProfile, humidProfile);
auto humidProfile2 = std::make_shared<HumidityProfiles::CConstant>(50);
auto tempProfile2 = std::make_shared<TemperatureProfiles::CISA>();
auto windProfile2 = std::make_shared<WindProfiles::CLog>(0.6, 0.1, VistaVector3D(1, 0, 0));
auto inhomogeneousAtmosphere = CStratifiedAtmosphere(tempProfile2, windProfile2, humidProfile2);
vector<double> altitudes;
......
......@@ -81,24 +81,24 @@ bool testWriteAndReadJSON()
bool ok = true;
try
{
auto humidProfile = std::make_unique<HumidityProfiles::CConstant>(1);
auto tempProfile = std::make_unique<TemperatureProfiles::CConstant>(4,2);
auto windProfile = std::make_unique<WindProfiles::CConstant>(42, VistaVector3D(1, 0, 0));