Skip to content

Commit

Permalink
RTL post init, auto RTL in importGCP
Browse files Browse the repository at this point in the history
  • Loading branch information
jmmuller committed Sep 24, 2024
1 parent a2ec214 commit 3d888d8
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 5 deletions.
18 changes: 18 additions & 0 deletions MMVII/Doc/CommandReferences/SysCo.tex
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
11 changes: 8 additions & 3 deletions MMVII/MMVII-UseCaseDataSet/TopoMini/Cmd.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions MMVII/include/MMVII_Sensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -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() ;
Expand Down
5 changes: 5 additions & 0 deletions MMVII/include/MMVII_SysCo.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -115,6 +117,9 @@ class cChangeSysCo : public cDataInvertibleMapping<tREAL8,3>
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;
Expand Down
19 changes: 19 additions & 0 deletions MMVII/src/ConvertFormat/ImportGCP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<tREAL8,cPt3dr> aAvgPt;

for (size_t aK=0 ; aK<aVXYZ.size() ; aK++)
{
aAvgPt.Add(1.0,aVXYZ[aK]);
}
std::string aRTLName = mPhProj.ChSysCo().SysTarget()->Def();
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<aVXYZ.size() ; aK++)
{
auto aSigma = mSigma;
Expand Down
26 changes: 24 additions & 2 deletions MMVII/src/SysCo/SysCo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,11 @@ public :

virtual cRotation3D<tREAL8> 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
};
//------------------------------------------------------------

Expand Down Expand Up @@ -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());
}

Expand All @@ -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]));
Expand Down Expand Up @@ -509,13 +518,14 @@ bool cSysCoRTL::computeRTL(tPt anOrigin, std::string aInDef)
<<aOmegaPhiKappa.x()<<SysCoDefSep<<aOmegaPhiKappa.y()<<SysCoDefSep<<aOmegaPhiKappa.z();
mDef = oss.str();
}

mIsReady = true;
return true;
}


cRotation3D<tREAL8> 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<cSysCoRTL*>(anOtherRTL.get());
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 3d888d8

Please sign in to comment.