Skip to content

Commit

Permalink
adds Topo! support and implements mkshort in .psp,
Browse files Browse the repository at this point in the history
.mxf, and .ozi.   From Alex Mottram.
  • Loading branch information
robertl committed Oct 10, 2002
1 parent a11e11b commit 0382705
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 35 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ CFLAGS=-g -Icoldsync

FMTS=magproto.o gpx.o geo.o gpsman.o mapsend.o mapsource.o \
gpsutil.o tiger.o pcx.o csv.o cetus.o gpspilot.o magnav.o \
psp.o mxf.o holux.o garmin.o ozi.o dna.o
psp.o mxf.o holux.o garmin.o ozi.o dna.o tpg.o

JEEPS=jeeps/gpsapp.o jeeps/gpscom.o jeeps/gpsfmt.o jeeps/gpsinput.o \
jeeps/gpsmath.o jeeps/gpsmem.o \
Expand Down Expand Up @@ -57,6 +57,7 @@ mapsource.o: mapsource.c defs.h queue.h
mkshort.o: mkshort.c defs.h queue.h
mxf.o: mxf.c defs.h queue.h csv_util.h
ozi.o: ozi.c defs.h queue.h csv_util.h
tpg.o: tpg.c defs.h queue.h
pcx.o: pcx.c defs.h queue.h
psp.o: psp.c defs.h queue.h
queue.o: queue.c queue.h
Expand Down
36 changes: 26 additions & 10 deletions mxf.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,20 +148,30 @@ mxf_waypt_pr(const waypoint * wpt)
char *shortname = NULL;
char *description = NULL;

