Skip to content

Commit

Permalink
fix ImportGCP
Browse files Browse the repository at this point in the history
  • Loading branch information
jmmuller committed Oct 11, 2024
1 parent ea63513 commit 7ccadf7
Showing 1 changed file with 2 additions and 105 deletions.
107 changes: 2 additions & 105 deletions MMVII/src/ImportFormat/ImportGCP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ int cAppli_ImportGCP::Exe()
}
*/

// coherence check ; JMM => I changed the test, becaus it seems more logical ???
// coherence check
if (withPatternAddInfoFree && (!withAddInfo))
MMVII_UserError(eTyUEr::eBadOptParam,"AddInfoFree specified but no 'A' in format string");

Expand All @@ -162,7 +162,6 @@ int cAppli_ImportGCP::Exe()
for (size_t aKL=0 ; aKL<aNRFS.NbLineRead() ; aKL++)
aVPts.push_back(aNRFS.GetPt3dr_XYZ(aKL));

// JMM, JO : make a function, of SysCo creation, as it will be re used with conversion of orientation
// compute output RTL if necessary
mPhProj.InitSysCoRTLIfNotReady(cWeightAv<tREAL8,cPt3dr>::AvgCst(aVPts));

Expand All @@ -186,7 +185,7 @@ int cAppli_ImportGCP::Exe()
if (wSigmaXYZ)
aSigma = aNRFS.GetFloat(mFieldSxyz,aKL);
// check AddInfoFree at end, because we can have sigma in format but point is free
if (withPatternAddInfoFree && MatchRegex(aNamePoint,mPatternAddInfoFree))
if (withPatternAddInfoFree && MatchRegex(aAdditionalInfo,mPatternAddInfoFree))
aSigma = -1;

cMes1GCP aMesGCP(aChSys.Value(aVPts[aKL]*mMulCoord),aNamePoint,aSigma,aAdditionalInfo);
Expand All @@ -200,108 +199,6 @@ int cAppli_ImportGCP::Exe()
return EXIT_SUCCESS;
}

#if (0)
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;
std::vector<cPt3dr> aVXYZ,aVWKP;


MMVII_INTERNAL_ASSERT_tiny(CptSameOccur(mFormat,"XYZN")==1,"Bad format vs NXYZ");

ReadFilesStruct
(
mNameFile, mFormat,
mL0, mLLast, aComment,
aVNames,aVXYZ,aVWKP,aVNums
);


if (! IsInit(&mNameGCP))
{
mNameGCP = FileOfPath(mNameFile,false);
if (IsPrefixed(mNameGCP))
mNameGCP = LastPrefix(mNameGCP);
}

cChangeSysCo & aChSys = mPhProj.ChSysCo();

cSetMesGCP aSetM(mNameGCP);

size_t aRankP_InF = mFormat.find('N');
size_t aRankA_InF = mFormat.find('A');
size_t aRankP = (aRankP_InF<aRankA_InF) ? 0 : 1;
size_t aRankA = 1 - aRankP;
bool aHasAdditionalInfo = aRankA_InF != mFormat.npos;
bool aUseAddInfoFree = IsInit(&mPatternAddInfoFree);
std::regex aRegexAddInfoFree;
try {
aRegexAddInfoFree = std::regex(mPatternAddInfoFree);
} catch (std::regex_error&) {
MMVII_UserError(eTyUEr::eBadPattern,"Invalid regular expression for AddInfoFree : '" + mPatternAddInfoFree + "'");
} catch (...) {
throw;
}
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;
std::string aName = aVNames.at(aK).at(aRankP);

if (IsInit(&mPatternTransfo))
{
// aName = PatternKthSubExpr(mPatternTransfo,1,aName);
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);
if (aUseAddInfoFree && std::regex_match(aAdditionalInfo, aRegexAddInfoFree))
aSigma = -1;
}
aSetM.AddMeasure(cMes1GCP(aChSys.Value(aVXYZ[aK]*mMulCoord),aName,aSigma,aAdditionalInfo));
}

mPhProj.SaveGCP(aSetM);
mPhProj.SaveCurSysCoGCP(aChSys.SysTarget());


return EXIT_SUCCESS;
}
#endif


std::vector<std::string> cAppli_ImportGCP::Samples() const
{
Expand Down

0 comments on commit 7ccadf7

Please sign in to comment.