void ossimplugins::ossimSentinel1SarSensorModel::readCoordinates(
        ossimXmlDocument const& xmlDoc, ossimString const& xpath,
        ossimString const& rg0_xpath, ossimString const& coeffs_xpath,
        std::vector<CoordinateConversionRecordType> & outputRecords)
{
   std::vector<ossimRefPtr<ossimXmlNode> > xnodes;
   xmlDoc.findNodes(xpath, xnodes);

   for(std::vector<ossimRefPtr<ossimXmlNode> >::iterator itNode = xnodes.begin(); itNode!=xnodes.end();++itNode)
   {
      CoordinateConversionRecordType coordRecord;

      coordRecord.azimuthTime = getTimeFromFirstNode(**itNode, attAzimuthTime);

      coordRecord.rg0 = getDoubleFromFirstNode(**itNode, rg0_xpath);;

      ossimString const& s = getTextFromFirstNode(**itNode, coeffs_xpath);
      std::vector<ossimString> ssplit = s.split(" ");

      if (ssplit.empty())
      {
         throw std::runtime_error(("The "+rg0_xpath+" record has an empty coef vector").string());
      }
      for (std::vector<ossimString>::const_iterator cIt = ssplit.begin(), e = ssplit.end()
            ; cIt != e
            ; ++cIt
          )
      {
         coordRecord.coefs.push_back(cIt->toDouble());
      }
      assert(!coordRecord.coefs.empty()&&"The rg0 record has empty coefs vector.");

      outputRecords.push_back(coordRecord);
   }
}
示例#2
0
bool ossimAuxXmlSupportData::getPath(
   const ossimString& path, const ossimXmlDocument& xdoc, ossimString& s) const
{
   bool result = false;

   std::vector<ossimRefPtr<ossimXmlNode> > xnodes;
   xdoc.findNodes(path, xnodes);
   if ( xnodes.size() == 1 ) // Error if more than one.
   {
      if ( xnodes[0].valid() )
      {
         s = xnodes[0]->getText();
         result = true;
      }
      else if(traceDebug())
      {
         ossimNotify(ossimNotifyLevel_WARN)
            << "ossimAuxXmlSupportData::getPath ERROR:\n"
            << "Node not found: " << path
            << std::endl;
      }
   }
   else if ( xnodes.size() == 0 )
   {
      if(traceDebug())
      {
         ossimNotify(ossimNotifyLevel_WARN)
            << "ossimAuxXmlSupportData::getPath ERROR:\n"
            << "Node not found: " << path
            << std::endl;
      }
   }
   else
   {
      if(traceDebug())
      {
         ossimNotify(ossimNotifyLevel_WARN)
            << "ossimAuxXmlSupportData::getPath ERROR:\n"
            << "Multiple nodes found: " << path
            << std::endl;
      }
   }

   if (!result)
   {
      s.clear();
   }
   return result;
   
} // bool ossimAuxXmlSupportData::getPath
示例#3
0
bool ossimAuxXmlSupportData::initializeProjection( const ossimXmlDocument xdoc,
                                                   const std::string& wkt, 
                                                   ossimProjection* proj ) const
{
   bool result = false;

   ossimRefPtr<ossimMapProjection> mapProj = dynamic_cast<ossimMapProjection*>( proj );
   if ( mapProj.valid() )
   {
      // Find the tie and scale.
      ossimString path = "/PAMDataset/Metadata/MDI";
      std::vector<ossimRefPtr<ossimXmlNode> > xnodes;
      xdoc.findNodes(path, xnodes);
      if ( xnodes.size() )
      {
         ossimDpt tie;
         ossimDpt scale;
         tie.makeNan();
         scale.makeNan();
         
         for ( ossim_uint32 i = 0; i < xnodes.size(); ++i )
         {
            if ( xnodes[i].valid() )
            {
               ossimString value;
               ossimString attrName = "key";
               
               ossimRefPtr<ossimXmlAttribute> attr = xnodes[i]->findAttribute( attrName );
               if ( attr.valid() )
               {
                  if (attr->getValue() == "IMAGE__XY_ORIGIN" )
                  {
                     value = xnodes[i]->getText();
                     if ( value.size() )
                     {
                        // Split it:
                        std::vector<ossimString> list;
                        value.split( list, ossimString(","), true );
                        if ( list.size() == 2 )
                        {
                           if ( list[0].size() )
                           {
                              tie.x = list[0].toFloat64();
                           }
                           if ( list[1].size() )
                           {
                              tie.y = list[1].toFloat64();
                           }
                        }
                     }
                  }
                  else if (attr->getValue() == "IMAGE__X_RESOLUTION" )
                  {
                     value = xnodes[i]->getText();
                     if ( value.size() )
                     {
                        scale.x = value.toFloat64();
                     }
                  }
                  else if (attr->getValue() == "IMAGE__Y_RESOLUTION" )
                  {
                     value = xnodes[i]->getText();
                     if ( value.size() )
                     {
                        scale.y = value.toFloat64();
                     }
                  }
               }
               
            } // Matches: if ( xnodes[i].valid() )
            
         } // Matches: for ( ossim_uint32 i = 0; i < xnodes.size(); ++i )

         if ( !tie.hasNans() && !scale.hasNans() )
         {
            if ( mapProj->isGeographic() )
            {
               // Assuming tie and scale in decimal degrees:
               mapProj->setDecimalDegreesPerPixel( scale );
               ossimGpt gpt(tie.y, tie.x, 0.0);
               mapProj->setUlTiePoints( ossimGpt( gpt ) );
               result = true;
            }
            else
            {
               // Get the units:
               ossimUnitType units = getUnits( wkt );

               // Convert to meters:
               result = true;
               if ( units != OSSIM_METERS )
               {
                  if ( units == OSSIM_FEET )
                  {
                     tie.x = tie.x * MTRS_PER_FT;
                     tie.y = tie.y * MTRS_PER_FT;
                     scale.x = scale.x * MTRS_PER_FT;
                     scale.y = scale.y * MTRS_PER_FT;                     
                  }
                  else if ( units == OSSIM_US_SURVEY_FEET)
                  {
                     tie.x = tie.x * US_METERS_PER_FT;
                     tie.y = tie.y * US_METERS_PER_FT;
                     scale.x = scale.x * OSSIM_US_SURVEY_FEET;
                     scale.y = scale.y * OSSIM_US_SURVEY_FEET;
                  }
                  else
                  {
                     ossimNotify(ossimNotifyLevel_WARN)
                        << "ossimAuxXmlSupportData::initializeProjection WARNING: "
                        << "Unhandled unit type: " << units << std::endl;
                     result = false;
                  }
               }

               if ( result )
               {
                  mapProj->setMetersPerPixel( scale );
                  mapProj->setUlTiePoints( tie );
               }
            }
         }
         
      } // Matches: if ( xnodes.size() ) 
   }

   return result;
   
} // ossimAuxXmlSupportData::initializeProjection