-
Notifications
You must be signed in to change notification settings - Fork 28
/
S52MP.c
615 lines (474 loc) · 23.4 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
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
// S52MP.c: Mariner Parameter
//
// Project: OpENCview
/*
This file is part of the OpENCview project, a viewer of ENC.
Copyright (C) 2000-2018 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
*/
// FIXME: add textual name of mariner's parameter
// FIXME: use the X macro to sync: http://www.drdobbs.com/cpp/the-x-macro/228700289
/*
#define COLORS \
X(Cred, "red") \
X(Cblue, "blue") \
X(Cgreen, "green")
// Put this in color.h. Then, in the place where the enum is declared:
#define X(a, b) a,
enum Color { COLORS };
#undef X
// You can see where this is going. In the source file color.c:
#define X(a, b) b,
static char *ColorStrings[] = { COLORS };
#undef X
*/
/* from HN commentor
Or a higher-order macro:
#define CMD_LIST(X) X(1) X(2) X(3) X(4)
enum {
#define CMD(x) CMD##x = x - 1,
CMD_LIST(CMD)
#undef CMD
};
*/
/* so S52 mar par wold look:
#define S52MARPARS \
// # enum symbol enum name default
X(0, S52_MAR_ERROR, "S52_MAR_ERROR", 0.0) \
X(1, S52_MAR_SHOW_TEXT, "S52_MAR_SHOW_TEXT", 1.0) \
X(..)
*/
// WARNING: must be in sync with S52MarinerParameter (see X macro above)
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 (false -> 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 0x000002 OTHER
// S52_MAR_DISP_CATEGORY_SELECT, // 1 << 2 0x000004 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 1:1)
//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 0x0000008 - MARINERS' NONE
S52_MAR_DISP_LAYER_LAST_STD, // 1 << 4 0x0000010 - MARINERS' STANDARD (default)
//S52_MAR_DISP_LAYER_LAST_OTHER, // 1 << 5 0x0000020 - MARINERS' OTHER
//S52_MAR_DISP_LAYER_LAST_SELECT, // 1 << 6 0x0000040 - MARINERS' SELECT (override)
0.0, // 28 - S52_MAR_ROT_BUOY_LIGHT (deg)
1.0, // 29 - S52_MAR_DISP_CRSR_PICK, 0 - off,
// 1 - dump pick/highlight top object (default),
// 2 - dump pick stack/highlight top object,
// 3 - dump 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_UNION, 0 - union HO data limit "m_covr" (default), 1 - all HO data limit (M_COVR+m_covr)
// Note: M_COVR:OTHER, m_covr:BASE
0.0, // 50 - S52_MAR_DISP_SCLBDY_UNION, 0 - union Scale Boundary (default), 1 - all Scale Boundary "sclbdy" (debug)
// Note: sclbdU:STD, sclbdy:STD
51.0 // number of parameter type
};
static double _validate_bool(double val)
{
val = (val==0.0)? 0.0 : 1.0;
//PRINTF("NOTE: toggle to: %s\n", (val==0.0)? "OFF" : "ON");
return val;
}
static double _validate_meter(double val)
{
PRINTF("NOTE: Meter: %f\n", val);
return val;
}
static double _validate_nm(double val)
{
if (val < 0.0) val = -val;
PRINTF("NOTE: Nautical Mile: %f\n", val);
return val;
}
static double _validate_min(double val)
{
if (val < 0.0) {
PRINTF("WARNING: time negatif, reset to 0.0: %f\n", val);
val = 0.0;
}
PRINTF("NOTE: Minute: %f\n", val);
return val;
}
static double _validate_int(double val)
{
int val_int = (int) val;
return (double)val_int;
}
static double _validate_disp(double val)
// Note: allow BASE bit for debugging
{
int crntMask = (int) S52_MP_get(S52_MAR_DISP_CATEGORY);
int newMask = (int) val;
int maxMask =
S52_MAR_DISP_CATEGORY_BASE +
S52_MAR_DISP_CATEGORY_STD +
S52_MAR_DISP_CATEGORY_OTHER +
S52_MAR_DISP_CATEGORY_SELECT;
if (newMask < S52_MAR_DISP_CATEGORY_BASE || newMask > maxMask) {
PRINTF("WARNING: ignoring category value (%i)\n", newMask);
return crntMask;
}
/* FIXME: useless test now !
// check if the newMask has one of possible bit
if (!(0 == newMask) &&
!(S52_MAR_DISP_CATEGORY_BASE & newMask) &&
!(S52_MAR_DISP_CATEGORY_STD & newMask) &&
!(S52_MAR_DISP_CATEGORY_OTHER & newMask) &&
!(S52_MAR_DISP_CATEGORY_SELECT & newMask) ) {
PRINTF("WARNING: ignoring category value (%i)\n", newMask);
g_assert(0);
return crntMask;
}
*/
//PRINTF("DEBUG: Display Priority before: crntMask:0x%x, newMask:0x%x)\n", crntMask, newMask);
if (crntMask & newMask)
crntMask -= newMask;
else
crntMask += newMask;
PRINTF("DEBUG: Display Priority after : crntMask:0x%x, newMask:0x%x)\n", crntMask, newMask);
return (double)crntMask;
}
static double _validate_mar(double val)
// S52_MAR_DISP_LAYER_LAST - MARINERS' CATEGORY (drawn on top - last)
{
int crntMask = (int) S52_MP_get(S52_MAR_DISP_LAYER_LAST);
int newMask = (int) val;
int maxMask =
S52_MAR_DISP_LAYER_LAST_NONE +
S52_MAR_DISP_LAYER_LAST_STD +
S52_MAR_DISP_LAYER_LAST_OTHER +
S52_MAR_DISP_LAYER_LAST_SELECT;
if (newMask < S52_MAR_DISP_LAYER_LAST_NONE || newMask > maxMask) {
PRINTF("WARNING: ignoring mariners' value (%i)\n", newMask);
return crntMask;
}
/* FIXME: useless test now !
if (!(S52_MAR_DISP_LAYER_LAST_NONE & newMask) &&
!(S52_MAR_DISP_LAYER_LAST_STD & newMask) &&
!(S52_MAR_DISP_LAYER_LAST_OTHER & newMask) &&
!(S52_MAR_DISP_LAYER_LAST_SELECT & newMask) ) {
PRINTF("WARNING: ignoring mariners' value (%i)\n", newMask);
g_assert(0);
return crntMask;
}
*/
if (newMask & crntMask) {
crntMask -= newMask;
} else
crntMask += newMask;
return (double)crntMask;
}
static double _validate_deg(double val)
{
// AIS a value of 360 mean heading course unknown
//if (val < 0.0 || 360.0 <= val) {
if (val < 0.0 || 360.0 <= val) {
PRINTF("WARNING: degree out of bound [0.0 .. 360.0[, reset to 0.0: %f\n", val);
val = 0.0;
}
return val;
}
static double _validate_filter(double val)
{
int crntMask = (int) S52_MP_get(S52_CMD_WRD_FILTER);
int newMask = (int) val;
int maxMask =
S52_CMD_WRD_FILTER_SY +
S52_CMD_WRD_FILTER_LS +
S52_CMD_WRD_FILTER_LC +
S52_CMD_WRD_FILTER_AC +
S52_CMD_WRD_FILTER_AP +
S52_CMD_WRD_FILTER_TX;
if (newMask < S52_CMD_WRD_FILTER_SY || newMask > maxMask) {
PRINTF("WARNING: ignoring filter mask (%i)\n", newMask);
return crntMask;
}
if (crntMask & newMask)
crntMask -= newMask;
else
crntMask += newMask;
#ifdef S52_DEBUG
PRINTF("DEBUG: Command Word Filter State:\n");
PRINTF("DEBUG: S52_CMD_WRD_FILTER_SY:%s\n",(S52_CMD_WRD_FILTER_SY & crntMask) ? "TRUE" : "FALSE");
PRINTF("DEBUG: S52_CMD_WRD_FILTER_LS:%s\n",(S52_CMD_WRD_FILTER_LS & crntMask) ? "TRUE" : "FALSE");
PRINTF("DEBUG: S52_CMD_WRD_FILTER_LC:%s\n",(S52_CMD_WRD_FILTER_LC & crntMask) ? "TRUE" : "FALSE");
PRINTF("DEBUG: S52_CMD_WRD_FILTER_AC:%s\n",(S52_CMD_WRD_FILTER_AC & crntMask) ? "TRUE" : "FALSE");
PRINTF("DEBUG: S52_CMD_WRD_FILTER_AP:%s\n",(S52_CMD_WRD_FILTER_AP & crntMask) ? "TRUE" : "FALSE");
#endif
return (double)crntMask;
}
static double _validate_positive(double val)
{
if (val < 0.0) {
val = -val;
PRINTF("WARNING: sign change: %f\n", val);
}
return val;
}
static int _fixme(S52MarinerParameter paramName)
{
PRINTF("FIXME: S52MarinerParameter %i not implemented\n", paramName);
return TRUE;
}
double S52_MP_get(S52MarinerParameter paramID)
// 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<=paramID && paramID<S52_MAR_NUM) {
return _MARparamVal[paramID];
} else {
PRINTF("WARNING: param invalid(%f)\n", paramID);
g_assert(0);
return _MARparamVal[S52_MAR_ERROR];
}
}
int S52_MP_set(S52MarinerParameter paramID, double val)
{
switch (paramID) {
case S52_MAR_ERROR : break;
case S52_MAR_SHOW_TEXT : val = _validate_bool(val); break;
// _SEABED01->DEPARE01;
case S52_MAR_TWO_SHADES : val = _validate_bool(val); break;
// DEPCNT02; _SEABED01->DEPARE01; _UDWHAZ03->OBSTRN04, WRECKS02;
case S52_MAR_SAFETY_CONTOUR : val = _validate_meter(val); break;
// _SNDFRM02->OBSTRN04, WRECKS02;
case S52_MAR_SAFETY_DEPTH : val = _validate_meter(val); break;
// _SEABED01->DEPARE01;
case S52_MAR_SHALLOW_CONTOUR : val = _validate_meter(val); break;
// _SEABED01->DEPARE01;
case S52_MAR_DEEP_CONTOUR : val = _validate_meter(val); break;
// _SEABED01->DEPARE01;
case S52_MAR_SHALLOW_PATTERN : val = _validate_bool(val); break;
case S52_MAR_SHIPS_OUTLINE : val = _validate_bool(val); break;
case S52_MAR_DISTANCE_TAGS : val = _validate_nm(val); _fixme(paramID); break;
case S52_MAR_TIME_TAGS : val = _validate_min(val); _fixme(paramID); break;
case S52_MAR_FULL_SECTORS : val = _validate_bool(val); break;
// RESARE02;
case S52_MAR_SYMBOLIZED_BND : val = _validate_bool(val); break;
case S52_MAR_SYMPLIFIED_PNT : val = _validate_bool(val); break;
case S52_MAR_DISP_CATEGORY : val = _validate_disp(val); break;
case S52_MAR_VECPER : val = _validate_min(val); break;
case S52_MAR_VECMRK : val = _validate_int(val); break;
case S52_MAR_VECSTB : val = _validate_int(val); break;
case S52_MAR_HEADNG_LINE : val = _validate_bool(val); break;
case S52_MAR_BEAM_BRG_NM : val = _validate_nm(val); break;
//case S52_MAR_DISP_GRATICULE : val = _validate_bool(val); break;
case S52_MAR_DISP_GRATICULE : val = _validate_positive(val); break;
case S52_MAR_DISP_WHOLIN : val = _validate_int(val); break;
case S52_MAR_DISP_LEGEND : val = _validate_bool(val); break;
case S52_MAR_DISP_CALIB : val = _validate_bool(val); break;
//
//---- experimental variables / debug ----
//
case S52_MAR_FONT_SOUNDG : val = _fixme(val); break;
// DEPARE01; DEPCNT02; _DEPVAL01; SLCONS03; _UDWHAZ03;
case S52_MAR_DATUM_OFFSET : val = _validate_meter(val); break;
//case S52_MAR_SCAMIN : val = _validate_bool(val); break;
case S52_MAR_SCAMIN : val = _validate_positive(val); break;
case S52_MAR_ANTIALIAS : val = _validate_bool(val); break;
case S52_MAR_QUAPNT01 : val = _validate_bool(val); break;
case S52_MAR_DISP_OVERLAP : val = _validate_bool(val); break;
case S52_MAR_DISP_LAYER_LAST : val = _validate_mar (val); break;
case S52_MAR_ROT_BUOY_LIGHT : val = _validate_deg(val); break;
case S52_MAR_DISP_CRSR_PICK : val = _validate_int(val); break;
case S52_MAR_DOTPITCH_MM_X : val = _validate_positive(val); break;
case S52_MAR_DOTPITCH_MM_Y : val = _validate_positive(val); break;
case S52_MAR_DISP_DRGARE_PATTERN : val = _validate_bool(val); break;
case S52_MAR_DISP_NODATA_LAYER : val = _validate_bool(val); break;
case S52_MAR_DISP_VESSEL_DELAY : val = _validate_int (val); break;
case S52_MAR_DISP_AFTERGLOW : val = _validate_bool(val); break;
//case S52_MAR_DISP_CENTROIDS : val = _validate_bool(val); break;
case S52_MAR_DISP_CENTROIDS : val = _validate_int (val); break;
case S52_MAR_DISP_WORLD : val = _validate_bool(val); break;
case S52_MAR_DISP_RND_LN_END : val = _validate_bool(val); break;
case S52_MAR_DISP_VRMEBL_LABEL : val = _validate_bool(val); break;
case S52_MAR_DISP_RADAR_LAYER : val = _validate_bool(val); break;
case S52_CMD_WRD_FILTER : val = _validate_filter(val); break;
case S52_MAR_GUARDZONE_BEAM : val = _validate_positive(val); break;
case S52_MAR_GUARDZONE_LENGTH : val = _validate_positive(val); break;
case S52_MAR_GUARDZONE_ALARM : val = _validate_int (val); break;
case S52_MAR_DISP_HODATA_UNION : val = _validate_bool(val); break;
case S52_MAR_DISP_SCLBDY_UNION : val = _validate_bool(val); break;
// allready check
default: break;
}
if (S52_MAR_ERROR<=paramID && paramID<S52_MAR_NUM) {
_MARparamVal[paramID] = val;
return TRUE;
} else {
PRINTF("WARNING: param invalid(%f)\n", paramID);
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)
{
state = _validate_bool(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 (TEXT_IDX_MAX < prioIdx+count) {
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;
}