Skip to content

Commit 19dc13d

Browse files
committed
feat(base): add nmea2gpx converter
Add nmea2gpx helper that converts .log files to .gpx with gpsbabel and logs each conversion. Update README function anchors and bump BASE_VERSION.
1 parent 2869b32 commit 19dc13d

File tree

2 files changed

+45
-28
lines changed

2 files changed

+45
-28
lines changed

README.adoc

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -108,28 +108,29 @@ The public functions are, in alphabetical order:
108108
{url-base}#L503[`map_del`],
109109
{url-base}#L523[`map_get`],
110110
{url-base}#L545[`map_put`],
111-
{url-base}#L557[`pdf2jpg`],
112-
{url-base}#L562[`pdf2png`],
113-
{url-base}#L581[`prettytable`],
114-
{url-base}#L607[`prettyuptime`],
115-
{url-base}#L630[`realdir`],
116-
{url-base}#L639[`realpath`],
117-
{url-base}#L652[`semver`],
118-
{url-base}#L670[`should_continue`],
119-
{url-base}#L726[`timestamp`],
120-
{url-base}#L746[`tolog`],
121-
{url-base}#L752[`tologe`],
122-
{url-base}#L759[`tolower`],
123-
{url-base}#L777[`totsout`],
124-
{url-base}#L783[`tsout`],
125-
{url-base}#L791[`url_exists`],
126-
{url-base}#L815[`user_exists`],
127-
{url-base}#L831[`validate_cmd`],
128-
{url-base}#L838[`validate_var`],
129-
{url-base}#L845[`var_exists`],
130-
{url-base}#L879[`ver_ge`],
131-
{url-base}#L887[`vid2aud`],
132-
{url-base}#L901[`ytda`].
111+
{url-base}#L557[`nmea2gpx`],
112+
{url-base}#L573[`pdf2jpg`],
113+
{url-base}#L578[`pdf2png`],
114+
{url-base}#L597[`prettytable`],
115+
{url-base}#L623[`prettyuptime`],
116+
{url-base}#L646[`realdir`],
117+
{url-base}#L655[`realpath`],
118+
{url-base}#L668[`semver`],
119+
{url-base}#L686[`should_continue`],
120+
{url-base}#L742[`timestamp`],
121+
{url-base}#L762[`tolog`],
122+
{url-base}#L768[`tologe`],
123+
{url-base}#L775[`tolower`],
124+
{url-base}#L793[`totsout`],
125+
{url-base}#L799[`tsout`],
126+
{url-base}#L807[`url_exists`],
127+
{url-base}#L831[`user_exists`],
128+
{url-base}#L847[`validate_cmd`],
129+
{url-base}#L854[`validate_var`],
130+
{url-base}#L861[`var_exists`],
131+
{url-base}#L895[`ver_ge`],
132+
{url-base}#L903[`vid2aud`],
133+
{url-base}#L917[`ytda`].
133134

134135
Global variables have the `BASE_` prefix and can be used by clients.
135136
Clients should place temporary files under `$BASE_WIP`.
@@ -204,7 +205,7 @@ eval "$(
204205
log I\'m using the shellbase.
205206
----
206207

207-
{url-base}#L581[`prettytable`] example:
208+
{url-base}#L597[`prettytable`] example:
208209

209210
[,sh]
210211
----

lib/base.sh

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
# cmd_exists, cya, die, dng2jpg, echo, ellipsize, file_exists,
1717
# handle_pipefails, heic2jpg, gitlog, grbt, inside, isempty, isfunc, isnumber,
1818
# isreadable, isroot, issolid, iswritable, log, loge, logw, map_del, map_get,
19-
# map_put, pdf2jpg, pdf2png, prettytable, prettyuptime, realdir, realpath,
20-
# semver, should_continue, timestamp, tolog, tologe, tolower, totsout, tsout,
21-
# url_exists, user_exists, validate_cmd, validate_var, var_exists, ver_ge,
22-
# vid2aud, ytda.
19+
# map_put, nmea2gpx, pdf2jpg, pdf2png, prettytable, prettyuptime, realdir,
20+
# realpath, semver, should_continue, timestamp, tolog, tologe, tolower,
21+
# totsout, tsout, url_exists, user_exists, validate_cmd, validate_var,
22+
# var_exists, ver_ge, vid2aud, ytda.
2323
#
2424
# Global variables have BASE_ prefix and clients could use them. Clients should
2525
# place temporary files under $BASE_WIP. All functions started with base_
@@ -47,7 +47,7 @@ BASE_RC_CON_NO=14
4747
BASE_RC_CON_TO=13
4848
BASE_RC_DIE_NO=10
4949
BASE_SHOULD_CON=false
50-
BASE_VERSION=0.9.20260328
50+
BASE_VERSION=0.9.20260402
5151

5252
# Removes any file besides mp3, m4a, flac in the current directory.
5353
# Removes empty directories.
@@ -553,6 +553,22 @@ map_put() {
553553
printf %s "$val" >"$dir/$nme/$key"
554554
}
555555

556+
# Converts all .log files in the current directory to .gpx files.
557+
nmea2gpx() {
558+
local fle
559+
cmd_exists gpsbabel || return $?
560+
for fle in ./*.log; do
561+
# Skip unmatched glob literals and broken paths.
562+
[ -e "$fle" ] || [ -L "$fle" ] || continue
563+
log "Converting $fle to ${fle%.log}.gpx."
564+
gpsbabel \
565+
--input nmea \
566+
--file "$fle" \
567+
--output gpx \
568+
--outfile "${fle%.log}.gpx" || return $?
569+
done
570+
}
571+
556572
# Converts all PDF files in current directory to JPEG files.
557573
pdf2jpg() {
558574
base_pdf2img -jpeg

0 commit comments

Comments
 (0)