if (wpt->shortname) {
if ((! wpt->shortname) || (global_opts.synthesize_shortnames)) {
if (wpt->description) {
if (global_opts.synthesize_shortnames)
shortname = mkshort(wpt->description);
else
shortname = csv_stringclean(wpt->description, ",\"");
} else {
/* no description available */
shortname = xstrdup("");
}
} else{
shortname = csv_stringclean(wpt->shortname, ",\"");
shortname = csv_stringtrim(shortname, "");
} else {
shortname = xstrdup("");
}

if (wpt->description) {

if (! wpt->description) {
if (shortname) {
description = csv_stringclean(shortname, ",\"");
} else {
description = xstrdup("");
}
} else{
description = csv_stringclean(wpt->description, ",\"");
description = csv_stringtrim(description, "");
} else {
shortname = xstrdup("");
}

fprintf(file_out, "%08.5f, %08.5f, \"%s\", \"%s\", \"%s\", %s, %d\n",
wpt->position.latitude.degrees, wpt->position.longitude.degrees,
description, shortname, description,
Expand All @@ -176,6 +186,12 @@ mxf_waypt_pr(const waypoint * wpt)
static void
data_write(void)
{
if (global_opts.synthesize_shortnames) {
setshort_length(32);
setshort_whitespace_ok(0);
setshort_badchars("\",");
}

waypt_disp_all(mxf_waypt_pr);
}

Expand Down
36 changes: 28 additions & 8 deletions ozi.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,15 +183,29 @@ ozi_waypt_pr(const waypoint * wpt)
ozi_time = (wpt->creation_time / 86400.0) + 25569.0;
alt_feet = (wpt->position.altitude.altitude_meters * 3.2808);

if (wpt->description)
description = csv_stringclean(wpt->description, ",");
else
description = xstrdup("");

if (wpt->shortname)
if ((! wpt->shortname) || (global_opts.synthesize_shortnames)) {
if (wpt->description) {
if (global_opts.synthesize_shortnames)
shortname = mkshort(wpt->description);
else
shortname = csv_stringclean(wpt->description, ",");
} else {
/* no description available */
shortname = xstrdup("");
}
} else{
shortname = csv_stringclean(wpt->shortname, ",");
else
shortname = xstrdup("");
}

if (! wpt->description) {
if (shortname) {
description = csv_stringclean(shortname, ",");
} else {
description = xstrdup("");
}
} else{
description = csv_stringclean(wpt->description, ",");
}

index++;

Expand All @@ -214,6 +228,12 @@ data_write(void)
fprintf(file_out, "Reserved 2\n");
fprintf(file_out, "Reserved 3\n");

if (global_opts.synthesize_shortnames) {
setshort_length(32);
setshort_whitespace_ok(0);
setshort_badchars("\",");
}

waypt_disp_all(ozi_waypt_pr);
}

Expand Down
41 changes: 25 additions & 16 deletions psp.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,26 +331,30 @@ psp_waypt_pr(const waypoint *wpt)
int i;
char *shortname;
char *description;


/* this output format pretty much requires a description
* and a shortname
*/

if (wpt->shortname) {
shortname = xstrdup(wpt->shortname);
} else {
if (wpt->description)
shortname = xstrdup(wpt->description);
else
if ((! wpt->shortname) || (global_opts.synthesize_shortnames)) {
if (wpt->description) {
if (global_opts.synthesize_shortnames)
shortname = mkshort(wpt->description);
else
shortname = xstrdup(wpt->description);
} else {
/* no description available */
shortname = xstrdup("");
}
} else{
shortname = xstrdup(wpt->shortname);
}

if (wpt->description) {

if (! wpt->description) {
if (shortname) {
description = xstrdup(shortname);
} else {
description = xstrdup("");
}
} else{
description = xstrdup(wpt->description);
} else {
description = xstrdup(shortname);
}
}

/* convert lat/long back to radians */
lat = (wpt->position.latitude.degrees * M_PI) / 180.0;
Expand Down Expand Up @@ -431,6 +435,11 @@ psp_write(void)
/* offset 0x0C - 0x0D = 2 byte pin count */

s = waypt_count();

if (global_opts.synthesize_shortnames) {
setshort_length(32);
setshort_whitespace_ok(1);
}

if (s > MAXPSPOUTPUTPINS) {
fatal(MYNAME ": attempt to output too many pushpins (%d). The max is %d. Sorry.\n", s, MAXPSPOUTPUTPINS);
Expand Down
Binary file added reference/tpg.tpg
Binary file not shown.
11 changes: 11 additions & 0 deletions testo
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,17 @@ ${PNAME} -i mxf -f reference/mxf.mxf -o mxf -F ${TMPDIR}/mx.mxf
${PNAME} -i mxf -f ${TMPDIR}/mx.mxf -o mxf -F ${TMPDIR}/mxf.mxf
diff ${TMPDIR}/mxf.mxf reference

# TPG (NG Topo!) file format
# This is hard to test as the datum conversions create minute
# inconsistencies in the coordinates. So.. we test our i/o
# against a format that rounds higher than we care to compare
# for binary data.
rm -f ${TMPDIR}/topo.mxf ${TMPDIR}/tpg.mxf ${TMPDIR}/geo.tpg
${PNAME} -i geo -f geocaching.loc -o tpg -F ${TMPDIR}/geo.tpg
${PNAME} -i tpg -f ${TMPDIR}/geo.tpg -o mxf -F ${TMPDIR}/tpg.mxf
${PNAME} -i tpg -f reference/tpg.tpg -o mxf -F ${TMPDIR}/topo.mxf
diff ${TMPDIR}/tpg.mxf ${TMPDIR}/topo.mxf

# OZI (OziExplorer 1.1) file format
rm -f ${TMPDIR}/oz.ozi ${TMPDIR}/ozi.ozi
${PNAME} -i ozi -f reference/ozi.ozi -o ozi -F ${TMPDIR}/oz.ozi
Expand Down
6 changes: 6 additions & 0 deletions vecs.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ extern ff_vecs_t garmin_vecs;
extern ff_vecs_t mxf_vecs;
extern ff_vecs_t holux_vecs;
extern ff_vecs_t ozi_vecs;
extern ff_vecs_t tpg_vecs;
extern ff_vecs_t dna_vecs;
extern ff_vecs_t xmap_vecs;

Expand Down Expand Up @@ -145,6 +146,11 @@ vecs_t vec_list[] = {
"ozi",
"OziExplorer Waypoint"
},
{
&tpg_vecs,
"tpg",
"National Geographic Topo .tpg"
},

{
NULL,
Expand Down

0 comments on commit 0382705

Please sign in to comment.