5cba955f2625 — pouya@nohup.io tip 4 months ago
rename geogrep.sh to geogrep
5 files changed, 23 insertions(+), 24 deletions(-)

M README
M examples/famous_trees.sh
M examples/grid.sh
M scripts/geogrep.sh => scripts/geogrep
M smap.1
M README +7 -7
@@ 90,18 90,18 @@ EXAMPLES
 
        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 @@ HISTORY
        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.
 

          
M examples/famous_trees.sh +2 -2
@@ 12,7 12,7 @@ cntry=$1
 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 @@ printf "plotting famous trees in $cntry.
 	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"

          
M examples/grid.sh +10 -11
@@ 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 @@ bop() {
 	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

          
M scripts/geogrep.sh => scripts/geogrep +0 -0

M smap.1 +4 -4
@@ 208,7 208,7 @@ contains commands to generate a simple m
 .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 @@ split by class, and
 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 @@ as well as considerable code and complex
 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