forked from sduclos/S52
-
Notifications
You must be signed in to change notification settings - Fork 0
/
S52.h
1086 lines (950 loc) · 37.3 KB
/
S52.h
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
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// S52.h: top-level interface to libS52.so
//
// 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/>.
*/
// Summary:
// - def / type / enum
// - call at any time
// - call available fater S52_init()
// - call from main loop / GL context
// -- call for cell un/loaging
// -- call to camera movement
// -- call to PLib state
// -- call for MIO's
// -- call made over DBUS, Socket, WebSocket (_S52.i)
// --- JSON Grammar (see ./test/s52ui)
#ifndef _S52_H_
#define _S52_H_
#ifdef _MINGW
#include <windows.h>
#define DLL __declspec (dllexport)
#define STD __stdcall
#else
#define DLL
#define STD
#endif
#ifdef __cplusplus
// Ruby FFI need to see C when libS52.so is compiled with g++
extern "C" {
#endif
typedef enum S52ObjectType {
S52__META = 0, // meta geo stuff (ex: C_AGGR)
S52_AREAS = 1,
S52_LINES = 2,
S52_POINT = 3,
S52_N_OBJ = 4 // number of object type
} S52ObjectType;
// global parameter for mariners' selection
typedef enum S52MarinerParameter {
S52_MAR_ERROR = 0, //
S52_MAR_SHOW_TEXT = 1, // flags to show text (see S52_setTextDisp() for details) (on/off) [default ON]
S52_MAR_TWO_SHADES = 2, // flag indicating selection of two depth shades (on/off) [default ON]
S52_MAR_SAFETY_CONTOUR = 3, // S52_LINES: selected safety contour (meters) [IMO PS 3.6]
S52_MAR_SAFETY_DEPTH = 4, // S52_POINT: selected safety depth (for sounding color) (meters) [IMO PS 3.7]
S52_MAR_SHALLOW_CONTOUR = 5, // S52_AREAS: selected shallow water contour (meters) (optional) [OFF==S52_MAR_TWO_SHADES]
S52_MAR_DEEP_CONTOUR = 6, // S52_AREAS: selected deepwater contour (meters) (optional)
S52_MAR_SHALLOW_PATTERN = 7, // flag indicating selection of shallow water highlight (on/off)(optional) [default OFF]
S52_MAR_SHIPS_OUTLINE = 8, // flag indicating selection of ship scale symbol (on/off) [IMO PS 8.4]
S52_MAR_DISTANCE_TAGS = 9, // NOT IMPLEMENTED: selected spacing of "distance to run" tags at a route (nm) [default 0.0 - OFF]
S52_MAR_TIME_TAGS = 10, // NOT IMPLEMENTED: selected spacing of time tags at the past track (min)
S52_MAR_FULL_SECTORS = 11, // show full length light sector lines (on/off) [default ON]
S52_MAR_SYMBOLIZED_BND = 12, // symbolized area boundaries (on/off) [default ON]
S52_MAR_SYMPLIFIED_PNT = 13, // simplified point (on/off) [default ON]
S52_MAR_DISP_CATEGORY = 14, // display category (see [1] bellow)
S52_MAR_COLOR_PALETTE = 15, // color palette (0 - DAY_BRIGHT, 1 - DAY_BLACKBACK, 2 - DAY_WHITEBACK, 3 - DUSK, 4 - NIGHT)
// (call S52_getPalettesNameList() to get the current palette list
S52_MAR_VECPER = 16, // vecper: OWNSHP & VESSEL: Vector-length time-period (min) (normaly 6 or 12)
S52_MAR_VECMRK = 17, // vecmrk: OWNSHP & VESSEL: Vector time-mark interval (0 - none, 1 - 1&6 min, 2 - 6 min)
S52_MAR_VECSTB = 18, // vecstb: OWNSHP : Vector Stabilization (0 - none, 1 - ground, 2 - water)
S52_MAR_HEADNG_LINE = 19, // OWNSHP & VESSEL: show heading line (on/off)
S52_MAR_BEAM_BRG_NM = 20, // OWNSHP : beam bearing length (nm) (0 - off)
//---- experimental variables ----
S52_MAR_FONT_SOUNDG = 21, // NOT IMPLEMENTED: use font for sounding (on/off)
S52_MAR_DATUM_OFFSET = 22, // value of chart datum offset. FIXME: 2 datum: sounding / vertical (ex bridge clearance)
S52_MAR_SCAMIN = 23, // flag for using SCAMIN filter (on/off) (default ON)
S52_MAR_ANTIALIAS = 24, // flag for color blending (anti-aliasing) (on/off)
S52_MAR_QUAPNT01 = 25, // display QUAPNT01 (quality of position symbol) (on/off) (default on)
S52_MAR_DISP_OVERLAP = 26, // display cells, overlapping layer (debug)
S52_MAR_DISP_LAYER_LAST = 27, // enable S52_drawLast (see [1] bellow)
S52_MAR_ROT_BUOY_LIGHT = 28, // rotate buoy light (deg from north)
S52_MAR_DISP_CRSR_PICK = 29, // 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)
// those 3 are in S52 specs
S52_MAR_DISP_GRATICULE = 30, // display graticule (on/off)
S52_MAR_DISP_WHOLIN = 31, // wholin auto placement: 0 - off, 1 - wholin, 2 - arc, 3 - wholin + arc (default off)
S52_MAR_DISP_LEGEND = 32, // display legend (on/off) (default off)
S52_CMD_WRD_FILTER = 33, // toggle command word filter mask for profiling (see [3] bellow)
S52_MAR_DOTPITCH_MM_X = 34, // dotpitch X (mm) - pixel size in X
S52_MAR_DOTPITCH_MM_Y = 35, // dotpitch Y (mm) - pixel size in Y
// in S52 specs
S52_MAR_DISP_CALIB = 36, // display calibration symbol (on/off) (default off)
S52_MAR_DISP_DRGARE_PATTERN = 37, // display DRGARE pattern (on/off) (default on)
S52_MAR_DISP_NODATA_LAYER = 38, // display NODATA layer 0 (on/off) (default on)
S52_MAR_DISP_VESSEL_DELAY = 39, // time delay (sec) defore deleting old AIS (default 0 - OFF)
S52_MAR_DISP_AFTERGLOW = 40, // display synthetic afterglow (in PLAUX_00.DAI) for OWNSHP & VESSEL (on/off)
S52_MAR_DISP_CENTROIDS = 41, // display all centered symb of one area (on/off) (default off)
S52_MAR_DISP_WORLD = 42, // display World - TM_WORLD_BORDERS_SIMPL-0.2.shp - (on/off) (default off)
S52_MAR_DISP_RND_LN_END = 43, // display rounded line segment ending (on/off)
S52_MAR_DISP_VRMEBL_LABEL = 44, // display bearing / range label on VRMEBL (on/off)
S52_MAR_DISP_RADAR_LAYER = 45, // display Raster: RADAR, Bathy, ... (on/off) (default off)
// FIXME: DISP TEXT SHADOW - 0-7 bit: N NE E SE S SW W NW, 0 - off
S52_MAR_GUARDZONE_BEAM = 46, // Danger/Indication Highlight used by LEGLIN&Position (meters) [0.0 - off]
S52_MAR_GUARDZONE_LENGTH = 47, // Danger/Indication Highlight used by Position (meters, user computed from speed/time or distance)
S52_MAR_GUARDZONE_ALARM = 48, // FIXME: 1&2 ON at the same time. 0 - no error, 1 - alarm, 2 - indication
// -1 - display highlight
S52_MAR_DISP_HODATA = 49, // 0 - union HO data limit "m_covr"(default), 1 - all HO data limit (M_COVR+m_covr)
S52_MAR_NUM = 50 // number of parameters
} S52MarinerParameter;
// [3] debug - command word filter for profiling
typedef enum S52_CMD_WRD_FILTER_t {
S52_CMD_WRD_FILTER_SY = 1 << 0, // 0x000001 - SY
S52_CMD_WRD_FILTER_LS = 1 << 1, // 0x000010 - LS
S52_CMD_WRD_FILTER_LC = 1 << 2, // 0x000100 - LC
S52_CMD_WRD_FILTER_AC = 1 << 3, // 0x001000 - AC
S52_CMD_WRD_FILTER_AP = 1 << 4, // 0x010000 - AP
S52_CMD_WRD_FILTER_TX = 1 << 5 // 0x100000 - TE & TX
} S52_CMD_WRD_FILTER_t;
// [1] S52_MAR_DISP_CATEGORY / S52_MAR_DISP_LAYER_LAST
// 0x0000000 - DISPLAYBASE: only objects of the DISPLAYBASE category are shown (always ON)
// 0x0000001 - STANDARD: only objects of the categorys DISPLAYBASE and STANDARD are shown (default)
// 0x0000010 - OTHER: only objects of the categorys DISPLAYBASE and OTHER are shown
// 0x0000100 - SELECT: initialy all objects are show (DISPLAYBASE + STANDARD + OHTER.) (see [2])
// 0x0001000 - MARINERS' NONE: - when set, a call to S52_drawLast() output nothing
// 0x0010000 - MARINERS' STANDARD: - (default!)
// 0x0100000 - MARINERS' OTHER: -
// 0x1000000 - MARINERS' SELECT: - (see [2])
// [2] the display/supression of objects on STANDARD and/or OHTER is set via S52_setS57ObjClassSupp()
typedef enum S52_MAR_DISP_CATEGORY_t {
S52_MAR_DISP_CATEGORY_BASE = 0, // 0x0000000 - DISPLAY BASE
S52_MAR_DISP_CATEGORY_STD = 1 << 0, // 0x0000001 - STANDARD
S52_MAR_DISP_CATEGORY_OTHER = 1 << 1, // 0x0000010 - OTHER
S52_MAR_DISP_CATEGORY_SELECT = 1 << 2, // 0x0000100 - SELECT
//S52_MAR_DISP_LAYER_LAST - MARINERS' CATEGORY (drawn on top - last)
S52_MAR_DISP_LAYER_LAST_NONE = 1 << 3, // 0x0001000 - MARINERS' NONE
S52_MAR_DISP_LAYER_LAST_STD = 1 << 4, // 0x0010000 - MARINERS' STANDARD
S52_MAR_DISP_LAYER_LAST_OTHER = 1 << 5, // 0x0100000 - MARINERS' OTHER
S52_MAR_DISP_LAYER_LAST_SELECT = 1 << 6 // 0x1000000 - MARINERS' SELECT
} S52_MAR_DISP_CATEGORY_t;
/**
* S52_version:
*
* Internal Version.
*
*
* Return: (transfer none): String with the version of libS52 and the '#define' used to build it
*/
#define S52_VERSION "libS52-2016MAY26-1.179"
DLL const char * STD S52_version(void);
/**
* S52_getMarinerParam:
* @paramID: (in): ID of Mariners' Parameter
*
* Get the value of the Mariners' Parameter @paramID (global variables/system wide)
*
* Invalid @paramID will return the value of S52_MAR_ERROR
*
*
* Return: value
*/
DLL double STD S52_getMarinerParam(S52MarinerParameter paramID);
/**
* S52_setMarinerParam:
* @paramID: (in): ID of Mariners' Parameter
* @val: (in): value
*
* Note: S52_MAR_DISP_CATEGORY, S52_MAR_DISP_LAYER_LAST, S52_CMD_WRD_FILTER,
* XOR the value of the global variables @paramID
*
*
* Return: TRUE on success, else FALSE
*/
DLL int STD S52_setMarinerParam(S52MarinerParameter paramID, double val);
/**
* S52_setTextDisp:
* @dispPrioIdx: (in): display priority index (0..99)
* @count: (in): count
* @state: (in): display state (TRUE/FALSE)
*
* Set text @state display priority starting from @dispPrioIdx
* to @count index.
*
* 75 - OWNSHP label
* 76 - VESSEL label
*
* Return: TRUE on success, else FALSE
*/
DLL int STD S52_setTextDisp(unsigned int dispPrioIdx, unsigned int count, unsigned int state);
/**
* S52_getTextDisp:
* @dispPrioIdx: (in): display priority index (0..99)
*
* Get the @state of text display priority at @dispPrioIdx
*
*
* Return: state, TRUE / FALSE / -1 (fail)
*/
DLL int STD S52_getTextDisp(unsigned int dispPrioIdx);
/**
* S52_setEGLcb: register callback use by draw(), drawLast(), drawStr() and drawBlit()
* @eglBeg: (in): callback to EGL begin (makecurrent)
* @eglBeg: (in): callback to EGL end (swap)
* @EGLctx: (in): EGL context (user_data)
*
*
* Return: TRUE on success, else FALSE
*/
typedef int (*S52_EGL_cb)(void *EGLctx, const char *tag);
DLL int STD S52_setEGLCallBack(S52_EGL_cb eglBeg, S52_EGL_cb eglEnd, void *EGLctx);
/**
* S52_setRADARCallBack:
* @cb: (scope call) (allow-none):
* @texRadius: (in): texture radius (pixels), if 0 free cb
*
* S52_RADAR_cb: return alpha texture data
* @cLat: (in): center latitude (deg)
* @cLng: (in): center longitude (deg)
* @rNM : (in): radar range (NM)
*
* Signal that libS52 is at RADAR layer in the layer's sequence in S52_draw()
* (compile with S52_USE_RADAR)
*
*
* Return: TRUE on success, else FALSE
*/
typedef unsigned char * (*S52_RADAR_cb)(double *cLat, double *cLng, double *rNM);
DLL int STD S52_setRADARCallBack(S52_RADAR_cb cb, unsigned int textureRadiusPX);
//
//----- All call bellow need S52_init() first ----------------
//
//----- need a GL context / config event (main loop) --------
/**
* S52_draw:
*
* Draw S57 object (cell) on layer 0-8
*
* Note: call will fail if no ENC loaded (via S52_loadCell)
* Note: Interrupt 2 (ANSI) - user press Ctrl-C to stop long running process
*
* WARNING: At startup, this call must be the very first draw call to set projection
*
*
* Return: TRUE on success, else FALSE
*/
DLL int STD S52_draw(void);
/**
* S52_drawLast:
*
* Draw layer 9 (last) stuff that change all the time (ex AIS)
* fast update
*
* Note: call will fail if no ENC loaded (via S52_loadCell)
* Note: Interrupt 2 (ANSI) - user press Ctrl-C to stop long running process
*
*
* Return: TRUE on success, else FALSE
*/
DLL int STD S52_drawLast(void);
// deprecated
DLL int STD S52_drawLayer(const char *name);
/**
* S52_drawStr:
* @pixels_x: (in): origin LL corner
* @pixels_y: (in): origin LL corner
* @colorName: (in): S52 UI color name
* @bsize: (in): body size (1..)
* @str: (in):
*
* For reference S52 UI color name:
* "UINFD", "UINFF", "UIBCK", "UIAFD",
* "UINFR", "UINFG", "UINFO", "UINFB",
* "UINFM", "UIBDR", "UIAFF"
*
* Note: client must register EGL callback via S52_setEGLcb()
* to handle the framebuffer (or handle FB by hand)
*
* Note: call will fail if no ENC loaded (via S52_loadCell)
*
*
* Return: TRUE on success, else FALSE
*/
DLL int STD S52_drawStr(double pixels_x, double pixels_y, const char *colorName, unsigned int bsize, const char *str);
/**
* S52_drawBlit: Blitting
* @scale_x: (in): -1.0 .. 0.0 .. +1.0
* @scale_y: (in): -1.0 .. 0.0 .. +1.0
* @scale_z: (in): -1.0 .. 0.0 .. +1.0
* @north: (in): [0.0 .. 360.0[ (<0 or >=360 unchage)
*
* Note: call will fail if no ENC loaded (via S52_loadCell)
*
*
* Return: TRUE on success, else FALSE
*/
DLL int STD S52_drawBlit(double scale_x, double scale_y, double scale_z, double north);
/**
* S52_pickAt: Cursor pick
* @pixels_x: (in): origin LL corner
* @pixels_y: (in): origin LL corner
*
*
* NOTE:
* - in the next frame, the object is drawn with the "DNGHL" color (experimental))
* - using 'double' instead of 'unsigned int' because X11 handle mouse in 'double'.
*
* Note: call will fail if no ENC loaded (via S52_loadCell)
*
*
* Return: (transfer none): string '<name>:<S57ID>' or if relationship existe
* '<name>:<S57ID>:<relationS57IDa>,<S57IDa>,...:<relationS57IDb>,<S57IDb>,...'
* of the S57 object, else NULL
*/
DLL const char * STD S52_pickAt(double pixels_x, double pixels_y);
//----- NO GL context (can work outside main loop) ----------
// --- Helper ---
/**
* S52_xy2LL:
* @pixels_x: (inout): origin LL corner (return longitude)
* @pixels_y: (inout): origin LL corner (return latitude)
*
* Convert pixel X/Y to longitude/latitude (deg)
*
* Note: call will fail if no ENC loaded (via S52_loadCell)
*
*
* Return: TRUE on success, else FALSE
*/
DLL int STD S52_xy2LL(double *pixels_x, double *pixels_y);
/**
* S52_LL2xy:
* @longitude: (inout): degree (return X)
* @latitude: (inout): degree (return Y)
*
* Convert longitude/latitude to X/Y (pixel - origin LL corner)
*
* Note: call will fail if no ENC loaded (via S52_loadCell)
*
*
* Return: TRUE on success, else FALSE
*/
DLL int STD S52_LL2xy(double *longitude, double *latitude);
// --------------
/**
* S52_init:
* @screen_pixels_w: (in): use to compute DOTPITCH_X (px)
* @screen_pixels_h: (in): use to compute DOTPITCH_Y (px)
* @screen_mm_w: (in): use to compute DOTPITCH_X (mm)
* @screen_mm_h: (in): use to compute DOTPITCH_Y (mm)
* @log_cb: (scope call) (allow-none): log callback
*
* Initialize libS52, install SIGINT handler to abort drawing (Ctrl-C)
* xrandr can be used if framework doesn't do it (ie Clutter)
*
* Note: the ratio screen mmw/w and screen mm_h/h is used to compute initial DOTPITCH,
* overide with S52_MAR_DOTPITCH_MM_X/Y after init().
*
* Note: screen_pixels_w, int screen_pixels_h are used to setViewPort to full-screen
*
*
* Return: TRUE on success, else FALSE
*/
typedef int (*S52_log_cb)(const char *str);
DLL int STD S52_init(int screen_pixels_w, int screen_pixels_h, int screen_mm_w, int screen_mm_h, S52_log_cb log_cb);
/**
* S52_done:
*
* Free up all ressources
*
*
* Return: TRUE on success, else FALSE
*/
DLL int STD S52_done(void);
// ---- CHART LOADING (cell) -------------------------------------------
//
// callback for each layer to add app. specific stuff
// callback: S52_loadCell() --> S52_loadLayer() --> S52_loadObject()
// -OR-
// callback: S52_loadCell() --> S52_loadObject()
// Note: objects of a layer have the same name as the layer's name
//
/**
* S52_loadObject:
* @objname: (in): name of S57 object (same as layer name)
* @feature: (in): S57 object feature passed from GDAL/OGR
*
* Can be called more than once (in theorie)
*
*
* Return: TRUE on success, else FALSE
*/
int S52_loadObject(const char *objname, /* OGRFeatureH */ void *feature);
/**
* S52_loadObject_cb:
* @objname: (in): name of S57 object (same as layer name)
* @feature: (in): S57 object feature passed from GDAL/OGR (OGRFeatureH)
*
* This callback provide a way to manipulate each S57 object before
* they are inserted into the scenegraph (via S52_loadObject())
*
*
* Return: TRUE on success, else FALSE
*/
typedef int (*S52_loadObject_cb)(const char *objname, /* OGRFeatureH */ void *feature);
/**
* S52_loadCell:
* @encPath: (allow-none):
* @loadObject_cb: (allow-none) (scope call):
*
* if @encPath is NULL look for label 'CHART' in s52.cfg
* if @encPath is a path load all S57 base cell + update
* if @loadObject_cb is NULL then S52_loadObject() is executed
*
* Note: the first call to S52_loadCell() will set the Mercator Projection Latitude
* and Longitude of any futher S52_loadCell() call(s)
* Note: Interrupt 2 (ANSI) - user press Ctrl-C to stop long running process
* (if compiled with S52_USE_SUPP_LINE_OVERLAP and/or S52_USE_C_AGGR_C_ASSO,
* analysis can be expensive in large file)
*
* Return: TRUE on success, else FALSE
*/
DLL int STD S52_loadCell(const char *encPath, S52_loadObject_cb loadObject_cb);
/**
* S52_doneCell:
* @encPath: (in):
*
* Free up all ressources used by @encPath
*
*
* Return: TRUE on success, else FALSE
*/
DLL int STD S52_doneCell (const char *encPath);
// ---- CHART LOADING (cell) -------------------------------------------
/**
* S52_setViewPort:
* @pixels_x: (in): origine LL corner
* @pixels_y: (in): origine LL corner
* @pixels_width: (in): viewport width in pixels
* @pixels_height: (in): viewport height in pixels
*
* Call this if viewPort change (ex: going full screen)
* From WebGL (OpenGL ES 2.0) spec:
* Rationale: automatically setting the viewport will interfere with applications
* that set it manually. Applications are expected to use onresize handlers to
* respond to changes in size of the canvas and set the OpenGL viewport in turn.
*
* Use this call in conjuction with S52_setView() and S52_draw() to setup a magnifying glass
* or an overview
*
*
* Return: TRUE on success, else FALSE
*/
DLL int STD S52_setViewPort(int pixels_x, int pixels_y, int pixels_width, int pixels_height);
/**
* S52_setView:
* @cLat: (in): latitude of the center of the view (deg) [- 90 .. + 90]
* @cLon: (in): longitude of the center of the view (deg) [-180 .. +180]
* @rNM: (in): range (radius of view (NM), <0 unchange
* @north: (in): angle from north (deg), <0 unchange
*
* Set center of view / where to place the camera on model
*
*
* Return: TRUE on success, else FALSE
*/
DLL int STD S52_setView(double cLat, double cLon, double rNM, double north);
/**
* S52_getView:
* @cLat: (out) (transfer full): latitude of the center of the view (deg) [- 90 .. + 90]
* @cLon: (out) (transfer full): longitude of the center of the view (deg) [-180 .. +180]
* @rNM: (out) (transfer full): range (radius of view (NM), <0 unchange
* @north: (out) (transfer full): angle from north (deg), <0 unchange
*
* Get center of view / where is the camera on model
*
*
* Return: TRUE on success, else FALSE
*/
DLL int STD S52_getView(double *cLat, double *cLon, double *rNM, double *north);
/**
* S52_getCellExtent:
* @filename: (in) (allow-none) :
* @S: (out) (transfer full): latitude (deg)
* @W: (out) (transfer full): longitude (deg)
* @N: (out) (transfer full): latitude (deg)
* @E: (out) (transfer full): longitude (deg)
*
* Cell extent; South, West, North, East
* if @filename is NULL then return the extent of all cells loaded
*
*
* Return: TRUE on success, else FALSE
*/
DLL int STD S52_getCellExtent(const char *filename, double *S, double *W, double *N, double *E);
/**
* S52_getS57ObjClassSupp:
* @className: (in): name of the classe of S57 object
*
* get Object class suppression state
*
*
* Return: TRUE if suppression is ON else FALSE, error -1 (DISPLAYBASE or invalid className)
*/
DLL int STD S52_getS57ObjClassSupp(const char *className);
/**
* S52_setS57ObjClassSupp:
* @className: (in): name of the S57 classe
* @value: (in): TRUE / FALSE
*
* set suppression (TRUE/FALSE) from display of all Objects of the S57 class @className
*
* NOTE: S52_MAR_DISP_CATEGORY must be set to SELECT.
*
*
* Return: TRUE if call successfull to set new value else FALSE, error -1 (DISPLAYBASE or invalid className)
*/
DLL int STD S52_setS57ObjClassSupp(const char *className, int value);
/**
* S52_loadPLib:
* @plibName: (allow-none): name or path+name
*
* If @plibName is NULL look for label 'PLIB' in s52.cfg
*
*
* Return: TRUE on success, else FALSE
*/
DLL int STD S52_loadPLib(const char *plibName);
/**
* S52_getPLibNameList:
*
* List of PLib name loaded delimited by ','
*
*
* Return: (transfer none): string
*/
DLL const char * STD S52_getPLibNameList(void);
/**
* S52_getPalettesNameList:
*
* List of palettes name loaded separated by ','.
* Note: use S52_MAR_COLOR_PALETTE, as an index, to select one of them.
*
*
* Return: (transfer none): NULL if call fail
*/
DLL const char * STD S52_getPalettesNameList(void);
/**
* S52_getCellNameList:
*
* List of cells name loaded
*
*
* Return: (transfer none): NULL if call fail
*/
DLL const char * STD S52_getCellNameList(void);
/**
* S52_getS57ClassList: get list of all S57 class in a cell
* @cellName: (in) (allow-none): cell name
*
* if @cellName is not NULL then return a list of all S57 class
* in the cell @cellName. The first element of the list is the cell's name.
* If @cellName is NULL then all S57 class is return.
*
*
* Return: (transfer none): List of all class name separeted by ',', NULL if call fail
*/
DLL const char * STD S52_getS57ClassList(const char *cellName);
/**
* S52_getObjList: get list of S52 objets of @className in @cellName
* @cellName: (in): cell name (not NULL)
* @className: (in): class name (not NULL)
*
* Return a string list of element separated by ','
* Where the first elementy is the cell name, the second element is the class name
* and the following elements are quadruplet, one for each S52 object
* A quadruplet is made of ::= <S57ID>:<geoType>:<disp cat>:<disp prio>
* <S57ID> ::= number
* <geoType> ::= P|L|A (see S57data.h:S52_Obj_t)
* <disp cat> ::= D|S|O|A|T|P|- (see S52PL.h:S52_DisCat)
* <disp prio> ::= 0|1|2|3|4|5|6|7|8|9
*
*
* Return: (transfer none): string of all element separeted by ',', NULL if call fail
*/
DLL const char * STD S52_getObjList(const char *cellName, const char *className);
/**
* S52_getAttList: get Attributes of a S52 object (S57ID)
* @S57ID: (in) : a S52 object has a unique S57ID
*
* Where the first element is the '<ObjName>:<S57ID>' folowed by list of '<key>:<value>' pair.
*
*
* Return: (transfer none): string of all element separeted by ',', NULL if call fail
*/
DLL const char * STD S52_getAttList(unsigned int S57ID);
/**
* S52_setRGB:
* @colorName: (in): S52 color name
* @R: (in): red, [0..255]
* @G: (in): green, [0..255]
* @B: (in): blue, [0..255]
*
* Overright the current RGB for @colorName of current palette
*
*
* Return: TRUE on success, else FALSE
*/
DLL int STD S52_setRGB(const char *colorName, unsigned char R, unsigned char G, unsigned char B);
/**
* S52_getRGB:
* @colorName: (in) : S52 color name
* @R: (out) (transfer full): red, [0..255]
* @G: (out) (transfer full): green, [0..255]
* @B: (out) (transfer full): blue, [0..255]
*
*
* Return: TRUE on success, else FALSE
*/
DLL int STD S52_getRGB(const char *colorName, unsigned char *R, unsigned char *G, unsigned char *B);
/**
* S52_dumpS57IDPixels: DEBUG dump region of framebuffer to .PNG
* @toFilename: (in): PNG file (with full path) to dump pixels to
* @S57ID: (in): internal ID of object (return via S52_getObjList() or S52_pickAt())
* @width: (in): width of dump in pixels (max viewport width)
* @height: (in): height of dump in pixels (max viewport height)
*
* Dump (@width x @height) pixels to PNG @toFilename centered on @S57ID of the current framebuffer
* Note: changing the size of the viewport require a call to draw() before this call
* (ie size of framebuffer must be in sync with the size of the viewport).
*
* If @S57ID is zero (0) then the whole framebuffer is dumped (ie @width and @height are ignore).
*
* Note: use glReadPixels() instead to get raw pixles.
*
* Note: call will fail if no ENC loaded (via S52_loadCell)
*
*
* Return: TRUE on success, else FALSE
*/
DLL int STD S52_dumpS57IDPixels(const char *toFilename, unsigned int S57ID, unsigned int width, unsigned int height);
///////////////////////////////////////////////////////////////
//
// Mariners' Object (ownshp, vessel, legline & stuff like that)
//
//
// --- all the Mariners' Objects that are 'known' in S52raz-3.2.rle ----
//
// Note: number in () indicate the S52 layer
//
// AREA : dnghlt (8), marfea (8), mnufea (5)
// LINE : clrlin (9), ebline (9), leglin (8), marfea (8), mnufea (5),
// pastrk (3), poslin (3), rngrng (9), vrmark (9), wholin (8)
// POINT: cursor (8), dnghlt (8), events (8), marfea (8), marnot (8),
// mnufea (5), ownshp (9), plnpos (5), positn (5), refpnt (7),
// tidcur (7), vessel (9), waypnt (8)
// NOTE: Mariners' Object *not* on layer 9
// need a call to S52_draw() to be drawn
/**
* S52ObjectHandle:
*
* Type used for storing references to S52 objects, the S52ObjectHandle
* is a fully opaque type without any public data members.
*/
typedef unsigned int S52ObjectHandle; // guint S75ID
// ---- Basic Call (all other S52_new*() call are a specialisation of this one) ----
/**
* S52_newMarObj:
* @plibObjName: (in) (type gchar*):
* @objType: (in): S52ObjectType
* @xyznbrmax: (in): maximum number of xyz (point)(see S52_pushPosition()) (one or more)
* @xyz: (in) (type gpointer):
* @listAttVal: (in) (type gchar*): format: "att1:val1,att2:val2,..."
* OR "[att1,val1,att2,al2,...]" (JSON array)
*
* Create new S52_obj - Basic Call.
* All other call of the form S52_new*() are a specialisation of this one.
*
* NOTE: LIFO stack so 'cursor' should be created first to be drawn on top.
*
* In 'listAttVal', in S52 attribute name (ex: att1) of 6 lower case letters are reserve
* for Mariners' Object. Lower case attribute name starting with an unserscore ('_')
* are reserve for internal libS52 use.
*
* Note: call will fail if no ENC loaded (via S52_loadCell)
*
*
* Return: @S52ObjectHandle of the new S52_obj or FALSE if call fail
*/
DLL S52ObjectHandle STD S52_newMarObj(const char *plibObjName, S52ObjectType objType,
unsigned int xyznbrmax, double *xyz, const char *listAttVal);
/**
* S52_delMarObj:
* @objH: (in) (transfer none): addressed S52ObjectHandle
*
* Delete ressources in libS52 for this S52_obj.
*
*
* Return: NULL if S52_obj was deleted successfully, if call fail return @S52ObjectHandle
*/
DLL S52ObjectHandle STD S52_delMarObj(S52ObjectHandle objH);
/**
* S52_getMarObj : get Mariners' Object handle
* @S57ID: (in) : a S52 object internal S57ID
*
* get the handle of a Mariners' Object from is internal S57ID
* (return via S52_pickAt())
*
*
* Return: @S52ObjectHandle of the adressed S52_obj or FALSE if call fail
*/
DLL S52ObjectHandle STD S52_getMarObj(unsigned int S57ID);
/**
* S52_toggleDispMarObj:
* @objH: (in) (transfer none): addressed S52ObjectHandle
*
* Initially Mariners' Object are ON (ie display of object NOT suppressed)
* FIXME: maybe add toggleDispMarObj ON / OFF for clarity as toggleObjClass..
*
*
* Return: @S52ObjectHandle of the adressed S52_obj or FALSE if call fail
*/
DLL S52ObjectHandle STD S52_toggleDispMarObj(S52ObjectHandle objH);
// ---- Mariners' Objects that call the Conditional Symbology (CS) code ----
// CLRLIN:
// LEGLIN:
// OWNSHP:
// PASTRK:
// VESSEL:
// VRMEBL:
/**
* S52_newCLRLIN:
* @catclr: (in): 0 - undefined, 1 - NMT (not more than), 2 - NLT (not less than)
* @latBegin: (in): lat of LEGLIN beginning (degdecimal)
* @lonBegin: (in): lon of LEGLIN beginning (degdecimal)
* @latEnd: (in): lat of LEGLIN ending (degdecimal)
* @lonEnd: (in): lon of LEGLIN ending (degdecimal)
*
* new S52_obj "Clearing Line"
* 'clrlin': CS(CLRLIN--)
*
*
* Return: @S52ObjectHandle of the new S52_obj or FALSE if call fail
*/
DLL S52ObjectHandle STD S52_newCLRLIN(int catclr, double latBegin, double lonBegin, double latEnd, double lonEnd);
/**
* S52_newLEGLIN:
* @select: (in): Selection: 1 - planned, 2 - alternate
* @plnspd: (in): planned speed (0.0 for no speed label)
* @wholinDist: (in): distance of the 'wholin' (wheel-over-line) from End in NM
* @latBegin: (in): lat of LEGLIN beginning (degdecimal)
* @lonBegin: (in): lon of LEGLIN beginning (degdecimal)
* @latEnd: (in): lat of LEGLIN ending (degdecimal)
* @lonEnd: (in): lon of LEGLIN ending (degdecimal)
* @previousLEGLIN: (allow-none): handle to the previous LEGLIN, used to draw 'wholin' and/or curve
*
* new S52_obj "Leg Line" segment
* 'leglin': CS(LEGLIN--)
*
*
* Return: @S52ObjectHandle of the new S52_obj or FALSE if call fail
*/
DLL S52ObjectHandle STD S52_newLEGLIN(int select, double plnspd, double wholinDist,
double latBegin, double lonBegin, double latEnd, double lonEnd,
S52ObjectHandle previousLEGLIN);
/**
* S52_newOWNSHP:
* @label: (in) (allow-none): for example Ship's name or MMSI or NULL
*
* new S52_obj "Own Ship"
* 'ownshp': CS(OWNSHP--)
* Note: if OWNSHP has allready been created then an other call will
* return the handle of the first OWNSHIP call.
* Note: text priority of @label is 75
*
*
* Return: @S52ObjectHandle of the new S52_obj or FALSE if call fail
*/
DLL S52ObjectHandle STD S52_newOWNSHP(const char *label);
// --- Vector, Dimension, ... of OWNSHP and VESSEL object -------------------
/**
* S52_setDimension:
* @objH: (in) (transfer none): addressed S52ObjectHandle
* @a: (in): dist form foward
* @b: (in): dist from aft (a + b = length)
* @c: (in): dist from port
* @d: (in): dist from starboard (c + d = beam)
*
* conning position - for AIS this is the antenna position
*
*
* Return: @S52ObjectHandle of the adressed S52_obj or FALSE if call fail
*/
DLL S52ObjectHandle STD S52_setDimension(S52ObjectHandle objH, double a, double b, double c, double d);
/**
* S52_setVector: OWNSHP & VESSEL
* @objH: (in) (transfer none): addressed S52ObjectHandle
* @vecstb: (in): 0 - none, 1 - ground, 2 - water
* @course: (in): (deg)
* @speed: (in): (kt)
*
* Note: @vecstb apply to VESSEL only, use S52_MAR_VECSTB for OWNSHP
*
*
* Return: @S52ObjectHandle of the adressed S52_obj or FALSE if call fail
*/
DLL S52ObjectHandle STD S52_setVector (S52ObjectHandle objH, int vecstb, double course, double speed);
/**
* S52_newPASTRK:
* @catpst: (in): Category of past track: 0 - undefined, 1 - primary, 2 - secondary
* @xyznbrmax: (in): maximum number of PASTRK positon (point) (one or more)
*
* 'pastrk': CS(PASTRK--)
*
*
* Return: @S52ObjectHandle of the new S52_obj or FALSE if call fail
*/
DLL S52ObjectHandle STD S52_newPASTRK(int catpst, unsigned int xyznbrmax);
/**
* S52_pushPosition:
* @objH: (in) (transfer none): addressed S52ObjectHandle
* @latitude: (in):
* @longitude: (in):
* @data: (in):
*
* Push a position on a FIFO stack. The size of the stack is one for object of type S52_POINT.
* For object of type S52_LINES and S52_AREAS the size of the stack is set via 'xyznbrmax'.
* S52_AREAS are expected to have the same first and last point (as any S57 area).
*
* 'data' is used to display time (hh.mm) if the object is PASTRK.
* If the object is VESSEL or OWNSHP then 'data' is the heading.
*
* Note: call will fail if no ENC loaded (via S52_loadCell)
*
*
* Return: @S52ObjectHandle of the adressed S52_obj or FALSE if call fail
*/
DLL S52ObjectHandle STD S52_pushPosition(S52ObjectHandle objH, double latitude, double longitude, double data);
/**
* S52_newVESSEL:
* @vesrce: (in): vessel report source: 1 - ARPA target, 2 - AIS vessel report, 3 - VTS report
* @label: (in) (allow-none): NULL or a string
*
* 'vessel': CS(VESSEL--) ARPA & AIS
* Note: text priority of @label is 76
*
*
* Return: @S52ObjectHandle of the new S52_obj or FALSE if call fail
*/
DLL S52ObjectHandle STD S52_newVESSEL(int vesrce, const char *label);
/**
* S52_setVESSELlabel:
* @objH: (in) (transfer none): addressed S52ObjectHandle
* @newLabel: (in) (allow-none) : NULL or a string
*
* (re) set label
* Note: text priority of @newLabel is 76
*
*
* Return: @S52ObjectHandle of the adressed S52_obj or FALSE if call fail
*/
DLL S52ObjectHandle STD S52_setVESSELlabel(S52ObjectHandle objH, const char *newLabel);
/**
* S52_setVESSELstate:
* @objH: (in) (transfer none): addressed S52ObjectHandle
* @vesselSelect: (in): 0 - undefined, 1 - selected (ON) and follow, 2 - de-seltected (OFF), (ie bracket symbol on vessel),
* @vestat: (in): 0 - undefined, 1 - AIS active, 2 - AIS sleeping, 3 - AIS active, close quarter (red)
* @vesselTurn: (in): Turn rate is encoded as follows: [from gpsd doc]
* 0 - not turning
* 1..126 - turning right at up to 708 degrees per minute or higher
* -1..-126 - turning left at up to 708 degrees per minute or higher
* 127 - turning right at more than 5deg/30s (No TI available)
* -127 - turning left at more than 5deg/30s (No TI available)
* 128 - (80 hex) indicates no turn information available (default)
* 129 - undefined
*
* "undefined" mean that the current value of the variable of this objH is unafected
*
* Note: experimental @vestat = 3, compile with S52_USE_SYM_VESSEL_DNGHL, symb in PLAUX_00
*
*
* Return: @S52ObjectHandle of the adressed S52_obj or FALSE if call fail