OpenCPN Partial API docs
Loading...
Searching...
No Matches
MagneticPlotMap.h
1
/******************************************************************************
2
* $Id: MagneticPlotMap.h,v 1.0 2011/02/26 01:54:37 nohal Exp $
3
*
4
* Project: OpenCPN
5
* Purpose: WMM Plugin
6
* Author: Sean D'Epagnier
7
*
8
***************************************************************************
9
* Copyright (C) 2013 by Sean D'Epagnier *
10
* *
11
* This program is free software; you can redistribute it and/or modify *
12
* it under the terms of the GNU General Public License as published by *
13
* the Free Software Foundation; either version 2 of the License, or *
14
* (at your option) any later version. *
15
* *
16
* This program is distributed in the hope that it will be useful, *
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
19
* GNU General Public License for more details. *
20
* *
21
* You should have received a copy of the GNU General Public License *
22
* along with this program; if not, write to the *
23
* Free Software Foundation, Inc., *
24
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
25
***************************************************************************
26
*/
27
28
#include <list>
29
#include "pi_TexFont.h"
30
#include "GeomagnetismHeader.h"
31
32
enum
MagneticPlotType {
33
DECLINATION_PLOT,
34
INCLINATION_PLOT,
35
FIELD_STRENGTH_PLOT
36
};
37
38
class
pi_ocpnDC
;
39
40
/* must be a power of 2, and also divide 360 and 176;
41
really only 8 works without more modifications */
42
#define ZONE_SIZE 8
43
44
/* divisible by 8 and any closer to the pole than this plots
45
horribly anyway on a flattened earth. */
46
#define MAX_LAT 88
47
#define LATITUDE_ZONES (2 * MAX_LAT / ZONE_SIZE)
/* perfectly divisible */
48
#define LONGITUDE_ZONES (360 / ZONE_SIZE)
49
50
/* a single line segment in the plot */
51
class
PlotLineSeg
{
52
public
:
53
PlotLineSeg
(
double
_lat1,
double
_lon1,
double
_lat2,
double
_lon2,
54
double
_contour)
55
: lat1(_lat1), lon1(_lon1), lat2(_lat2), lon2(_lon2), contour(_contour) {}
56
double
lat1, lon1, lat2, lon2;
57
double
contour;
58
};
59
60
/* cache values computed from wmm to improve speed */
61
class
ParamCache
{
62
public
:
63
ParamCache
() : values(NULL), m_step(0), m_lat(0.0) {}
64
~ParamCache
() {
delete
[] values; }
65
void
Initialize(
double
step);
66
bool
Read(
double
lat,
double
lon,
double
&value);
67
68
double
*values;
69
double
m_step;
70
double
m_lat;
71
};
72
73
/* main model map suitable for a single plot type */
74
class
MagneticPlotMap
{
75
public
:
76
MagneticPlotMap
(MagneticPlotType type,
MAGtype_MagneticModel
*&mm,
77
MAGtype_MagneticModel
*&tmm,
MAGtype_Ellipsoid
*ellip)
78
: m_type(type),
79
m_bEnabled(
false
),
80
m_Spacing(0.0),
81
m_Step(0.0),
82
m_PoleAccuracy(0.0),
83
MagneticModel(mm),
84
TimedMagneticModel(tmm),
85
Ellip(ellip),
86
lastx(0),
87
lasty(0) {
88
UserDate.Year = 2015;
89
UserDate.Month = 1;
90
UserDate.Day = 1;
91
UserDate.DecimalYear = 2015.0;
92
}
93
94
~MagneticPlotMap
() { ClearMap(); }
95
96
void
ConfigureAccuracy(
int
stepsize,
int
poleaccuracy);
97
double
CalcParameter(
double
lat,
double
lon);
98
void
BuildParamCache(
ParamCache
&cache,
double
lat);
99
double
CachedCalcParameter(
double
lat,
double
lon);
100
bool
Interpolate(
double
x1,
double
x2,
double
y1,
double
y2,
bool
lat,
101
double
lonval,
double
&rx,
double
&ry);
102
void
PlotRegion(std::list<PlotLineSeg *> ®ion,
double
lat1,
double
lon1,
103
double
lat2,
double
lon2);
104
bool
Recompute(wxDateTime date);
105
void
Plot(
pi_ocpnDC
*dc,
PlugIn_ViewPort
*vp, wxColour color);
106
107
void
ClearMap();
108
void
DrawContour(
pi_ocpnDC
*dc,
PlugIn_ViewPort
&VP,
double
contour,
109
double
lat,
double
lon);
110
111
MagneticPlotType m_type;
112
bool
m_bEnabled;
113
double
m_Spacing;
114
double
m_Step;
115
double
m_PoleAccuracy;
116
117
/* two caches for all longitudes alternate
118
places (step over each other) to cover the two latitudes
119
currently being built */
120
ParamCache
m_Cache[2];
121
122
MAGtype_MagneticModel
*&MagneticModel;
123
MAGtype_MagneticModel
*&TimedMagneticModel;
124
MAGtype_Ellipsoid
*Ellip;
125
MAGtype_Date
UserDate;
126
127
/* the line segments for the entire globe split into zones */
128
std::list<PlotLineSeg *> m_map[LATITUDE_ZONES][LONGITUDE_ZONES];
129
130
TexFont
m_TexFont;
131
int
lastx, lasty;
/* when rendering to prevent overcluttering */
132
};
MagneticPlotMap
Definition
MagneticPlotMap.h:74
ParamCache
Definition
MagneticPlotMap.h:61
PlotLineSeg
Definition
MagneticPlotMap.h:51
PlugIn_ViewPort
Definition
ocpn_plugin.h:183
TexFont
Definition
pi_TexFont.h:68
pi_ocpnDC
Definition
pi_ocpndc.h:65
MAGtype_Date
Definition
GeomagnetismHeader.h:167
MAGtype_Ellipsoid
Definition
GeomagnetismHeader.h:144
MAGtype_MagneticModel
Definition
GeomagnetismHeader.h:124
plugins
wmm_pi
src
MagneticPlotMap.h
Generated on Sat Mar 1 2025 02:28:52 for OpenCPN Partial API docs by
1.9.8