Ejemplo n.º 1
0
std::string terrama2::core::DataStoragerPostGis::getDataSetTableName(DataSetPtr dataSet) const
{
  try
  {
    return dataSet->format.at("table_name");
  }
  catch (...)
  {
    QString errMsg = QObject::tr("Undefined table name in dataset: %1.").arg(dataSet->id);
    TERRAMA2_LOG_ERROR() << errMsg;
    throw UndefinedTagException() << ErrorDescription(errMsg);
  }
}
Ejemplo n.º 2
0
std::string terrama2::core::DataStoragerTiff::getMask(DataSetPtr dataSet) const
{
  try
  {
    return dataSet->format.at("mask");
  }
  catch(...)
  {
    QString errMsg = QObject::tr("Undefined mask in dataset: %1.").arg(dataSet->id);
    TERRAMA2_LOG_ERROR() << errMsg;
    throw UndefinedTagException() << ErrorDescription(errMsg);
  }
}
Ejemplo n.º 3
0
std::string terrama2::core::getTimeInterval(terrama2::core::DataSetPtr dataset)
{
  try
  {
    std::string interval = dataset->format.at("time_interval");
    std::string unit = dataset->format.at("time_interval_unit");

    return interval+unit;
  }
  catch(...)
  {
    QString errMsg = QObject::tr("Undefined tag for time interval in dataset: %1.").arg(dataset->id);
    TERRAMA2_LOG_ERROR() << errMsg;
    throw UndefinedTagException() << ErrorDescription(errMsg);
  }
}
Ejemplo n.º 4
0
std::string terrama2::core::getProperty(DataSetPtr dataSet, DataSeriesPtr dataSeries, std::string tag, bool logErrors)
{
  std::string property;
  if(dataSeries)
  {
    try
    {
      auto semantics = dataSeries->semantics;
      property = semantics.metadata.at(tag);
      // protection for invalid javascript data
     if(property=="null")
       property.clear();
    }
    catch(...)  //exceptions will be treated later
    {
    }
  }

  if(property.empty())
  {
    try
    {
      property = dataSet->format.at(tag);
      // protection for invalid javascript data
      if(property=="null")
        property.clear();
    }
    catch(...)  //exceptions will be treated later
    {
    }
  }


  if(property.empty())
  {
    QString errMsg = QObject::tr("Undefined %2 in dataset: %1.").arg(dataSet->id).arg(QString::fromStdString(tag));
    if(logErrors)
      TERRAMA2_LOG_ERROR() << errMsg;
    throw UndefinedTagException() << ErrorDescription(errMsg);
  }

  return property;
}