Skip to content

Commit 9117a3c

Browse files
authored
remove commented out tpo code from 2012. (#1371)
1 parent e3c01bc commit 9117a3c

File tree

1 file changed

+0
-142
lines changed

1 file changed

+0
-142
lines changed

tpo.cc

Lines changed: 0 additions & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -502,21 +502,9 @@ void TpoFormatBase::tpo_process_tracks()
502502
} else { // Assign a generic style name
503503
styles[ii].name = QStringLiteral("STYLE %1").arg(ii);
504504
}
505-
#ifdef Tracks2012
506-
//TBD: Should this be TRACKNAMELENGTH?
507-
for (unsigned xx = 0; xx < 3; xx++) {
508-
if (styles[ii].name[xx] == ',') {
509-
styles[ii].name[xx] = '_';
510-
}
511-
if (styles[ii].name[xx] == '=') {
512-
styles[ii].name[xx] = '_';
513-
}
514-
}
515-
#else
516505
// Should limit be TRACKNAMELENGTH? No! But also should not be '3' like it was.
517506
styles[ii].name.replace(',', '_');
518507
styles[ii].name.replace('=', '_');
519-
#endif
520508

521509
// one byte for line width (value 1-4), one byte for 'dashed' boolean
522510
styles[ii].wide = (uint8_t) gbfgetc(tpo_file_in);
@@ -701,9 +689,6 @@ void TpoFormatBase::tpo_process_tracks()
701689
int latscale = 0;
702690
int lonscale = 0;
703691

704-
#ifdef Tracks2012
705-
int llvalid = 0; // boolean has been replaced with multiple modes
706-
#else
707692
#define EndScalePoints 0
708693
#define CheckLonScale 1
709694
#define CheckLatScale 2
@@ -715,78 +700,13 @@ void TpoFormatBase::tpo_process_tracks()
715700
int tpmode = GetFullPoint; // prior to 2020 we used "llvalid" (boolean), which did not provide enough flow control
716701
#define EndScaleTag 0x00
717702
#define FullPointTag 0x88
718-
#endif
719703

