Skip to content

Commit

Permalink
MMVII: ImportGCP: add sigma and free points options
Browse files Browse the repository at this point in the history
  • Loading branch information
meynardc committed Jul 18, 2024
1 parent d21ca73 commit ab5a0d8
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 42 deletions.
39 changes: 19 additions & 20 deletions MMVII/Doc/CommandReferences/SysCo.tex
Original file line number Diff line number Diff line change
Expand Up @@ -235,29 +235,29 @@ \subsection{3D points file}
The initial coordinates of the 4 points, in Lambert 93, are in a simple text file (\texttt{inputs/coords.txt}):

\begin{verbatim}
PtA 657700.000 6860700.000 10.000
PtB 657710 6860700 10
PtC 657710 6860710 10
PtD 657700.000 6860690.000 10.000
* 1st column: 0 = free point
1 PtA 657700.000 6860700.000 10.000
0 PtB 657710 6860700 10 * approx
0 PtC 657710 6860710 10 * approx
1 PtD 657700.000 6860690.000 10.000
\end{verbatim}

The coordinates of PtA and PtD are supposed known (with a certain precision).
The coordinates of PtB and PtC are just for initialization.
\\

To import these coordinates in \CdPPP\ we use the \texttt{ImportGCP} command, where we give the text format
(name, x, y, z), the name of the resulting \texttt{PointsMeasure} and the coordinates SysCo.
(additional\_info, name, x, y, z), the name of the resulting \texttt{PointsMeasure} and the coordinates SysCo.
We also specify that the points who have an additional\_info of '0' are free points, that the sigma for
known points is 0.001m and that lines starting with '*' are comment lines.

\begin{lstlisting}
MMVII ImportGCP inputs/coords.txt NXYZ InitL93 ChSys=[L93]
MMVII ImportGCP inputs/coords.txt ANXYZ InitL93 ChSys=[L93] AddInfoFree=0 Sigma=0.001 Comment=*
\end{lstlisting}

In the resulting file \texttt{MMVII-PhgrProj/PointsMeasure/InitL93/MesGCP-coords.xml},
we have to remove the coordinates constraints on points PtB and PtC to make them free points
with initial coordinates. To do that, their \texttt{\_\_Opt\_\_Sigma2} nodes have to be deleted.

The points PtA and PtD have a \texttt{\_\_Opt\_\_Sigma2} corresponding to a 1 m $\sigma$. In adjustment,
we will use the \texttt{GCPW} factor to get a $\sigma$ of 1 mm.
The points PtA and PtD have a \texttt{\_\_Opt\_\_Sigma2} set to 0.001 m $\sigma$.
The points PtB and PtC have no \texttt{\_\_Opt\_\_Sigma2}, making them free points.

\begin{comment}
The resulting \texttt{MMVII-PhgrProj/PointsMeasure/InitL93/MesGCP-coords.xml} file is:
Expand All @@ -274,24 +274,24 @@ \subsection{3D points file}
<el>
<Name>"PtA"</Name>
<Pt>-0.000000000016875 0.000000000583916 10.000000000498177</Pt>
<AdditionalInfo>""</AdditionalInfo>
<__Opt__Sigma2>1 0 0 1 0 1</__Opt__Sigma2>
<AdditionalInfo>"1"</AdditionalInfo>
<__Opt__Sigma2>0.000001000000111 0 0 0.000001000000111 0 0.000001000000111</__Opt__Sigma2>
</el>
<el>
<Name>"PtB"</Name>
<Pt>10.000907818502791 0.07300202118504 9.999992174224545</Pt>
<AdditionalInfo>""</AdditionalInfo>
<AdditionalInfo>"0"</AdditionalInfo>
</el>
<el>
<Name>"PtC"</Name>
<Pt>9.927905478628638 10.073909554171774 9.999984325034628</Pt>
<AdditionalInfo>""</AdditionalInfo>
<AdditionalInfo>"0"</AdditionalInfo>
</el>
<el>
<Name>"PtD"</Name>
<Pt>0.073001699489761 -10.000908193716121 9.999992150963823</Pt>
<AdditionalInfo>""</AdditionalInfo>
<__Opt__Sigma2>1 0 0 1 0 1</__Opt__Sigma2>
<AdditionalInfo>"1"</AdditionalInfo>
<__Opt__Sigma2>0.000001000000111 0 0 0.000001000000111 0 0.000001000000111</__Opt__Sigma2>
</el>
</Measures>
</SetGCP>
Expand Down Expand Up @@ -405,10 +405,9 @@ \subsection{Adjustment}
\end{verbatim}

In our example, the input topo directory is \texttt{Obs1} and the input PointsMeasure is \texttt{InitRTL}.
We give output directories names for topo and points, and add a weight factor for 3D constrained coordinates
because PtA and PtD are known with a precision of 1 mm:
We give output directories names for topo and points.
\begin{lstlisting}
MMVII TopoAdj Obs1 Obs1_out InitRTL FinalRTL GCPW=0.001
MMVII TopoAdj Obs1 Obs1_out InitRTL FinalRTL
\end{lstlisting}

The final $\sigma_0$ value should be around 1 if everything goes well.
Expand Down
6 changes: 2 additions & 4 deletions MMVII/MMVII-UseCaseDataSet/TopoMini/Cmd.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ set -e
rm -Rf MMVII-PhgrProj

# import coords
MMVII ImportGCP inputs/coords.txt NXYZ InitL93 ChSys=[L93]

"remove __Opt__Sigma2 for PtB and PtC"
MMVII ImportGCP inputs/coords.txt ANXYZ InitL93 ChSys=[L93] AddInfoFree=0 Sigma=0.001 Comment=*


