#!/bin/sh -eu
# equidistant -- make map with equidistant small circles
# handy for finding e.g. what part of Africa is nearest to us
# Copyright       : http://www.fsf.org/copyleft/gpl.html
# Author          : Dan Jacobson -- http://jidanni.org/
# Created On      : Mon Apr 19 12:19:35 2004
# Last Modified On: Mon Apr 26 17:11:35 2004
# Update Count    : 158
# Status          : only did just enough so far for basic output
# To customize, use command line variable overrides, and/or rewrite program.
: ${origin=121\ 24} #center of small circles
: ${interval=2000} #between small circles, units=km
: ${scale=10c} #size of picture edge in cm
: ${R=-R0/360/-90/90} #region of interest
while read longitude latitude place
do
J=-JE$longitude/$latitude/$scale
o=/tmp/eq_$place
> $o.ps
#We use GMT, http://www.soest.hawaii.edu/gmt/
pscoast -Dc -K -A${A=22222} -W $R $J >> $o.ps
grdmath -R$R -I45m $origin GDIST 111.13 MUL = $o.grd #ugly if -I too big or small
grdcontour -C$interval -O $R $J $o.grd >> $o.ps #To do: labels
#The above is a better way than using project(1), says GMT staff.
gs -sDEVICE=pngmono -sOutputFile=$o.png -dNOPAUSE -dBATCH $o.ps #Ghostscript
#Wanted to magnify without increasing file size, but couldn't figure out how.
rm $o.ps $o.grd
convert -crop 0x0 -rotate 90 $o.png $o.png #ImageMagick
done <<EOF
-100	40	namerica
0	40	europe
121	24	taiwan
EOF
