Ignore:
Timestamp:
03/24/09 12:33:56 (15 years ago)
Author:
Malte Marquarding
Message:

Fix for Ticket #90; treating integer as double columns now

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/LineCatalog.cpp

    r1259 r1534  
    6262void LineCatalog::setPattern(const std::string& name, const std::string& stype)
    6363{
    64   //std::string mode = stype+"('"+name+"')";
    65   std::string taql = "SELECT FROM $1 WHERE Column1 == pattern('"+name+"')";
    66   cerr << taql << endl;
     64  std::string mode = stype+"('"+name+"')";
     65  std::string taql = "SELECT FROM $1 WHERE Column1 == " + mode;
    6766  Table tmp = tableCommand(taql, table_);
    6867  if (tmp.nrow() > 0) table_ = tmp.sort("Column2");
     
    110109      }
    111110  }
    112   /// @todo implement me
    113111  return String(oss);
    114112}
    115113
    116 /*!
    117     \fn asap::LineCatalog::getName(int row)
    118  */
     114
    119115std::string LineCatalog::getName(uint row) const
    120116{
     
    123119}
    124120
    125 double asap::LineCatalog::getFrequency(uint row) const
     121double LineCatalog::getFrequency(uint row) const
    126122{
    127   ROScalarColumn<Double> col(table_, "Column2");
    128   return col(row);
     123  return getDouble("Column2", row);
    129124}
    130125
    131 double asap::LineCatalog::getStrength(uint row) const
     126double LineCatalog::getStrength(uint row) const
    132127{
    133   ROScalarColumn<Double> col(table_, "Column3");
    134   return col(row);
     128  return getDouble("Column4", row);
    135129}
    136130
     131double LineCatalog::getDouble(const std::string& colname, uint row) const {
     132  DataType dtype = table_.tableDesc().columnDesc(colname).dataType();
     133  if (dtype == TpDouble) {
     134    ROScalarColumn<Double> col(table_, colname);
     135    return col(row);
     136  } else if (dtype == TpInt) {
     137    ROScalarColumn<Int> col(table_, colname);
     138    return Double(col(row));
     139  } else {
     140    throw AipsError("Column " + colname + "doesn't contain numerical values." );
     141  }
     142}
    137143
    138144} // namespace
Note: See TracChangeset for help on using the changeset viewer.