Esempio n. 1
0
ossimDpt ossimRpcProjection::getMetersPerPixel() const
{
   ossimDpt result;
   
//    ossimDpt left  = ossimDpt(theSampOffset-1,
//                              theLineOffset);
//    ossimDpt right = ossimDpt(theSampOffset+1,
//                              theLineOffset);
   ossimDpt top  = ossimDpt(theSampOffset,
                            theLineOffset-1);
   ossimDpt bottom = ossimDpt(theSampOffset,
                              theLineOffset+1);
//    ossimGpt leftG;
//    ossimGpt rightG;
   ossimGpt topG;
   ossimGpt bottomG;
   
//    lineSampleToWorld(left, leftG);
//    lineSampleToWorld(right, rightG);
   lineSampleToWorld(top, topG);
   lineSampleToWorld(bottom, bottomG);
   
//    result.x = (ossimEcefPoint(leftG) - ossimEcefPoint(rightG)).magnitude()/2.0;
   result.y = (ossimEcefPoint(topG) - ossimEcefPoint(bottomG)).magnitude()/2.0;
   result.x = result.y;

   return result;
}
Esempio n. 2
0
rspfGpt rspfLlxyProjection::inverse(const rspfDpt &projectedPoint) const
{
   rspfGpt result;
   
   lineSampleToWorld(projectedPoint, result);
   
   return result;
}
Esempio n. 3
0
void ossimAlphaSensorHSI::updateModel()
{
   if (traceDebug())
   {
      ossimNotify(ossimNotifyLevel_DEBUG)
         << "ossimAlphaSensorHSI::updateModel DEBUG:" << std::endl;
   }
   ossimAlphaSensor::updateModel();  
     
   try
   {
      computeGsd();
   }
   catch(...)
   {
      
   }
   if (traceDebug())
   {
      ossimNotify(ossimNotifyLevel_DEBUG)
         << "ossimAlphaSensorHSI::updateModel complete..." << std::endl;
   }

   // Ref point
   lineSampleToWorld(theRefImgPt, theRefGndPt);


   // Bounding rectangle
   ossimGpt gpt;
   theBoundGndPolygon.clear();
   
   lineSampleToWorld(theImageClipRect.ul(),gpt); //+ossimDpt(-w, -h), gpt);
   theBoundGndPolygon.addPoint(gpt.lond(), gpt.latd());

   lineSampleToWorld(theImageClipRect.ur(),gpt); //+ossimDpt(w, -h), gpt);
   theBoundGndPolygon.addPoint(gpt.lond(), gpt.latd());

   lineSampleToWorld(theImageClipRect.lr(),gpt); //+ossimDpt(w, h), gpt);
   theBoundGndPolygon.addPoint(gpt.lond(), gpt.latd());

   lineSampleToWorld(theImageClipRect.ll(),gpt); //+ossimDpt(-w, h), gpt);
   theBoundGndPolygon.addPoint(gpt.lond(), gpt.latd());
}
void ossimSpectraboticsRedEdgeModel::updateModel()
{
   ossimGpt gpt;
   ossimGpt wgs84Pt;
   double metersPerDegree = wgs84Pt.metersPerDegree().x;
   double degreePerMeter = 1.0/metersPerDegree;
   double latShift = computeParameterOffset(1)*theMeanGSD*degreePerMeter;
   double lonShift = computeParameterOffset(0)*theMeanGSD*degreePerMeter;

   gpt = m_ecefPlatformPosition;
   double height = gpt.height();
   gpt.height(height + computeParameterOffset(5));
   gpt.latd(gpt.latd() + latShift);
   gpt.lond(gpt.lond() + lonShift);
   m_adjEcefPlatformPosition = gpt;
   ossimLsrSpace lsrSpace(m_adjEcefPlatformPosition);

   NEWMAT::Matrix heading = ossimMatrix4x4::createRotationZMatrix(m_heading+computeParameterOffset(4), OSSIM_RIGHT_HANDED);
   NEWMAT::Matrix roll = ossimMatrix4x4::createRotationYMatrix(m_roll+computeParameterOffset(2), OSSIM_RIGHT_HANDED);
   NEWMAT::Matrix pitch = ossimMatrix4x4::createRotationXMatrix(m_pitch+computeParameterOffset(3), OSSIM_LEFT_HANDED);
   ossimMatrix4x4 lsrMatrix(lsrSpace.lsrToEcefRotMatrix());
   NEWMAT::Matrix orientation = heading*pitch*roll;//roll*pitch*heading;
   m_compositeMatrix        = (lsrMatrix.getData()*orientation);
   m_compositeMatrixInverse = m_compositeMatrix.i();

   theBoundGndPolygon.resize(4);
   // ossim_float64 w = theImageClipRect.width()*2.0;
   // ossim_float64 h = theImageClipRect.height()*2.0;
   theExtrapolateImageFlag = false;
   theExtrapolateGroundFlag = false;


   lineSampleToWorld(theImageClipRect.ul(),gpt);//+ossimDpt(-w, -h), gpt);
   theBoundGndPolygon[0] = gpt;
   lineSampleToWorld(theImageClipRect.ur(),gpt);//+ossimDpt(w, -h), gpt);
   theBoundGndPolygon[1] = gpt;
   lineSampleToWorld(theImageClipRect.lr(),gpt);//+ossimDpt(w, h), gpt);
   theBoundGndPolygon[2] = gpt;
   lineSampleToWorld(theImageClipRect.ll(),gpt);//+ossimDpt(-w, h), gpt);
   theBoundGndPolygon[3] = gpt;
}
Esempio n. 5
0
void ossimBuckeyeSensor::updateModel()
{
	if (traceDebug())  ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimBuckeyeSensor::updateModel: entering..." << std::endl;
	ossimGpt gpt;
	ossimGpt wgs84Pt;
	double metersPerDegree = wgs84Pt.metersPerDegree().x;
	double degreePerMeter = 1.0/metersPerDegree;
	double latShift = -computeParameterOffset(1)*degreePerMeter;
	double lonShift = computeParameterOffset(0)*degreePerMeter;

	gpt = theEcefPlatformPosition;
	double height = gpt.height();
	gpt.height(height + computeParameterOffset(5));
	gpt.latd(gpt.latd() + latShift);
	gpt.lond(gpt.lond() + lonShift);
	theAdjEcefPlatformPosition = gpt;
	ossimLsrSpace lsrSpace(theAdjEcefPlatformPosition, theHeading+computeParameterOffset(4));

	// make a left handed roational matrix;
	ossimMatrix4x4 lsrMatrix(lsrSpace.lsrToEcefRotMatrix());
	NEWMAT::Matrix orientation = (ossimMatrix4x4::createRotationXMatrix(thePitch+computeParameterOffset(3), OSSIM_LEFT_HANDED)*
		ossimMatrix4x4::createRotationYMatrix(theRoll+computeParameterOffset(2), OSSIM_LEFT_HANDED));
	theCompositeMatrix        = (lsrMatrix.getData()*orientation);
	theCompositeMatrixInverse = theCompositeMatrix.i();

	theBoundGndPolygon.resize(4);
	// ossim_float64 w = theImageClipRect.width()*2.0;
	// ossim_float64 h = theImageClipRect.height()*2.0;
	theExtrapolateImageFlag = false;
	theExtrapolateGroundFlag = false;

	lineSampleToWorld(theImageClipRect.ul(),gpt);//+ossimDpt(-w, -h), gpt);
	theBoundGndPolygon[0] = gpt;
	lineSampleToWorld(theImageClipRect.ur(),gpt);//+ossimDpt(w, -h), gpt);
	theBoundGndPolygon[1] = gpt;
	lineSampleToWorld(theImageClipRect.lr(),gpt);//+ossimDpt(w, h), gpt);
	theBoundGndPolygon[2] = gpt;
	lineSampleToWorld(theImageClipRect.ll(),gpt);//+ossimDpt(-w, h), gpt);
	theBoundGndPolygon[3] = gpt;
	if (traceDebug())  ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimBuckeyeSensor::updateModel: returning..." << std::endl;
}
Esempio n. 6
0
void rspfBuckeyeSensor::updateModel()
{
   rspfGpt gpt;
   rspfGpt wgs84Pt;
   double metersPerDegree = wgs84Pt.metersPerDegree().y;
   double degreePerMeter = 1.0/metersPerDegree;
   double latShift = computeParameterOffset(1)*degreePerMeter;
   double lonShift = computeParameterOffset(0)*degreePerMeter;
   
   gpt = m_platformPosition;
   double height = gpt.height();
   gpt.height(height + computeParameterOffset(5));
   gpt.latd(gpt.latd() + latShift);
   gpt.lond(gpt.lond() + lonShift);
   
   m_ecefPlatformPosition = gpt;
   rspfLsrSpace lsrSpace(m_ecefPlatformPosition, m_yaw+computeParameterOffset(4));
   
   NEWMAT::Matrix platformLsrMatrix = lsrSpace.lsrToEcefRotMatrix();
   NEWMAT::Matrix orientationMatrix = (                                      
                                       rspfMatrix3x3::createRotationXMatrix(m_pitch+computeParameterOffset(3), RSPF_LEFT_HANDED)
                                       *rspfMatrix3x3::createRotationYMatrix(m_roll+computeParameterOffset(2), RSPF_LEFT_HANDED)
                                      );
   
   m_compositeMatrix         = platformLsrMatrix*orientationMatrix;
   m_compositeMatrixInverse  = m_compositeMatrix.i();
   
   
   theBoundGndPolygon.resize(4);
   rspf_float64 w = theImageClipRect.width()*2.0;
   rspf_float64 h = theImageClipRect.height()*2.0;
   lineSampleToWorld(theImageClipRect.ul()+rspfDpt(-w, -h), gpt);
   theBoundGndPolygon[0] = gpt;
   lineSampleToWorld(theImageClipRect.ur()+rspfDpt(w, -h), gpt);
   theBoundGndPolygon[1] = gpt;
   lineSampleToWorld(theImageClipRect.lr()+rspfDpt(w, h), gpt);
   theBoundGndPolygon[2] = gpt;
   lineSampleToWorld(theImageClipRect.ll()+rspfDpt(-w, h), gpt);
   theBoundGndPolygon[3] = gpt;
   lineSampleToWorld(theRefImgPt, theRefGndPt);
}
void rspfApplanixEcefModel::updateModel()
{
   rspfGpt gpt;
   rspfGpt wgs84Pt;
   double metersPerDegree = wgs84Pt.metersPerDegree().x;
   double degreePerMeter = 1.0/metersPerDegree;
   double latShift = -computeParameterOffset(1)*theMeanGSD*degreePerMeter;
   double lonShift = computeParameterOffset(0)*theMeanGSD*degreePerMeter;

   gpt = theEcefPlatformPosition;
   double height = gpt.height();
   gpt.height(height + computeParameterOffset(5));
   gpt.latd(gpt.latd() + latShift);
   gpt.lond(gpt.lond() + lonShift);
   theAdjEcefPlatformPosition = gpt;
   rspfLsrSpace lsrSpace(theAdjEcefPlatformPosition, theHeading+computeParameterOffset(4));

   // make a left handed roational matrix;
   rspfMatrix4x4 lsrMatrix(lsrSpace.lsrToEcefRotMatrix());
   NEWMAT::Matrix orientation = (rspfMatrix4x4::createRotationXMatrix(thePitch+computeParameterOffset(3), RSPF_LEFT_HANDED)*
                                 rspfMatrix4x4::createRotationYMatrix(theRoll+computeParameterOffset(2), RSPF_LEFT_HANDED));
   theCompositeMatrix        = (lsrMatrix.getData()*orientation);
   theCompositeMatrixInverse = theCompositeMatrix.i();

   theBoundGndPolygon.resize(4);
   // rspf_float64 w = theImageClipRect.width()*2.0;
   // rspf_float64 h = theImageClipRect.height()*2.0;
   theExtrapolateImageFlag = false;
   theExtrapolateGroundFlag = false;

   lineSampleToWorld(theImageClipRect.ul(),gpt);//+rspfDpt(-w, -h), gpt);
   theBoundGndPolygon[0] = gpt;
   lineSampleToWorld(theImageClipRect.ur(),gpt);//+rspfDpt(w, -h), gpt);
   theBoundGndPolygon[1] = gpt;
   lineSampleToWorld(theImageClipRect.lr(),gpt);//+rspfDpt(w, h), gpt);
   theBoundGndPolygon[2] = gpt;
   lineSampleToWorld(theImageClipRect.ll(),gpt);//+rspfDpt(-w, h), gpt);
   theBoundGndPolygon[3] = gpt;
}
Esempio n. 8
0
bool ossimApplanixUtmModel::loadState(const ossimKeywordlist& kwl,
                                   const char* prefix)
{
   if(traceDebug())
   {
      std::cout << "ossimApplanixUtmModel::loadState: ......... entered" << std::endl;
   }
   theImageClipRect = ossimDrect(0,0,4076,4091);
   theRefImgPt      = ossimDpt(2046.0, 2038.5);
   
   ossimSensorModel::loadState(kwl, prefix);

   if(getNumberOfAdjustableParameters() < 1)
   {
      initAdjustableParameters();
   }

   const char* eo_file           = kwl.find(prefix, "eo_file");
   const char* eo_id             = kwl.find(prefix, "eo_id");
   const char* omega             = kwl.find(prefix, "omega");
   const char* phi               = kwl.find(prefix, "phi");
   const char* kappa             = kwl.find(prefix, "kappa");
   const char* bore_sight_tx     = kwl.find(prefix, "bore_sight_tx");
   const char* bore_sight_ty     = kwl.find(prefix, "bore_sight_ty");
   const char* bore_sight_tz     = kwl.find(prefix, "bore_sight_tz");
   
   const char* principal_point   = kwl.find(prefix, "principal_point");
   const char* pixel_size        = kwl.find(prefix, "pixel_size");
   const char* focal_length      = kwl.find(prefix, "focal_length");
   const char* latlonh_platform_position = kwl.find(prefix, "latlonh_platform_position");
   const char* utm_platform_position = kwl.find(prefix, "utm_platform_position");
   const char* compute_gsd_flag  = kwl.find(prefix, "compute_gsd_flag");
   const char* utm_zone          = kwl.find(prefix, "utm_zone");
   const char* utm_hemisphere    = kwl.find(prefix, "utm_hemisphere");
   const char* camera_file       = kwl.find(prefix, "camera_file");
   const char* shift_values      = kwl.find(prefix, "shift_values");
   
   theCompositeMatrix          = ossimMatrix3x3::createIdentity();
   theCompositeMatrixInverse   = ossimMatrix3x3::createIdentity();
   theOmega                    = 0.0;
   thePhi                      = 0.0;
   theKappa                    = 0.0;
   theBoreSightTx              = 0.0;
   theBoreSightTy              = 0.0;
   theBoreSightTz              = 0.0;
   theFocalLength              = 55.0;
   thePixelSize = ossimDpt(.009, .009);
   theEcefPlatformPosition = ossimGpt(0.0,0.0, 1000.0);

   bool loadedFromEoFile = false;

   if(eo_id)
   {
      theImageID = eo_id;
   }
   // loading from standard eo file with given record id
   //
   if(eo_file)
   {
      ossimApplanixEOFile eoFile;
      
      if(eoFile.parseFile(ossimFilename(eo_file)))
      {
         ossimRefPtr<ossimApplanixEORecord> record = eoFile.getRecordGivenId(theImageID);

         if(record.valid())
         {
            loadedFromEoFile = true;
            theBoreSightTx = eoFile.getBoreSightTx()/60.0;
            theBoreSightTy = eoFile.getBoreSightTy()/60.0;
            theBoreSightTz = eoFile.getBoreSightTz()/60.0;
            theShiftValues = ossimEcefVector(eoFile.getShiftValuesX(),
                                             eoFile.getShiftValuesY(),
                                             eoFile.getShiftValuesZ());
            ossim_int32 easting  = eoFile.getFieldIdxLike("EASTING");
            ossim_int32 northing = eoFile.getFieldIdxLike("NORTHING");
            ossim_int32 height   = eoFile.getFieldIdxLike("HEIGHT");
            ossim_int32 omega    = eoFile.getFieldIdxLike("OMEGA");
            ossim_int32 phi      = eoFile.getFieldIdxLike("PHI");
            ossim_int32 kappa    = eoFile.getFieldIdxLike("KAPPA");

            if((omega>=0)&&
               (phi>=0)&&
               (kappa>=0)&&
               (height>=0)&&
               (easting>=0)&&
               (northing>=0))
            {
               theOmega = (*record)[omega].toDouble();
               thePhi   = (*record)[phi].toDouble();
               theKappa = (*record)[kappa].toDouble();
               double h = (*record)[height].toDouble();
               ossimString heightType = kwl.find(prefix, "height_type");
               if(eoFile.isUtmFrame())
               {
                  theUtmZone = eoFile.getUtmZone();
                  theUtmHemisphere = eoFile.getUtmHemisphere()=="North"?'N':'S';
                  ossimUtmProjection utmProj;
                  utmProj.setZone(theUtmZone);
                  utmProj.setHemisphere((char)theUtmHemisphere);
                  theUtmPlatformPosition.x = (*record)[easting].toDouble();
                  theUtmPlatformPosition.y = (*record)[northing].toDouble();
                  theUtmPlatformPosition.z = h;
                  thePlatformPosition = utmProj.inverse(ossimDpt(theUtmPlatformPosition.x,
                                                                 theUtmPlatformPosition.y));
                  thePlatformPosition.height(h);

                  if(eoFile.isHeightAboveMSL())
                  {
                     double offset = ossimGeoidManager::instance()->offsetFromEllipsoid(thePlatformPosition);
                     if(!ossim::isnan(offset))
                     {
                        thePlatformPosition.height(h + offset);
                        theUtmPlatformPosition.z = h + offset;
                     }
                  }
               }
               else
               {
                  return false;
               }
            }
            theEcefPlatformPosition = thePlatformPosition;
         }
         else
         {
            return false;
         }
      }
   }
   if(!loadedFromEoFile)
   {
      if(shift_values)
      {
         std::vector<ossimString> splitString;
         ossimString tempString(shift_values);
         tempString = tempString.trim();
         tempString.split(splitString, " " );
         if(splitString.size() == 3)
         {
            theShiftValues = ossimEcefVector(splitString[0].toDouble(),
                                             splitString[1].toDouble(),
                                             splitString[2].toDouble());
         }
      }
      if(omega&&phi&&kappa)
      {
         theOmega = ossimString(omega).toDouble();
         thePhi   = ossimString(phi).toDouble();
         theKappa = ossimString(kappa).toDouble();
      }
      if(bore_sight_tx&&bore_sight_ty&&bore_sight_tz)
      {
         theBoreSightTx = ossimString(bore_sight_tx).toDouble()/60.0;
         theBoreSightTy = ossimString(bore_sight_ty).toDouble()/60.0;
         theBoreSightTz = ossimString(bore_sight_tz).toDouble()/60.0;
      }
      double lat=0.0, lon=0.0, h=0.0;
      if(utm_zone)
      {
         theUtmZone = ossimString(utm_zone).toInt32();
      }
      if(utm_hemisphere)
      {
         ossimString hem = utm_hemisphere;
         hem = hem.trim();
         hem = hem.upcase();
         theUtmHemisphere = *(hem.begin());
      }
      if(utm_platform_position)
      {
         ossimUtmProjection utmProj;
         std::vector<ossimString> splitString;
         ossimString tempString(utm_platform_position);
         tempString = tempString.trim();
         ossimString datumString;
         utmProj.setZone(theUtmZone);
         utmProj.setHemisphere((char)theUtmHemisphere);
         tempString.split(splitString, " ");
         if(splitString.size() > 2)
         {
            theUtmPlatformPosition.x = splitString[0].toDouble();
            theUtmPlatformPosition.y = splitString[1].toDouble();
            theUtmPlatformPosition.z = splitString[2].toDouble();
         }
         if(splitString.size() > 3)
         {
            datumString = splitString[3];
         }
         const ossimDatum* datum = ossimDatumFactory::instance()->create(datumString);
         if(datum)
         {
            utmProj.setDatum(datum);
         }
         
         thePlatformPosition = utmProj.inverse(ossimDpt(theUtmPlatformPosition.x,
                                                        theUtmPlatformPosition.y));
         thePlatformPosition.height(theUtmPlatformPosition.z);
         
         ossimString heightType = kwl.find(prefix, "height_type");
         if(heightType == "msl")
         {
            double offset = ossimGeoidManager::instance()->offsetFromEllipsoid(thePlatformPosition);
            if(ossim::isnan(offset) == false)
            {
               thePlatformPosition.height(thePlatformPosition.height() + offset);
               theUtmPlatformPosition.z = thePlatformPosition.height();
            }
         }
         theEcefPlatformPosition = thePlatformPosition;
      }
      else if(latlonh_platform_position)
      {
         std::vector<ossimString> splitString;
         ossimString tempString(latlonh_platform_position);
         std::string datumString;
         tempString = tempString.trim();
         tempString.split(splitString, " ");
         if(splitString.size() > 2)
         {
            lat = splitString[0].toDouble();
            lon = splitString[1].toDouble();
            h = splitString[2].toDouble();
         }
         if(splitString.size() > 3)
         {
            datumString = splitString[3];
         }
         thePlatformPosition.latd(lat);
         thePlatformPosition.lond(lon);
         thePlatformPosition.height(h);
         const ossimDatum* datum = ossimDatumFactory::instance()->create(datumString);
         if(datum)
         {
            thePlatformPosition.datum(datum);
         }
         ossimString heightType = kwl.find(prefix, "height_type");
         if(heightType == "msl")
         {
            double offset = ossimGeoidManager::instance()->offsetFromEllipsoid(thePlatformPosition);
            if(ossim::isnan(offset) == false)
            {
               thePlatformPosition.height(thePlatformPosition.height() + offset);
            }
         }
         theEcefPlatformPosition = thePlatformPosition;
      }
   }
   if(principal_point)
   {
      std::vector<ossimString> splitString;
      ossimString tempString(principal_point);
      tempString = tempString.trim();
      tempString.split(splitString, " ");
      if(splitString.size() == 2)
      {
         thePrincipalPoint.x = splitString[0].toDouble();
         thePrincipalPoint.y = splitString[1].toDouble();
      }
   }
   if(pixel_size)
   {
      std::vector<ossimString> splitString;
      ossimString tempString(principal_point);
      tempString = tempString.trim();
      tempString.split(splitString, " ");
      if(splitString.size() == 2)
      {
         thePixelSize.x = splitString[0].toDouble();
         thePixelSize.y = splitString[1].toDouble();
      }
   }
   if(focal_length)
   {
      theFocalLength = ossimString(focal_length).toDouble();
   }

   if(camera_file)
   {
      ossimKeywordlist cameraKwl;
      ossimKeywordlist lensKwl;
      cameraKwl.add(camera_file);
      const char* sensor = cameraKwl.find("sensor");
      const char* image_size      = cameraKwl.find(prefix, "image_size");
      principal_point = cameraKwl.find("principal_point");
      focal_length    = cameraKwl.find("focal_length");
      pixel_size      = cameraKwl.find(prefix, "pixel_size");
      focal_length    = cameraKwl.find(prefix, "focal_length");
      const char* distortion_units = cameraKwl.find(prefix, "distortion_units");
      ossimUnitConversionTool tool;
      ossimUnitType unitType = OSSIM_MILLIMETERS;

      if(distortion_units)
      {
         unitType = (ossimUnitType)ossimUnitTypeLut::instance()->getEntryNumber(distortion_units);

         if(unitType == OSSIM_UNIT_UNKNOWN)
         {
            unitType = OSSIM_MILLIMETERS;
         }
      }
      if(image_size)
      {
         std::vector<ossimString> splitString;
         ossimString tempString(image_size);
         tempString = tempString.trim();
         tempString.split(splitString, " ");
         double w=1, h=1;
         if(splitString.size() == 2)
         {
            w = splitString[0].toDouble();
            h = splitString[1].toDouble();
         }
         theImageClipRect = ossimDrect(0,0,w-1,h-1);
         theRefImgPt      = ossimDpt(w/2.0, h/2.0);
      }
      if(sensor)
      {
         theSensorID = sensor;
      }
      if(principal_point)
      {
         std::vector<ossimString> splitString;
         ossimString tempString(principal_point);
         tempString = tempString.trim();
         tempString.split(splitString, " ");
         if(splitString.size() == 2)
         {
            thePrincipalPoint.x = splitString[0].toDouble();
            thePrincipalPoint.y = splitString[1].toDouble();
         }
      }
      if(pixel_size)
      {
         std::vector<ossimString> splitString;
         ossimString tempString(pixel_size);
         tempString = tempString.trim();
         tempString.split(splitString, " ");
         if(splitString.size() == 1)
         {
            thePixelSize.x = splitString[0].toDouble();
            thePixelSize.y = thePixelSize.x;
         }
         else if(splitString.size() == 2)
         {
            thePixelSize.x = splitString[0].toDouble();
            thePixelSize.y = splitString[1].toDouble();
         }
      }
      if(focal_length)
      {
         theFocalLength = ossimString(focal_length).toDouble();
      }

      ossim_uint32 idx = 0;
      for(idx = 0; idx < 26; ++idx)
      {
         const char* value = cameraKwl.find(ossimString("d")+ossimString::toString(idx));

         if(value)
         {
            std::vector<ossimString> splitString;
            ossimString tempString(value);
            double distance=0.0, distortion=0.0;
            tempString = tempString.trim();
            tempString.split(splitString, " ");
            if(splitString.size() == 2)
            {
               distance = splitString[0].toDouble();
               distortion = splitString[1].toDouble();
            }
            
            tool.setValue(distortion, unitType);
            lensKwl.add(ossimString("distance") + ossimString::toString(idx),
                        distance,
                        true);
            lensKwl.add(ossimString("distortion") + ossimString::toString(idx),
                        tool.getMillimeters(),
                        true);
         }
         lensKwl.add("convergence_threshold",
                     .00001,
                     true);
         if(pixel_size)
         {
            lensKwl.add("dxdy",
                        ossimString(pixel_size) + " " + ossimString(pixel_size),
                        true);
         }
         else
         {
            lensKwl.add("dxdy",
                        ".009 .009",
                        true);
         }
      }
      if(theLensDistortion.valid())
      {
         theLensDistortion->loadState(lensKwl,"");
      }
   }
   else
   {
      
      if(principal_point)
      {
         std::vector<ossimString> splitString;
         ossimString tempString(principal_point);
         tempString = tempString.trim();
         tempString.split(splitString, " ");
         if(splitString.size() == 2)
         {
            thePrincipalPoint.x = splitString[0].toDouble();
            thePrincipalPoint.y = splitString[1].toDouble();
         }
      }
      else
      {
         if(traceDebug())
         {
            ossimNotify(ossimNotifyLevel_DEBUG) << "No principal_point found" << std::endl;
            return false;
         }
      }
      if(pixel_size)
      {
         std::vector<ossimString> splitString;
         ossimString tempString(pixel_size);
         tempString = tempString.trim();
         tempString.split(splitString, " ");
         if(splitString.size() == 1)
         {
            thePixelSize.x = splitString[0].toDouble();
            thePixelSize.y = thePixelSize.x;
         }
         else if(splitString.size() == 2)
         {
            thePixelSize.x = splitString[0].toDouble();
            thePixelSize.y = splitString[1].toDouble();
         }
      }
      else
      {
         if(traceDebug())
         {
            ossimNotify(ossimNotifyLevel_DEBUG) << "No pixel size found" << std::endl;
            return false;
         }
      }
      if(focal_length)
      {
         theFocalLength = ossimString(focal_length).toDouble();
      }
      else
      {
         if(traceDebug())
         {
            ossimNotify(ossimNotifyLevel_DEBUG) << "No focal length found" << std::endl;
            return false;
         }
      }
      
      if(theLensDistortion.valid())
      {
         ossimString lensPrefix = ossimString(prefix)+"distortion.";
         theLensDistortion->loadState(kwl,
                                      lensPrefix.c_str());
      }
   }
   theRefGndPt = thePlatformPosition;
   
   updateModel();

   lineSampleToWorld(theRefImgPt, theRefGndPt);
   if(compute_gsd_flag)
   {
      if(ossimString(compute_gsd_flag).toBool())
      {
         ossimGpt right;
         ossimGpt top;
         lineSampleToWorld(theRefImgPt + ossimDpt(1.0, 0.0),
                           right);
         lineSampleToWorld(theRefImgPt + ossimDpt(1.0, 0.0),
                           top);

         ossimEcefVector horizontal = ossimEcefPoint(theRefGndPt)-ossimEcefPoint(right);
         ossimEcefVector vertical   = ossimEcefPoint(theRefGndPt)-ossimEcefPoint(top);

         theGSD.x = horizontal.length();
         theGSD.y = vertical.length();
         theMeanGSD = (theGSD.x+theGSD.y)*.5;
      }
   }
   if(traceDebug())
   {
      ossimNotify(ossimNotifyLevel_DEBUG) << "theOmega:              " << theOmega << std::endl
                                          << "thePhi:                " << thePhi   << std::endl
                                          << "theKappa:              " << theKappa << std::endl;
      std::cout << "platform position:     " << thePlatformPosition << std::endl;
      std::cout << "platform position ECF: " << theEcefPlatformPosition << std::endl;
      std::cout << "ossimApplanixModel::loadState: ......... leaving" << std::endl;
   }

   return true;
}
Esempio n. 9
0
void ossimApplanixUtmModel::updateModel()
{

   ossimGpt wgs84Pt;
   double metersPerDegree = wgs84Pt.metersPerDegree().x;
   double degreePerMeter = 1.0/metersPerDegree;
   double latShift = -computeParameterOffset(1)*theMeanGSD*degreePerMeter;
   double lonShift = computeParameterOffset(0)*theMeanGSD*degreePerMeter;

   ossimGpt gpt = thePlatformPosition;
//   gpt.height(0.0);
   double height = gpt.height();
   gpt.height(height + computeParameterOffset(5));
   gpt.latd(gpt.latd() + latShift);
   gpt.lond(gpt.lond() + lonShift);
   
   theAdjEcefPlatformPosition = gpt;
   ossimLsrSpace lsrSpace(theAdjEcefPlatformPosition);
   // ORIENT TO A UTM AXIS
   //
    NEWMAT::ColumnVector v(3);
   
    v[0] = 0.0;
    v[1] = 0.0;
    v[2] = 1.0;
    NEWMAT::ColumnVector v2 = lsrSpace.lsrToEcefRotMatrix()*v;
    ossimEcefVector zVector(v2[0], v2[1], v2[2]);
    zVector.normalize();
   
   // now lets create a UTM axis by creating a derivative at the center
   // by shift over a few pixels and subtracting
   //
   ossimUtmProjection utmProj;
   
   utmProj.setZone(theUtmZone);
   utmProj.setZone(theUtmHemisphere);
   utmProj.setMetersPerPixel(ossimDpt(1.0,1.0));
   ossimDpt midPt  = utmProj.forward(theAdjEcefPlatformPosition);
   ossimDpt rPt    = midPt + ossimDpt(10, 0.0);
   ossimDpt uPt    = midPt + ossimDpt(0.0, 10.0);
   ossimGpt wMidPt = utmProj.inverse(midPt);
   ossimGpt wRPt   = utmProj.inverse(rPt);
   ossimGpt wUPt   = utmProj.inverse(uPt);
   
   ossimEcefPoint ecefMidPt = wMidPt;
   ossimEcefPoint ecefRPt   = wRPt;
   ossimEcefPoint ecefUPt   = wUPt;
   
   ossimEcefVector east  = ecefRPt-ecefMidPt;
   ossimEcefVector north = ecefUPt-ecefMidPt;
   east.normalize();
   north.normalize();
   
   // now use the lsr space constructors to construct an orthogonal set of axes
   //
   lsrSpace = ossimLsrSpace(thePlatformPosition,
                            0,
                            north,
                            east.cross(north));
//   lsrSpace = ossimLsrSpace(thePlatformPosition);
   // DONE ORIENT TO UTM AXIS
   
   NEWMAT::Matrix platformLsrMatrix = lsrSpace.lsrToEcefRotMatrix();
   NEWMAT::Matrix orientationMatrix = (ossimMatrix3x3::createRotationXMatrix(theOmega+computeParameterOffset(2), OSSIM_LEFT_HANDED)*
                                       ossimMatrix3x3::createRotationYMatrix(thePhi+computeParameterOffset(3), OSSIM_LEFT_HANDED)*
                                       ossimMatrix3x3::createRotationZMatrix(theKappa+computeParameterOffset(4), OSSIM_LEFT_HANDED));
   
   theCompositeMatrix         = platformLsrMatrix*orientationMatrix;
   theCompositeMatrixInverse  = theCompositeMatrix.i();

//   theAdjEcefPlatformPosition = theEcefPlatformPosition; 

   theBoundGndPolygon.resize(4);
   ossim_float64 w = theImageClipRect.width()*2.0;
   ossim_float64 h = theImageClipRect.height()*2.0;
   
   lineSampleToWorld(theImageClipRect.ul()+ossimDpt(-w, -h), gpt);
   theBoundGndPolygon[0] = gpt;
   lineSampleToWorld(theImageClipRect.ur()+ossimDpt(w, -h), gpt);
   theBoundGndPolygon[1] = gpt;
   lineSampleToWorld(theImageClipRect.lr()+ossimDpt(w, h), gpt);
   theBoundGndPolygon[2] = gpt;
   lineSampleToWorld(theImageClipRect.ll()+ossimDpt(-w, h), gpt);
   theBoundGndPolygon[3] = gpt;
}