27 #include "../common/STLUtils.h" 
   28 #include "../common/Translator.h" 
   29 #include "../geometry/Coord2D.h" 
   30 #include "../geometry/Envelope.h" 
   31 #include "../raster/BandProperty.h" 
   32 #include "../raster/Grid.h" 
   43 #include <boost/format.hpp> 
   68   throw Exception(
TR_GRIB(
"Not implemented yet!"));
 
   84   std::map<std::string, std::string>::const_iterator it = rinfo.find(
"URI");
 
   86   if ( it == rinfo.end() )
 
   87     throw Exception(
TR_GRIB(
"Missing Grib filename"));
 
   90   std::string file_name = it->second;
 
   93     m_file = fopen(file_name.c_str(), 
"r");
 
   95     m_file = fopen(file_name.c_str(), 
"rw");
 
   98     throw Exception((boost::format(
TR_GRIB(
"Grib file can not be opened: %1%")) %file_name).str());
 
  103   grib_handle* handle = 0;
 
  107   while((handle = grib_handle_new_from_file(sm_context, m_file, &err)) != 0)
 
  109     Band* band = 
new Band(
this, bandId, handle);
 
  111     m_bands.push_back(band);
 
  117     throw Exception((boost::format(
TR_GRIB(
"Can not create Grib handle for file %1% due to the following error: %2%.")) % file_name % 
Band::getErrMsg(err)).str());
 
  122   int gtype = m_bands[0]->getLong(
"dataRepresentationType");
 
  124     setGridSatelliteRep();
 
  128     setGridReducedGGRep();
 
  131     throw Exception((boost::format(
TR_GRIB(
"Could not determine the data projection in the grib file: %1%.")) % file_name).str());
 
  137   throw Exception(
TR_GRIB(
"Not implemented yet!"));
 
  143   return std::map<std::string, std::string>();
 
  148   return m_bands.size();
 
  153   assert(i < m_bands.size());
 
  182   throw Exception(
TR_GRIB(
"Not implemented yet!"));
 
  204   long nx = m_bands[0]->getLong(
"numberOfPointsAlongXAxis");
 
  205   long ny = m_bands[0]->getLong(
"numberOfPointsAlongYAxis");
 
  208   double altitude = m_bands[0]->getDouble(
"NrInRadiusOfEarth") * 0.000001;
 
  210   double pri = 2. * asin(1. / altitude) / m_bands[0]->getDouble(
"dy");
 
  211   double prj = 2.0* asin(1. / altitude) / m_bands[0]->getDouble(
"dx");
 
  214   double resx = (double)(std::atan(std::tan(pri) * (altitude - 1.) ) * 
TeEARTHRADIUS);
 
  215   double resy = (double)(std::atan(std::tan(prj) * (altitude - 1.) ) * 
TeEARTHRADIUS);
 
  218   double offx = m_bands[0]->getDouble(
"xCoordinateOfOriginOfSectorImage");
 
  219   double offy = m_bands[0]->getDouble(
"yCoordinateOfOriginOfSectorImage");
 
  222   double ulx = offx * resx;
 
  223   double uly = -(offy * resy);
 
  224   double lrx = (offx + nx - 1) * resx;
 
  225   double lry = -(offy + ny - 1) * resy;
 
  245   long nx = m_bands[0]->getLong(
"numberOfPointsAlongAParallel");
 
  246   long ny = m_bands[0]->getLong(
"numberOfPointsAlongAMeridian");
 
  249   double north = m_bands[0]->getDouble(
"latitudeOfFirstGridPointInDegrees");
 
  250   double west  = m_bands[0]->getDouble(
"longitudeOfFirstGridPointInDegrees");
 
  251   double south = m_bands[0]->getDouble(
"latitudeOfLastGridPointInDegrees");;
 
  252   double east  = m_bands[0]->getDouble(
"longitudeOfLastGridPointInDegrees");;
 
  256   double resx = (east-west)   / (nx-1);
 
  257   double resy = (north-south) / (ny-1);
 
const te::rst::Band * getBand(std::size_t i) const 
Returns the raster i-th band. 
 
te::dt::AbstractData * clone() const 
It returns a clone of this object. 
 
A raster band description. 
 
~Raster()
Virtual destructor. 
 
const double TeEARTHRADIUS
 
An exception class for GRIB. 
 
static grib_context * sm_context
Grib API context. 
 
A raster class for GRIB format. 
 
AccessPolicy
Supported data access policies (can be used as bitfield). 
 
An Envelope defines a 2D rectangular region. 
 
void open(const std::map< std::string, std::string > &rinfo, te::common::AccessPolicy p=te::common::RAccess)
Opens a raster. 
 
std::map< std::string, std::string > getInfo() const 
It returns additional information about the raster. 
 
A base class for values that can be retrieved from the data access module. 
 
A raster band description. 
 
void setGridSatelliteRep()
 
Band implemntatin for GRIB. 
 
A raster class for GRIB format. 
 
static std::string getErrMsg(int errCode)
 
void setGridReducedGGRep()
 
int getType() const 
It returns the data type of the elements in the band. 
 
std::size_t getNumberOfBands() const 
Returns the number of bands (dimension of cells attribute values) in the raster. 
 
const te::rst::Band & operator[](std::size_t i) const 
Access band in i position. 
 
int getBandDataType(std::size_t i) const 
Returns the data type in a particular band (or dimension). 
 
void FreeContents(boost::unordered_map< K, V * > &m)
This function can be applied to a map of pointers. It will delete each pointer in the map...
 
Band implemntatin for GRIB. 
 
#define TR_GRIB(message)
It marks a string in order to get translated. This is a special mark used in the DataAccess module of...