# convert to RTL
Expand All @@ -15,6 +13,6 @@ MMVII GCPChSysCo "RTL*657700*6860700*0*IGNF:LAMB93" InitL93 InitRTL
mkdir -p MMVII-PhgrProj/Topo/Obs1/
cp inputs/meas.obs MMVII-PhgrProj/Topo/Obs1/

MMVII TopoAdj Obs1 Obs1_out InitRTL FinalRTL GCPW=0.001
MMVII TopoAdj Obs1 Obs1_out InitRTL FinalRTL

MMVII GCPChSysCo L93 FinalRTL FinalL93
9 changes: 5 additions & 4 deletions MMVII/MMVII-UseCaseDataSet/TopoMini/inputs/coords.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
PtA 657700.000 6860700.000 10.000
PtB 657710 6860700 10
PtC 657710 6860710 10
PtD 657700.000 6860690.000 10.000
* 1st column: 0 = free point
1 PtA 657700.000 6860700.000 10.000
0 PtB 657710 6860700 10 * approx
0 PtC 657710 6860710 10 * approx
1 PtD 657700.000 6860690.000 10.000
45 changes: 31 additions & 14 deletions MMVII/src/ConvertFormat/ImportGCP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,21 @@ class cAppli_ImportGCP : public cMMVII_Appli
std::string mNameGCP;
int mL0;
int mLLast;
int mComment;
char mComment;
int mNbDigName;
std::vector<std::string> mPatternTransfo;
double mMulCoord;
double mSigma;
std::string mAddInfoFree;
};

cAppli_ImportGCP::cAppli_ImportGCP(const std::vector<std::string> & aVArgs,const cSpecMMVII_Appli & aSpec) :
cMMVII_Appli (aVArgs,aSpec),
mPhProj (*this),
mL0 (0),
mLLast (-1),
mComment (-1),
mMulCoord (1.0)
mMulCoord (1.0),
mSigma (1.0)
{
}

Expand All @@ -76,12 +78,19 @@ cCollecSpecArg2007 & cAppli_ImportGCP::ArgOpt(cCollecSpecArg2007 & anArgObl)
<< AOpt2007(mPatternTransfo,"PatName","Pattern for transforming name (first sub-expr)",{{eTA2007::ISizeV,"[2,2]"}})
<< mPhProj.ArgChSys(true) // true => default init with None
<< AOpt2007(mMulCoord,"MulCoord","Coordinate multiplier, used to change unity as meter to mm")
<< AOpt2007(mSigma,"Sigma","Sigma for all coords (covar is 0). -1 to make all points free",{eTA2007::HDV})
<< AOpt2007(mComment,"Comment","Character for commented line")
<< AOpt2007(mAddInfoFree,"AddInfoFree","All points whose Additional Info is set to this value are Free")
;
}


int cAppli_ImportGCP::Exe()
{
int aComment = -1;
if (IsInit(&mComment))
aComment = mComment;

mPhProj.FinishInit();
std::vector<std::vector<std::string>> aVNames;
std::vector<std::vector<double>> aVNums;
Expand All @@ -93,7 +102,7 @@ int cAppli_ImportGCP::Exe()
ReadFilesStruct
(
mNameFile, mFormat,
mL0, mLLast, mComment,
mL0, mLLast, aComment,
aVNames,aVXYZ,aVWKP,aVNums
);

Expand All @@ -114,23 +123,31 @@ int cAppli_ImportGCP::Exe()
bool aHasAdditionalInfo = aRankA_InF != mFormat.npos;
size_t aRankP = (aRankP_InF<aRankA_InF) ? 0 : 1;
size_t aRankA = 1 - aRankP;
if (IsInit(&mAddInfoFree) && !aHasAdditionalInfo)
MMVII_UserError(eTyUEr::eBadOptParam,"AddInfoFree specified but no 'A' in format string");

for (size_t aK=0 ; aK<aVXYZ.size() ; aK++)
{
std::string aName = aVNames.at(aK).at(aRankP);
auto aSigma = mSigma;
std::string aName = aVNames.at(aK).at(aRankP);

if (IsInit(&mPatternTransfo))
{
if (IsInit(&mPatternTransfo))
{
// aName = PatternKthSubExpr(mPatternTransfo,1,aName);
aName = ReplacePattern(mPatternTransfo.at(0),mPatternTransfo.at(1),aName);
}
if (IsInit(&mNbDigName))
aName = ReplacePattern(mPatternTransfo.at(0),mPatternTransfo.at(1),aName);
}

if (IsInit(&mNbDigName))
aName = ToStr(cStrIO<int>::FromStr(aName),mNbDigName);

std::string aAdditionalInfo = "";
if (aHasAdditionalInfo)
aAdditionalInfo = aVNames.at(aK).at(aRankA);
aSetM.AddMeasure(cMes1GCP(aChSys.Value(aVXYZ[aK]*mMulCoord),aName,1.0,aAdditionalInfo));
std::string aAdditionalInfo = "";
if (aHasAdditionalInfo)
{
aAdditionalInfo = aVNames.at(aK).at(aRankA);
if (IsInit(&mAddInfoFree) && aAdditionalInfo == mAddInfoFree)
aSigma = -1;
}
aSetM.AddMeasure(cMes1GCP(aChSys.Value(aVXYZ[aK]*mMulCoord),aName,aSigma,aAdditionalInfo));
}

mPhProj.SaveGCP(aSetM);
Expand Down

0 comments on commit ab5a0d8

Please sign in to comment.