720704
// Process the track bytes - ugly flow control due to many special cases in file structure
721705
int cnttp = 0; // just for debug stroking
722706
float lastlat = 0.0; // to catch discontinuities we can't seem to fix
723707
float lastlon = 0.0;
724708
for (unsigned int jj = 0; jj < track_byte_count;) { // NO INCREMENT - advance "jj" in the loop
725709
Waypoint* waypoint_temp;
726-
#ifdef Tracks2012
727-
if constexpr(debug > 3) {
728-
gbDebug("%02x %02x %02x %02x - byte %u, track %u, llvallid=%d\n",
729-
buf[jj], buf[jj+1], buf[jj+2], buf[jj+3], jj, ii+1, llvalid);
730-
}
731-
// Time to read a new latlong?
732-
if (!llvalid) {
733-
734-
lon = le_read32(&buf[jj]);
735-
if constexpr(debug > 3) {
736-
gbDebug("%02x %02x %02x %02x - raw lon = %d (byte %u)\n", buf[jj], buf[jj+1], buf[jj+2], buf[jj+3], lon,jj);
737-
}
738-
jj+=4;
739-
740-
lat = le_read32(&buf[jj]);
741-
if constexpr(debug > 3) {
742-
gbDebug("%02x %02x %02x %02x - raw lat = %d (byte %u)\n", buf[jj], buf[jj+1], buf[jj+2], buf[jj+3], lat,jj);
743-
}
744-
jj+=4;
745-
746-
//printf("L");
747-
748-
// Peek to see if next is a lonscale. Note that it
749-
// can begin with 0x88, which is confusing. Here we
750-
// allow up to 16-bits of offset, so two of the
751-
// bytes must be 0x00 for us to recognize it.
752-
if (jj+3<track_byte_count
753-
&& !buf[jj+3]
754-
&& !buf[jj+2]) {
755-
756-
lonscale = le_read32(&buf[jj]);
757-
if constexpr(debug > 3) {
758-
gbDebug("%02x %02x %02x %02x - raw lon scale = %d (byte %u)\n", buf[jj], buf[jj+1], buf[jj+2], buf[jj+3], lonscale, jj);
759-
}
760-
//printf(" LONSCALE:");
761-
//printf("%02x%02x%02x%02x", buf[jj], buf[jj+1], buf[jj+2], buf[jj+3]);
762-
jj+=4;
763-
}
764-
// Peek to see if next is a latscale. Note that it
765-
// can begin with 0x88, which is confusing. Here we
766-
// allow up to 16-bits of offset, so two of the
767-
// bytes must be 0x00 for us to recognize it.
768-
if (jj+3<track_byte_count
769-
&& !buf[jj+3]
770-
&& !buf[jj+2]) {
771-
772-
latscale = le_read32(&buf[jj]);
773-
if constexpr(debug > 3) {
774-
gbDebug("%02x %02x %02x %02x - raw lat scale = %d (byte %u)\n", buf[jj], buf[jj+1], buf[jj+2], buf[jj+3], latscale, jj);
775-
}
776-
//printf(" LATSCALE:");
777-
//printf("%02x%02x%02x%02x ", buf[jj], buf[jj+1], buf[jj+2], buf[jj+3]);
778-
jj+=4;
779-
}
780-
llvalid = 1;
781-
782-
waypoint_temp = tpo_convert_ll(lat, lon);
783-
track_add_wpt(track_temp, waypoint_temp);
784-
cnttp++;
785-
if constexpr(debug > 3) {
786-
gbDebug("Adding BASIC trackpoint #%i: lat=%.5f, lon=%.5f\n", cnttp, waypoint_temp->latitude, waypoint_temp->longitude);
787-
}
788-
}
789-
#else
790710
if constexpr(debug > 3) {
791711
gbDebug("%02x %02x %02x %02x = bytes %u-%u (track %u, mode now %s)\n",
792712
buf[jj], buf[jj+1], buf[jj+2], buf[jj+3], jj, jj+3, ii+1, tpmodeshow[tpmode]);
@@ -863,19 +783,7 @@ void TpoFormatBase::tpo_process_tracks()
863783
tpmode = Check0x88Tag;
864784
continue; // for jj
865785
}
866-
#endif
867786

868-
#ifdef Tracks2012
869-
// Check whether there's a lonlat coming up instead of
870-
// offsets.
871-
else if (buf[jj] == 0x88) {
872-
if constexpr(debug > 3) {
873-
gbDebug("%02x should mean full lat/lon comes next (byte %u)\n",buf[jj],jj);
874-
}
875-
jj++;
876-
llvalid = 0;
877-
}
878-
#else
879787
// Check whether 8 bytes of lon+lat are next, instead of offsets or another scaling spec.
880788
// 0x88 is a tag that signals a full trackpoint will follow
881789
if (tpmode == Check0x88Tag) {
@@ -890,56 +798,7 @@ void TpoFormatBase::tpo_process_tracks()
890798
tpmode = ScaleOneByte; // only if no 0x88 tag
891799
continue; // for jj
892800
}
893-
#endif
894-
895-
#ifdef Tracks2012
896-
// Check whether there's a lonlat + lonscale/latscale
897-
// combo embedded in this track next.
898-
else if (buf[jj] == 0x00) {
899-
if constexpr(debug > 3) {
900-
gbDebug("%02x should mean full lat/lon or lonscale/latscale comes next (at byte %u)\n",buf[jj],jj);
901-
}
902-
//printf(" ZERO ");
903-
jj++;
904-
llvalid = 0;
905-
}
906-
907-
// Process the delta
908-
else {
909-
static const int scarray[] = {0,1,2,3,4,5,6,7,-8,-7,-6,-5,-4,-3,-2,-1};
910-
if constexpr(debug) {
911-
gbDebug("%02x - lat mult = %d, lon mult=%d, byte %u\n", buf[jj], scarray[buf[jj] & 0xf], scarray[buf[jj] >> 4], jj);
912-
}
913-
914-
915-
if (buf[jj] == 0) {
916-
gbFatal("Found unexpected ZERO\n");
917-
}
918801

919-
if (latscale == 0 || lonscale == 0) {
920-
gbFatal("Found bad scales lonscale=0x%x latscale=0x%x\n", lonscale, latscale);
921-
}
922-
923-
924-
if constexpr(debug > 3) {
925-
gbDebug("%02x - adjusting prev lat/lon from %i/%i", buf[jj], lat, lon);
926-
}
927-
lon += lonscale * scarray[buf[jj] >> 4];
928-
lat += latscale * scarray[(buf[jj] & 0xf)];
929-
if constexpr(debug > 3) {
930-
gbDebug(" to %i/%i, byte %u\n", lat, lon, jj);
931-
}
932-
//printf(".");
933-
jj++;
934-
935-
waypoint_temp = tpo_convert_ll(lat, lon);
936-
track_add_wpt(track_temp, waypoint_temp);
937-
cnttp++;
938-
if constexpr(debug > 3) {
939-
gbDebug("Adding ADJUSTED trackpoint #%i: lat=%.5f, lon=%.5f\n", cnttp, waypoint_temp->latitude, waypoint_temp->longitude);
940-
}
941-
}
942-
#else
943802
// ScaleOneByte applies lonscale and latscale to a single byte to create an 8-byte lat+lon
944803
// EndScalePoints (0) is a tag that signals an end to adjusted trackpoints (full point or scale may follow)
945804
if (tpmode == ScaleOneByte) {
@@ -1003,7 +862,6 @@ void TpoFormatBase::tpo_process_tracks()
1003862
lastlat = waypoint_temp->latitude;
1004863
lastlon = waypoint_temp->longitude;
1005864
} // if ScaleOneByte
1006-
#endif
1007865

1008866
} // end for jj track_byte_count
1009867
} // end for ii track_count

0 commit comments

Comments
 (0)