ossimGpt ossimThreeParamDatum::shiftToWgs84(const ossimGpt &aPt)const
{
   
   if(ossim::almostEqual(param1(),  0.0)&&
      ossim::almostEqual(param2(), 0.0)&&
      ossim::almostEqual(param3(), 0.0))
   {
      return ossimGpt(aPt.latd(),
                      aPt.lond(),
                      aPt.latd(),
                      ossimGpt().datum());
   }
      
   ossimEcefPoint p1 = aPt;
   ossimEcefPoint p2;
 
   
   if(withinMolodenskyRange(aPt.latd()))
   {
      ossimWgs84Datum wgs84;
      double latin, lonin, hgtin;
      double latout, lonout, hgtout;
      
      double da = wgs84.ellipsoid()->getA() - ellipsoid()->getA();
      double df = wgs84.ellipsoid()->getFlattening() - ellipsoid()->getFlattening();

      latin = aPt.latr();
      lonin = aPt.lonr();
      hgtin = aPt.height();

      if(aPt.isHgtNan())
      {
         hgtin = 0.0;
      }
      molodenskyShift(ellipsoid()->getA(), da, ellipsoid()->getFlattening(), df, param1(), param2(), param3(),
                      latin, lonin, hgtin,
                      latout, lonout, hgtout);
      ossimGpt g;

      g.latr(latout);
      g.lonr(lonout);
      g.height(hgtout);
      g.datum(this);
      return g;
   }
   else
     {
       p2 = ossimEcefPoint(p1.x() + theParam1,
			   p1.y() + theParam2,
			   p1.z() + theParam3);
     }
   
   return ossimGpt(p2); // defaults to WGS84
}
Esempio n. 2
0
//*****************************************************************************
//  METHOD: ossimRpcModel::worldToLineSample()
//
//  Overrides base class implementation. Directly computes line-sample from
//  the polynomials.
//*****************************************************************************
void ossimRpcModel::worldToLineSample(const ossimGpt& ground_point,
                                      ossimDpt&       img_pt) const
{
    // if (traceExec())  ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimRpcModel::worldToLineSample(): entering..." << std::endl;

    if(ground_point.isLatNan() || ground_point.isLonNan() )
    {
        img_pt.makeNan();
        return;
    }

    //***
    // First check if the world point is inside bounding rectangle:
    //***
    //ossimDpt wdp (ground_point);
    //if (!(theBoundGndPolygon.pointWithin(ground_point)))
    // {
    //img_pt = extrapolate(ground_point);
    //if (traceExec())  CLOG << "returning..." << endl;
    //   img_pt.makeNan();
    //    return;
    // }

    //***
    // Normalize the lat, lon, hgt:
    //***
    double nlat = (ground_point.lat - theLatOffset) / theLatScale;
    double nlon = (ground_point.lon - theLonOffset) / theLonScale;
    double nhgt;

    if( ground_point.isHgtNan() )
    {
        // nhgt = (theHgtScale - theHgtOffset) / theHgtScale;
        nhgt = ( - theHgtOffset) / theHgtScale;
    }
    else
    {
        nhgt = (ground_point.hgt - theHgtOffset) / theHgtScale;
    }

    //***
    // Compute the adjusted, normalized line (U) and sample (V):
    //***
    double Pu = polynomial(nlat, nlon, nhgt, theLineNumCoef);
    double Qu = polynomial(nlat, nlon, nhgt, theLineDenCoef);
    double Pv = polynomial(nlat, nlon, nhgt, theSampNumCoef);
    double Qv = polynomial(nlat, nlon, nhgt, theSampDenCoef);
    double U_rot  = Pu / Qu;
    double V_rot  = Pv / Qv;

    //***
    // U, V are normalized quantities. Need now to establish the image file
    // line and sample. First, back out the adjustable parameter effects
    // starting with rotation:
    //***
    double U = U_rot*theCosMapRot + V_rot*theSinMapRot;
    double V = V_rot*theCosMapRot - U_rot*theSinMapRot;

    //***
    // Now back out skew, scale, and offset adjustments:
    //***
    img_pt.line = U*(theLineScale+theIntrackScale) + theLineOffset + theIntrackOffset;

    img_pt.samp = V*(theSampScale+theCrtrackScale) + theSampOffset + theCrtrackOffset;

    // if (traceExec())  ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimRpcModel::worldToLineSample(): returning..." << std::endl;
    return;
}