static bool ParseAngle(const TCHAR *&src, Angle &angle) { // 41.234234N TCHAR *endptr; // Parse numerical value double value = _tcstod(src, &endptr); if (endptr == src) return false; src = endptr; angle = Angle::Degrees(value); // Skip until next whitespace and look for NSEW signs bool found = false; while (*src != _T(' ') && *src != _T('\0')) { if (!found) { if (*src == _T('N') || *src == _T('n') || *src == _T('E') || *src == _T('e')) { found = true; } else if (*src == _T('S') || *src == _T('s') || *src == _T('W') || *src == _T('w')) { found = true; angle.Flip(); } } src++; } return found; }
Angle SunEphemeris::GetHourAngle(Angle lat, Angle declin) { Angle dfo = Angle::Degrees(SUN_DIAMETER / 2 + AIR_REFRACTION); // Correction: different sign at southern hemisphere if (negative(lat.Degrees())) dfo.Flip(); fixed fo = (declin + dfo).tan() * lat.tan(); return Angle::asin(fo) + Angle::QuarterCircle(); }
static bool ReadLongitude(NMEAInputLine &line, Angle &value_r) { Angle value; if (!ReadPositiveAngle(line, value)) return false; if (line.read_first_char() == 'W') value.Flip(); value_r = value; return true; }
static bool ReadLongitude(NMEAInputLine &line, Angle &value_r) { Angle value; if (!ReadGeoAngle(line, value)) return false; char ch = line.ReadOneChar(); if (ch == 'W') value.Flip(); else if (ch != 'E') return false; value_r = value; return true; }