User:Lupin/mapping

From Wikipedia, the free encyclopedia

coords[edit]

Data from http://freepages.genealogy.rootsweb.com/~agene/locations/ converted into text files in ./locations

Also now on wikisource.

#!/bin/bash

DIR=./locations

for i in "$@"; do
    #echo $i
    j=$(echo "$i" | sed -e 's/^\(.\).*$/\1/')
    k=$(echo $j | tr a-z A-Z)
    l=$(echo $j | tr A-Z a-z)
    cat $DIR/*{$k,$l}* 2>/dev/null | \
        grep -i "$i"   | \
        sed -e 's/^ *\([^0-9]*\)\([0-9NWSE.]* [0-9NWSE.]*\).*/\2 \1/' \
          -e 's/\([0-9]\)[NE]/\1/g' \
          -e 's/\(^[0-9.]*\)S/-\1/' \
          -e 's/ \([0-9.]*\)W/ -\1/' \
          -e 's/^\([-0-9.]*\) \([-0-9.]*\)/\2 \1/'  | \
        grep -i '[0-9] '"$i"
done

params[edit]

china-params3	SCALE=5/.7/20/400 VIEWPORT=72/136.2/17/54
finland2	VIEWPORT=18/35/59/82 SCALE=4.75/1/62/200
france-corsica-params	VIEWPORT=-5.3/10/41/51.2 SCALE=.5/2/10/100
france-params-2	SCALE=.85/2/48/200 VIEWPORT=-5.3/9/42/51.2
italy-params2	SCALE=.5/1.7/10/100 VIEWPORT=6.4/19/35.5/47.25
japan	SCALE=4.8/1/26/400 VIEWPORT=122/151.4/22/46.6
liechtenstein	SCALE=4.5/9/47.15/5 VIEWPORT=9.44/9.66/47.04/47.28
switzerland	SCALE=5/.8/45.5/100 VIEWPORT=5.8/10.6/45.3/48

makemap[edit]

#!/bin/bash

# GB map with red dot

x=$1
y=$2

if [ -n "$VIEWPORT" ]; then
    VIEWPORT=-R$VIEWPORT
else
    VIEWPORT=-R-9/2/49.7/58.9
fi

PROJECTION=-JM6i
BDY_ANNOTATION=$BDY_ANNOTATION
PORTRAIT=-P

COMMON_OPTIONS="$VIEWPORT $PROJECTION $BDY_ANNOTATION $PORTRAIT"

LAND_COLOUR=32/141/43
SEA_COLOUR=100/164/217

# high res data (not full)
: ${COAST_DATA:=h}

RIVERS=a/.01p/100/164/217
POLITICAL=a/1.5p/0/60/0

if [ -n "$SCALE" ]; then
    SCALE=-Lx$SCALE
else
    SCALE=-Lx1/1.3/51.47/200 
fi

DOT=c.35c
DOT_COLOUR=255/255/0

# standard GB map
# -K means no PS trailer (more to come)
pscoast $COMMON_OPTIONS\
    -D$COAST_DATA\
    -G$LAND_COLOUR\
    -S$SEA_COLOUR\
    -K\
    -I$RIVERS\
    -N$POLITICAL\
    $SCALE | sed \
    -e "s/^\([0-9]*\) \([0-9]*\) M\(.* km[)]\)/\1 \2 58 sub M\3/" \
    -e 's/58 F0/145 F0/' \
    -e 's/S 2 W/S 10 W/'

# the sed expressions: (1) move "200 km" down by 58
#                      (2) make it a larger font
#                      (3) make the scale line thicker

# -O means no PS header (overlay)
echo $1 $2 | \
    psxy $COMMON_OPTIONS\
    -S$DOT -G$DOT_COLOUR -O 

mappng[edit]

#!/bin/bash

RES=300
FIFO=$(tempfile -p $(basename $0) -s .ps)
rm $FIFO
mkfifo $FIFO

while read lat long place; do
    echo $lat $long $place
    safeplace=$(echo "$place" | sed -e 's/ /_/g')
    file="$safeplace"_dot.png
    (./makemap $lat $long > $FIFO ) &
    convert -density $RES -trim $FIFO $file 
    optipng -zc 9 -zm 8 -zs 0 -f 0 $file    
done

rm -v $FIFO