From: Robert Lipe <robertlipe@us...> - 2006-02-03 19:26:55
Architecturally, I've long been rather determined that we should be able
to read anything we write. I like symmetry.
Pragmatically, I realize that sometimes we just don't care and the world
does have write-only formats or formats that make no sense to read.
When I implemented support for writing files to Garmin's POI loader some
time ago, it seemed pretty simple. (As an aside, they've changed some of
the limits, so I need to revisit that formta anyway...) It was straight
Four field CSV - the kind of format we routinely stamp out in under a
minute with our style files.
I was reading a recent discovery that Garmin's POI loader works on
Garmin's X series.
for those of you that boycott those forums...)
and I found that pretty interesting. I've started a conversation
with 'GotGPS' as he is pretty clearly building these by hand right
now as they're a little inconsistent and the prose is clearly being
optimized by a human for size. But it occurred to me that we wanted
to display geocaching fields difficulty and terrain (with associated
punctuation!) if we had them, but not if we didn't. Unfortunately, you
can't express that in our style mechanisms and I really didn't want a
"garmin_poi" and a "garmin_poi_geo". Even if I would have tolerated such
a thing, it wouldn't work now that Groundspeaks PQs may contain both
geocaching-annoited waypoints and unadorned ones.
What I wanted was output something like this:
[robertl@... gpsbabel]$ make && ./gpsbabel -i gpx -f /tmp/GCPV0B.gpx -o garmin_poi -F -
make: Nothing to be done for `all'.
-122.62498,47.52952,GCPV0B Trad (2.0/1.5),CACHE QUIPS - Encrypt/Decrypt Pasha
What I really wanted was to be able to describe this in a style format
OFIELD LON_DECIMAL, "", "%08.5f"
OFIELD LAT_DECIMAL, "", "%08.5f"
OFIELD SHORTNAME, "", "%-.24s"
OFIELD GEOCACHE_TYPE, "", " %-.4s ", "no_delim_before,optional"
OFIELD GEOCACHE_DIFF, "", "(%3.1f", "no_delim_before,optional"
OFIELD GEOCACHE_TERR, "", "/%3.1f)", "no_delim_before,optional"
OFIELD DESCRIPTION, "", "%-.50s"
OFIELD GEOCACHE_PLACER, "", " %s", "no_delim_before,optional"
Now there's a mere matter of programming to teach the CSV code what
'optional' means and how to tell it how to determine how each of our
bazillion internal fields are "empty", but that's not rocket science.
I'll probably clean this up, doc it, and commit it by this weekend, but
I thought I'd throw it out for discussion. I think the basic plumbing
opens some doors for some creativity in our XCSV formats.