forked from sduclos/S52
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathS52MP.c
296 lines (223 loc) · 11.9 KB
/
S52MP.c
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
// S52MP.c: Mariner Parameter
//
// Project: OpENCview
/*
This file is part of the OpENCview project, a viewer of ENC.
Copyright (C) 2000-2016 Sylvain Duclos [email protected]
OpENCview is free software: you can redistribute it and/or modify
it under the terms of the Lesser GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpENCview 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
Lesser GNU General Public License for more details.
You should have received a copy of the Lesser GNU General Public License
along with OpENCview. If not, see <http://www.gnu.org/licenses/>.
*/
#include "S52MP.h" // S52_MP_get/set()
#include "S52utils.h" // PRINTF()
#include <glib.h> // TRUE, FALSE
///////////////////////////////////////////////////////////////////
//
// GLOBAL MARINER PARAMETER (will move out)
//
// NOTE: value for Chart No 1 found in README
//
// Soundings ON
// Text ON
// Depth Shades 4
// Safety Contour 10 m
// Safety Depth 7 m
// Shallow 5 m
// Deep 30 m
/* A) value for Chart No 1 */
/*
static double SHOW_TEXT = TRUE; // view group 23
static double TWO_SHADES = FALSE; // flag indicating selection of two depth shades (on/off) [default ON]
static double SAFETY_CONTOUR = 10.0; // selected safety contour (meters) [IMO PS 3.6]
static double SAFETY_DEPTH = 7.0; // selected safety depth (meters) [IMO PS 3.7]
static double SHALLOW_CONTOUR = 5.0; // selected shallow water contour (meters) (optional)
static double DEEP_CONTOUR = 30.0; // selected deepwatercontour (meters) (optional)
*/
/* B) value for testing */
/*
//gboolean TWO_SHADES = TRUE; // flag indicating selection of two depth shades (on/off) [default ON]
gboolean TWO_SHADES = FALSE; // flag indicating selection of two depth shades (on/off) [default ON]
gboolean SHOW_TEXT = TRUE; // view group 23
//double SAFETY_DEPTH = 30.0; // selected safety depth (meters) [IMO PS 3.7]
//double SHALLOW_CONTOUR = 2.0; // selected shallow water contour (meters) (optional)
double SAFETY_DEPTH = 15.0; // selected safety depth (meters) [IMO PS 3.7]
double SHALLOW_CONTOUR = 5.0; // selected shallow water contour (meters) (optional)
//double SAFETY_CONTOUR = 30.0; // selected safety contour (meters) [IMO PS 3.6]
//double DEEP_CONTOUR = 30.0; // selected deepwatercontour (meters) (optional)
//double SAFETY_CONTOUR = 5.0; // selected safety contour (meters) [IMO PS 3.6]
//double DEEP_CONTOUR = 10.0; // selected deepwatercontour (meters) (optional)
double SAFETY_CONTOUR = 10.0; // selected safety contour (meters) [IMO PS 3.6]
double DEEP_CONTOUR = 15.0; // selected deepwatercontour (meters) (optional)
*/
/* param needed for certain conditional symbology */
/*
gboolean SHALLOW_PATTERN = FALSE; // flag indicating selection of shallow water highlight (on/off)(optional) [default OFF]
gboolean SHIPS_OUTLINE = FALSE; // flag indicating selection of ship scale symbol (on/off) [IMO PS 8.4]
double DISTANCE_TAGS = 0.0; // selected spacing of "distance to run" tags at a route (nm)
double TIME_TAGS = 0.0; // selected spacing of time tags at the pasttrack (min)
gboolean FULL_SECTORS = TRUE; // show full length light sector lines
gboolean SYMBOLIZED_BND = TRUE; // symbolized area boundaries
*/
// textual name of mariner's parameter
// WARNING: must be in sync with S52MarinerParameter
static double _MARparamVal[] = {
0.0, // 0 - ERROR: 0 - no error,
//0.0, // 1 - SHOW_TEXT (0 - off)
1.0, // 1 - SHOW_TEXT (default)
FALSE, // 2 - TWO_SHADES (flase -> 4 shade)
//TRUE, // 2 - TWO_SHADES (SEABED01 default)
15.0, // 3 - SAFETY_CONTOUR
//0.0, // 3 - SAFETY_CONTOUR --to test DEPCNT02 selection (GL) in CA49995A.000
//0.5, // 3 - SAFETY_CONTOUR --to test DEPCNT02 selection (GL) in CA49995A.000
//30.0, // 3 - SAFETY_CONTOUR (SEABED01 default)
7.0, // 4 - SAFETY_DEPTH
//5.0, // 4 - SAFETY_DEPTH
2.0, // 5 - SHALLOW_CONTOUR (SEABED01 default)
//5.0, // 5 - SHALLOW_CONTOUR
//30.0, // 6 - DEEP_CONTOUR (SEABED01 default)
15.0, // 6 - DEEP_CONTOUR
FALSE, // 7 - SHALLOW_PATTERN (SEABED01 default)
//TRUE, // 7 - SHALLOW_PATTERN
FALSE, // 8 - SHIPS_OUTLINE
0.0, // 9 - S52_DISTANCE_TAGS (default OFF)
0.0, // 10 - TIME_TAGS (default OFF)
TRUE, // 11 - FULL_SECTORS
TRUE, // 12 - SYMBOLIZED_BND
//FALSE, // 12 - SYMBOLIZED_BND
TRUE, // 13 - SYMPLIFIED_PNT
//FALSE, // 13 - SYMPLIFIED_PNT
// 14 - S52_MAR_DISP_CATEGORY
// S52_MAR_DISP_CATEGORY_BASE, // 0, 0x000000 DISPLAY BASE
S52_MAR_DISP_CATEGORY_STD, // 1 << 0 0x000001 STANDARD (default)
// S52_MAR_DISP_CATEGORY_OTHER, // 1 << 1 0x000010 OTHER
// S52_MAR_DISP_CATEGORY_SELECT, // 1 << 2 0x000100 SELECT (override)
0, // 15 - S52_MAR_COLOR_PALETTE --DAY_BRIGHT
// 1, // 15 - S52_MAR_COLOR_PALETTE --DAY_BLACKBACK
// 2, // 15 - S52_MAR_COLOR_PALETTE --DAY_WHITEBACK
// 3, // 15 - S52_MAR_COLOR_PALETTE --DUSK
// 4, // 15 - S52_MAR_COLOR_PALETTE --NIGHT
12.0, // 16 - S52_MAR_VECPER (min)
1.0, // 17 - S52_MAR_VECMRK 0/1/2 (0 - for none, 1 - 1&6 min, 2 - 6 min)
1.0, // 18 - S52_MAR_VECSTB 0/1/2 (0 - for none, 1 - ground, 2 - water)
0.0, // 19 - S52_MAR_HEADNG_LINE (default OFF)
//1.0, // 19 - S52_MAR_HEADNG_LINE (debug)
0.0, // 20 - S52_MAR_BEAM_BRG_NM - beam bearing NM (default OFF)
//1.0, // 20 - S52_MAR_BEAM_BRG_NM - beam bearing NM (debug)
//---- experimantal ----
0.0, // 21 - S52_MAR_FONT_SOUNDG --NOT IMPLEMENTED: use font for souding (on/off)
0.0, // 22 - S52_MAR_DATUM_OFFSET --value of chart datum offset (raster_sound must be ON)
1.0, // 23 - S52_MAR_SCAMIN --flag for using SCAMIN filter (on/off) (default ON)
//0.0, // 23 - S52_MAR_SCAMIN --flag for using SCAMIN filter (on/off)
0.0, // 24 - S52_MAR_ANTIALIAS (on/off)
1.0, // 25 - display QUAPNT01 (quality of position symbol) (on/off)
0.0, // 26 - display overlapping symbol (default to false, debug)
// 27 - S52_MAR_DISP_LAYER_LAST to enable S52_drawLast()
//S52_MAR_DISP_LAYER_LAST_NONE, // 1 << 3 0x0001000 - MARINERS' NONE
S52_MAR_DISP_LAYER_LAST_STD, // 1 << 4 0x0010000 - MARINERS' STANDARD (default)
//S52_MAR_DISP_LAYER_LAST_OTHER, // 1 << 5 0x0100000 - MARINERS' OTHER
//S52_MAR_DISP_LAYER_LAST_SELECT, // 1 << 6 0x1000000 - MARINERS' SELECT (override)
0.0, // 28 - S52_MAR_ROT_BUOY_LIGHT (deg)
1.0, // 29 - S52_MAR_DISP_CRSR_PICK, 0 - off, 1 - pick/highlight top object, 2 - pick stack/highlight top,
// 3 - pick stack+ASSOC/highlight ASSOC (compiled with -DS52_USE_C_AGGR_C_ASSO)
0.0, // 30 - S52_MAR_DISP_GRATICULE (default off)
0.0, // 31 - S52_MAR_DISP_WHOLIN (default off)
0.0, // 32 - S52_MAR_DISP_LEGEND (default off)
0.0, // 33 - S52_CMD_WRD_FILTER command word filter for profiling (default off)
0.3, // 34 - S52_MAR_DOTPITCH_MM_X dotpitch X (mm) - pixel size in X
0.3, // 35 - S52_MAR_DOTPITCH_MM_Y dotpitch Y (mm) - pixel size in Y
0.0, // 36 - S52_MAR_DISP_CALIB - display calibration symbol (on/off) (default off)
1.0, // 37 - S52_MAR_DISP_DRGARE_PATTERN - display DRGARE pattern (default on)
1.0, // 38 - S52_MAR_DISP_NODATA_LAYER - display layer 0 (no data) (default on)
//600.0, // 39 - S52_MAR_DISP_VESSEL_DELAY (sec)
0.0, // 39 - S52_MAR_DISP_VESSEL_DELAY (sec) (default OFF)
0.0, // 40 - S52_MAR_DISP_AFTERGLOW (default off)
//1.0, // 40 - S52_MAR_DISP_AFTERGLOW (on)
//0.0, // 41 - S52_MAR_DISP_CENTROIDS display all centered symb of one area (on/off) (default off)
1.0, // 41 - S52_MAR_DISP_CENTROIDS display all centered symb of one area (on/off) (default off)
0.0, // 42 - S52_MAR_DISP_WORLD display World - TM_WORLD_BORDERS_SIMPL-0.2.shp - (on/off) (default off)
//1.0, // 42 - S52_MAR_DISP_WORLD display World - TM_WORLD_BORDERS_SIMPL-0.2.shp - (on/off) (default off)
1.0, // 43 - S52_MAR_DISP_RND_LN_END - display rounded line ending (on/off)
1.0, // 44 - S52_MAR_DISP_VRMEBL_LABEL - display bearing / range label on VRMEBL (on/off)
0.0, // 45 - S52_MAR_DISP_RADAR_LAYER - display Raster: RADAR, Bathy, ... (on/off) (default off)
1852.0, // 46 - S52_MAR_GUARDZONE_BEAM - Danger/Indication Highlight used by LEGLIN & Position (meters)
1852.0*6, // 47 - S52_MAR_GUARDZONE_LENGTH - Danger/Indication Highlight used by Position
// (meters, user computed from speed/time or distance) [default 6 NM, 30 min. @ 12kt]
0.0, // 48 - S52_MAR_GUARDZONE_ALARM // FIXME: put MAR_ERROR code here
// FIXME: 1&2 ON at the same time. 0 - no error, 1 - alarm, 2 - indication
0.0, // 49 - S52_MAR_DISP_HODATA, 0 - union HO data limit "m_covr" (default), 1 - all HO data limit (M_COVR+m_covr)
50.0 // number of parameter type
};
double S52_MP_get(S52MarinerParameter param)
// return Mariner parameter or S52_MAR_ERROR if fail
// FIXME: check mariner param against groups selection
{
//if (param<S52_MAR_ERROR || S52_MAR_NUM<=param) {
if (S52_MAR_ERROR<=param && param<S52_MAR_NUM) {
return _MARparamVal[param];
} else {
PRINTF("WARNING: param invalid(%f)\n", param);
g_assert(0);
return _MARparamVal[S52_MAR_ERROR];
}
}
int S52_MP_set(S52MarinerParameter param, double val)
{
//if (param<S52_MAR_ERROR || S52_MAR_NUM<=param) {
if (S52_MAR_ERROR<=param && param<S52_MAR_NUM) {
_MARparamVal[param] = val;
return TRUE;
} else {
PRINTF("WARNING: param invalid(%f)\n", param);
g_assert(0);
return FALSE;
}
}
// ------ Text Display Priority --------------------------------------------------
//
//
#define TEXT_IDX_MAX 100
//static unsigned int _textDisp[TEXT_IDX_MAX] = {[0 ... 99] = 1}; // not ISO C (gcc specific)
static unsigned int _textDisp[TEXT_IDX_MAX] = {
1,1,1,1,1,1,1,1,1,1, // 00 - 09 reserved for future assignment by IHO
1,1,1,1,1,1,1,1,1,1, // 10 - 19 Important Text
1,1,1,1,1,1,1,1,1,1, // 20 - 29 Other text
1,1,1,1,1,1,1,1,1,1, // 30 - 39 30 - na, 31 - national language text (NOBJNM, NINFOM, NTXTDS)
1,1,1,1,1,1,1,1,1,1, // 40 - 49 32 - 49 reserved for IHO
1,1,1,1,1,1,1,1,1,1, // 50 - 59 mariners text, including planned speed etc.
1,1,1,1,1,1,1,1,1,1, // 60 - 69 manufacturer's text
1,1,1,1,1,1,1,1,1,1, // 70 - 79 future requirements (AIS etc.)
1,1,1,1,1,1,1,1,1,1, // 80 - 89 future requirements (AIS etc.)
1,1,1,1,1,1,1,1,1,1 // 90 - 99 future requirements (AIS etc.)
};
int S52_MP_setTextDisp(unsigned int prioIdx, unsigned int count, unsigned int state)
{
if (TEXT_IDX_MAX < prioIdx) {
PRINTF("WARNING: prioIdx out of bound (%i)\n", prioIdx);
return FALSE;
}
if (TEXT_IDX_MAX < count) {
PRINTF("WARNING: count out of bound (%i)\n", count);
return FALSE;
}
if (prioIdx+count > TEXT_IDX_MAX) {
PRINTF("WARNING: prioIdx + count out of bound (%i)\n", prioIdx + count);
return FALSE;
}
for (guint i=0; i<count; ++i)
_textDisp[prioIdx + i] = state;
return TRUE;
}
int S52_MP_getTextDisp(unsigned int prioIdx)
{
if (prioIdx < TEXT_IDX_MAX)
return _textDisp[prioIdx];
else
return -1;
}