void ossimDtedElevationImageSource::getPostSpacing(const ossimGrect& rect,
                                                   ossim_uint32 lines,
                                                   ossim_uint32 samples,
                                                   ossimDpt& result) const
{
   result.lat = (rect.ul().lat - rect.ll().lat) / (lines   - 1);
   result.lon = (rect.lr().lon - rect.ll().lon) / (samples - 1);
}
Exemplo n.º 2
0
void oms::SingleImageChain::setViewCut(const ossimGrect& grect)
{
   std::vector<ossimGpt> pointList(4);
   pointList[0] = grect.ul();
   pointList[1] = grect.ur();
   pointList[2] = grect.lr();
   pointList[3] = grect.ll();
   setViewCut(pointList);
};
void ossimDtedElevationImageSource::computeImageRect(
   const ossimMapProjection* view,
   const ossimGrect& grect,
   ossimIrect& irect) const
{
   if (!view)
   {
      return;
   }
   
   ossimDpt dpt;
   view->worldToLineSample(grect.ul(), dpt);
   irect.set_ul(dpt);
   view->worldToLineSample(grect.lr(), dpt);
   irect.set_lr(dpt);
}
Exemplo n.º 4
0
void ossimElevManager::getCellsForBounds( const ossimGrect& bbox,
                                          std::vector<std::string>& cells,
                                          ossim_uint32 maxCells)
{
   getCellsForBounds(bbox.lr().lat, bbox.ul().lon, bbox.ul().lat, bbox.lr().lon, cells, maxCells);
}
void ossimDtedElevationImageSource::snap(const ossimGrect& rect,
                                         const ossimDpt& postSpacing,
                                         ossimGrect& clipRect) const
{
   ossim_float64 d;

   // upper left latitude
   d = (rect.ul().lat - clipRect.ul().lat) / postSpacing.y;
   if (d != 0.0)
   {
      clipRect.ul().lat = floor(d) * postSpacing.y;
   }

   // upper left longitude
   d = (rect.ul().lon - clipRect.ul().lon) / postSpacing.x;
   if (d != 0.0)
   {
      clipRect.ul().lon = ceil(d) * postSpacing.x;
   }

   // upper right latitude
   d = (rect.ul().lat - clipRect.ur().lat) / postSpacing.y;
   if (d != 0.0)
   {
      clipRect.ur().lat = floor(d) * postSpacing.y;
   }

   // upper right longitude
   d = (rect.ul().lon - clipRect.ur().lon) / postSpacing.x;
   if (d != 0.0)
   {
      clipRect.ul().lon = floor(d) * postSpacing.x;
   }

   // lower right latitude
   d = (rect.ul().lat - clipRect.lr().lat) / postSpacing.y;
   if (d != 0.0)
   {
      clipRect.lr().lat = ceil(d) * postSpacing.y;
   }

   // lower right longitude
   d = (rect.ul().lon - clipRect.lr().lon) / postSpacing.x;
   if (d != 0.0)
   {
      clipRect.ul().lon = floor(d) * postSpacing.x;
   }

   // lower left latitude
   d = (rect.ul().lat - clipRect.ll().lat) / postSpacing.y;
   if (d != 0.0)
   {
      clipRect.ll().lat = ceil(d) * postSpacing.y;
   }

   // lower left longitude
   d = (rect.ul().lon - clipRect.ll().lon) / postSpacing.x;
   if (d != 0.0)
   {
      clipRect.ul().lon = ceil(d) * postSpacing.x;
   }
}
void ossimDtedElevationImageSource::resampleCellBilinear(
   const ossimGrect& rect,
   const ossimFilename& dtedFile,
   ossimImageData& id,
   const ossimDpt& postSpacing) const
{
   cout << dtedFile << endl;
   if (traceDebug())
   {
      ossimNotify(ossimNotifyLevel_DEBUG)
         << "ossimDtedElevationImageSource::resampleCellBilinear DEBUG:"
         << " Entered..."
         << endl;
   }

   ossimRefPtr<ossimDtedHandler> dh = new ossimDtedHandler(dtedFile);
   if (!dh)
   {
      return;
   }
   if (dh->getErrorStatus() != ossimErrorCodes::OSSIM_OK)
   {
      dh = 0;
      return;
   }

   ossim_float32* buf = id.getFloatBuf();
   if (!buf)
   {
      dh = 0;
      return;
   }
   
   // Get the clip rectangle.
   const ossimGrect clipRect = rect.clipToRect(dh->getBoundingGndRect());
   const ossimGpt STOP_GPT = clipRect.lr();
   ossimGpt gpt = clipRect.ul();

   if (traceDebug())
   {
      ossimNotify(ossimNotifyLevel_DEBUG)
         << "clipRect:  " << clipRect
         << "\nSTOP_GPT:  " << STOP_GPT
         << "\nStarting gpt:       " << gpt
         << endl;
   }

   // Walk in the latitude (line) direction.
   while (gpt.lat >= STOP_GPT.lat)
   {
      // Walk in longitude (sample) direction.
      gpt.lon = clipRect.ul().lon;
      while (gpt.lon <= STOP_GPT.lon)
      {
         ossim_int32 index = computeIndex(id, rect, gpt, postSpacing);
//         cout << "index:  " << index << endl;
         if (index != OSSIM_INT_NAN)
         {
            ossim_float32 hgt =
               static_cast<ossim_float32>(dh->getHeightAboveMSL(gpt));
//             cout << "index: " << index
//                  << "\ngpt: " << gpt
//                  << "\nhgt: " << hgt
//                  << endl;
            buf[index] = hgt;
            if (hgt == -32767.0)
            {
               cout << gpt << endl;
            }
            // static_cast<ossim_float32>(dh->getHeightAboveMSL(gpt));
         }
         else
         {
            cout << "nan index for gpt:\n" << gpt << endl;
         }
         
         gpt.lon = gpt.lon + postSpacing.x;
      }
      gpt.lat = gpt.lat - postSpacing.y;
   }
//   cout << "Ending gpt:  " << gpt << endl;

//    // Walk in the latitude direction
//    while (gpt.lat <= STOP_GPT.lat)
//    {
//       while (gpt.lon <= STOP_GPT.lon)
//       {
//          gpt.lon += postSpacing.x;
//       }
//       gpt.lat += postSpacing.y;
//    }

   if (traceDebug())
   {
      ossimNotify(ossimNotifyLevel_DEBUG)
         << "ossimDtedElevationImageSource::resampleCellBilinear DEBUG:"
         << " Exited..."
         << endl;
   }

   dh = 0;
}