From 3d888d8d0602800148bc90fd134650c557365903 Mon Sep 17 00:00:00 2001 From: jmmuller Date: Mon, 23 Sep 2024 18:25:23 +0200 Subject: [PATCH] RTL post init, auto RTL in importGCP --- MMVII/Doc/CommandReferences/SysCo.tex | 18 ++++++++++++++ MMVII/MMVII-UseCaseDataSet/TopoMini/Cmd.txt | 11 ++++++--- MMVII/include/MMVII_Sensor.h | 1 + MMVII/include/MMVII_SysCo.h | 5 ++++ MMVII/src/ConvertFormat/ImportGCP.cpp | 19 +++++++++++++++ MMVII/src/SysCo/SysCo.cpp | 26 +++++++++++++++++++-- 6 files changed, 75 insertions(+), 5 deletions(-) diff --git a/MMVII/Doc/CommandReferences/SysCo.tex b/MMVII/Doc/CommandReferences/SysCo.tex index 6236f0d087..394999a571 100644 --- a/MMVII/Doc/CommandReferences/SysCo.tex +++ b/MMVII/Doc/CommandReferences/SysCo.tex @@ -272,6 +272,24 @@ \subsection{SysCo} MMVII GCPChSysCo "RTL*657700*6860700*0*IGNF:LAMB93" InitL93 InitRTL \end{lstlisting} + +The two previous steps can be done in one \texttt{ImportGCP} call, the \texttt{ChSys} parameter accepting two +SysCos: + +\begin{lstlisting} +MMVII ImportGCP inputs/coords.txt ANXYZ InitL93 ChSys="[L93,RTL*657700*6860700*0*IGNF:LAMB93]" AddInfoFree=0 Sigma=0.001 Comment=* +\end{lstlisting} + +\subsection{Auto RTL SysCo} + +\texttt{ImportGCP} can automatically create a \texttt{RTL} SysCo, with its origin equal to the average of the input coordinates: +just give \texttt{RTL} as the destination SysCo. This new SysCo will be saved as \texttt{MMVII-PhgrProj/SysCo/RTL.xml}, making +the SysCo available for every following command as \texttt{RTL}. + +\begin{lstlisting} +MMVII ImportGCP inputs/coords.txt ANXYZ InitL93 ChSys=[L93,RTL] AddInfoFree=0 Sigma=0.001 Comment=* +\end{lstlisting} + \begin{comment} \subsection{SysCo shortcut} The SysCo file \texttt{MMVII-PhgrProj/PointsMeasure/InitRTL/CurSysCo.xml}, created by \texttt{ImportGCP} diff --git a/MMVII/MMVII-UseCaseDataSet/TopoMini/Cmd.txt b/MMVII/MMVII-UseCaseDataSet/TopoMini/Cmd.txt index 7579de885b..94bb8ed529 100644 --- a/MMVII/MMVII-UseCaseDataSet/TopoMini/Cmd.txt +++ b/MMVII/MMVII-UseCaseDataSet/TopoMini/Cmd.txt @@ -4,10 +4,15 @@ set -e rm -Rf MMVII-PhgrProj # import coords -MMVII ImportGCP inputs/coords.txt ANXYZ InitL93 ChSys=[L93] AddInfoFree=0 Sigma=0.001 Comment=* - +#MMVII ImportGCP inputs/coords.txt ANXYZ InitL93 ChSys=[L93] AddInfoFree=0 Sigma=0.001 Comment=* # convert to RTL -MMVII GCPChSysCo "RTL*657700*6860700*0*IGNF:LAMB93" InitL93 InitRTL +#MMVII GCPChSysCo "RTL*657700*6860700*0*IGNF:LAMB93" InitL93 InitRTL + +# or direct convert to RTL +#MMVII ImportGCP inputs/coords.txt ANXYZ InitRTL ChSys=[L93,"RTL*657700*6860700*0*IGNF:LAMB93"] AddInfoFree=0 Sigma=0.001 Comment=* + +# or auto RTL from average + create SysCo/RTL.xml +MMVII ImportGCP inputs/coords.txt ANXYZ InitRTL ChSys=[L93,RTL] AddInfoFree=0 Sigma=0.001 Comment=* # import obs MMVII ImportOBS inputs/meas.obs Obs1 diff --git a/MMVII/include/MMVII_Sensor.h b/MMVII/include/MMVII_Sensor.h index 24e12f8e8e..de730a81aa 100755 --- a/MMVII/include/MMVII_Sensor.h +++ b/MMVII/include/MMVII_Sensor.h @@ -670,6 +670,7 @@ class cPhotogrammetricProject void SaveCurSysCoGCP(tPtrSysCo) const ; void SaveStdCurSysCo(bool IsOri) const; /// save the Cur Sysco in Orient/GCP void CpSysIn2Out(bool OriIn,bool OriOut) const; // bool : Ori/GCP do it only if exist, else no error + std::string getDirSysCo() const { return mDirSysCo; } const cChangeSysCo & ChSysCo() const; cChangeSysCo & ChSysCo() ; diff --git a/MMVII/include/MMVII_SysCo.h b/MMVII/include/MMVII_SysCo.h index 5d4a941e79..e307909f48 100644 --- a/MMVII/include/MMVII_SysCo.h +++ b/MMVII/include/MMVII_SysCo.h @@ -74,6 +74,7 @@ public : tREAL8 getEllipsoid_a() const {return semi_axis;} tREAL8 getEllipsoid_e2() const {return e2;} tREAL8 getEllipsoid_b() const {return b;} + bool isReady() const {return mIsReady; } protected : cSysCo(bool aDebug); cSysCo(const std::string & def, bool aDebug); @@ -82,6 +83,7 @@ protected : PJ_CONTEXT* mPJContext; PJ* mPJ_GeoC2Geog; //< for generic use bool mDebug; //< show debug messages + bool mIsReady = true; // to be able to compute transfo later //GRS80 const tREAL8 semi_axis = 6378137; @@ -115,6 +117,9 @@ class cChangeSysCo : public cDataInvertibleMapping tPtrSysCo SysOrigin() const { return mSysCoOrigin; }; ///< Accessor tPtrSysCo SysTarget() const { return mSysCoTarget; }; ///< Accessor + void setOriginSysCo(tPtrSysCo aSysCo); + void setTargetsysCo(tPtrSysCo aSysCo); + private: tPtrSysCo mSysCoOrigin; tPtrSysCo mSysCoTarget; diff --git a/MMVII/src/ConvertFormat/ImportGCP.cpp b/MMVII/src/ConvertFormat/ImportGCP.cpp index 70c8882623..d53b2c3eb4 100644 --- a/MMVII/src/ConvertFormat/ImportGCP.cpp +++ b/MMVII/src/ConvertFormat/ImportGCP.cpp @@ -137,6 +137,25 @@ int cAppli_ImportGCP::Exe() if (aUseAddInfoFree && !aHasAdditionalInfo) MMVII_UserError(eTyUEr::eBadOptParam,"AddInfoFree specified but no 'A' in format string"); + // compute output RTL if necessary + if (mPhProj.ChSysCo().SysTarget()->getType()==eSysCo::eRTL && !mPhProj.ChSysCo().SysTarget()->isReady()) + { + cWeightAv aAvgPt; + + for (size_t aK=0 ; aKDef(); + mPhProj.ChSysCo().setTargetsysCo(mPhProj.CreateSysCoRTL( + aAvgPt.Average(), + mPhProj.ChSysCo().SysOrigin()->Def())); + SaveInFile(mPhProj.ChSysCo().SysTarget()->toSysCoData(), + mPhProj.getDirSysCo() + aRTLName + "." + GlobTaggedNameDefSerial()); + + } + + for (size_t aK=0 ; aK getRot2Vertical(const tPt &aPtIn) const override; //< get rotation from SysCo origin to vertical at this point + bool computeRTL(tPt anOrigin, std::string aInDef); //< init mTranfo2GeoC for RTL case + protected: cSysCoRTL(const std::string & def, bool aDebug); //< construct from a definition, starting with RTL cSysCoRTL(tPt anOrigin, std::string aInDef, bool aDebug); //< construct for RTL - bool computeRTL(tPt anOrigin, std::string aInDef); //< init mTranfo2GeoC for RTL case }; //------------------------------------------------------------ @@ -421,11 +422,13 @@ cSysCoLEuc::~cSysCoLEuc() tPt3dr cSysCoLEuc::Value(const tPt & in) const //< to GeoC { + MMVII_INTERNAL_ASSERT_User(mIsReady, eTyUEr::eSysCo, "SysCo not ready") return getTranfo2GeoC()->Rot().Mat() * in + getTranfo2GeoC()->Tr(); } tPt3dr cSysCoLEuc::Inverse(const tPt & in) const //< from GeoC { + MMVII_INTERNAL_ASSERT_User(mIsReady, eTyUEr::eSysCo, "SysCo not ready") return getTranfo2GeoC()->Rot().Mat().Transpose() * (in - getTranfo2GeoC()->Tr()); } @@ -443,6 +446,12 @@ cSysCoRTL::cSysCoRTL(const std::string &aDef, bool aDebug) : "Error in RTL definition format: \""+mDef+"\"") if (tokens[0]==MMVII_SysCoRTL) { + if (tokens.size()==1) + { + // RTL to be made later + mIsReady = false; + return; + } MMVII_INTERNAL_ASSERT_User(tokens.size()==5, eTyUEr::eInsufNbParam, "Error in RTL definition format: \""+mDef+"\"") tPt anOrigin(std::stod(tokens[1]), std::stod(tokens[2]), std::stod(tokens[3])); @@ -509,13 +518,14 @@ bool cSysCoRTL::computeRTL(tPt anOrigin, std::string aInDef) < cSysCoRTL::getRot2Vertical(const tPt & aPtIn) const { + MMVII_INTERNAL_ASSERT_User(mIsReady, eTyUEr::eSysCo, "SysCo not ready") tPt ptGeoC = Value(aPtIn); auto anOtherRTL = cSysCoLEuc::makeRTL(ptGeoC, MMVII_SysCoDefGeoC); auto anOtherRTL_asRTL = static_cast(anOtherRTL.get()); @@ -539,6 +549,7 @@ cSysCoProj::~cSysCoProj() tPt3dr cSysCoProj::Value(const tPt & in) const //< to GeoC { + MMVII_INTERNAL_ASSERT_User(mIsReady, eTyUEr::eSysCo, "SysCo not ready") PJ_COORD pj_in, pj_out; pj_in = proj_coord(in.x(), in.y(), in.z(), 0.); pj_out = proj_trans(mPJ_Proj2GeoC, PJ_FWD, pj_in); @@ -548,6 +559,7 @@ tPt3dr cSysCoProj::Value(const tPt & in) const //< to GeoC tPt3dr cSysCoProj::Inverse(const tPt & in) const //< from GeoC { + MMVII_INTERNAL_ASSERT_User(mIsReady, eTyUEr::eSysCo, "SysCo not ready") PJ_COORD pj_in, pj_out; pj_in = proj_coord(in.x(), in.y(), in.z(), 0.); pj_out = proj_trans(mPJ_Proj2GeoC, PJ_INV, pj_in); @@ -602,6 +614,16 @@ tPt3dr cChangeSysCo::Inverse(const tPt &in) const } } +void cChangeSysCo::setOriginSysCo(tPtrSysCo aSysCo) +{ + mSysCoOrigin = aSysCo; +} + +void cChangeSysCo::setTargetsysCo(tPtrSysCo aSysCo) +{ + mSysCoTarget = aSysCo; +} + //------------------------------------------------------------ void GenSpec_SysCo(const std::string & aDir)