Browse Source

various fixes for altitude in tpo readers:

for TOPO versions older than 3, and TOPO versions 3 and newer, don't use an altitude of zero for unknown as this represents a valid altitude.
for TOPO versions 3 and newer don't truncate the fractional part of altitude.
for TOPO versions 3 and newer correctly convert negative altitudes.
for TOPO versions 3 and newer change the value used to check for unknown altitudes.
tags/gpsbabel_1_5_4
tsteven4 4 years ago
parent
commit
2de8ca5830
8 changed files with 1656 additions and 4728 deletions
  1. 12
    12
      reference/LineStyles.gpx
  2. 12
    12
      reference/LineStyles.kml
  3. BIN
      reference/NegElev.tpo
  4. 34
    0
      reference/NegElev.~tpo.gpx
  5. 23
    23
      reference/tpo-sample3.gpx
  6. 1558
    4674
      reference/track/tpo-sample1.gpx
  7. 4
    0
      testo.d/tpo.test
  8. 13
    7
      tpo.cc

+ 12
- 12
reference/LineStyles.gpx View File

@@ -3,73 +3,73 @@
<time>1970-01-01T00:00:00Z</time>
<bounds minlat="37.507930994" minlon="-122.292645574" maxlat="37.538625002" maxlon="-122.258695364"/>
<wpt lat="37.538136244" lon="-122.291540504">
<ele>2.000000</ele>
<ele>2.130000</ele>
<name>HairDash0</name>
<cmt>HairDash0</cmt>
<desc>HairDash0</desc>
</wpt>
<wpt lat="37.535985708" lon="-122.291663289">
<ele>3.000000</ele>
<ele>3.350000</ele>
<name>ThinDash0</name>
<cmt>ThinDash0</cmt>
<desc>ThinDash0</desc>
</wpt>
<wpt lat="37.533444166" lon="-122.292031646">
<ele>4.000000</ele>
<ele>4.570000</ele>
<name>RedHair0</name>
<cmt>RedHair0</cmt>
<desc>RedHair0</desc>
</wpt>
<wpt lat="37.530853748" lon="-122.292277217">
<ele>8.000000</ele>
<ele>8.840000</ele>
<name>RedThin0</name>
<cmt>RedThin0</cmt>
<desc>RedThin0</desc>
</wpt>
<wpt lat="37.528654337" lon="-122.292584181">
<ele>21.000000</ele>
<ele>21.030000</ele>
<name>RedMed0</name>
<cmt>RedMed0</cmt>
<desc>RedMed0</desc>
</wpt>
<wpt lat="37.524988651" lon="-122.292645574">
<ele>64.000000</ele>
<ele>64.920000</ele>
<name>RedThick0</name>
<cmt>RedThick0</cmt>
<desc>RedThick0</desc>
</wpt>
<wpt lat="37.520198822" lon="-122.292093039">
<ele>125.000000</ele>
<ele>125.580000</ele>
<name>YellowMed0</name>
<cmt>YellowMed0</cmt>
<desc>YellowMed0</desc>
</wpt>
<wpt lat="37.517950535" lon="-122.291847467">
<ele>61.000000</ele>
<ele>61.260000</ele>
<name>GreenMed0</name>
<cmt>GreenMed0</cmt>
<desc>GreenMed0</desc>
</wpt>
<wpt lat="37.515653372" lon="-122.291970253">
<ele>39.000000</ele>
<ele>39.320000</ele>
<name>BlueMed0</name>
<cmt>BlueMed0</cmt>
<desc>BlueMed0</desc>
</wpt>
<wpt lat="37.513160706" lon="-122.291110754">
<ele>37.000000</ele>
<ele>37.490000</ele>
<name>PurpleMed0</name>
<cmt>PurpleMed0</cmt>
<desc>PurpleMed0</desc>
</wpt>
<wpt lat="37.510277033" lon="-122.291356325">
<ele>59.000000</ele>
<ele>59.440000</ele>
<name>BlackMed0</name>
<cmt>BlackMed0</cmt>
<desc>BlackMed0</desc>
</wpt>
<wpt lat="37.508028746" lon="-122.291724682">
<ele>49.000000</ele>
<ele>49.680000</ele>
<name>WhiteMed0</name>
<cmt>WhiteMed0</cmt>
<desc>WhiteMed0</desc>

+ 12
- 12
reference/LineStyles.kml View File

