cIsValidLine method

bool cIsValidLine(
  1. String str,
  2. eTleLine line
)

IsTleFormat() Returns true if "str" is a valid data line of a two-line element set, else false.

To be valid a line must: Have as the first character the line number Have as the second character a blank Be TLE_LEN_LINE_DATA characters long Have a valid checksum (note: no longer required as of 12/96)

Implementation

bool cIsValidLine(String str, eTleLine line) {
  str.trimLeft();
  str.trimRight();

  int nLen = str.length;

  if (nLen != TLE_LEN_LINE_DATA) {
    return false;
  }

  // First char in string must be line number
  if (str[0] != line.index.toString()) {
    return false;
  }

  // Second char in string must be blank
  if (str[1] != ' ') {
    return false;
  }

  /*
    NOTE: 12/96
    The requirement that the last char in the line data must be a valid
    checksum is too restrictive.

    // Last char in string must be checksum
    int nSum = CheckSum(str);

    if (nSum != (str[TLE_LEN_LINE_DATA - 1] - '0'))
    {
       return false;
    }
 */

  return true;
}