From: robertl Date: Tue, 28 Jul 2009 16:41:38 +0000 (+0000) Subject: Improve Garmin GPI reader to read the more GPI files. X-Git-Tag: archive/raspbian/1.10.0+ds-2+rpi1~1^2~199^2~195 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=c40e5a13c72f8f71679b70212a1e294e23188a65;p=gpsbabel.git Improve Garmin GPI reader to read the more GPI files. --- diff --git a/garmin_gpi.c b/garmin_gpi.c index 2918dbf1f..f905ac2a7 100644 --- a/garmin_gpi.c +++ b/garmin_gpi.c @@ -176,7 +176,7 @@ typedef struct { } gpi_waypt_t; static gbfile *fin, *fout; -static gbint32 codepage; /* code-page, i.e. 1252 */ +static gbint16 codepage; /* code-page, i.e. 1252 */ static reader_data_t *rdata; static writer_data_t *wdata; static short_handle short_h; @@ -290,8 +290,16 @@ read_header(void) len = gbfgetint16(fin); gbfseek(fin, len, SEEK_CUR); /* "my.gpi" */ - (void) gbfgetint32(fin); /* 1 */ + i = gbfgetint32(fin); /* 1 */ (void) gbfgetint32(fin); /* 12 */ + /* There are two dwords next. On most typical files, they're + * "1" and "12". On files from garminoneline.de/extras/poi, the + * next two words are "15" and "5" and there's 17 additional bytes + * that I can't identify. So hardcode a seek here for now. + */ + if (i == 15) { + gbfseek(fin, 17, SEEK_CUR); + } gbfread(&rdata->POI, 1, sizeof(rdata->POI) - 1, fin); if (strcmp(rdata->POI, "POI") != 0) @@ -300,7 +308,9 @@ read_header(void) for (i = 0; i < 3; i++) (void)gbfgetc(fin); gbfread(&rdata->S8, 1, sizeof(rdata->S8) - 1, fin); - codepage = gbfgetint32(fin); + codepage = gbfgetint16(fin); + (void) gbfgetint16(fin); /* typically 0, but 0x11 in + Garminonline.de files. */ #ifdef GPI_DBG PP; @@ -562,6 +572,32 @@ read_tag(const char *caller, const int tag, waypoint *wpt) case 0x80012: /* ? sounds / images ? */ break; + case 0x11: + case 0xb: + case 0xc: + /* appears to be web links. If the first 16 bit + value is 0x10, the remainder is a length/URL pair. + if it's 0x19, there is a length/phone # (?) pair followed + by a length/URL pair. + */ + case 0x80007: + /* Looks like some kind of calendar information. */ + +#ifdef GPI_DBG + { + int x; + char *b = xmalloc(sz); + fprintf(stderr, "Tag: %x\n", tag); + gbfread(b, 1, sz, fin); + fprintf(stderr, "\n"); + for (x = 0; x < sz; x++) + fprintf(stderr, "%02x ", b[x]); + fprintf(stderr, "\n"); + for (x = 0; x < sz; x++) + fprintf(stderr, "%c", isalnum(b[x]) ? b[x] : '.'); + } +#endif GPI_DBG + break; default: warning(MYNAME ": Unknown tag (0x%x). Please report!\n", tag); return 0; @@ -997,7 +1033,8 @@ write_header(void) gbfputc(0, fout); gbfputc(0, fout); gbfwrite("00", 1, 2, fout); - gbfputint32(codepage, fout); + gbfputint16(codepage, fout); + gbfputint16(0, fout); } diff --git a/reference/umsonstdraussen.gpi b/reference/umsonstdraussen.gpi new file mode 100644 index 000000000..de6f9b6e6 Binary files /dev/null and b/reference/umsonstdraussen.gpi differ diff --git a/reference/umsonstdraussen.gpx b/reference/umsonstdraussen.gpx new file mode 100644 index 000000000..9d920f04d --- /dev/null +++ b/reference/umsonstdraussen.gpx @@ -0,0 +1,478 @@ + + + + + + Uferlos Festival + Uferlos Festival + Uferlos Festival + Waypoint + + + Schlossgrabenfest + Schlossgrabenfest + Schlossgrabenfest + Waypoint + + + Kultival + Kultival + Kultival + Waypoint + + + Hafengeburtstag Hamburg + Hafengeburtstag Hamburg + Hafengeburtstag Hamburg + Waypoint + + + EselRock + EselRock + EselRock + Waypoint + + + EuroCityFest Münster + EuroCityFest Münster + EuroCityFest Münster + Waypoint + + + Wispa Festival + Wispa Festival + Wispa Festival + Waypoint + + + Umsonst + Draußen Würzburg + Umsonst + Draußen Würzburg + Umsonst + Draußen Würzburg + Waypoint + + + Umsonst + Draußen Bad Kissingen + Umsonst + Draußen Bad Kissingen + Umsonst + Draußen Bad Kissingen + Waypoint + + + Teichrock + Teichrock + Teichrock + Waypoint + + + Spreehafenfestival + Spreehafenfestival + Spreehafenfestival + Waypoint + + + Rohrer Seefest + Rohrer Seefest + Rohrer Seefest + Waypoint + + + Rock die Heide + Rock die Heide + Rock die Heide + Waypoint + + + Rock and Bike + Rock and Bike + Rock and Bike + Waypoint + + + RACT Festival + RACT Festival + RACT Festival + Waypoint + + + Polterplatz Open Air + Polterplatz Open Air + Polterplatz Open Air + Waypoint + + + Parkpop + Parkpop + Parkpop + Waypoint + + + Open Air Werden + Open Air Werden + Open Air Werden + Waypoint + + + Open Doors Festivals + Open Doors Festivals + Open Doors Festivals + Waypoint + + + Happiness + Happiness + Happiness + Waypoint + + + Hafenfest Hamm + Hafenfest Hamm + Hafenfest Hamm + Waypoint + + + Free for All + Free for All + Free for All + Waypoint + + + Friedensfestival + Friedensfestival + Friedensfestival + Waypoint + + + Das Fest Karlsruhe + Das Fest Karlsruhe + Das Fest Karlsruhe + Waypoint + + + Donauinselfest + Donauinselfest + Donauinselfest + Waypoint + + + Backnanger Nachwuchsfestival + Backnanger Nachwuchsfestival + Backnanger Nachwuchsfestival + Waypoint + + + Abifestival + Abifestival + Abifestival + Waypoint + + + Weinlabyrinth + Weinlabyrinth + Weinlabyrinth + Waypoint + + + Waldstock + Waldstock + Waldstock + Waypoint + + + Umsonst + Draußen Mössingen + Umsonst + Draußen Mössingen + Umsonst + Draußen Mössingen + Waypoint + + + Umsonst + Draußen Vlotho + Umsonst + Draußen Vlotho + Umsonst + Draußen Vlotho + Waypoint + + + Umsonst + Draußen Lindau + Umsonst + Draußen Lindau + Umsonst + Draußen Lindau + Waypoint + + + Umsonst + Draußen Karlstadt + Umsonst + Draußen Karlstadt + Umsonst + Draußen Karlstadt + Waypoint + + + Umsonst + Draußen Heubach + Umsonst + Draußen Heubach + Umsonst + Draußen Heubach + Waypoint + + + Sinnflutfestival + Sinnflutfestival + Sinnflutfestival + Waypoint + + + Südwinsen Festival + Südwinsen Festival + Südwinsen Festival + Waypoint + + + Rocktreff + Rocktreff + Rocktreff + Waypoint + + + Rheinkultur + Rheinkultur + Rheinkultur + Waypoint + + + Open Air am Garchinger See + Open Air am Garchinger See + Open Air am Garchinger See + Waypoint + + + Obstwiesenfestival + Obstwiesenfestival + Obstwiesenfestival + Waypoint + + + Live at Plaza + Live at Plaza + Live at Plaza + Waypoint + + + KuRt Festival + KuRt Festival + KuRt Festival + Waypoint + + + HORST Festival + HORST Festival + HORST Festival + Waypoint + + + Go Ahead Weekend + Go Ahead Weekend + Go Ahead Weekend + Waypoint + + + Flörsheimer Open Air + Flörsheimer Open Air + Flörsheimer Open Air + Waypoint + + + Frequenzen Festival + Frequenzen Festival + Frequenzen Festival + Waypoint + + + Bardentreffen + Bardentreffen + Bardentreffen + Waypoint + + + Bayerisches Jazzweekend + Bayerisches Jazzweekend + Bayerisches Jazzweekend + Waypoint + + + Bochum Total + Bochum Total + Bochum Total + Waypoint + + + 48er Festival + 48er Festival + 48er Festival + Waypoint + + + Umsonst + Draußen Mössingen + Umsonst + Draußen Mössingen + Umsonst + Draußen Mössingen + Waypoint + + + Umsonst + Draußen Vlotho + Umsonst + Draußen Vlotho + Umsonst + Draußen Vlotho + Waypoint + + + Sinnflutfestival + Sinnflutfestival + Sinnflutfestival + Waypoint + + + Wutzrock Festival + Wutzrock Festival + Wutzrock Festival + Waypoint + + + Wutzdog Festival + Wutzdog Festival + Wutzdog Festival + Waypoint + + + Welt Astra Tag + Welt Astra Tag + Welt Astra Tag + Waypoint + + + Umsonst + Draußen Stuttgart + Umsonst + Draußen Stuttgart + Umsonst + Draußen Stuttgart + Waypoint + + + TeteRock Festival + TeteRock Festival + TeteRock Festival + Waypoint + + + Stemweder Openair Festival + Stemweder Openair Festival + Stemweder Openair Festival + Waypoint + + + Staatsforsten Open Air + Staatsforsten Open Air + Staatsforsten Open Air + Waypoint + + + Sommerschein Festival + Sommerschein Festival + Sommerschein Festival + Waypoint + + + Sommerfühl + Sommerfühl + Sommerfühl + Waypoint + + + Rockfield Open Air + Rockfield Open Air + Rockfield Open Air + Waypoint + + + Römersee Open Air + Römersee Open Air + Römersee Open Air + Waypoint + + + Olgas Rock Festival + Olgas Rock Festival + Olgas Rock Festival + Waypoint + + + Midsummer Open Air + Midsummer Open Air + Midsummer Open Air + Waypoint + + + Live im Schlossgarten + Live im Schlossgarten + Live im Schlossgarten + Waypoint + + + Holter Meeting + Holter Meeting + Holter Meeting + Waypoint + + + Gogenkrog Open-Air + Gogenkrog Open-Air + Gogenkrog Open-Air + Waypoint + + + Fest der leisen Tönen + Fest der leisen Tönen + Fest der leisen Tönen + Waypoint + + + Folklorefest Krefeld + Folklorefest Krefeld + Folklorefest Krefeld + Waypoint + + + Essen Original + Essen Original + Essen Original + Waypoint + + + Open Air Folksfest + Open Air Folksfest + Open Air Folksfest + Waypoint + + + Open Ernstival + Open Ernstival + Open Ernstival + Waypoint + + + Karneval der Kulturen Hamburg + Karneval der Kulturen Hamburg + Karneval der Kulturen Hamburg + Waypoint + + + Fehmarn Open Air + Fehmarn Open Air + Fehmarn Open Air + Waypoint + + + Eber-Hart Open Air + Eber-Hart Open Air + Eber-Hart Open Air + Waypoint + + + Detten Rockt + Detten Rockt + Detten Rockt + Waypoint + + diff --git a/testo b/testo index 2cd21ab78..e1331c81d 100755 --- a/testo +++ b/testo @@ -1288,6 +1288,10 @@ gpsbabel -i garmin_gpi -f ${TMPDIR}/garmin_gpi3a.gpi -o garmin_gpi -F ${TMPDIR}/ bincompare ${TMPDIR}/garmin_gpi3a.gpi ${TMPDIR}/garmin_gpi3b.gpi gpsbabel -i garmin_gpi -f ${REFERENCE}/gpi_ext-sample.gpi -o unicsv -F ${TMPDIR}/gpi_ext-sample.csv compare ${REFERENCE}/gpi_ext-sample.csv ${TMPDIR}/gpi_ext-sample.csv +# Don't test writing this sample file from garminonline.de/extras/poi, but +# prove we can read it +gpsbabel -i garmin_gpi -f ${REFERENCE}/umsonstdraussen.gpi -o gpx -F ${TMPDIR}/umsonstdraussen.gpx +compare ${REFERENCE}/umsonstdraussen.gpx ${TMPDIR}/umsonstdraussen.gpx # # Nokia LMX