@@ -77,84 +77,84 @@
<name>HairDash0</name>
<styleUrl>#waypoint</styleUrl>
<Point>
<coordinates>-122.291541,37.538136,2.00</coordinates>
<coordinates>-122.291541,37.538136,2.13</coordinates>
</Point>
</Placemark>
<Placemark>
<name>ThinDash0</name>
<styleUrl>#waypoint</styleUrl>
<Point>
<coordinates>-122.291663,37.535986,3.00</coordinates>
<coordinates>-122.291663,37.535986,3.35</coordinates>
</Point>
</Placemark>
<Placemark>
<name>RedHair0</name>
<styleUrl>#waypoint</styleUrl>
<Point>
<coordinates>-122.292032,37.533444,4.00</coordinates>
<coordinates>-122.292032,37.533444,4.57</coordinates>
</Point>
</Placemark>
<Placemark>
<name>RedThin0</name>
<styleUrl>#waypoint</styleUrl>
<Point>
<coordinates>-122.292277,37.530854,8.00</coordinates>
<coordinates>-122.292277,37.530854,8.84</coordinates>
</Point>
</Placemark>
<Placemark>
<name>RedMed0</name>
<styleUrl>#waypoint</styleUrl>
<Point>
<coordinates>-122.292584,37.528654,21.00</coordinates>
<coordinates>-122.292584,37.528654,21.03</coordinates>
</Point>
</Placemark>
<Placemark>
<name>RedThick0</name>
<styleUrl>#waypoint</styleUrl>
<Point>
<coordinates>-122.292646,37.524989,64.00</coordinates>
<coordinates>-122.292646,37.524989,64.92</coordinates>
</Point>
</Placemark>
<Placemark>
<name>YellowMed0</name>
<styleUrl>#waypoint</styleUrl>
<Point>
<coordinates>-122.292093,37.520199,125.00</coordinates>
<coordinates>-122.292093,37.520199,125.58</coordinates>
</Point>
</Placemark>
<Placemark>
<name>GreenMed0</name>
<styleUrl>#waypoint</styleUrl>
<Point>
<coordinates>-122.291847,37.517951,61.00</coordinates>
<coordinates>-122.291847,37.517951,61.26</coordinates>
</Point>
</Placemark>
<Placemark>
<name>BlueMed0</name>
<styleUrl>#waypoint</styleUrl>
<Point>
<coordinates>-122.291970,37.515653,39.00</coordinates>
<coordinates>-122.291970,37.515653,39.32</coordinates>
</Point>
</Placemark>
<Placemark>
<name>PurpleMed0</name>
<styleUrl>#waypoint</styleUrl>
<Point>
<coordinates>-122.291111,37.513161,37.00</coordinates>
<coordinates>-122.291111,37.513161,37.49</coordinates>
</Point>
</Placemark>
<Placemark>
<name>BlackMed0</name>
<styleUrl>#waypoint</styleUrl>
<Point>
<coordinates>-122.291356,37.510277,59.00</coordinates>
<coordinates>-122.291356,37.510277,59.44</coordinates>
</Point>
</Placemark>
<Placemark>
<name>WhiteMed0</name>
<styleUrl>#waypoint</styleUrl>
<Point>
<coordinates>-122.291725,37.508029,49.00</coordinates>
<coordinates>-122.291725,37.508029,49.68</coordinates>
</Point>
</Placemark>
<Placemark>

BIN
reference/NegElev.tpo View File


+ 34
- 0
reference/NegElev.~tpo.gpx View File

@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<gpx version="1.0" creator="GPSBabel - http://www.gpsbabel.org" xmlns="http://www.topografix.com/GPX/1/0">
<time>1970-01-01T00:00:00Z</time>
<bounds minlat="35.925966620" minlon="-119.142470002" maxlat="37.755579948" maxlon="-116.689650059"/>
<wpt lat="35.937649965" lon="-116.704583287">
<ele>-11.000000</ele>
<name>MINUS11m</name>
<cmt>MINUS11m</cmt>
<desc>MINUS11m</desc>
</wpt>
<wpt lat="35.935250044" lon="-116.722333312">
<ele>-53.000000</ele>
<name>MINUS53m</name>
<cmt>MINUS53m</cmt>
<desc>MINUS53m</desc>
</wpt>
<wpt lat="35.925966620" lon="-116.691149950">
<ele>14.000000</ele>
<name>PLUS14m</name>
<cmt>PLUS14m</cmt>
<desc>PLUS14m</desc>
</wpt>
<wpt lat="35.926949978" lon="-116.689650059">
<ele>-1.000000</ele>
<name>MINUS1m</name>
<cmt>MINUS1m</cmt>
<desc>MINUS1m</desc>
</wpt>
<wpt lat="37.755579948" lon="-119.142470002">
<name>UnknownElevation</name>
<cmt>UnknownElevation</cmt>
<desc>UnknownElevation</desc>
</wpt>
</gpx>

