# HG changeset patch # User pouya@nohup.io # Date 1645040483 -3600 # Wed Feb 16 20:41:23 2022 +0100 # Node ID 5cba955f26252b0016cd7c5170e30b7ee7715519 # Parent 5dc34e9b83e74837970ed459c6d134512124b42f rename geogrep.sh to geogrep diff --git a/README b/README --- a/README +++ b/README @@ -90,18 +90,18 @@ cat examples/demo.smap | ./smap -z 3 -R i >demo.ppm - The included script scripts/geogrep.sh can be used to produce smap com- + The included script scripts/geogrep can be used to produce smap com- mands to plot a wide variety of locations of interest based on GeoNames [2] data, which can be downloaded and prepared (unzip(1)ped, split by class, and gzip(1)ped) using the helper script scripts/fetchdata.sh (splitting the data by class is not strictly necessary as - scripts/geogrep.sh can and does fall back onto the whole dataset when - it cannot find or use the splits, but it does speed up lookups consid- - erably at the expense of extra storage). + scripts/geogrep can and does fall back onto the whole dataset when it + cannot find or use the splits, but it does speed up lookups consider- + ably at the expense of extra storage). The example script examples/famous_tree.sh demonstrates how - scripts/geogrep.sh can be combined with smap, by using it to find and - generate maps of famous trees in a specified country. It can be invoked + scripts/geogrep can be combined with smap, by using it to find and gen- + erate maps of famous trees in a specified country. It can be invoked thus: cd examples && ./famous_trees.sh NZ @@ -114,7 +114,7 @@ and could not display icons. The next version added a new primitive for icons, as well as considerable code and complexity to process and display GeoNames data via a (now defunct) loc keyword. The latter were - subsequently removed in favour of using the supplied scripts/geogrep.sh + subsequently removed in favour of using the supplied scripts/geogrep script to generate primitive smap commands to mark desired GeoNames locations. diff --git a/examples/famous_trees.sh b/examples/famous_trees.sh --- a/examples/famous_trees.sh +++ b/examples/famous_trees.sh @@ -12,7 +12,7 @@ fn="famous_trees_$cntry.ppm" printf "finding coordinates of $cntry... " -coords=$(../scripts/geogrep.sh name -fmt "-lat %lat -lon %lon" '.*' A PCLI "$cntry") +coords=$(../scripts/geogrep name -fmt "-lat %lat -lon %lon" '.*' A PCLI "$cntry") printf "%s\n" "$coords" printf "plotting famous trees in $cntry...\n" @@ -20,7 +20,7 @@ echo "map|shores|3" echo "map|borders|1" echo "map|rivers|2" - ../scripts/geogrep.sh name -fmt 'icon|%lat|%lon|tree.pgm|0|0|127|0\ntext|%lat|%lon|%name|2|1|0|127|0\n' '.*' V TREE $cntry + ../scripts/geogrep name -fmt 'icon|%lat|%lon|tree.pgm|0|0|127|0\ntext|%lat|%lon|%name|2|1|0|127|0\n' '.*' V TREE $cntry } | smap $coords -wd "$wd" -ht "$ht" -z 10 -R h >"$fn" [ -e "$fn" ] && echo "output was written to $fn" || { echo "something went wrong" diff --git a/examples/grid.sh b/examples/grid.sh --- a/examples/grid.sh +++ b/examples/grid.sh @@ -2,6 +2,11 @@ style="0|191|255|255" +usage() { + printf "usage: %s dlat dlon\n" "${0##*/}" >&2 + exit 1 +} + cmp() { printf "[1p]st [0p]sf %f %f %stef\n" "$1" "$2" "$3" | tr - _ | dc } @@ -10,25 +15,19 @@ printf "%f %f %s p\n" "$1" "$2" "$3" | tr - _ | dc } -delta="$1" -case $delta in -[0-9]*) - ;; -*) - printf "usage: %s [delta]\n" "${0##*/}" >&2 - exit 1 - ;; -esac +[ $# -lt 2 ] && usage +dlat="$1"; shift +dlon="$1" lat=-90 while [ 1 -eq $(cmp $lat 90 '!<') ]; do printf "line|%f|-180|%f|180|%s\n" "$lat" "$lat" "$style" - lat=$(bop "$lat" "$delta" +) + lat=$(bop "$lat" "$dlat" +) done lon=-180 while [ 1 -eq $(cmp $lon 180 '!<') ]; do printf "line|-90|%f|90|%f|%s\n" "$lon" "$lon" "$style" - lon=$(bop "$lon" "$delta" +) + lon=$(bop "$lon" "$dlon" +) done diff --git a/scripts/geogrep.sh b/scripts/geogrep rename from scripts/geogrep.sh rename to scripts/geogrep diff --git a/smap.1 b/smap.1 --- a/smap.1 +++ b/smap.1 @@ -208,7 +208,7 @@ .B cat examples/demo.smap | ./smap -z 3 -R i >demo.ppm .P The included script -.B scripts/geogrep.sh +.B scripts/geogrep can be used to produce .B smap commands to plot a wide variety of locations of interest based on @@ -221,13 +221,13 @@ using the helper script .B scripts/fetchdata.sh (splitting the data by class is not strictly necessary as -.B scripts/geogrep.sh +.B scripts/geogrep can and does fall back onto the whole dataset when it cannot find or use the splits, but it does speed up lookups considerably at the expense of extra storage). .P The example script .B examples/famous_tree.sh demonstrates how -.B scripts/geogrep.sh +.B scripts/geogrep can be combined with .BR smap , by using it to find and generate maps of famous trees in a specified country. It can be invoked thus: @@ -245,7 +245,7 @@ data via a (now defunct) .I loc keyword. The latter were subsequently removed in favour of using the supplied -.B scripts/geogrep.sh +.B scripts/geogrep script to generate primitive .B smap commands to mark desired