Fonc_Num  AdaptFonc2FileOriMnt
          (
                 const std::string & aContext,
                 const cFileOriMnt & anOriCible,
                 const cFileOriMnt &  aOriInit,
                 Fonc_Num            aFonc,
                 bool                aModifDyn,
                 double              aZOffset,
                 const Pt2dr &       CropInOriCible

          ) 
{
    if (! SameGeometrie(aOriInit,anOriCible))
    {
       cElWarning::GeomIncompAdaptF2Or.AddWarn
       (
            aContext,
             __LINE__,
             __FILE__
       );
       // std::cout  << "Geometrie incompatible Cible/Xml, AdaptFoncFileOriMnt\n" ;
    }


    Pt2dr aSxyC = anOriCible.ResolutionPlani();
    Pt2dr aSxyI = aOriInit.ResolutionPlani();

    double aSx = aSxyC.x / aSxyI.x;
    double aSy = aSxyC.y / aSxyI.y;

    if ((aSx<=0) || (aSy <=0))
    {
        std::cout << "Context = " << aContext << "\n";
        ELISE_ASSERT
        (
            false,
            "Signe incompatibles dans AdaptFoncFileOriMnt"
        );
    }

    Pt2dr aTr = anOriCible.OriginePlani() -  aOriInit.OriginePlani();

// std::cout << aTr << CropInOriCible << aSxyI << " " << aSx << "\n";
    aTr =  Pt2dr(aTr.x/aSxyI.x,aTr.y/aSxyI.y);
    aTr =  aTr +CropInOriCible.mcbyc(Pt2dr(aSx,aSy));

    aFonc =  StdFoncChScale_Bilin
             (
                  aFonc,
                  aTr,
                  // Pt2dr(aTr.x/aSxyI.x,aTr.y/aSxyI.y) + CropInOriCible,
                  Pt2dr(aSx,aSy)
             );

    if (aModifDyn)
    {
       double aZ0I = aOriInit.OrigineAlti();
       double aZ0C = anOriCible.OrigineAlti();
       double aStZC = anOriCible.ResolutionAlti();
       double aStZI = aOriInit.ResolutionAlti();
       aFonc = (aZOffset+ aZ0I-aZ0C)/aStZC + (aStZI/aStZC)*aFonc;
    }

    return aFonc;
}
示例#2
0
void dump(const cFileOriMnt &aFileOriMnt, const string &aPrefix = string(), ostream &aStream = cout)
{
	aStream << aPrefix << "NameFileMnt     = [" << aFileOriMnt.NameFileMnt() << ']' << endl;
	if (aFileOriMnt.NameFileMasque().IsInit()) aStream << aPrefix << "NameFileMasque  = [" << aFileOriMnt.NameFileMasque().Val() << ']' << endl;
	aStream << aPrefix << "NombrePixels    = " << aFileOriMnt.NombrePixels() << endl;
	aStream << aPrefix << "OriginePlani    = " << aFileOriMnt.OriginePlani() << endl;
	aStream << aPrefix << "ResolutionPlani = " << aFileOriMnt.ResolutionPlani() << endl;
	aStream << aPrefix << "OrigineAlti     = " << aFileOriMnt.OrigineAlti() << endl;
	aStream << aPrefix << "ResolutionAlti  = " << aFileOriMnt.ResolutionAlti() << endl;
	if (aFileOriMnt.NumZoneLambert().IsInit()) aStream << aPrefix << "NumZoneLambert  = " << aFileOriMnt.NumZoneLambert().Val() << endl;
	aStream << aPrefix << "Geometrie       = " << eToString(aFileOriMnt.Geometrie()) << endl;
	if (aFileOriMnt.OrigineTgtLoc().IsInit()) aStream << aPrefix << "OrigineTgtLoc  = " << aFileOriMnt.OrigineTgtLoc().Val() << endl;
	if (aFileOriMnt.Rounding().IsInit()) aStream << aPrefix << "Rounding  = " << aFileOriMnt.Rounding().Val() << endl;
}
bool SameGeometrie(const cFileOriMnt & aF1,const cFileOriMnt & aF2)
{
   if (aF1.Geometrie() != aF2.Geometrie())
      return false;

   if (aF1.Geometrie() == eGeomMNTCarto )
   {
      if (aF1.NumZoneLambert().Val() != aF2.NumZoneLambert().Val())
         return false;
   }

   if (aF1.Geometrie() == eGeomMNTEuclid )
   {
      if (aF1.OrigineTgtLoc().IsInit() != aF2.OrigineTgtLoc().IsInit())
         return false;

      if (aF1.OrigineTgtLoc().IsInit() )
      {
         if (aF1.OrigineTgtLoc().Val() != aF2.OrigineTgtLoc().Val())
            return false;
      }
   }

   return true;
}