+ 23
- 23
reference/tpo-sample3.gpx View File

@@ -2,79 +2,79 @@
<gpx version="1.0" creator="GPSBabel - http://www.gpsbabel.org" xmlns="http://www.topografix.com/GPX/1/0">
<bounds minlat="39.047567844" minlon="-119.913288116" maxlat="39.068486691" maxlon="-119.875101328"/>
<wpt lat="39.050695896" lon="-119.911156178">
<ele>2428.000000</ele>
<ele>2428.350000</ele>
<name>001</name>
<cmt>001</cmt>
<desc>001</desc>
</wpt>
<wpt lat="39.050353765" lon="-119.908585310">
<ele>2439.000000</ele>
<ele>2439.930000</ele>
<name>002</name>
<cmt>002</cmt>
<desc>002</desc>
</wpt>
<wpt lat="39.049960017" lon="-119.905889988">
<ele>2462.000000</ele>
<ele>2462.180000</ele>
<name>003</name>
<cmt>WITH MESSAGE</cmt>
<desc>WITH MESSAGE</desc>
</wpt>
<wpt lat="39.048154354" lon="-119.897549391">
<ele>2559.000000</ele>
<ele>2559.110000</ele>
<name>GPSRTE0</name>
<cmt>GPSRTE0</cmt>
<desc>GPSRTE0</desc>
</wpt>
<wpt lat="39.049571753" lon="-119.896608829">
<ele>2582.000000</ele>
<ele>2582.580000</ele>
<name>GPSRTE1</name>
<cmt>GPSRTE1</cmt>
<desc>GPSRTE1</desc>
</wpt>
<wpt lat="39.048447609" lon="-119.895542860">
<ele>2586.000000</ele>
<ele>2586.840000</ele>
<name>GPSRTE2</name>
<cmt>GPSRTE2</cmt>
<desc>GPSRTE2</desc>
</wpt>
<wpt lat="39.049474001" lon="-119.893724442">
<ele>2612.000000</ele>
<ele>2612.140000</ele>
<name>GPSRTE3</name>
<cmt>GPSRTE3</cmt>
<desc>GPSRTE3</desc>
</wpt>
<wpt lat="39.048398733" lon="-119.892971992">
<ele>2606.000000</ele>
<ele>2606.350000</ele>
<name>GPSRTE4</name>
<cmt>GPSRTE4</cmt>
<desc>GPSRTE4</desc>
</wpt>
<wpt lat="39.049180746" lon="-119.891341686">
<ele>2632.000000</ele>
<ele>2632.560000</ele>
<name>GPSRTE5</name>
<cmt>GPSRTE5</cmt>
<desc>GPSRTE5</desc>
</wpt>
<wpt lat="39.047763348" lon="-119.889899492">
<ele>2627.000000</ele>
<ele>2627.080000</ele>
<name>GPSRTE6</name>
<cmt>GPSRTE6</cmt>
<desc>GPSRTE6</desc>
</wpt>
<wpt lat="39.048936367" lon="-119.888206482">
<ele>2622.000000</ele>
<ele>2622.200000</ele>
<name>GPSRTE7</name>
<cmt>GPSRTE7</cmt>
<desc>GPSRTE7</desc>
</wpt>
<wpt lat="39.047567844" lon="-119.886074543">
<ele>2639.000000</ele>
<ele>2639.880000</ele>
<name>GPSRTE8</name>
<cmt>GPSRTE8</cmt>
<desc>GPSRTE8</desc>
</wpt>
<wpt lat="39.048887491" lon="-119.885071278">
<ele>2599.000000</ele>
<ele>2599.030000</ele>
<name>GPSRTE9</name>
<cmt>GPSRTE9</cmt>
<desc>GPSRTE9</desc>
@@ -136,43 +136,43 @@
<name>RTE 1</name>
<number>1</number>
<rtept lat="39.048154354" lon="-119.897549391">
<ele>2559.000000</ele>
<ele>2559.110000</ele>
<name>GPSRTE0</name>
</rtept>
<rtept lat="39.049571753" lon="-119.896608829">
<ele>2582.000000</ele>
<ele>2582.580000</ele>
<name>GPSRTE1</name>
</rtept>
<rtept lat="39.048447609" lon="-119.895542860">
<ele>2586.000000</ele>
<ele>2586.840000</ele>
<name>GPSRTE2</name>
</rtept>
<rtept lat="39.049474001" lon="-119.893724442">
<ele>2612.000000</ele>
<ele>2612.140000</ele>
<name>GPSRTE3</name>
</rtept>
<rtept lat="39.048398733" lon="-119.892971992">
<ele>2606.000000</ele>
<ele>2606.350000</ele>
<name>GPSRTE4</name>
</rtept>
<rtept lat="39.049180746" lon="-119.891341686">
<ele>2632.000000</ele>
<ele>2632.560000</ele>
<name>GPSRTE5</name>
</rtept>
<rtept lat="39.047763348" lon="-119.889899492">
<ele>2627.000000</ele>
<ele>2627.080000</ele>
<name>GPSRTE6</name>
</rtept>
<rtept lat="39.048936367" lon="-119.888206482">
<ele>2622.000000</ele>
<ele>2622.200000</ele>
<name>GPSRTE7</name>
</rtept>
<rtept lat="39.047567844" lon="-119.886074543">
<ele>2639.000000</ele>
<ele>2639.880000</ele>
<name>GPSRTE8</name>
</rtept>
<rtept lat="39.048887491" lon="-119.885071278">
<ele>2599.000000</ele>
<ele>2599.030000</ele>
<name>GPSRTE9</name>
</rtept>
</rte>

