Esempio n. 1
0
int ConvertRtk_main(int argc,char ** argv)
{
	std::string aDir, aFile, aOut;
	bool addInc = false;
	
	ElInitArgMain
    (
          argc, argv,
          LArgMain() << EAMC(aDir, "Directory")
					 << EAMC(aFile, "Rtk output.txt file",  eSAM_IsExistFile),
          LArgMain() << EAM(aOut,"Out",false,"output txt file name : def=Output.txt")
					 << EAM(addInc,"addInc",false,"export also uncertainty values : def=flase",eSAM_IsBool)
    );
    
    std::string aFullName = aDir+aFile;
    
    //name output .xml file
    if (aOut=="")
    {
		aOut = StdPrefixGen(aFile) + ".xml";
    }
    
    std::vector<Pt3dr> aPosList;
    std::vector<Pt3dr> aIcList;
    
    //read rtk input file
    ifstream fichier(aFullName.c_str());  								//déclaration du flux et ouverture du fichier

    if(fichier)  														// si l'ouverture a réussi
    {

		std::string ligne; 												//Une variable pour stocker les lignes lues
        
        while(!fichier.eof())
        {
			getline(fichier,ligne);
            
            if(ligne.compare(0,1,"%") == 0)								//pour sauter l'entête (toute les lignes qui commencent par "%")
            {
				std::cout << " % Skip Header Line % " << std::endl;
				std::cout << "Ligne = "<< ligne << std::endl;				
            }
            
            else if(ligne.size() != 0)       							// problème de dernière ligne du fihier
            {
				std::string s = ligne;
                std::vector<string> coord;                 
                int lowmark=-1;
                int uppermark=-1;
                
                for(unsigned int i=0;i<s.size()+1;i++)     				// parser chaque ligne par l'espace
                {
					if(std::isspace(s[i]) && (lowmark!=-1))
                    {                             
						string token = s.substr(lowmark,uppermark);                             
                        coord.push_back(token);
                        
                        //nouveau mot
                        lowmark=-1;
                        uppermark=-1;
                    }
                    else
                        if(!(std::isspace(s[i])) && (lowmark==-1))
                        {
							lowmark=i;
                            uppermark=i+1;
                        }
                        else if(!(std::isspace(s[i])) && (lowmark!=-1))
                        {
                              uppermark++;
                        }
                        else
                        {
                              lowmark=-1;
                              uppermark=-1;
                        }
                }

                      Pt3dr Pt;											//position
                      Pt3dr Ic;
                      
                      Pt.x = atof(coord[2].c_str());
                      Pt.y = atof (coord[3].c_str());
                      Pt.z = atof (coord[4].c_str());
                      
                      Ic.x = atof(coord[7].c_str());
                      Ic.y = atof(coord[8].c_str());
                      Ic.z = atof(coord[9].c_str());
                      
                      aPosList.push_back(Pt);                      
                      aIcList.push_back(Ic);                      
            }
        }
      
        fichier.close();  												// fermeture fichier
    }
    
    else
    
		std::cout<< "Erreur à l'ouverture !" << '\n';
	
	//save coordinates in a .xml file
	
	cDicoAppuisFlottant  aDico;
    for (int aKP=0 ; aKP<int(aPosList.size()) ; aKP++)
    {
		cOneAppuisDAF aOAD;
        aOAD.Pt() = aPosList[aKP];
        aOAD.Incertitude() = aIcList[aKP];

        aDico.OneAppuisDAF().push_back(aOAD);
	}

    MakeFileXML(aDico,aOut);
    
   	return EXIT_SUCCESS;
}
Esempio n. 2
0
int Dimap2Grid_main(int argc, char **argv)
{
    std::string aNameFileDimap; // fichier Dimap
    std::string aNameImage;     // nom de l'image traitee
	std::string inputSyst = "+proj=latlong +datum=WGS84 "; //+ellps=WGS84"; //input syst proj
    std::string targetSyst="+init=IGNF:LAMB93";//systeme de projection cible - format proj4
    std::string refineCoef="processing/refineCoef.txt";

    //Creation d'un dossier pour les fichiers intermediaires
    ELISE_fp::MkDirSvp("processing");

    //Creation du fichier de coef par defaut (grille non affinee)
    std::ofstream ficWrite(refineCoef.c_str());
    ficWrite << std::setprecision(15);
    ficWrite << 0 <<" "<< 1 <<" "<< 0 <<" "<< 0 <<" "<< 0 <<" "<< 1 <<" "<<std::endl;

    double altiMin, altiMax;
    int nbLayers;

    double stepPixel = 100.f;
    double stepCarto = 50.f;

    int rowCrop  = 0;
    int sampCrop = 0;

    ElInitArgMain
    (
        argc, argv,
        LArgMain() << EAMC(aNameFileDimap,"RPC Dimap file")
                  // << EAMC(aNameFileGrid,"Grid file")
                   << EAMC(aNameImage,"Image name")
                   << EAMC(altiMin,"min altitude (ellipsoidal)")
                   << EAMC(altiMax,"max altitude (ellipsoidal)")
                   << EAMC(nbLayers,"number of layers (min 4)"),
        LArgMain()
                 //caracteristique du systeme geodesique saisies sans espace (+proj=utm +zone=10 +north +datum=WGS84...)
                 << EAM(targetSyst,"targetSyst", true,"target system in Proj4 format")
                 << EAM(stepPixel,"stepPixel",true,"Step in pixel")
                 << EAM(stepCarto,"stepCarto",true,"Step in m (carto)")
                 << EAM(sampCrop,"sampCrop",true,"upper left samp - crop")
                 << EAM(rowCrop,"rowCrop",true,"upper left row - crop")
                 << EAM(refineCoef,"refineCoef",true,"File of Coef to refine Grid")
     );

    // fichier GRID en sortie
    std::string aNameFileGrid = StdPrefixGen(aNameImage)+".GRI";

    Dimap dimap(aNameFileDimap);
    dimap.info();

    std::vector<double> vAltitude;
    for(int i=0;i<nbLayers;++i)
        vAltitude.push_back(altiMin+i*(altiMax-altiMin)/(nbLayers-1));
	
    /* ISN'T THIS USELESS??
	//Parser du targetSyst
    std::size_t found = targetSyst.find_first_of("+");
	std::string str = "+";
	std::vector<int> position;
    while (found!=std::string::npos)
    {
        targetSyst[found]=' ';
        position.push_back(found);
        found=targetSyst.find_first_of("+",found+1);
    }
    for (int i=position.size()-1; i>-1;i--)
        targetSyst.insert(position[i]+1,str);
	*/
	
    //recuperation des coefficients pour affiner le modele
    std::vector<double> vRefineCoef;
    std::ifstream ficRead(refineCoef.c_str());
    while(!ficRead.eof()&&ficRead.good())
    {
        double a0,a1,a2,b0,b1,b2;
        ficRead >> a0 >> a1 >> a2 >> b0 >> b1 >> b2;

        if (ficRead.good())
        {
            vRefineCoef.push_back(a0);
            vRefineCoef.push_back(a1);
            vRefineCoef.push_back(a2);
            vRefineCoef.push_back(b0);
            vRefineCoef.push_back(b1);
            vRefineCoef.push_back(b2);
        }
    }
    std::cout <<"coef "<<vRefineCoef[0]<<" "<<vRefineCoef[1]<<" "<<vRefineCoef[2]
        <<" "<<vRefineCoef[3]<<" "<<vRefineCoef[4]<<" "<<vRefineCoef[5]<<" "<<std::endl;




    //Test si le modele est affine pour l'appellation du fichier de sortie
    bool refine=false;
    double noRefine[]={0,1,0,0,0,1};

    for(int i=0; i<6;i++)
    {
        if(vRefineCoef[i] != noRefine[i])
            refine=true;
    }

    if (refine)
    {
        //Effacement du fichier de coefficients (affinite=identite) par defaut
        if (ifstream(refineCoef.c_str())) ELISE_fp::RmFile(refineCoef.c_str());

        //New folder
        std::string dir = "refine_" + aNameImage;
        ELISE_fp::MkDirSvp(dir);

        std::cout<<"le modele est affine"<<std::endl;
        aNameFileGrid = dir + ELISE_CAR_DIR + aNameFileGrid;
    }

    dimap.clearing(aNameFileGrid, refine);
    dimap.createGrid(aNameFileGrid,aNameImage,
                     stepPixel,stepCarto,
                     rowCrop, sampCrop,
                     vAltitude,targetSyst,inputSyst,vRefineCoef);

    return EXIT_SUCCESS;
}
Esempio n. 3
0
void cEtapeMecComp::OneBasculeMnt
(
    Pt2di aP0Sauv,
    Pt2di aP1Sauv,
    cBasculeRes & aBR,
    float ** aDataF,
    INT2 ** aDataI,
    Pt2di   aSzData
)
{
    ELISE_ASSERT
    (
        mIsOptimCont,
        "Basculement requiert une optimisation continue "
    );

    cFileOriMnt anOri;
    if (aBR.Explicite().IsInit())
    {
        anOri = aBR.Explicite().Val();
        std::string aNameXML =    mAppli.FullDirResult()
                                  + StdPrefixGen(anOri.NameFileMnt())
                                  + std::string(".xml");
        MakeFileXML(anOri,aNameXML);
    }
    else if (aBR.ByFileNomChantier().IsInit())
    {
        std::string aNameFile =
            mAppli.WorkDir()
            +   aBR.Prefixe()
            +   (aBR.NomChantier().Val() ? mAppli.NameChantier() :"")
            +   aBR.Postfixe();


        anOri = StdGetObjFromFile<cFileOriMnt>
                (
                    aNameFile,
                    mAppli.NameSpecXML(),
                    aBR.NameTag().Val(),
                    "FileOriMnt"

                );
    }
    else
    {
        ELISE_ASSERT(false,"Internal Error cEtapeMecComp::OneBasculeMnt");
    }
    // cFileOriMnt * aPtrOri=0;
    // cFileOriMnt * aPtrOri=0;

    // cFileOriMnt & anOri = aBR.Ori();

    // std::cout << "XML MADE \n"; getchar();

    const cGeomBasculement3D * aGeomB = 0;

    if (anOri.Geometrie() == eGeomMNTEuclid)
    {
        if (
            (mAppli.GeomMNT()==eGeomMNTFaisceauIm1ZTerrain_Px1D)
            || (mAppli.GeomMNT()==eGeomMNTFaisceauIm1ZTerrain_Px2D)
        )
        {
            aGeomB = (mAppli.PDV1()->Geom().GeoTerrainIntrinseque());
        }
        /*
         CE CAS PARTICULIER VIENT DE CE QUE cGeomImage_Faisceau redifinit la methode
        Bascule. A ete utilise avec Denis Feurer & Co pour basculer en terrain
        les reultat image.
        */
        else if (
            (mAppli.GeomMNT()==eGeomMNTFaisceauIm1PrCh_Px1D)
            || (mAppli.GeomMNT()==eGeomMNTFaisceauIm1PrCh_Px2D)
        )
        {
            aGeomB = &(mAppli.PDV2()->Geom());
        }
        else
        {
            ELISE_ASSERT(false,"Geometrie source non traitee dans le basculement");
        }
    }
    else
    {
        ELISE_ASSERT(false,"Geometrie destination non traitee dans le basculement");
    }

    Pt2dr  aP0 = mGeomTer.DiscToR2(Pt2di(0,0));
    Pt2dr  aP1 = mGeomTer.DiscToR2(Pt2di(1,1));


    cBasculeMNT   aBasc
    (
        mGeomTer,
        aP0,
        aP1-aP0,
        anOri.OriginePlani(),
        anOri.ResolutionPlani(),
        aGeomB,
        mIsOptimCont,
        aDataF,
        aDataI,
        aSzData
    );

    Pt2di anOffset;
    double aDef = -1e10;
    double aSousDef = -9e9;

    std::cout << "BEGIN BASCULE \n";
//Im2D_REAL4   aMnt=  aBasc.Basculer(anOffset,aP0Sauv,aP1Sauv,aDef);
    Im2D_REAL4   aMnt=  aBasc.BasculerAndInterpoleInverse(anOffset,aP0Sauv,aP1Sauv,(float)aDef);


    ELISE_COPY
    (
        select(aMnt.all_pts(),aMnt.in() > aSousDef),
        (aMnt.in()-anOri.OrigineAlti())/anOri.ResolutionAlti(),
        aMnt.out()
    );

    std::cout  << anOffset << " " << aMnt.sz();
    std::cout << "END  BASCULE \n";

    bool isNewFile;
    Tiff_Im aFileRes = Tiff_Im::CreateIfNeeded
                       (
                           isNewFile,
                           anOri.NameFileMnt(),
                           anOri.NombrePixels(),
                           GenIm::real4,
                           Tiff_Im::No_Compr,
                           Tiff_Im::BlackIsZero
                       );
    Tiff_Im * aFileMasq =0;
    if ( anOri.NameFileMasque().IsInit())
    {
        aFileMasq = new Tiff_Im(Tiff_Im::CreateIfNeeded
                                (
                                    isNewFile,
                                    anOri.NameFileMasque().Val(),
                                    anOri.NombrePixels(),
                                    GenIm::bits1_msbf,
                                    Tiff_Im::No_Compr,
                                    Tiff_Im::BlackIsZero
                                )
                               );
    }

    if (isNewFile)
    {
        ELISE_COPY
        (
            aFileRes.all_pts(),
            aBR.OutValue().Val(),
            aFileRes.out()
        );
        if (aFileMasq)
        {
            ELISE_COPY
            (
                aFileMasq->all_pts(),
                0,
                aFileMasq->out()
            );
        }
    }

    Im2D_REAL4 anOld(aMnt.sz().x,aMnt.sz().y);

    ELISE_COPY
    (
        anOld.all_pts(),
        trans(aFileRes.in(aBR.OutValue().Val()),anOffset),
        anOld.out()
    );
    ELISE_COPY
    (
        select(anOld.all_pts(),aMnt.in()>aSousDef),
        aMnt.in(),
        anOld.out()
    );
    ELISE_COPY
    (
        rectangle(anOffset,anOffset+aMnt.sz()),
        trans(anOld.in(),-anOffset),
        aFileRes.out()
    );

    if (aFileMasq)
    {
        ELISE_COPY
        (
            rectangle(anOffset,anOffset+aMnt.sz()),
            aFileMasq->in(0) || trans(aMnt.in()>aSousDef,-anOffset),
            aFileMasq->out()
        );
    }

    delete aFileMasq;
}
Esempio n. 4
0
void  cAppliMergeCloud::CreateGrapheConx()
{
   mRecouvrTot  =  mVSoms.size();  // Recouvrement total
            // Couple d'homologues
   std::string aKSH = "NKS-Set-Homol@@"+ mParam.ExtHom().Val();
   std::string aKAH = "NKS-Assoc-CplIm2Hom@@"+ mParam.ExtHom().Val();

   std::vector<tMCArc *> aVAddCur;
   const cInterfChantierNameManipulateur::tSet * aSetHom = ICNM()->Get(aKSH);




   for (int aKH=0 ; aKH<int(aSetHom->size()) ; aKH++)
   {
       const std::string & aNameFile = (*aSetHom)[aKH];
       std::string aFullNF = Dir() + aNameFile;
       if (sizeofile(aFullNF.c_str()) > mParam.MinSzFilHom().Val())
       {
           std::pair<std::string,std::string> aPair = ICNM()->Assoc2To1(aKAH,aNameFile,false);
           tMCSom * aS1 = SomOfName(aPair.first);
           tMCSom * aS2 = SomOfName(aPair.second);
           // if ((aS1!=0) && (aS2!=0) && (sizeofile(aNameFile.c_str())>mParam.MinSzFilHom().Val()))
           // MPD : redondant + erreur car pas aFullNF 
           if ((aS1!=0) && (aS2!=0) )
           {
              tMCArc *  anArc = TestAddNewarc(aS1,aS2);
              if (anArc)
                 aVAddCur.push_back(anArc);
           }
       }
   }
            // Ajout recursif des voisin
   while (! aVAddCur.empty())
   {
       std::cout << "ADD " << aVAddCur.size() << "\n";
       std::vector<tMCArc *> aVAddNew;
       for (int aK=0 ; aK<int(aVAddCur.size()) ; aK++)
       {
           tMCArc & anArc = *(aVAddCur[aK]);
           AddVoisVois(aVAddNew,anArc.s1(),anArc.s2());
           AddVoisVois(aVAddNew,anArc.s2(),anArc.s1());
       }
       aVAddCur = aVAddNew;
   }

   // Calcul des voisins proches (contenu dans Apero ChImSec)
   for (int aK=0 ; aK<int(mVSoms.size()) ; aK++)
   {
       tMCSom * aS1 =  mVSoms[aK];

       const cOneSolImageSec *   aSol = aS1->attr()->SolOfCostPerIm(mParam.CostPerImISOM().Val());

       if (aSol)
       {
           for 
           (
               std::list<std::string>::const_iterator itS=aSol->Images().begin();
               itS !=aSol->Images().end();
               itS++
           )
           {
                tMCSom *  aS2 = SomOfName(*itS);
                if (aS2)
                {
                    tMCArc * anArc = mGr.arc_s1s2(*aS1,*aS2);
                    if (anArc)
                    {
                       // anArc->sym_flag_set_kth_true(mFlagCloseN);
                       anArc->flag_set_kth_true(mFlagCloseN);
                       aS1->attr()->AddCloseVois(aS2->attr());
                    }
                    // std::cout << "AAAaA  :" << anArc << "\n";
                }
           }
       }
   }

   // Na pas effacer, permet de voir le graphe des close image en cas de doute
   if (1)
   {
       for (int aK=0 ; aK<int(mVSoms.size()) ; aK++)
       {
           tMCSom * aS1 =  mVSoms[aK];
           std::cout << aS1->attr()->IMM()->mNameIm 
                     << " All: " << aS1->nb_succ(mSubGrAll) 
                     << " Closed: " << aS1->nb_succ(mSubGrCloseN) ;

            std::cout << " ";
            for (tArcIter itA = aS1->begin(mSubGrCloseN) ; itA.go_on() ; itA++)
            {
                const std::string & aN2 = (*itA).s2().attr()->IMM()->mNameIm;
                std::cout << ExtractDigit(StdPrefixGen(aN2),"0000") << " ";

            }
            std::cout << "\n";
       }
   }

   mRecMoy = mRecouvrTot /  mVSoms.size();
   mNbImMoy = mVSoms.size() / mRecMoy;  // En Fait NbIm^2 /mRecouvrTot
   std::cout  << "REC TOT " << mRecouvrTot << " RMoy " << mRecMoy << " NbIm " << mNbImMoy << "\n";
}