-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDF_Proj_Report.hpp
154 lines (139 loc) · 5.17 KB
/
DF_Proj_Report.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
// DFLib: A library of Bearings Only Target Localization algorithms
// Copyright (C) 2009-2015 Thomas V. Russo
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
// Filename : $RCSfile$
//
// Purpose : Implements the DFLib::Abstract::Report interface such that
// the "user" coordinate system is specified using a proj.4
// spatial reference system and the "XY" coordinate system
// is a mercator projection on the WGS84 ellipsoid.
//
// Special Notes : Use of this class treats bearing lines to target
// transmitter as loxodromes, not geodesics. Technically,
// that is incorrect. For practical VHF target localization,
// it is probably good enough. To implement a Report class
// that implements completely correct geodesic calculations
// would be much harder, and I haven't done it yet. One
// would require an X-Y coordinate system in which straight
// lines are geodesics rather than loxodromes, and there is no
// conformal projection that does that.
//
// Creator :
//
// Creation Date :
//
// Revision Information:
// ---------------------
//
// Revision Number: $Revision$
//
// Revision Date : $Date$
//
// Current Owner : $Author$
//-------------------------------------------------------------------------
#ifndef DF_PROJ_REPORT_HPP
#define DF_PROJ_REPORT_HPP
#ifdef _MSC_VER
#define _USE_MATH_DEFINES
#endif
#include "DFLib_port.h"
#include <cmath>
#include "DF_Abstract_Report.hpp"
namespace DFLib
{
namespace Proj
{
class Point;
/// \brief DF report in user-specified coordinates
class CPL_DLL Report
: public DFLib::Abstract::Report
{
private:
Point *receiverLocation;
double bearing,sigma;
public:
Report(const std::vector<double> &theLocationUser,
const double &bearing,const double &std_dev,
const std::string &theName,const std::vector<std::string>&projArgs);
Report(const Report & right);
Report & operator=(const Report& rhs);
virtual ~Report();
virtual const std::vector<double> &getReceiverLocation();
virtual Point getReceiverPoint() const;
virtual double getReportBearingRadians() const;
virtual double getBearing() const;
virtual double getBearingStandardDeviationRadians() const;
virtual double getSigma() const;
virtual void setReceiverLocationUser(const std::vector<double> &theLocation);
virtual void setReceiverLocationMercator(const std::vector<double> &theLocation);
//! set bearing in degrees
virtual void setBearing(double Bearing);
//! set standard deviation in degrees
virtual void setSigma(double Sigma);
//! allow us to change the projection of the user coordinates
virtual void setUserProj(const std::vector<std::string> &projArgs);
};
}
inline double DFLib::Proj::Report::getReportBearingRadians() const
{
// bearing *must* be in 0<bearing<2*pi
return bearing;
}
inline double DFLib::Proj::Report::getBearing() const
{
// always return bearing in range 0-360 degrees
return (getReportBearingRadians()*180.0/M_PI);
}
inline double DFLib::Proj::Report::getBearingStandardDeviationRadians() const
{
return sigma;
}
inline double DFLib::Proj::Report::getSigma() const
{
return sigma*180/M_PI;
}
inline void DFLib::Proj::Report::setReceiverLocationUser(const std::vector<double> &theLocation)
{
receiverLocation->setUserCoords(theLocation);
}
inline void DFLib::Proj::Report::setReceiverLocationMercator(const std::vector<double> &theLocation)
{
receiverLocation->setXY(theLocation);
}
inline void DFLib::Proj::Report::setUserProj(const std::vector<std::string> &projArgs)
{
receiverLocation->setUserProj(projArgs);
}
inline const std::vector<double> & DFLib::Proj::Report::getReceiverLocation()
{
return receiverLocation->getXY();
}
inline void DFLib::Proj::Report::setBearing(double Bearing)
{
// bearing *must* be in 0<bearing<2*pi
bearing=Bearing*M_PI/180.0;
while (bearing < 0)
bearing += 2*M_PI;
while (bearing >= 2*M_PI)
bearing -= 2*M_PI;
}
inline void DFLib::Proj::Report::setSigma(double Sigma)
{
sigma=Sigma*M_PI/180;
}
}
#endif // DF_PROJ_REPORT_HPP