+ 1558
- 4674
reference/track/tpo-sample1.gpx
File diff suppressed because it is too large
View File


+ 4
- 0
testo.d/tpo.test View File

@@ -23,3 +23,7 @@ compare ${REFERENCE}/tpo-sample3.gpx ${TMPDIR}/tpo-sample3.gpx2
gpsbabel -t -w -r -i tpo3 -f ${REFERENCE}/LineStyles.tpo -o gpx -F ${TMPDIR}/LineStyles.gpx -o kml -F ${TMPDIR}/LineStyles.kml
compare ${REFERENCE}/LineStyles.gpx ${TMPDIR}/LineStyles.gpx
compare ${REFERENCE}/LineStyles.kml ${TMPDIR}/LineStyles.kml
# check negative and unknown altitudes
rm -f ${TMPDIR}/NegElev.~tpo.gpx
gpsbabel -i tpo3 -f ${REFERENCE}/NegElev.tpo -o gpx -F ${TMPDIR}/NegElev.~tpo.gpx
compare ${REFERENCE}/NegElev.~tpo.gpx ${TMPDIR}/NegElev.~tpo.gpx

+ 13
- 7
tpo.cc View File

@@ -153,6 +153,7 @@ tpo_check_version_string()
string_buffer[string_size] = 0;

/* check for the presence of a 3.0-style id string */
/* Note this check also finds version 4 id strings, e.g. "TOPO! Ver. 4.5.0" */
if (strncmp(v3_id_string, string_buffer, strlen(v3_id_string)) == 0) {
/* fatal(MYNAME ": gpsbabel can only read TPO version 2.7.7 or below; this file is %s\n", string_buffer); */
//fprintf(stderr,"gpsbabel can only read TPO version 2.7.7 or below; this file is %s\n", string_buffer);
@@ -356,7 +357,8 @@ void tpo_read_2_x(void)
78);

/* there is no elevation data for the waypoints */
waypoint_temp->altitude = 0;
/* this is unecessary, the constructor will do this anyway. */
waypoint_temp->altitude = unknown_alt;

track_add_wpt(track_temp, waypoint_temp);
}
@@ -846,7 +848,7 @@ void tpo_process_waypoints(void)
unsigned int name_length;
int lat;
int lon;
unsigned int altitude;
int altitude;

//UNKNOWN DATA LENGTH
(void)tpo_read_int(); // 0x00
@@ -877,13 +879,17 @@ void tpo_process_waypoints(void)
// Assign the waypoint name
waypoint_temp->shortname = waypoint_name;

// Grab the altitude in meters
// Grab the altitude in centimeters
altitude = gbfgetint32(tpo_file_in);
if (altitude == 0xfffd000c) { // Unknown altitude
altitude = 0;
// The original untested check for unknown altitude was for 0xfffd000c (-196596 cm),
// but a test case submitted later used 0xffce0000 (-3276800 cm).
if (altitude == -3276800) { // Unknown altitude
/* this is unecessary, the constructor will do this anyway. */
waypoint_temp->altitude = unknown_alt;
} else {
waypoint_temp->altitude = (double) altitude / 100.0; // Meters
}
waypoint_temp->altitude = altitude / 100; // Meters
//printf("\tAltitude: %1.0f meters\n", waypoint_temp->altitude);
//printf("\tAltitude: %1.2f meters\n", waypoint_temp->altitude);

//UNKNOWN DATA LENGTH
// Fetch comment length

Loading…
Cancel
Save