1 /********************************************************************
2 ** @source JEEPS output functions
3 **
4 ** @author Copyright (C) 1999 Alan Bleasby
5 ** @version 1.0
6 ** @modified Dec 28 1999 Alan Bleasby. First version
7 ** @@
8 **
9 ** This library is free software; you can redistribute it and/or
10 ** modify it under the terms of the GNU Library General Public
11 ** License as published by the Free Software Foundation; either
12 ** version 2 of the License, or (at your option) any later version.
13 **
14 ** This library is distributed in the hope that it will be useful,
15 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 ** Library General Public License for more details.
18 **
19 ** You should have received a copy of the GNU Library General Public
20 ** License along with this library; if not, write to the
21 ** Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 ** Boston, MA  02111-1307, USA.
23 ********************************************************************/
24 #include "gps.h"
25 #include <stdio.h>
26 #include <time.h>
27 
28 
29 static void GPS_Fmt_Print_Way100(GPS_PWay way, FILE* outf);
30 static void GPS_Fmt_Print_Way101(GPS_PWay way, FILE* outf);
31 static void GPS_Fmt_Print_Way102(GPS_PWay way, FILE* outf);
32 static void GPS_Fmt_Print_Way103(GPS_PWay way, FILE* outf);
33 static void GPS_Fmt_Print_Way104(GPS_PWay way, FILE* outf);
34 static void GPS_Fmt_Print_Way105(GPS_PWay way, FILE* outf);
35 static void GPS_Fmt_Print_Way106(GPS_PWay way, FILE* outf);
36 static void GPS_Fmt_Print_Way107(GPS_PWay way, FILE* outf);
37 static void GPS_Fmt_Print_Way108(GPS_PWay way, FILE* outf);
38 static void GPS_Fmt_Print_Way109(GPS_PWay way, FILE* outf);
39 static void GPS_Fmt_Print_Way150(GPS_PWay way, FILE* outf);
40 static void GPS_Fmt_Print_Way151(GPS_PWay way, FILE* outf);
41 static void GPS_Fmt_Print_Way152(GPS_PWay way, FILE* outf);
42 static void GPS_Fmt_Print_Way154(GPS_PWay way, FILE* outf);
43 static void GPS_Fmt_Print_Way155(GPS_PWay way, FILE* outf);
44 
45 static void GPS_Fmt_Print_Track301(GPS_PTrack* trk, int32 n, FILE* outf);
46 static void GPS_Fmt_Print_D300(GPS_PTrack trk, FILE* outf);
47 static void GPS_Fmt_Print_D301(GPS_PTrack trk, FILE* outf);
48 
49 static int32 GPS_Fmt_Print_Route201(GPS_PWay* way, int32 n, FILE* outf);
50 
51 
52 char* gps_marine_sym[]= {
53   "Anchor","Bell","Diamond-grn","Diamond_red","Dive1","Dive2","Dollar",
54   "Fish","Fuel","Horn","House","Knife","Light","Mug","Skull",
55   "Square_grn","Square_red","Wbuoy","Wpt_dot","Wreck","Null","Mob",
56 
57   "Buoy_amber","Buoy_blck","Buoy_blue","Buoy_grn","Buoy_grn_red",
58   "Buoy_grn_wht","Buoy_orng","Buoy_red","Buoy_red_grn","Buoy_red_wht",
59   "Buoy_violet","Buoy_wht","Buoy_wht_grn","Buoy_wht_red","Dot","Rbcn",
60 
61   "","","","","","","","","","",
62   "","","","","","","","","","",
63   "","","","","","","","","","",
64   "","","","","","","","","","",
65   "","","","","","","","","","",
66   "","","","","","","","","","",
67   "","","","","","","","","","",
68   "","","","","","","","","","",
69   "","","","","","","","","","",
70   "","","","","","","","","","",
71   "","","","","","","","","","",
72   "","",
73 
74   "Boat_ramp","Camp","Toilets","Showers","Drinking_wtr","Phone",
75   "1st_aid","Info","Parking","Park","Picnic","Scenic","Skiing",
76   "Swimming","Dam","Controlled","Danger","Restricted","Null_2","Ball",
77   "Car","Deer","Shpng_trolley","Lodging","Mine","Trail_head",
78   "Lorry_stop","User_exit","Flag","Circle-x"
79 };
80 
81 
82 
83 char* gps_land_sym[]= {
84   "Is_hwy","Us_hwy","St_hwy","Mi_mrkr","Trcbck","Golf","Sml_cty",
85   "Med_cty","Lrg_cty","Freeway","Ntl_hwy","Cap_cty","Amuse_pk",
86   "Bowling","Car_rental","Car_repair","Fastfood","Fitness","Film",
87   "Museum","Chemist","Pizza","Post_ofc","Rv_park","School",
88   "Stadium","Shop","Zoo","Petrol_plus","Theatre","Ramp_int",
89   "St_int","","","Weigh_stn","Toll_booth","Elev_pt","Ex_no_srvc",
90   "Geo_place_mm","Geo_place_wtr","Geo_place_lnd","Bridge","Building",
91   "Cemetery","Church","Civil_loc","Crossing","Hist_town","River_Embankment",
92   "Military_loc","Oil_field","Tunnel","Beach","Forest","Summit",
93   "Lrg_ramp_int","Lrg_exit_no_srvc","Official_badge","Gambling",
94   "Snow_ski","Ice_ski","Tow_truck","Border"
95 };
96 
97 
98 char* gps_aviation_sym[]= {
99   "Airport","Int","Ndb","Vor","Heliport","Private","Soft_fld",
100   "Tall_tower","Short_tower","Glider","Ultralight","Parachute",
101   "Vortac","Vordme","Faf","Lom","Map","Tacan","Seaplane"
102 };
103 
104 
105 char* gps_16_sym[]= {
106   "Dot","House","Fuel","Car","Fish","Boat","Anchor","Wreck",
107   "Exit","Skull","Flag","Camp","Circle-x","Deer","1st_aid","Back_track"
108 };
109 
110 
111 
112 
113 
114 /* @func GPS_Fmt_Print_Time ********************************************
115 **
116 ** Output Date/time
117 **
118 ** @param [r] Time [time_t] unix-style time
119 ** @param [w] outf [FILE *] output stream
120 **
121 ** @return [void]
122 ************************************************************************/
123 
GPS_Fmt_Print_Time(time_t Time,FILE * outf)124 void GPS_Fmt_Print_Time(time_t Time, FILE* outf)
125 {
126   (void) fprintf(outf,"%s",ctime(&Time));
127   fflush(outf);
128 
129   return;
130 }
131 
132 
133 
134 /* @func GPS_Fmt_Print_Position ********************************************
135 **
136 ** Output position
137 **
138 ** @param [r] lat [double] latitude  (deg)
139 ** @param [r] lon [double] longitude (deg)
140 ** @param [w] outf [FILE *] output stream
141 **
142 ** @return [void]
143 ************************************************************************/
144 
GPS_Fmt_Print_Position(double lat,double lon,FILE * outf)145 void GPS_Fmt_Print_Position(double lat, double lon, FILE* outf)
146 {
147   (void) fprintf(outf,"Latitude: %f   Longitude %f\n",lat,lon);
148   fflush(outf);
149 
150   return;
151 }
152 
153 
154 
155 /* @func GPS_Fmt_Print_Pvt ********************************************
156 **
157 ** Output pvt
158 **
159 ** @param [r] pvt [GPS_PPvt_Data] pvt
160 ** @param [w] outf [FILE *] output stream
161 **
162 ** @return [void]
163 ************************************************************************/
164 
GPS_Fmt_Print_Pvt(GPS_PPvt_Data pvt,FILE * outf)165 void GPS_Fmt_Print_Pvt(GPS_PPvt_Data pvt, FILE* outf)
166 {
167 
168   (void) fprintf(outf,"Fix: ");
169   switch (pvt->fix) {
170   case 0:
171     (void) fprintf(outf,"UNUSABLE\n\n");
172     break;
173   case 1:
174     (void) fprintf(outf,"INVALID \n\n");
175     break;
176   case 2:
177     (void) fprintf(outf,"2D      \n\n");
178     break;
179   case 3:
180     (void) fprintf(outf,"3D      \n\n");
181     break;
182   case 4:
183     (void) fprintf(outf,"2D-diff \n\n");
184     break;
185   case 5:
186     (void) fprintf(outf,"2D-diff \n\n");
187     break;
188   default:
189     (void) fprintf(stderr,"PVT: Unsupported Fix type\n");
190     break;
191   }
192 
193   (void) fprintf(outf,"Altitude (WGS 84): %-20f \n",pvt->alt);
194   (void) fprintf(outf,"EPE:               %-20f \n",pvt->epe);
195   (void) fprintf(outf,"EPE (hor only):    %-20f \n",pvt->eph);
196   (void) fprintf(outf,"EPE (ver only):    %-20f \n",pvt->epv);
197   (void) fprintf(outf,"Time of week:      %-20d \n",(int)pvt->tow);
198   (void) fprintf(outf,"Latitude:          %-20f \n",pvt->lat);
199   (void) fprintf(outf,"Longitude:         %-20f \n",pvt->lon);
200   (void) fprintf(outf,"East velocity:     %-20f \n",pvt->east);
201   (void) fprintf(outf,"North velocity:    %-20f \n",pvt->north);
202   (void) fprintf(outf,"Upward velocity    %-20f \n",pvt->up);
203   (void) fprintf(outf,"Height above MSL:  %-20f \n",pvt->msl_hght+pvt->alt);
204   (void) fprintf(outf,"Leap seconds:      %-20d \n",pvt->leap_scnds);
205   (void) fprintf(outf,"Week number days:  %-20d \n",(int)pvt->wn_days);
206 
207   fflush(outf);
208 
209   return;
210 }
211 
212 
213 
214 /* @func GPS_Fmt_Print_Almanac ********************************************
215 **
216 ** Output almanac
217 **
218 ** @param [r] alm [GPS_PAlmanac *] almanac array
219 ** @param [r] n [int32] number of almanac entries
220 ** @param [w] outf [FILE *] output stream
221 **
222 ** @return [void]
223 ************************************************************************/
224 
GPS_Fmt_Print_Almanac(GPS_PAlmanac * alm,int32 n,FILE * outf)225 void GPS_Fmt_Print_Almanac(GPS_PAlmanac* alm, int32 n, FILE* outf)
226 {
227   int32 i;
228   int32 t;
229   int32 s;
230 
231   /* Type 0 models require all 32 satellites to be sent */
232   t=32;
233   s=0;
234   if (n && alm[0]->svid!=0xff) {
235     s=1;
236     t=n;
237   }
238   (void) fprintf(outf,"Almanac %d %d\n",(int)t,(int)s);
239 
240 
241   for (i=0; i<n; ++i) {
242     if (alm[i]->wn<0) {
243       continue;
244     }
245 
246     if (alm[i]->svid == 0xff) {
247       alm[i]->svid = i;
248     }
249     (void) fprintf(outf,"#\n#\n");
250     (void) fprintf(outf,"\tID:                           %d\n",
251                    alm[i]->svid+1);
252     (void) fprintf(outf,"\tWeek number:                  %d\n",
253                    alm[i]->wn);
254     (void) fprintf(outf,"\tAlmanac Data Reference Time:  %f\n",
255                    alm[i]->toa);
256     (void) fprintf(outf,"\tClock Correction Coeff (s):   %f\n",
257                    alm[i]->af0);
258     (void) fprintf(outf,"\tClock Correction Coeff (s/s): %f\n",
259                    alm[i]->af1);
260     (void) fprintf(outf,"\tEccentricity:                 %f\n",
261                    alm[i]->e);
262     (void) fprintf(outf,"\tSqrt of semi-major axis:      %f\n",
263                    alm[i]->sqrta);
264     (void) fprintf(outf,"\tMean Anomaly at Ref. Time:    %f\n",
265                    alm[i]->m0);
266     (void) fprintf(outf,"\tArgument of perigee:          %f\n",
267                    alm[i]->w);
268     (void) fprintf(outf,"\tRight ascension:              %f\n",
269                    alm[i]->omg0);
270     (void) fprintf(outf,"\tRate of right ascension:      %f\n",
271                    alm[i]->odot);
272     (void) fprintf(outf,"\tInclination angle:            %f\n",
273                    alm[i]->i);
274     (void) fprintf(outf,"\tHealth:                       %d\n",
275                    alm[i]->hlth);
276   }
277 
278 
279   fflush(outf);
280 
281   return;
282 }
283 
284 
285 
286 /* @func GPS_Fmt_Print_Track ********************************************
287 **
288 ** Output track log
289 **
290 ** @param [r] trk [GPS_PTrack *] track array
291 ** @param [r] n [int32] number of track entries
292 ** @param [w] outf [FILE *] output stream
293 **
294 ** @return [void]
295 ************************************************************************/
296 
GPS_Fmt_Print_Track(GPS_PTrack * trk,int32 n,FILE * outf)297 void GPS_Fmt_Print_Track(GPS_PTrack* trk, int32 n, FILE* outf)
298 {
299   int32 i;
300 
301 
302   switch (gps_trk_transfer) {
303   case pA300:
304     break;
305   case pA301:
306     GPS_Fmt_Print_Track301(trk,n,outf);
307     return;
308   default:
309     GPS_Error("GPS_Fmt_Print_Track: Unknown protocol");
310     return;
311   }
312 
313 
314   (void) fprintf(outf,"Track log 300 %d\n#\n",(int)gps_trk_type);
315   (void) fprintf(outf,"Start\n#\n");
316 
317   for (i=0; i<n; ++i) {
318     if (trk[i]->tnew) {
319       (void) fprintf(outf,"#\nNew track\n#\n");
320     }
321 
322     switch (gps_trk_type) {
323     case pD300:
324       GPS_Fmt_Print_D300(trk[i],outf);
325       break;
326     case pD301:
327       GPS_Fmt_Print_D301(trk[i],outf);
328       break;
329     default:
330       break;
331     }
332   }
333 
334   (void) fprintf(outf,"End\n#\n");
335   fflush(outf);
336 
337   return;
338 }
339 
340 
341 
342 /* @funcstatic GPS_Fmt_Print_Track301 ***********************************
343 **
344 ** Output track log
345 **
346 ** @param [r] trk [GPS_PTrack *] track array
347 ** @param [r] n [int32] number of track entries
348 ** @param [w] outf [FILE *] output stream
349 **
350 ** @return [void]
351 ************************************************************************/
352 
GPS_Fmt_Print_Track301(GPS_PTrack * trk,int32 n,FILE * outf)353 static void GPS_Fmt_Print_Track301(GPS_PTrack* trk, int32 n, FILE* outf)
354 {
355   int32 i;
356 
357   if (!n) {
358     return;
359   }
360 
361   (void) fprintf(outf,"Track log 301 %d\n#\n",(int)gps_trk_type);
362   (void) fprintf(outf,"Start\n#\n");
363 
364   for (i=0; i<n; ++i) {
365     if (trk[i]->ishdr) {
366       (void) fprintf(outf,"Header\n");
367       (void) fprintf(outf,"\tIdent:       %s\n",trk[i]->trk_ident);
368       (void) fprintf(outf,"\tDisplay:     %d\n",(int)trk[i]->dspl);
369       (void) fprintf(outf,"\tColour:      %d\n#\n",
370                      (int)trk[i]->colour);
371       continue;
372     }
373 
374     if (trk[i]->tnew) {
375       (void) fprintf(outf,"#\nNew track\n#\n");
376     }
377 
378     switch (gps_trk_type) {
379     case pD300:
380       GPS_Fmt_Print_D300(trk[i],outf);
381       break;
382     case pD301:
383       GPS_Fmt_Print_D301(trk[i],outf);
384       break;
385     default:
386       break;
387     }
388   }
389 
390   (void) fprintf(outf,"End\n#\n");
391   fflush(outf);
392 
393   return;
394 }
395 
396 
397 /* @funcstatic GPS_Fmt_Print_D300 ****************************************
398 **
399 ** Output track log
400 **
401 ** @param [r] trk [GPS_PTrack *] track array
402 ** @param [w] outf [FILE *] output stream
403 **
404 ** @return [void]
405 ************************************************************************/
406 
GPS_Fmt_Print_D300(GPS_PTrack trk,FILE * outf)407 static void GPS_Fmt_Print_D300(GPS_PTrack trk, FILE* outf)
408 {
409   (void) fprintf(outf,"\tLatitude:    %f\n",trk->lat);
410   (void) fprintf(outf,"\tLongitude:   %f\n",trk->lon);
411   if (trk->Time) {
412     (void) fprintf(outf,"\tTime:        %s\n",ctime(&trk->Time));
413   } else {
414     (void) fprintf(outf,"\tTime:        Computer\n\n");
415   }
416 
417   return;
418 }
419 
420 
421 
422 /* @funcstatic GPS_Fmt_Print_D301 ****************************************
423 **
424 ** Output track log
425 **
426 ** @param [r] trk [GPS_PTrack *] track array
427 ** @param [w] outf [FILE *] output stream
428 **
429 ** @return [void]
430 ************************************************************************/
431 
GPS_Fmt_Print_D301(GPS_PTrack trk,FILE * outf)432 static void GPS_Fmt_Print_D301(GPS_PTrack trk, FILE* outf)
433 {
434   (void) fprintf(outf,"\tLatitude:    %f\n",trk->lat);
435   (void) fprintf(outf,"\tLongitude:   %f\n",trk->lon);
436   if (trk->Time) {
437     (void) fprintf(outf,"\tTime:        %s",ctime(&trk->Time));
438   } else {
439     (void) fprintf(outf,"\tTime:        Computer\n");
440   }
441   (void) fprintf(outf,"\tAltitude:    %f\n",trk->alt);
442   (void) fprintf(outf,"\tDepth:       %f\n\n",trk->dpth);
443 
444   return;
445 }
446 
447 
448 
449 
450 /* @func GPS_Fmt_Print_Waypoint *****************************************
451 **
452 ** Output waypoints
453 **
454 ** @param [r] way [GPS_PWay *] waypoint array
455 ** @param [r] n [int32] number of waypoint entries
456 ** @param [w] outf [FILE *] output stream
457 **
458 ** @return [int32] success
459 ************************************************************************/
460 
GPS_Fmt_Print_Waypoint(GPS_PWay * way,int32 n,FILE * outf)461 int32 GPS_Fmt_Print_Waypoint(GPS_PWay* way, int32 n, FILE* outf)
462 {
463   int32 i;
464 
465 
466   if (!n) {
467     return 1;
468   }
469 
470   (void) fprintf(outf,"Waypoints Type: %d\n#\nStart\n#\n",
471                  (int)way[0]->prot);
472 
473 
474   for (i=0; i<n; ++i) {
475     switch (way[i]->prot) {
476     case 100:
477       GPS_Fmt_Print_Way100(way[i],outf);
478       break;
479     case 101:
480       GPS_Fmt_Print_Way101(way[i],outf);
481       break;
482     case 102:
483       GPS_Fmt_Print_Way102(way[i],outf);
484       break;
485     case 103:
486       GPS_Fmt_Print_Way103(way[i],outf);
487       break;
488     case 104:
489       GPS_Fmt_Print_Way104(way[i],outf);
490       break;
491     case 105:
492       GPS_Fmt_Print_Way105(way[i],outf);
493       break;
494     case 106:
495       GPS_Fmt_Print_Way106(way[i],outf);
496       break;
497     case 107:
498       GPS_Fmt_Print_Way107(way[i],outf);
499       break;
500     case 108:
501       GPS_Fmt_Print_Way108(way[i],outf);
502       break;
503     case 109:
504       GPS_Fmt_Print_Way109(way[i],outf);
505       break;
506     case 150:
507       GPS_Fmt_Print_Way150(way[i],outf);
508       break;
509     case 151:
510       GPS_Fmt_Print_Way151(way[i],outf);
511       break;
512     case 152:
513       GPS_Fmt_Print_Way152(way[i],outf);
514       break;
515     case 154:
516       GPS_Fmt_Print_Way154(way[i],outf);
517       break;
518     case 155:
519       GPS_Fmt_Print_Way155(way[i],outf);
520       break;
521     default:
522       GPS_Error("Print_Waypoint: Unknown waypoint protocol");
523       return PROTOCOL_ERROR;
524     }
525     (void) fprintf(outf,"#\n");
526   }
527   (void) fprintf(outf,"End\n#\n");
528 
529   return 1;
530 }
531 
532 
533 
534 /* @func GPS_Fmt_Print_Proximity *****************************************
535 **
536 ** Output proximity
537 **
538 ** @param [r] way [GPS_PWay *] waypoint array
539 ** @param [r] n [int32] number of waypoint entries
540 ** @param [w] outf [FILE *] output stream
541 **
542 ** @return [int32] success
543 ************************************************************************/
544 
GPS_Fmt_Print_Proximity(GPS_PWay * way,int32 n,FILE * outf)545 int32 GPS_Fmt_Print_Proximity(GPS_PWay* way, int32 n, FILE* outf)
546 {
547   int32 i;
548 
549 
550   if (!n) {
551     return 1;
552   }
553 
554   (void) fprintf(outf,"Waypoints Type: %d\n#\nStart\n#\n",
555                  (int)way[0]->prot);
556 
557 
558   for (i=0; i<n; ++i) {
559     switch (way[i]->prot) {
560     case 400:
561       GPS_Fmt_Print_Way100(way[i],outf);
562       break;
563     case 101:
564       GPS_Fmt_Print_Way101(way[i],outf);
565       break;
566     case 102:
567       GPS_Fmt_Print_Way102(way[i],outf);
568       break;
569     case 403:
570       GPS_Fmt_Print_Way103(way[i],outf);
571       break;
572     case 104:
573       GPS_Fmt_Print_Way104(way[i],outf);
574       break;
575     case 105:
576       GPS_Fmt_Print_Way105(way[i],outf);
577       break;
578     case 106:
579       GPS_Fmt_Print_Way106(way[i],outf);
580       break;
581     case 107:
582       GPS_Fmt_Print_Way107(way[i],outf);
583       break;
584     case 108:
585       GPS_Fmt_Print_Way108(way[i],outf);
586       break;
587     case 109:
588       GPS_Fmt_Print_Way109(way[i],outf);
589       break;
590     case 450:
591       GPS_Fmt_Print_Way150(way[i],outf);
592       (void) fprintf(outf,"\tPindex:           %d\n",(int)way[i]->idx);
593       break;
594     case 151:
595       GPS_Fmt_Print_Way151(way[i],outf);
596       break;
597     case 152:
598       GPS_Fmt_Print_Way152(way[i],outf);
599       break;
600     case 154:
601       GPS_Fmt_Print_Way154(way[i],outf);
602       break;
603     case 155:
604       GPS_Fmt_Print_Way155(way[i],outf);
605       break;
606     default:
607       GPS_Error("Print_Proximity: Unknown proximity protocol");
608       return PROTOCOL_ERROR;
609     }
610     (void) fprintf(outf,"\tDistance:         %f\n",way[i]->dst);
611     (void) fprintf(outf,"#\n");
612   }
613   (void) fprintf(outf,"End\n#\n");
614 
615   return 1;
616 }
617 
618 
619 
620 
621 /* @funcstatic GPS_Fmt_Print_Way100 *************************************
622 **
623 ** Output waypoint D100
624 **
625 ** @param [r] way [GPS_PWay] waypoint
626 ** @param [w] outf [FILE *] output stream
627 **
628 ** @return [void]
629 ************************************************************************/
630 
GPS_Fmt_Print_Way100(GPS_PWay way,FILE * outf)631 static void GPS_Fmt_Print_Way100(GPS_PWay way, FILE* outf)
632 {
633 
634   (void) fprintf(outf,"\tIdent:            %-6.6s\n",way->ident);
635   (void) fprintf(outf,"\tLatitude:         %f\n",way->lat);
636   (void) fprintf(outf,"\tLongitude:        %f\n",way->lon);
637   (void) fprintf(outf,"\tComment:          %-40.40s\n",way->cmnt);
638 
639   return;
640 }
641 
642 
643 /* @funcstatic GPS_Fmt_Print_Way101 ************************************
644 **
645 ** Output waypoint D101
646 **
647 ** @param [r] way [GPS_PWay] waypoint
648 ** @param [w] outf [FILE *] output stream
649 **
650 ** @return [void]
651 ************************************************************************/
652 
GPS_Fmt_Print_Way101(GPS_PWay way,FILE * outf)653 static void GPS_Fmt_Print_Way101(GPS_PWay way, FILE* outf)
654 {
655 
656   if (way->smbl > 176) {
657     way->smbl=36;
658   }
659 
660   (void) fprintf(outf,"\tIdent:            %-6.6s\n",way->ident);
661   (void) fprintf(outf,"\tLatitude:         %f\n",way->lat);
662   (void) fprintf(outf,"\tLongitude:        %f\n",way->lon);
663   (void) fprintf(outf,"\tComment:          %-40.40s\n",way->cmnt);
664   (void) fprintf(outf,"\tSymbol:           %d [%s]\n",(int)way->smbl,
665                  gps_marine_sym[way->smbl]);
666 
667   return;
668 }
669 
670 
671 /* @funcstatic GPS_Fmt_Print_Way102 *************************************
672 **
673 ** Output waypoint D102
674 **
675 ** @param [r] way [GPS_PWay] waypoint
676 ** @param [w] outf [FILE *] output stream
677 **
678 ** @return [void]
679 ************************************************************************/
680 
GPS_Fmt_Print_Way102(GPS_PWay way,FILE * outf)681 static void GPS_Fmt_Print_Way102(GPS_PWay way, FILE* outf)
682 {
683   char** p;
684   int32  x;
685 
686   if (way->smbl < 8192) {
687     p = gps_marine_sym;
688     x = 0;
689   } else if (way->smbl < 16384) {
690     p = gps_land_sym;
691     x = 8192;
692   } else {
693     p = gps_aviation_sym;
694     x = 16384;
695   }
696 
697 
698   (void) fprintf(outf,"\tIdent:            %-6.6s\n",way->ident);
699   (void) fprintf(outf,"\tLatitude:         %f\n",way->lat);
700   (void) fprintf(outf,"\tLongitude:        %f\n",way->lon);
701   (void) fprintf(outf,"\tComment:          %-40.40s\n",way->cmnt);
702   (void) fprintf(outf,"\tSymbol:           %d [%s]\n",(int)way->smbl,
703                  p[way->smbl-x]);
704 
705   return;
706 }
707 
708 
709 /* @funcstatic GPS_Fmt_Print_Way103 ************************************
710 **
711 ** Output waypoint D103
712 **
713 ** @param [r] way [GPS_PWay] waypoint
714 ** @param [w] outf [FILE *] output stream
715 **
716 ** @return [void]
717 ************************************************************************/
718 
GPS_Fmt_Print_Way103(GPS_PWay way,FILE * outf)719 static void GPS_Fmt_Print_Way103(GPS_PWay way, FILE* outf)
720 {
721   static char* dspl[]= {
722     "SW","S","SC"
723   };
724 
725   (void) fprintf(outf,"\tIdent:            %-6.6s\n",way->ident);
726   (void) fprintf(outf,"\tLatitude:         %f\n",way->lat);
727   (void) fprintf(outf,"\tLongitude:        %f\n",way->lon);
728   (void) fprintf(outf,"\tComment:          %-40.40s\n",way->cmnt);
729   (void) fprintf(outf,"\tSymbol:           %-6d [%s]\n",(int)way->smbl,
730                  gps_16_sym[way->smbl]);
731   (void) fprintf(outf,"\tDisplay:          %-6d [%s]\n",(int)way->dspl,
732                  dspl[way->dspl]);
733 
734   return;
735 }
736 
737 
738 /* @funcstatic GPS_Fmt_Print_Way104 *************************************
739 **
740 ** Output waypoint D104
741 **
742 ** @param [r] way [GPS_PWay] waypoint
743 ** @param [w] outf [FILE *] output stream
744 **
745 ** @return [void]
746 ************************************************************************/
747 
GPS_Fmt_Print_Way104(GPS_PWay way,FILE * outf)748 static void GPS_Fmt_Print_Way104(GPS_PWay way, FILE* outf)
749 {
750   static char* dspl[]= {
751     "S","S","","SW","","SC"
752   };
753   char** p;
754   int32  x;
755 
756   if (way->smbl < 8192) {
757     p = gps_marine_sym;
758     x = 0;
759   } else if (way->smbl < 16384) {
760     p = gps_land_sym;
761     x = 8192;
762   } else {
763     p = gps_aviation_sym;
764     x = 16384;
765   }
766 
767   (void) fprintf(outf,"\tIdent:            %-6.6s\n",way->ident);
768   (void) fprintf(outf,"\tLatitude:         %f\n",way->lat);
769   (void) fprintf(outf,"\tLongitude:        %f\n",way->lon);
770   (void) fprintf(outf,"\tComment:          %-40.40s\n",way->cmnt);
771   (void) fprintf(outf,"\tSymbol:           %-6d [%s]\n",(int)way->smbl,
772                  p[way->smbl-x]);
773   (void) fprintf(outf,"\tDisplay:          %-6d [%s]\n",(int)way->dspl,
774                  dspl[way->dspl]);
775 
776   return;
777 }
778 
779 
780 /* @funcstatic GPS_Fmt_Print_Way105 ************************************
781 **
782 ** Output waypoint D105
783 **
784 ** @param [r] way [GPS_PWay] waypoint
785 ** @param [w] outf [FILE *] output stream
786 **
787 ** @return [void]
788 ************************************************************************/
789 
GPS_Fmt_Print_Way105(GPS_PWay way,FILE * outf)790 static void GPS_Fmt_Print_Way105(GPS_PWay way, FILE* outf)
791 {
792   char** p;
793   int32  x;
794 
795   if (way->smbl < 8192) {
796     p = gps_marine_sym;
797     x = 0;
798   } else if (way->smbl < 16384) {
799     p = gps_land_sym;
800     x = 8192;
801   } else {
802     p = gps_aviation_sym;
803     x = 16384;
804   }
805 
806   (void) fprintf(outf,"\tLatitude:         %f\n",way->lat);
807   (void) fprintf(outf,"\tLongitude:        %f\n",way->lon);
808   (void) fprintf(outf,"\tSymbol:           %-6d [%s]\n",(int)way->smbl,
809                  p[way->smbl-x]);
810   (void) fprintf(outf,"\tWpt_ident         %s\n",way->wpt_ident);
811 
812   return;
813 }
814 
815 
816 /* @funcstatic GPS_Fmt_Print_Way106 *************************************
817 **
818 ** Output waypoint D106
819 **
820 ** @param [r] way [GPS_PWay] waypoint
821 ** @param [w] outf [FILE *] output stream
822 **
823 ** @return [void]
824 ************************************************************************/
825 
GPS_Fmt_Print_Way106(GPS_PWay way,FILE * outf)826 static void GPS_Fmt_Print_Way106(GPS_PWay way, FILE* outf)
827 {
828   char** p;
829   int32  x;
830 
831   if (way->smbl < 8192) {
832     p = gps_marine_sym;
833     x = 0;
834   } else if (way->smbl < 16384) {
835     p = gps_land_sym;
836     x = 8192;
837   } else {
838     p = gps_aviation_sym;
839     x = 16384;
840   }
841 
842   if (!way->wpt_class) {
843     (void) fprintf(outf,"\tClass:            %d [User]\n",way->wpt_class);
844     (void) fprintf(outf,"\tSubclass:         %d [%-13.13s]\n",
845                    way->wpt_class,way->subclass);
846     (void) fprintf(outf,"\tSubclass:\n");
847   } else {
848     (void) fprintf(outf,"\tClass:            %d [Non-user]\n",
849                    way->wpt_class);
850     (void) fprintf(outf,"\tSubclass:         %d [%13.13s]\n",
851                    way->wpt_class,
852                    way->subclass);
853   }
854   (void) fprintf(outf,"\tLatitude:         %f\n",way->lat);
855   (void) fprintf(outf,"\tLongitude:        %f\n",way->lon);
856   (void) fprintf(outf,"\tSymbol:           %-6d [%s]\n",(int)way->smbl,
857                  p[way->smbl-x]);
858   (void) fprintf(outf,"\tWpt_ident         %s\n",way->wpt_ident);
859   (void) fprintf(outf,"\tLnk_ident         %s\n",way->lnk_ident);
860 
861   return;
862 }
863 
864 
865 /* @funcstatic GPS_Fmt_Print_Way107 ************************************
866 **
867 ** Output waypoint D107
868 **
869 ** @param [r] way [GPS_PWay] waypoint
870 ** @param [w] outf [FILE *] output stream
871 **
872 ** @return [void]
873 ************************************************************************/
874 
GPS_Fmt_Print_Way107(GPS_PWay way,FILE * outf)875 static void GPS_Fmt_Print_Way107(GPS_PWay way, FILE* outf)
876 {
877   static char* dspl[]= {
878     "SW","S","SC"
879   };
880   static char* col[]= {
881     "Default","Red","Green","Blue"
882   };
883 
884 
885   (void) fprintf(outf,"\tIdent:            %-6.6s\n",way->ident);
886   (void) fprintf(outf,"\tLatitude:         %f\n",way->lat);
887   (void) fprintf(outf,"\tLongitude:        %f\n",way->lon);
888   (void) fprintf(outf,"\tComment:          %-40.40s\n",way->cmnt);
889   (void) fprintf(outf,"\tSymbol:           %-6d [%s]\n",(int)way->smbl,
890                  gps_16_sym[way->smbl]);
891   (void) fprintf(outf,"\tDisplay:          %-6d [%s]\n",(int)way->dspl,
892                  dspl[way->dspl]);
893   (void) fprintf(outf,"\tColour:           %-6d [%s]\n",(int)way->colour,
894                  col[way->colour]);
895 
896   return;
897 }
898 
899 
900 
901 /* @funcstatic GPS_Fmt_Print_Way108 ************************************
902 **
903 ** Output waypoint D108
904 **
905 ** @param [r] way [GPS_PWay] waypoint
906 ** @param [w] outf [FILE *] output stream
907 **
908 ** @return [void]
909 ************************************************************************/
910 
GPS_Fmt_Print_Way108(GPS_PWay way,FILE * outf)911 static void GPS_Fmt_Print_Way108(GPS_PWay way, FILE* outf)
912 {
913   char** p;
914   int32  x;
915 
916   static char* dspl[]= {
917     "SW","S","SC"
918   };
919 
920   static char* col[]= {
921     "Black","Dark_Red","Dark_Green","Dark_Yellow","Dark_Blue",
922     "Dark_Magenta","Dark_Cyan","Light_Grey","Dark_Grey","Red","Green",
923     "Yellow","Blue","Magenta","Cyan","White"
924   };
925 
926 
927   if (way->smbl < 8192) {
928     p = gps_marine_sym;
929     x = 0;
930   } else if (way->smbl < 16384) {
931     p = gps_land_sym;
932     x = 8192;
933   } else {
934     p = gps_aviation_sym;
935     x = 16384;
936   }
937 
938   (void) fprintf(outf,"\tIdent:            %s\n",way->ident);
939   (void) fprintf(outf,"\tLatitude:         %f\n",way->lat);
940   (void) fprintf(outf,"\tLongitude:        %f\n",way->lon);
941   if (way->colour==0xff) {
942     (void) fprintf(outf,"\tColour:           255    [Default]\n");
943   } else
944     (void) fprintf(outf,"\tColour:           %-6d [%s]\n",(int)way->colour,
945                    col[way->colour]);
946   (void) fprintf(outf,"\tDisplay:          %-6d [%s]\n",(int)way->dspl,
947                  dspl[way->dspl]);
948   (void) fprintf(outf,"\tSymbol:           %-6d [%s]\n",(int)way->smbl,
949                  p[way->smbl-x]);
950   (void) fprintf(outf,"\tAltitude:         %d\n",(int)way->alt);
951   (void) fprintf(outf,"\tDepth:            %f\n",way->dpth);
952   (void) fprintf(outf,"\tState:            %-2.2s\n",way->state);
953   (void) fprintf(outf,"\tCountry:          %-2.2s\n",way->cc);
954   (void) fprintf(outf,"\tClass:            %d\n",way->wpt_class);
955   if (way->wpt_class>=0x80 && way->wpt_class<=0x85) {
956     (void) fprintf(outf,"\tSubclass:         %18.18s\n",way->subclass);
957   }
958   if (!way->wpt_class) {
959     (void) fprintf(outf,"\tComment:          %s\n",way->cmnt);
960   }
961   if (way->wpt_class>=0x40 && way->wpt_class<=0x46) {
962     (void) fprintf(outf,"\tFacility:         %s\n",way->facility);
963     (void) fprintf(outf,"\tCity:             %s\n",way->city);
964   }
965   if (way->wpt_class==0x83) {
966     (void) fprintf(outf,"\tAddress:          %s\n",way->addr);
967   }
968   if (way->wpt_class==0x82) {
969     (void) fprintf(outf,"\tCross Road:       %s\n",way->cross_road);
970   }
971 
972 
973   return;
974 }
975 
976 /* @funcstatic GPS_Fmt_Print_Way109 ************************************
977 **
978 ** Output waypoint D109
979 **
980 ** @param [r] way [GPS_PWay] waypoint
981 ** @param [w] outf [FILE *] output stream
982 **
983 ** @return [void]
984 ************************************************************************/
985 
GPS_Fmt_Print_Way109(GPS_PWay way,FILE * outf)986 static void GPS_Fmt_Print_Way109(GPS_PWay way, FILE* outf)
987 {
988   char** p;
989   int32  x;
990 
991   static char* dspl[]= {
992     "SW","S","SC"
993   };
994 
995   static char* col[]= {
996     "Black","Dark_Red","Dark_Green","Dark_Yellow","Dark_Blue",
997     "Dark_Magenta","Dark_Cyan","Light_Grey","Dark_Grey","Red","Green",
998     "Yellow","Blue","Magenta","Cyan","White"
999   };
1000 
1001 
1002   if (way->smbl < 8192) {
1003     p = gps_marine_sym;
1004     x = 0;
1005   } else if (way->smbl < 16384) {
1006     p = gps_land_sym;
1007     x = 8192;
1008   } else {
1009     p = gps_aviation_sym;
1010     x = 16384;
1011   }
1012 
1013   (void) fprintf(outf,"\tIdent:            %s\n",way->ident);
1014   (void) fprintf(outf,"\tLatitude:         %f\n",way->lat);
1015   (void) fprintf(outf,"\tLongitude:        %f\n",way->lon);
1016   if (way->colour==0xff) {
1017     (void) fprintf(outf,"\tColour:           255    [Default]\n");
1018   } else
1019     (void) fprintf(outf,"\tColour:           %-6d [%s]\n",(int)way->colour,
1020                    col[way->colour]);
1021 #if 0
1022   /* avoid bounds violation in D109.   Probably masking a bug elswhere...*/
1023   (void) fprintf(outf,"\tDisplay:          %-6d [%s]\n",(int)way->dspl,
1024                  dspl[way->dspl]);
1025 #endif
1026   (void) fprintf(outf,"\tSymbol:           %-6d [%s]\n",(int)way->smbl,
1027                  p[way->smbl-x]);
1028   (void) fprintf(outf,"\tAltitude:         %d\n",(int)way->alt);
1029   (void) fprintf(outf,"\tDepth:            %f\n",way->dpth);
1030   (void) fprintf(outf,"\tState:            %-2.2s\n",way->state);
1031   (void) fprintf(outf,"\tCountry:          %-2.2s\n",way->cc);
1032   (void) fprintf(outf,"\tClass:            %d\n",way->wpt_class);
1033   if (way->wpt_class>=0x80 && way->wpt_class<=0x85) {
1034     (void) fprintf(outf,"\tSubclass:         %18.18s\n",way->subclass);
1035   }
1036   if (!way->wpt_class) {
1037     (void) fprintf(outf,"\tComment:          %s\n",way->cmnt);
1038   }
1039   if (way->wpt_class>=0x40 && way->wpt_class<=0x46) {
1040     (void) fprintf(outf,"\tFacility:         %s\n",way->facility);
1041     (void) fprintf(outf,"\tCity:             %s\n",way->city);
1042   }
1043   if (way->wpt_class==0x83) {
1044     (void) fprintf(outf,"\tAddress:          %s\n",way->addr);
1045   }
1046   if (way->wpt_class==0x82) {
1047     (void) fprintf(outf,"\tCross Road:       %s\n",way->cross_road);
1048   }
1049 
1050 
1051   return;
1052 }
1053 
1054 /* @funcstatic GPS_Fmt_Print_Way150 *************************************
1055 **
1056 ** Output waypoint D150
1057 **
1058 ** @param [r] way [GPS_PWay] waypoint
1059 ** @param [w] outf [FILE *] output stream
1060 **
1061 ** @return [void]
1062 ************************************************************************/
1063 
GPS_Fmt_Print_Way150(GPS_PWay way,FILE * outf)1064 static void GPS_Fmt_Print_Way150(GPS_PWay way, FILE* outf)
1065 {
1066 
1067   (void) fprintf(outf,"\tIdent:            %-6.6s\n",way->ident);
1068   (void) fprintf(outf,"\tLatitude:         %f\n",way->lat);
1069   (void) fprintf(outf,"\tLongitude:        %f\n",way->lon);
1070   (void) fprintf(outf,"\tComment:          %-40.40s\n",way->cmnt);
1071   (void) fprintf(outf,"\tClass:            %d\n",way->wpt_class);
1072   if (way->wpt_class!=4) {
1073     (void) fprintf(outf,"\tCountry:          %-2.2s\n",way->cc);
1074     (void) fprintf(outf,"\tCity:             %-24.24s\n",way->city);
1075     (void) fprintf(outf,"\tState:            %-2.2s\n",way->state);
1076     (void) fprintf(outf,"\tName:             %-30.30s\n",way->name);
1077   }
1078   if (!way->wpt_class) {
1079     (void) fprintf(outf,"\tAltitude:         %d\n",(int)way->alt);
1080   }
1081 
1082   return;
1083 }
1084 
1085 
1086 /* @funcstatic GPS_Fmt_Print_Way151 ************************************
1087 **
1088 ** Output waypoint D151
1089 **
1090 ** @param [r] way [GPS_PWay] waypoint
1091 ** @param [w] outf [FILE *] output stream
1092 **
1093 ** @return [void]
1094 ************************************************************************/
1095 
GPS_Fmt_Print_Way151(GPS_PWay way,FILE * outf)1096 static void GPS_Fmt_Print_Way151(GPS_PWay way, FILE* outf)
1097 {
1098 
1099   (void) fprintf(outf,"\tIdent:            %-6.6s\n",way->ident);
1100   (void) fprintf(outf,"\tLatitude:         %f\n",way->lat);
1101   (void) fprintf(outf,"\tLongitude:        %f\n",way->lon);
1102   (void) fprintf(outf,"\tComment:          %-40.40s\n",way->cmnt);
1103   (void) fprintf(outf,"\tClass:            %d\n",way->wpt_class);
1104   if (way->wpt_class!=2) {
1105     (void) fprintf(outf,"\tCountry:          %-2.2s\n",way->cc);
1106     (void) fprintf(outf,"\tCity:             %-24.24s\n",way->city);
1107     (void) fprintf(outf,"\tState:            %-2.2s\n",way->state);
1108     (void) fprintf(outf,"\tName:             %-30.30s\n",way->name);
1109   }
1110   if (!way->wpt_class) {
1111     (void) fprintf(outf,"\tAltitude:         %d\n",(int)way->alt);
1112   }
1113 
1114   return;
1115 }
1116 
1117 
1118 
1119 /* @funcstatic GPS_Fmt_Print_Way152 ************************************
1120 **
1121 ** Output waypoint D152
1122 **
1123 ** @param [r] way [GPS_PWay] waypoint
1124 ** @param [w] outf [FILE *] output stream
1125 **
1126 ** @return [void]
1127 ************************************************************************/
1128 
GPS_Fmt_Print_Way152(GPS_PWay way,FILE * outf)1129 static void GPS_Fmt_Print_Way152(GPS_PWay way, FILE* outf)
1130 {
1131 
1132   (void) fprintf(outf,"\tIdent:            %-6.6s\n",way->ident);
1133   (void) fprintf(outf,"\tLatitude:         %f\n",way->lat);
1134   (void) fprintf(outf,"\tLongitude:        %f\n",way->lon);
1135   (void) fprintf(outf,"\tComment:          %-40.40s\n",way->cmnt);
1136   (void) fprintf(outf,"\tClass:            %d\n",way->wpt_class);
1137   if (way->wpt_class!=4) {
1138     (void) fprintf(outf,"\tCountry:          %-2.2s\n",way->cc);
1139     (void) fprintf(outf,"\tCity:             %-24.24s\n",way->city);
1140     (void) fprintf(outf,"\tState:            %-2.2s\n",way->state);
1141     (void) fprintf(outf,"\tName:             %-30.30s\n",way->name);
1142   }
1143   if (!way->wpt_class) {
1144     (void) fprintf(outf,"\tAltitude:         %d\n",(int)way->alt);
1145   }
1146 
1147   return;
1148 }
1149 
1150 
1151 /* @funcstatic GPS_Fmt_Print_Way154 ************************************
1152 **
1153 ** Output waypoint D154
1154 **
1155 ** @param [r] way [GPS_PWay] waypoint
1156 ** @param [w] outf [FILE *] output stream
1157 **
1158 ** @return [void]
1159 ************************************************************************/
1160 
GPS_Fmt_Print_Way154(GPS_PWay way,FILE * outf)1161 static void GPS_Fmt_Print_Way154(GPS_PWay way, FILE* outf)
1162 {
1163   char** p;
1164   int32  x;
1165 
1166   if (way->smbl < 8192) {
1167     p = gps_marine_sym;
1168     x = 0;
1169   } else if (way->smbl < 16384) {
1170     p = gps_land_sym;
1171     x = 8192;
1172   } else {
1173     p = gps_aviation_sym;
1174     x = 16384;
1175   }
1176 
1177 
1178   (void) fprintf(outf,"\tIdent:            %-6.6s\n",way->ident);
1179   (void) fprintf(outf,"\tLatitude:         %f\n",way->lat);
1180   (void) fprintf(outf,"\tLongitude:        %f\n",way->lon);
1181   (void) fprintf(outf,"\tComment:          %-40.40s\n",way->cmnt);
1182   (void) fprintf(outf,"\tSymbol:           %-6d [%s]\n",(int)way->smbl,
1183                  p[way->smbl-x]);
1184   (void) fprintf(outf,"\tClass:            %d\n",way->wpt_class);
1185   if (way->wpt_class!=4 && way->wpt_class!=8) {
1186     (void) fprintf(outf,"\tCountry:          %-2.2s\n",way->cc);
1187     (void) fprintf(outf,"\tCity:             %-24.24s\n",way->city);
1188     (void) fprintf(outf,"\tState:            %-2.2s\n",way->state);
1189     (void) fprintf(outf,"\tName:             %-30.30s\n",way->name);
1190   }
1191   if (!way->wpt_class) {
1192     (void) fprintf(outf,"\tAltitude:         %d\n",(int)way->alt);
1193   }
1194 
1195   return;
1196 }
1197 
1198 
1199 /* @funcstatic GPS_Fmt_Print_Way155 *************************************
1200 **
1201 ** Output waypoint D155
1202 **
1203 ** @param [r] way [GPS_PWay] waypoint
1204 ** @param [w] outf [FILE *] output stream
1205 **
1206 ** @return [void]
1207 ************************************************************************/
1208 
GPS_Fmt_Print_Way155(GPS_PWay way,FILE * outf)1209 static void GPS_Fmt_Print_Way155(GPS_PWay way, FILE* outf)
1210 {
1211   static char* dspl[]= {
1212     "","S","","SW","","SC"
1213   };
1214 
1215   char** p;
1216   int32  x;
1217 
1218   if (way->smbl < 8192) {
1219     p = gps_marine_sym;
1220     x = 0;
1221   } else if (way->smbl < 16384) {
1222     p = gps_land_sym;
1223     x = 8192;
1224   } else {
1225     p = gps_aviation_sym;
1226     x = 16384;
1227   }
1228 
1229 
1230   (void) fprintf(outf,"\tIdent:            %-6.6s\n",way->ident);
1231   (void) fprintf(outf,"\tLatitude:         %f\n",way->lat);
1232   (void) fprintf(outf,"\tLongitude:        %f\n",way->lon);
1233   (void) fprintf(outf,"\tComment:          %-40.40s\n",way->cmnt);
1234   (void) fprintf(outf,"\tSymbol:           %-6d [%s]\n",(int)way->smbl,
1235                  p[way->smbl-x]);
1236   (void) fprintf(outf,"\tDisplay:          %-6d [%s]\n",(int)way->dspl,
1237                  dspl[way->dspl]);
1238   (void) fprintf(outf,"\tClass:            %d\n",way->wpt_class);
1239   if (way->wpt_class!=4 && way->wpt_class!=8) {
1240     (void) fprintf(outf,"\tCountry:          %-2.2s\n",way->cc);
1241     (void) fprintf(outf,"\tCity:             %-24.24s\n",way->city);
1242     (void) fprintf(outf,"\tState:            %-2.2s\n",way->state);
1243     (void) fprintf(outf,"\tName:             %-30.30s\n",way->name);
1244   }
1245   if (!way->wpt_class) {
1246     (void) fprintf(outf,"\tAltitude:         %d\n",(int)way->alt);
1247   }
1248 
1249   return;
1250 }
1251 
1252 
1253 
1254 /* @func GPS_Fmt_Print_Route *****************************************
1255 **
1256 ** Output route(s)
1257 **
1258 ** @param [r] way [GPS_PWay *] waypoint array
1259 ** @param [r] n [int32] number of waypoint entries
1260 ** @param [w] outf [FILE *] output stream
1261 **
1262 ** @return [int32] success
1263 ************************************************************************/
1264 
GPS_Fmt_Print_Route(GPS_PWay * way,int32 n,FILE * outf)1265 int32 GPS_Fmt_Print_Route(GPS_PWay* way, int32 n, FILE* outf)
1266 {
1267   int32 i;
1268   int32 first;
1269 
1270   if (!n) {
1271     return 1;
1272   }
1273 
1274 
1275   switch (gps_route_transfer) {
1276   case pA200:
1277     break;
1278   case pA201:
1279     return GPS_Fmt_Print_Route201(way,n,outf);
1280   default:
1281     GPS_Error("GPS_Fmt_Print_Route: Unknown protocol");
1282     return PROTOCOL_ERROR;
1283   }
1284 
1285 
1286   (void) fprintf(outf,"Route log 200 %d\n#\n",(int)gps_rte_type);
1287   (void) fprintf(outf,"Start\n#\n");
1288 
1289 
1290 
1291   first = 1;
1292 
1293   for (i=0; i<n; ++i) {
1294     if (way[i]->isrte) {
1295       if (!first) {
1296         (void) fprintf(outf,"End\n#\n");
1297       }
1298       (void) fprintf(outf,"Route Type: %d ",(int)way[i]->rte_prot);
1299       first=0;
1300 
1301       switch (way[i]->rte_prot) {
1302       case 200:
1303         (void) fprintf(outf,"Number: %d",way[i]->rte_num);
1304         break;
1305       case 201:
1306         (void) fprintf(outf,"Number: %d Comment: %-20.20s",
1307                        way[i]->rte_num,way[i]->rte_cmnt);
1308         break;
1309       case 202:
1310         (void) fprintf(outf,"Comment: %s",way[i]->rte_ident);
1311         break;
1312       default:
1313         GPS_Error("Print_Route: Unknown route protocol");
1314         return PROTOCOL_ERROR;
1315       }
1316       (void) fprintf(outf,"\n#\n");
1317       (void) fprintf(outf,"Waypoints Type: %d\n#\nStart\n#\n"
1318                      ,(int)way[i]->prot);
1319       continue;
1320     }
1321 
1322     switch (way[i]->prot) {
1323     case 100:
1324       GPS_Fmt_Print_Way100(way[i],outf);
1325       break;
1326     case 101:
1327       GPS_Fmt_Print_Way101(way[i],outf);
1328       break;
1329     case 102:
1330       GPS_Fmt_Print_Way102(way[i],outf);
1331       break;
1332     case 103:
1333       GPS_Fmt_Print_Way103(way[i],outf);
1334       break;
1335     case 104:
1336       GPS_Fmt_Print_Way104(way[i],outf);
1337       break;
1338     case 105:
1339       GPS_Fmt_Print_Way105(way[i],outf);
1340       break;
1341     case 106:
1342       GPS_Fmt_Print_Way106(way[i],outf);
1343       break;
1344     case 107:
1345       GPS_Fmt_Print_Way107(way[i],outf);
1346       break;
1347     case 108:
1348       GPS_Fmt_Print_Way108(way[i],outf);
1349       break;
1350     case 109:
1351       GPS_Fmt_Print_Way109(way[i],outf);
1352       break;
1353     case 150:
1354       GPS_Fmt_Print_Way150(way[i],outf);
1355       break;
1356     case 151:
1357       GPS_Fmt_Print_Way151(way[i],outf);
1358       break;
1359     case 152:
1360       GPS_Fmt_Print_Way152(way[i],outf);
1361       break;
1362     case 154:
1363       GPS_Fmt_Print_Way154(way[i],outf);
1364       break;
1365     case 155:
1366       GPS_Fmt_Print_Way155(way[i],outf);
1367       break;
1368     default:
1369       GPS_Error("Print_Route: Unknown waypoint protocol");
1370       return PROTOCOL_ERROR;
1371     }
1372     (void) fprintf(outf,"#\n");
1373   }
1374   (void) fprintf(outf,"End\n#\n");
1375 
1376   return 1;
1377 }
1378 
1379 
1380 
1381 /* @funcstatic GPS_Fmt_Print_Route201 ***********************************
1382 **
1383 ** Output route(s)
1384 **
1385 ** @param [r] way [GPS_PWay *] waypoint array
1386 ** @param [r] n [int32] number of waypoint entries
1387 ** @param [w] outf [FILE *] output stream
1388 **
1389 ** @return [int32] success
1390 ************************************************************************/
1391 
GPS_Fmt_Print_Route201(GPS_PWay * way,int32 n,FILE * outf)1392 static int32 GPS_Fmt_Print_Route201(GPS_PWay* way, int32 n, FILE* outf)
1393 {
1394   int32 i;
1395   int32 first;
1396 
1397   if (!n) {
1398     return 1;
1399   }
1400 
1401 
1402   (void) fprintf(outf,"Route log 201 %d\n#\n",(int)gps_rte_link_type);
1403   (void) fprintf(outf,"Start\n#\n");
1404 
1405 
1406   first = 1;
1407 
1408   for (i=0; i<n; ++i) {
1409     if (way[i]->isrte) {
1410       if (!first) {
1411         (void) fprintf(outf,"End\n#\n");
1412       }
1413       (void) fprintf(outf,"Route Type: %d ",(int)way[i]->rte_prot);
1414       first=0;
1415 
1416       switch (way[i]->rte_prot) {
1417       case 200:
1418         (void) fprintf(outf,"Number: %d",way[i]->rte_num);
1419         break;
1420       case 201:
1421         (void) fprintf(outf,"Number: %d Comment: %-20.20s",
1422                        way[i]->rte_num,way[i]->rte_cmnt);
1423         break;
1424       case 202:
1425         (void) fprintf(outf,"Comment: %s",way[i]->rte_ident);
1426         break;
1427       default:
1428         GPS_Error("Print_Route: Unknown route protocol");
1429         return PROTOCOL_ERROR;
1430       }
1431       (void) fprintf(outf,"\n#\n");
1432       (void) fprintf(outf,"Waypoints Type: %d\n#\n"
1433                      ,(int)way[i]->prot);
1434       continue;
1435     }
1436 
1437 
1438     if (way[i]->islink) {
1439       (void) fprintf(outf,"\tLink Class:       %d\n",
1440                      (int)way[i]->rte_link_class);
1441       if (!(way[i]->rte_link_class==3 || way[i]->rte_link_class==0xff))
1442         (void) fprintf(outf,"\tLink Subclass:    %-18.18s\n",
1443                        way[i]->rte_link_subclass);
1444       (void) fprintf(outf,"\tLink Ident:       %s\n#\n",
1445                      way[i]->rte_link_ident);
1446       continue;
1447     }
1448 
1449 
1450     switch (way[i]->prot) {
1451     case 100:
1452       GPS_Fmt_Print_Way100(way[i],outf);
1453       break;
1454     case 101:
1455       GPS_Fmt_Print_Way101(way[i],outf);
1456       break;
1457     case 102:
1458       GPS_Fmt_Print_Way102(way[i],outf);
1459       break;
1460     case 103:
1461       GPS_Fmt_Print_Way103(way[i],outf);
1462       break;
1463     case 104:
1464       GPS_Fmt_Print_Way104(way[i],outf);
1465       break;
1466     case 105:
1467       GPS_Fmt_Print_Way105(way[i],outf);
1468       break;
1469     case 106:
1470       GPS_Fmt_Print_Way106(way[i],outf);
1471       break;
1472     case 107:
1473       GPS_Fmt_Print_Way107(way[i],outf);
1474       break;
1475     case 108:
1476       GPS_Fmt_Print_Way108(way[i],outf);
1477       break;
1478     case 109:
1479       GPS_Fmt_Print_Way109(way[i],outf);
1480       break;
1481     case 150:
1482       GPS_Fmt_Print_Way150(way[i],outf);
1483       break;
1484     case 151:
1485       GPS_Fmt_Print_Way151(way[i],outf);
1486       break;
1487     case 152:
1488       GPS_Fmt_Print_Way152(way[i],outf);
1489       break;
1490     case 154:
1491       GPS_Fmt_Print_Way154(way[i],outf);
1492       break;
1493     case 155:
1494       GPS_Fmt_Print_Way155(way[i],outf);
1495       break;
1496     default:
1497       GPS_Error("Print_Route: Unknown waypoint protocol");
1498       return PROTOCOL_ERROR;
1499     }
1500     (void) fprintf(outf,"#\n");
1501   }
1502   (void) fprintf(outf,"End\n");
1503 
1504   return 1;
1505 }
1506