2 Copyright 2006 Johnathan Corgan.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License version 2
6 as published by the Free Software Foundation.
8 This software is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
13 You should have received a copy of the GNU General Public License
14 along with GNU Radio; see the file COPYING. If not, write to
15 the Free Software Foundation, Inc., 51 Franklin Street,
16 Boston, MA 02110-1301, USA.
19 // Application level includes
30 m_location = Spherical(0.0, 0.0);
45 Sample::Sample(const Sample &sample)
47 m_time = sample.m_time;
48 m_valid = sample.m_valid;
49 m_location = sample.m_location;
50 m_heading = sample.m_heading;
51 m_speed = sample.m_speed;
52 m_in_phase = sample.m_in_phase;
53 m_quadrature = sample.m_quadrature;
54 m_phase = sample.m_phase;
55 m_strength = sample.m_strength;
56 m_volume = sample.m_volume;
57 m_rate = sample.m_rate;
58 m_filtering = sample.m_filtering;
59 m_error = sample.m_error;
60 m_ierror = sample.m_ierror;
61 m_qerror = sample.m_qerror;
64 Sample::Sample(wxString &line)
69 sscanf((char *)line.c_str(), "%c %i %lf %lf %f %f %f %f %f %f %f %f %f %f %i %i",
92 m_location = Spherical(lat, lon);
95 void Sample::Dump(char *str, int len)
97 // vld tim lat lon hdg speed vol stren inphs quad phase error ierr qerr rt flt
98 snprintf(str, len, "%s %10i %10.5lf %10.5lf %5.1f %6.2f %7.5f %7.5f %9.6f %9.6f %9.6f %7.2f %9.6f %9.6f %i %i",
101 m_location.Latitude(),
102 m_location.Longitude(),
117 void Sample::CalcError(const Spherical &location, float &angle, float &ierror, float &qerror) const
119 float actual_bearing = bearing(m_location, location);
120 float sample_relative_bearing = degree_normalize(to_degrees(m_phase));
121 float sample_absolute_bearing = degree_normalize(sample_relative_bearing+m_heading);
122 angle = sample_absolute_bearing-actual_bearing;
132 // Rotate I, Q by actual bearing
133 float i_act = cos(to_radians(-actual_bearing));
134 float q_act = sin(to_radians(-actual_bearing));
135 ierror = m_in_phase*i_act - m_quadrature*q_act;
136 qerror = m_quadrature*i_act + m_in_phase*q_act;