コード例 #1
0
ファイル: dag_reader.cpp プロジェクト: baharev/asol
void grab_content(const char* file_name, std::iostream& in) {

	parser p(file_name);

	interpreter_DAG ipt(p.get_problem_representation(), in);

	if (!in.good())
		error("unexpected error");
}
コード例 #2
0
int main(int argc, char* argv[])
{
   ossimInit::instance()->initialize(argc, argv);
   ossimString tempString;
   ossimString tempString2;
   osg::ArgumentParser::Parameter stringParam(tempString);
   osg::ArgumentParser::Parameter stringParam2(tempString2);
   
   osg::ArgumentParser arguments(&argc,argv);
   arguments.getApplicationUsage()->addCommandLineOption("--video", 
                                                         "specify the input video to process");
   arguments.getApplicationUsage()->addCommandLineOption("--animation-path-out", 
                                                         "specify the filename to output the animation path to");
   arguments.getApplicationUsage()->addCommandLineOption("--test-sensor-projection", 
                                                         "Test sensor projection from KlvInfo");
   unsigned int helpType = 0;
   if ((helpType = arguments.readHelpType()))
   {
      arguments.getApplicationUsage()->write(std::cout, helpType);
      return 1;
   }
   while(arguments.read("--video", stringParam))
   {
      if(arguments.read("--test-sensor-projection"))
      {
         ossimRefPtr<ossimPredatorUavProjection> proj = new ossimPredatorUavProjection;
         ossimRefPtr<ossimPredatorVideo> predatorVideo = new ossimPredatorVideo();
         
         if(predatorVideo->open(ossimFilename(tempString)))
         {
            ossim_uint32 imageWidth  = predatorVideo->imageWidth();
            ossim_uint32 imageHeight = predatorVideo->imageHeight();
            ossimRefPtr<ossimPredatorVideo::KlvInfo> klvinfo;
            ossim_float64 prevTime = -1.0;
            while(( klvinfo = predatorVideo->nextKlv()).valid())
            {
               ossim_float64 lat,lon,elev;
               ossim_float32 hfov;
               ossim_float32 vfov;
               ossim_float32 h,p,r;
               ossim_float32 obliquityAngle;
               ossim_float32 angleToNorth;
               ossim_float32 slantRange;
               ossim_float32 sensorRoll = 0.0;
               klvinfo->table()->print(std::cout) << std::endl;
               if(klvinfo->table()->getSensorPosition(lat, lon, elev)&&
                  klvinfo->table()->getPlatformOrientation(h,p,r))
               {
                  if(!klvinfo->table()->getObliquityAngle(obliquityAngle))
                  {
                     obliquityAngle = 0.0;
                  }
                  if(!klvinfo->table()->getSlantRange(slantRange))
                  {
                     slantRange = 1.0;
                  }
                  bool gotHfov = true;
                  if(!klvinfo->table()->getHorizontalFieldOfView(hfov))
                  {
                     hfov = 1.0;
                     gotHfov = false;
                  }
                  if(!klvinfo->table()->getVerticalFieldOfView(vfov))
                  {
                     vfov = hfov;
                  }
                  else if(!gotHfov)
                  {
                     hfov = vfov;
                  }
                  klvinfo->table()->getSensorRollAngle(sensorRoll);
                  if(!klvinfo->table()->getAngleToNorth(angleToNorth))
                  {
                     angleToNorth = 0.0;
                  }
                  ossim_float64 value = ossimGeoidManager::instance()->offsetFromEllipsoid(ossimGpt(lat, lon, elev));
                  if(!ossim::isnan(value))
                  {
                     elev += value;
                  }
                  proj->setParameters(imageWidth, 
                                      imageHeight, 
                                      ossimGpt(lat, lon, elev), 
                                      ossimGpt(), 
                                      h, p, sensorRoll,
                                      hfov,
                                      vfov,
                                      obliquityAngle,
                                      angleToNorth,
                                      0.0,
                                      0.0);
                  ossimDpt ipt(imageWidth*.5, imageHeight*.5);
                  ossimGpt centerProj;
                  ossimGpt ul;
                  ossimGpt ur;
                  ossimGpt lr;
                  ossimGpt ll;
                  proj->lineSampleToWorld(ipt, centerProj);
                  proj->lineSampleToWorld(ossimDpt(0,0), ul);
                  proj->lineSampleToWorld(ossimDpt(imageWidth,0), ur);
                  proj->lineSampleToWorld(ossimDpt(imageWidth,imageHeight), lr);
                  proj->lineSampleToWorld(ossimDpt(imageHeight,0), ll);
                  
                  std::cout << std::setprecision(15);
                  std::cout << "position = " << ossimGpt(lat, lon, elev) << std::endl;
                  std::cout << "centerGpt = " << centerProj << std::endl;
                  std::cout << "ul        = " << ul << std::endl;
                  std::cout << "ur        = " << ur << std::endl;
                  std::cout << "lr        = " << lr << std::endl;
                  std::cout << "ll        = " << ll << std::endl;
                  
//                  std::cout << "angle to north = " << angleToNorth << std::endl;
//                  std::cout << "ObliquityAngle = " << obliquityAngle << std::endl;
//                  std::cout << "hpr = " << h << ", " << p << ", " << r << std::endl;
//                  std::cout << "Platform  = " << ossimGpt(lat, lon, elev) << std::endl;
//                  std::cout << "World point = " << centerProj << std::endl;
                  if(klvinfo->table()->getFrameCenter(lat, lon, elev))
                  {
                     std::cout << "Center frame = " << ossimGpt(lat, lon, elev) << std::endl;
                  }
               }
            }
         }
      }
      
      if(arguments.read("--animation-path-out", stringParam2))
      {
         std::ofstream out(tempString2.c_str());
         if(out.good())
         {
            out << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
            out << "<AnimationPath>";
            out << "<GeospatialPath timeUnit='seconds' positionType='latlonhgt' orientationType='lsrhpr'>";
            out << "<description>Cool path</description>";
            out << "<coordinates>";
            
            ossimRefPtr<ossimPredatorVideo> predatorVideo = new ossimPredatorVideo();
            
            if(predatorVideo->open(ossimFilename(tempString)))
            {
               ossim_float32 srange;
               ossimRefPtr<ossimPredatorVideo::KlvInfo> klvinfo;
               ossim_float64 prevTime = -1.0;
               while(( klvinfo = predatorVideo->nextKlv()).valid())
               {
                  klvinfo->table()->getSlantRange(srange);
                  //std::cout << "range === " << srange << std::endl;
                  if(!ossim::almostEqual(klvinfo->time(), prevTime, 1e-10))
                  {
                     prevTime = klvinfo->time();
                     ossimString sensorLat, sensorLon, sensorAlt, h,p,r;
                     if(klvinfo->table()->valueAsString(sensorLat, KLV_KEY_SENSOR_LATITUDE)&&
                        klvinfo->table()->valueAsString(sensorLon, KLV_KEY_SENSOR_LONGITUDE)&&
                        klvinfo->table()->valueAsString(sensorAlt, KLV_KEY_SENSOR_TRUE_ALTITUDE))
                     {
                        klvinfo->table()->valueAsString(h,KLV_KEY_PLATFORM_HEADING_ANGLE);
                        klvinfo->table()->valueAsString(p,KLV_KEY_PLATFORM_PITCH_ANGLE);
                        klvinfo->table()->valueAsString(r,KLV_KEY_PLATFORM_ROLL_ANGLE);
                        
                        double headingAdjust = h.toDouble();
                        if(headingAdjust > 180.0) headingAdjust -= 360.0;
                        out << klvinfo->time() << "," 
                        << sensorLat <<"," << sensorLon << "," <<sensorAlt.toDouble()*0.304801 << ","
                        << headingAdjust << "," << p.toDouble() << "," << r.toDouble() <<std::endl;
                     }
                  }
               }
            }
            out << "</coordinates></GeospatialPath></AnimationPath>";
         }
      }
   }
}
コード例 #3
0
ファイル: ossimViewshedUtil.cpp プロジェクト: hunterfu/ossim
void RadialProcessor::doRadial(ossimViewshedUtil* vsUtil,
                               ossim_uint32 sector,
                               ossim_uint32 radial)
{
   double v;
   ossimDpt pt_i;
   double elev_i, elev;
   double r2_max = vsUtil->m_halfWindow*vsUtil->m_halfWindow;

   // Walk along the radial using the appropriate coordinate abscissa for that sector and
   // compute ordinate using the radials azimuth:
   for (double u=1.0; u <= (double) vsUtil->m_halfWindow; u += 1.0)
   {
      // Compute ordinate from abscissa and slope of this radial:
      v = vsUtil->m_radials[sector][radial].azimuth*(u);
      switch (sector)
      {
      case 0: // N-NE, (u, v) = (-y, x)
         pt_i.y = -u;
         pt_i.x = v;
         break;
      case 1: // NE-E, (u, v) = (x, -y)
         pt_i.x = u;
         pt_i.y = -v;
         break;
      case 2: // E-SE, (u, v) = (x, y)
         pt_i.x = u;
         pt_i.y = v;
         break;
      case 3: // SE-S, (u, v) = (y, x)
         pt_i.y = u;
         pt_i.x = v;
         break;
      case 4: // S-SW, (u, v) = (y, -x)
         pt_i.y = u;
         pt_i.x = -v;
         break;
      case 5: // SW-W, (u, v) = (-x, y)
         pt_i.x = -u;
         pt_i.y = v;
         break;
      case 6: // W-NW, (u, v) = (-x, -y)
         pt_i.x = -u;
         pt_i.y = -v;
         break;
      case 7: // NW-N, (u, v) = (-y, -x)
         pt_i.y = -u;
         pt_i.x = -v;
         break;
      default:
         break;
      }

      ossimIpt ipt (ossim::round<ossim_int32,double>(pt_i.x),
                    ossim::round<ossim_int32,double>(pt_i.y));

      // Check if we passed beyong the visibilty radius, and exit loop if so:
      if ((vsUtil->m_visRadius > 0) && ((u*u + v*v) >= r2_max))
      {
         OpenThreads::ScopedWriteLock lock (m_bufMutex);
         vsUtil->m_outBuffer->setValue(ipt.x, ipt.y, vsUtil->m_observerValue);
         break;
      }

      // Fetch the pixel value as the elevation value and compute elevation angle from
      // the observer pt as dz/dx
      ossimGpt gpt_i;
      vsUtil->m_geometry->localToWorld(pt_i, gpt_i);

      if (vsUtil->m_simulation && ossim::isnan(gpt_i.hgt))
         gpt_i.hgt = vsUtil->m_observerGpt.hgt-vsUtil->m_obsHgtAbvTer; // ground level

      else if (!gpt_i.hasNans())
      {
         // Compare elev angle to max angle latched so far along this radial:
         elev_i = (gpt_i.hgt - vsUtil->m_observerGpt.hgt) / u;
         elev = vsUtil->m_radials[sector][radial].elevation;
         if (elev_i > elev)
         {
            // point is visible, latch this line-of-sight as the new max elevation angle for this
            // radial, and mark the output pixel as visible:
            //   m_outBuffer->setValue(ossim::round<ossim_int32,double>(pt_i.x),
            //                           ossim::round<ossim_int32,double>(pt_i.y), m_visibleValue);
            //OpenThreads::ScopedWriteLock lock (m_radMutex);
            vsUtil->m_radials[sector][radial].elevation = elev_i;
         }
         else
         {
            OpenThreads::ScopedWriteLock lock (m_bufMutex);
            vsUtil->m_outBuffer->setValue(ipt.x, ipt.y, vsUtil->m_hiddenValue);
         }
      }
   } // end loop over radial's abscissas
}