forked from GPSBabel/gpsbabel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dmtlog.cc
865 lines (701 loc) · 17.3 KB
/
dmtlog.cc
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
/*
Support for TrackLogs digital mapping (.trl) files,
Copyright (C) 2006,2007 Olaf Klein, [email protected]
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 2 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, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA
*/
#include <QtCore/QXmlStreamAttributes>
#include "defs.h"
#include "jeeps/gpsmath.h"
#include "xmlgeneric.h"
#define MYNAME "dmtlog"
#define DEFLATE_BUFF_SIZE 16384
static gbfile* fin, *fout;
static char* xmlbin;
static Waypoint* xmlwpt;
static route_head* xmltrk;
static QString xmlgrid;
static int xmldatum;
static double xmlEasting, xmlNorthing;
static double xmlLatitude, xmlLongitude;
static double xmlAltitude;
#if !ZLIB_INHIBITED
static int xmlbinsize;
#endif
static char header_written;
static char* opt_index;
static int track_index, this_index;
static
arglist_t dmtlog_args[] = {
{
"index", &opt_index,
"Index of track (if more than one in source)", "1", ARGTYPE_INT, "1", NULL
},
ARG_TERMINATOR
};
#if !ZLIB_INHIBITED
static xg_callback tlog3a_xgcb_version, tlog3a_xgcb_length, tlog3a_xgcb_data;
static xg_tag_mapping tlog3a_xgcb_map[] = {
{ tlog3a_xgcb_version, cb_cdata, "/CXMLSafe/Version" },
{ tlog3a_xgcb_length, cb_cdata, "/CXMLSafe/Length" },
{ tlog3a_xgcb_data, cb_cdata, "/CXMLSafe/Data" },
{ NULL, (xg_cb_type)0, NULL}
};
#endif
static xg_callback tlog3b_xgcb_tfna, tlog3b_xgcb_tfdes;
static xg_callback tlog3b_xgcb_wptst, tlog3b_xgcb_tptst;
static xg_callback tlog3b_xgcb_tpten, tlog3b_xgcb_wpten;
static xg_callback tlog3b_xgcb_wptid, tlog3b_xgcb_wptdt;
static xg_callback tlog3b_xgcb_wptgr, tlog3b_xgcb_wptea;
static xg_callback tlog3b_xgcb_wptno, tlog3b_xgcb_wptal;
static xg_callback tlog3b_xgcb_tptdt;
static xg_tag_mapping tlog3b_xgcb_map[] = {
{ tlog3b_xgcb_tfna, cb_cdata, "/CTrackFile/Name" },
{ tlog3b_xgcb_tfdes, cb_cdata, "/CTrackFile/Description" },
{ tlog3b_xgcb_wptst, cb_start, "/CTrackFile/CWayPoint" },
{ tlog3b_xgcb_wptid, cb_cdata, "/CTrackFile/CWayPoint/Id" },
{ tlog3b_xgcb_wptdt, cb_cdata, "/CTrackFile/CWayPoint/Datum" },
{ tlog3b_xgcb_wptgr, cb_cdata, "/CTrackFile/CWayPoint/Grid" },
{ tlog3b_xgcb_wptea, cb_cdata, "/CTrackFile/CWayPoint/Easting" },
{ tlog3b_xgcb_wptno, cb_cdata, "/CTrackFile/CWayPoint/Northing" },
{ tlog3b_xgcb_wptal, cb_cdata, "/CTrackFile/CWayPoint/Altitude" },
{ tlog3b_xgcb_wpten, cb_end, "/CTrackFile/CWayPoint" },
{ tlog3b_xgcb_tptst, cb_start, "/CTrackFile/CTrackPoint" },
{ tlog3b_xgcb_wptid, cb_cdata, "/CTrackFile/CTrackPoint/Id" },
{ tlog3b_xgcb_tptdt, cb_cdata, "/CTrackFile/CTrackPoint/Datum" },
{ tlog3b_xgcb_wptgr, cb_cdata, "/CTrackFile/CTrackPoint/Grid" },
{ tlog3b_xgcb_wptea, cb_cdata, "/CTrackFile/CTrackPoint/Easting" },
{ tlog3b_xgcb_wptno, cb_cdata, "/CTrackFile/CTrackPoint/Northing" },
{ tlog3b_xgcb_wptal, cb_cdata, "/CTrackFile/CTrackPoint/Altitude" },
{ tlog3b_xgcb_tpten, cb_end, "/CTrackFile/CTrackPoint" },
{ NULL, (xg_cb_type)0, NULL}
};
/* helpers */
static void
convert_datum(Waypoint* wpt, int datum)
{
if (datum != DATUM_WGS84) {
double lat = wpt->latitude;
double lon = wpt->longitude;
double alt = wpt->altitude;
GPS_Math_Known_Datum_To_WGS84_C(lat, lon, alt,
&wpt->latitude, &wpt->longitude, &wpt->altitude,
datum);
}
}
static void
finalize_pt(Waypoint* wpt)
{
if (xmlgrid == "BNG") {
GPS_Math_NGENToAiry1830LatLon(xmlEasting, xmlNorthing,
&wpt->latitude, &wpt->longitude);
xmldatum = DATUM_OSGB36;
} else {
wpt->latitude = xmlLatitude;
wpt->longitude = xmlLongitude;
}
/* NOTE:
* Alan White reports this program actually subtracts a number
* of meters ranging between 46 and 50 meters. It appears to be
* constant for each location, but different without an obvious
* correlation to ground altitude. We considered offsetting this
* in GPSBabel, but concluded it wasn't worth the bother.
* If we get complaints, probably all of our alt reading and writing
* should offset an average of 46m or so.
*/
wpt->altitude = xmlAltitude;
convert_datum(wpt, xmldatum);
}
/* xml-reader callbacks */
#if !ZLIB_INHIBITED
static void
tlog3a_xgcb_version(xg_string args, const QXmlStreamAttributes*)
{
if (args != "1") {
fatal(MYNAME ": Unsupported file version '%s'!\n", qPrintable(args));
}
}
static void
tlog3a_xgcb_length(xg_string args, const QXmlStreamAttributes*)
{
}
static void
tlog3a_xgcb_data(xg_string args, const QXmlStreamAttributes*)
{
int len;
char* bin;
char* cin, *cout;
char cl, ch;
#if NEW_STRINGS
// This function needs rethinking.
len = args.length();
#else
len = strlen(args);
#endif
bin = (char*) xmalloc((len >> 1) + 1);
#if NEW_STRINGS
char* cincopy = xstrdup(args);
cin = cincopy;
#else
cin = (char*)args;
#endif
cout = bin;
cl = 0x10;
while (*cin) {
char c = *cin++;
if (c == '\0') {
break;
} else if ((c >= 'A') && (c <= 'F')) {
c -= 'A' - 10;
} else if ((c >= 'a') && (c <= 'f')) {
c -= 'a' - 10;
} else if ((c >= '0') && (c <= '9')) {
c -= '0';
} else {
continue;
}
if (cl == 0x10) {
cl = c;
} else {
ch = (cl << 4) | c;
*cout++ = ch;
cl = 0x10;
}
}
xmlbin = bin;
xmlbinsize = (cout - bin);
#if NEW_STRINGS
xfree(cincopy);
#endif
}
#endif
static void
tlog3b_xgcb_tfna(xg_string args, const QXmlStreamAttributes*)
{
if (xmltrk == NULL) {
xmltrk = route_head_alloc();
track_add_head(xmltrk);
}
xmltrk->rte_name = args;
}
static void
tlog3b_xgcb_tfdes(xg_string args, const QXmlStreamAttributes*)
{
if (xmltrk == NULL) {
xmltrk = route_head_alloc();
track_add_head(xmltrk);
}
xmltrk->rte_desc = args;
}
static void
tlog3b_xgcb_wptst(xg_string args, const QXmlStreamAttributes*)
{
xmlwpt = new Waypoint;
xmldatum = DATUM_WGS84;
}
static void
tlog3b_xgcb_tptst(xg_string args, const QXmlStreamAttributes*)
{
xmlwpt = new Waypoint;
xmldatum = DATUM_WGS84;
}
static void
tlog3b_xgcb_tpten(xg_string args, const QXmlStreamAttributes*)
{
finalize_pt(xmlwpt);
if (xmltrk == NULL) {
xmltrk = route_head_alloc();
track_add_head(xmltrk);
}
track_add_wpt(xmltrk, xmlwpt);
xmlwpt = NULL;
}
static void
tlog3b_xgcb_wptid(xg_string args, const QXmlStreamAttributes*)
{
xmlwpt->shortname = args;
}
static void
tlog3b_xgcb_wptdt(xg_string args, const QXmlStreamAttributes*)
{
xmldatum = GPS_Lookup_Datum_Index(args);
}
static void
tlog3b_xgcb_wptgr(xg_string args, const QXmlStreamAttributes*)
{
xmlgrid = args;
/*
if (xmlgrid != NULL) {
if (strcmp(xmlgrid, args) == 0) {
return;
}
xfree(xmlgrid);
}
xmlgrid = xstrdup(args);
*/
}
static void
tlog3b_xgcb_wptno(xg_string args, const QXmlStreamAttributes*)
{
xmlNorthing = args.toDouble();
}
static void
tlog3b_xgcb_wptea(xg_string args, const QXmlStreamAttributes*)
{
xmlEasting = args.toDouble();
}
static void
tlog3b_xgcb_wptal(xg_string args, const QXmlStreamAttributes*)
{
xmlAltitude = args.toDouble();
}
static void
tlog3b_xgcb_tptdt(xg_string args, const QXmlStreamAttributes*)
{
xmldatum = GPS_Lookup_Datum_Index(args);
}
static void
tlog3b_xgcb_wpten(xg_string args, const QXmlStreamAttributes*)
{
finalize_pt(xmlwpt);
waypt_add(xmlwpt);
xmlwpt = NULL;
}
static char*
read_str(gbfile* f)
{
int i;
char* res;
i = gbfgetc(f);
if (i == 0xff) {
i = gbfgetint16(f);
}
res = (char*) xmalloc(i + 1);
res[i] = '\0';
if (i) {
gbfread(res, 1, i, f);
}
return res;
}
static void
write_str(const char* str, gbfile* f)
{
if (str && *str) {
int len = strlen(str);
if (len > 0xfe) {
#if 0
if (len > 0x7fff) {
len = 0x7fff;
}
gbfputc((unsigned char) 0xff, f);
gbfputint16(len, f);
#else
len = 0xfe;
gbfputc(len, f);
#endif
} else {
gbfputc(len, f);
}
gbfwrite(str, len, 1, f);
} else {
gbfputc(0, f);
}
}
static void
write_str(const QString& str, gbfile* f)
{
write_str(CSTR(str), f);
}
static int
read_datum(gbfile* f)
{
int res;
char* d, *g;
d = read_str(f);
g = read_str(f);
res = GPS_Lookup_Datum_Index(d);
if (*g && (strcmp(d, g) != 0)) {
fatal(MYNAME ": Unsupported combination of datum '%s' and grid '%s'!\n",
d, g);
}
xfree(d);
xfree(g);
return res;
}
static void
read_CTrackFile(const int version)
{
char buf[128];
int32_t ver;
int32_t tcount, wcount;
int16_t u1;
int32_t ux;
route_head* track;
int i;
u1 = gbfgetint16(fin);
gbfread(buf, 1, 10, fin);
if ((u1 != 0x0a) || (strncmp("CTrackFile", buf, 10) != 0)) {
fatal(MYNAME ": Unknown or invalid track file.\n");
}
if (version == 8) {
gbfseek(fin, 36, SEEK_CUR); /* skip unknown 36 bytes */
}
ver = gbfgetint32(fin);
if (ver != version) {
fatal(MYNAME ": Unknown or invalid track file (%d).\n", ver);
}
ux = gbfgetint32(fin); // Unknown 2
ux = gbfgetint32(fin); // Unknown 3
ux = gbfgetint32(fin); // Unknown 4
(void) ux; // Silence warning.
track = route_head_alloc();
track_add_head(track);
/* S1 .. S9: comments, hints, jokes, aso */
for (i = 0; i < 9; i++) {
char* s = read_str(fin);
xfree(s);
}
tcount = gbfgetint32(fin);
int datum = 118;
if (tcount > 0) {
datum = read_datum(fin);
if (version == 8) {
int len;
gbfread(buf, 1, 4, fin);
len = gbfgetint16(fin);
gbfseek(fin, len, SEEK_CUR);
}
}
while (tcount > 0) {
Waypoint* wpt;
tcount--;
if (version == 8) {
datum = read_datum(fin);
}
wpt = new Waypoint;
wpt->latitude = gbfgetdbl(fin);
wpt->longitude = gbfgetdbl(fin);
wpt->altitude = gbfgetdbl(fin);
if (datum < 0) {
fatal(MYNAME ": Invalid datum %d found", datum);
}
convert_datum(wpt, datum);
track_add_wpt(track, wpt);
if (version == 8) {
gbfseek(fin, 34, SEEK_CUR); /* skip unknown 34 bytes */
}
}
if (version == 8) {
i = gbfgetint16(fin);
i = gbfgetc(fin);
if (i == 0) {
return;
}
gbfungetc(i, fin);
datum = read_datum(fin);
(void) gbfgetint16(fin);
(void) gbfgetint32(fin);
gbfread(buf, 1, 9, fin);
if (strncmp(buf, "CWayPoint", 9) != 0) {
warning(MYNAME ": Unsupported waypoint structure!\n");
return;
}
while (! gbfeof(fin)) {
Waypoint* wpt;
i = gbfgetc(fin);
if (i == 0) {
break;
}
gbfungetc(i, fin);
datum = read_datum(fin);
wpt = new Waypoint;
wpt->latitude = gbfgetdbl(fin);
wpt->longitude = gbfgetdbl(fin);
wpt->altitude = gbfgetdbl(fin);
gbfseek(fin, 36, SEEK_CUR); /* skip unknown 36 bytes */
wpt->notes = read_str(fin);
wpt->description = read_str(fin);
(void) gbfgetint16(fin);
waypt_add(wpt);
}
return;
}
wcount = gbfgetint32(fin);
if (wcount == 0) {
return;
}
datum = read_datum(fin);
while (wcount > 0) {
Waypoint* wpt;
int32_t namect, i;
wcount--;
wpt = new Waypoint;
wpt->latitude = gbfgetdbl(fin);
wpt->longitude = gbfgetdbl(fin);
wpt->altitude = gbfgetdbl(fin);
convert_datum(wpt, datum);
namect = gbfgetint32(fin);
// variants of shortname
for (i = 0; i < namect; i++) {
char* name;
name = read_str(fin);
if (name && *name) {
switch (i) {
case 0:
wpt->description = name;
break;
case 1:
wpt->shortname = name;
break;
}
}
xfree(name);
}
waypt_add(wpt);
}
}
#if !ZLIB_INHIBITED
static int
inflate_buff(const char* buff, const size_t size, char** out_buff)
{
int res = Z_OK;
z_stream strm;
char out[DEFLATE_BUFF_SIZE];
char* cout = NULL;
uint32_t bytes = 0;
uint32_t have;
strm.zalloc = Z_NULL;
strm.zfree = Z_NULL;
strm.opaque = Z_NULL;
strm.avail_in = 0;
strm.next_in = Z_NULL;
res = inflateInit(&strm);
if (res != Z_OK) {
return res;
}
strm.avail_in = size;
strm.next_in = (Bytef*)buff;
do {
strm.avail_out = DEFLATE_BUFF_SIZE;
strm.next_out = (Bytef*)out;
res = inflate(&strm, Z_NO_FLUSH);
switch (res) {
case Z_NEED_DICT:
res = Z_DATA_ERROR; /* and fall through */
case Z_DATA_ERROR:
case Z_MEM_ERROR:
(void)inflateEnd(&strm);
return res;
}
have = DEFLATE_BUFF_SIZE - strm.avail_out;
if (have > 0) {
cout = (char*) xrealloc(cout, bytes + have);
memcpy(cout+bytes, out, have);
bytes+=have;
}
} while (strm.avail_out == 0);
*out_buff = cout;
return res;
}
static void
read_CXMLSafe(void)
{
char* xmlstr = NULL;
xmlbin = NULL;
xmlbinsize = 0;
xml_init(fin->name, tlog3a_xgcb_map, NULL);
xml_read();
xml_deinit();
if (xmlbin != NULL) {
inflate_buff(xmlbin, xmlbinsize, &xmlstr);
xfree(xmlbin);
xml_init(NULL, tlog3b_xgcb_map, NULL);
xml_readstring(xmlstr);
xml_deinit();
xfree(xmlstr);
}
}
#endif
static void
read_XML(void)
{
xml_init(fin->name, tlog3b_xgcb_map, NULL);
xml_read();
xml_deinit();
return;
}
/*******************************************************************************
* %%% global callbacks called by gpsbabel main process %%% *
*******************************************************************************/
static void
dmtlog_rd_init(const char* fname)
{
fin = gbfopen_le(fname, "rb", MYNAME);
xmlbin = NULL;
xmltrk = NULL;
xmlwpt = NULL;
xmlgrid = QString();
}
static void
dmtlog_rd_deinit(void)
{
gbfclose(fin);
}
static void
dmtlog_read(void)
{
switch (gbfgetuint32(fin)) {
case 0x4FFFF:
read_CTrackFile(4);
break;
case 0x8FFFF:
read_CTrackFile(8);
break;
case 0x4d58433c:
#if !ZLIB_INHIBITED
read_CXMLSafe();
#else
fatal(MYNAME ": Zlib was not included in this build.\n");
#endif
break;
case 0x7254433c:
read_XML();
break;
default:
fatal(MYNAME ": Unknown or unsupported file type.\n");
}
}
static void
dmtlog_wr_init(const char* fname)
{
fout = gbfopen_le(fname, "wb", MYNAME);
}
static void
dmtlog_wr_deinit(void)
{
gbfclose(fout);
}
static void
write_header(const route_head* trk)
{
int count, i;
const char ZERO = '\0';
header_written = 1;
count = 0;
if (trk != NULL) {
queue* curr, *prev;
QUEUE_FOR_EACH(&trk->waypoint_list, curr, prev) count++;
}
if (!trk || trk->rte_name.isEmpty()) {
write_str("Name", fout);
} else {
write_str(trk->rte_name, fout);
}
// This fails for internationalization, but as this text is in the
// file itself, it shouldn't be localized.
QString cout = QString::number(count) + " trackpoints and " +
QString::number(waypt_count()) + " waypoints";
write_str(cout, fout);
for (i = 3; i <= 8; i++) {
gbfputc(ZERO, fout);
}
write_str("GPSBabel", fout);
gbfputint32(count, fout);
if (count > 0) {
write_str("WGS84", fout);
write_str("WGS84", fout);
}
}
static void
track_hdr_cb(const route_head* trk)
{
this_index++;
if (this_index != track_index) {
return;
}
write_header(trk);
}
static void
track_tlr_cb(const route_head* trk)
{
}
static void
track_wpt_cb(const Waypoint* wpt)
{
if (this_index != track_index) {
return;
}
gbfputdbl(wpt->latitude, fout);
gbfputdbl(wpt->longitude, fout);
gbfputdbl(wpt->altitude != unknown_alt ? wpt->altitude : 0, fout);
}
static void
wpt_cb(const Waypoint* wpt)
{
int names;
gbfputdbl(wpt->latitude, fout);
gbfputdbl(wpt->longitude, fout);
gbfputdbl(wpt->altitude != unknown_alt ? wpt->altitude : 0, fout);
names = 1;
if (!wpt->description.isEmpty()) {
names = 2;
}
gbfputint32(names, fout);
if (names > 1) {
write_str(wpt->description, fout);
}
write_str(wpt->shortname.isEmpty() ? "Name" : wpt->shortname, fout);
}
static void
dmtlog_write(void)
{
track_index = atoi(opt_index);
/* ... validate index */
gbfputint32(0x4FFFF, fout);
gbfputuint16(0x0A, fout);
gbfputs("CTrackFile", fout);
gbfputint32(4, fout);
gbfputint32(1, fout);
gbfputint32(0x100001, fout);
gbfputuint32((const uint32_t)gpsbabel_time, fout);
header_written = 0;
this_index = 0;
track_disp_all(track_hdr_cb, track_tlr_cb, track_wpt_cb);
if (!header_written) {
write_header(NULL);
}
gbfputint32(waypt_count(), fout);
if (waypt_count() > 0) {
write_str("WGS84", fout);
write_str("WGS84", fout);
waypt_disp_all(wpt_cb);
}
}
/**************************************************************************/
ff_vecs_t dmtlog_vecs = {
ff_type_file,
{
(ff_cap)(ff_cap_read | ff_cap_write) /* waypoints */,
(ff_cap)(ff_cap_read | ff_cap_write) /* tracks */,
ff_cap_none /* routes */
},
dmtlog_rd_init,
dmtlog_wr_init,
dmtlog_rd_deinit,
dmtlog_wr_deinit,
dmtlog_read,
dmtlog_write,
NULL,
dmtlog_args,
CET_CHARSET_ASCII, 0
};
/**************************************************************************/