Пример #1
0
uint64 htmInterface::lookupIDCmd(char *str) {

  cmd_ = str;
  if(t_)delete t_;
  t_ = new VarStrToken(cmd_);

  float64 v[3];
  cmdCode code = getCode();

  if(code == NAME) {
    VarStr token = t_->next();
    if(token.empty())
      throw SpatialInterfaceError("htmInterface:lookupIDCmd: expected Name");

    return index_->idByName(token.data());
  }

  getDepth();
  if(! parseVec(code, v) )
    throw SpatialInterfaceError("htmInterface:lookupIDCmd: Expect vector in Command. ", cmd_.data());

  if( code == J2000 )
    return lookupID(v[0], v[1]);
  return lookupID(v[0], v[1], v[2]);

}
Пример #2
0
// parse the string, returning the number of floats
// that have been in the string.
bool
htmInterface::parseVec( cmdCode code, float64 *v) {

  VarStr  token;
  size_t  i = 0, len;

  if(code == J2000)
    len = 2;
  else if(code == CARTESIAN)
    len = 3;
  else
    throw SpatialInterfaceError("htmInterface:parseVec: Expected code J2000 or CARTESIAN.");

  // parse the next len positions
  while( i < len  ) {
    token = t_->next();
    if(token.empty())break;

    if(!isFloat(token))
      throw SpatialInterfaceError("htmInterface:parse: Expected float at this position of Command. ",cmd_.data());
    if(i == len)
      throw SpatialInterfaceError("htmInterface:parse: Expect less floats in Command. ", cmd_.data());
    v[i++] = atof(token.data());
  }

  if(i < len)
    return false;
  return true;

}
Пример #3
0
// check whether string is a float
bool htmInterface::isFloat(const VarStr &str) {
  if(str.empty()) return false;
  uint32 len = str.length();
  return (strspn(str.data(),"+-.e0123456789") == len) ? true : false ;
}