This repository has been archived by the owner on Apr 28, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 148
/
Copy pathrdmgenshpmaps
119 lines (100 loc) · 2.35 KB
/
rdmgenshpmaps
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/bin/sh
#
# rdmgenshpmaps
#
# Utility to scan a directory for Canadian province shapefiles and
# process them through buildmap
#
# Usage:
#
# rdmgenshpmaps <shapefile path> [maps=<map-directory-path>]
# [test]
# [<province-abbrev> ...]
maps=/usr/local/share/roadmap
prov='*'
if [ $# -eq 0 ] ; then
echo 'Usage: rdmgenshpmaps <shapefile path> [maps=<map-directory-path>] [test] [dryrun] [<province-abbrev> ...]'
exit 1
fi
SRCDIR=$1
shift
verbose=''
gendir=Y
case $1 in
maps=*) maps=`expr $1 : 'maps=\(.*\)'`
shift
;;
esac
case $1 in
test) verbose=-v
gendir=N
shift
;;
esac
case $1 in
dryrun) DRYRUN=Y
shift
;;
esac
if [ -e ./buildmap ] ; then
BUILDMAP=./buildmap
else
BUILDMAP=buildmap
fi
# AB BC MB NB NL NS NT NU ON PE QC SK YT
# 87 88 89 90 91 92 93 94 95 96 97 98 99
function get_fips {
case $1 in
AB) FIPS=87001 ;;
BC) FIPS=88001 ;;
MB) FIPS=89001 ;;
NB) FIPS=90001 ;;
NL) FIPS=91001 ;;
NS) FIPS=92001 ;;
NT) FIPS=93001 ;;
NU) FIPS=94001 ;;
ON) FIPS=95001 ;;
PE) FIPS=96001 ;;
QC) FIPS=97001 ;;
SK) FIPS=98001 ;;
YT) FIPS=99001 ;;
*) FIPS='' ;;
esac
}
if [ $# -gt 0 ] ; then
for i in $*
do
get_fips $i
echo $BUILDMAP -f SHAPE -m $maps $verbose $FIPS $SRCDIR/$i
if [ $DRYRUN != 'Y' ] ; then
$BUILDMAP -f SHAPE -m $maps $verbose $FIPS $SRCDIR/$i
fi
done
else
for i in $SRCDIR/??rte.shp
do
if [ -e $i ] ; then
base=`basename $i`
prov_id=`expr substr $base 1 2`
get_fips $prov_id
echo $BUILDMAP -f SHAPE -m $maps $verbose $FIPS $SRCDIR/$prov_id
if [ $DRYRUN != 'Y' ] ; then
$BUILDMAP -f SHAPE -m $maps $verbose $FIPS $SRCDIR/$prov_id
fi
fi
done
fi
if [ $gendir = 'Y' ] ; then
echo "Generating usdir.rdm, please wait.."
if [ -e buildus ] ; then
echo ./buildus -s --maps=$maps
if [ $DRYRUN != 'Y' ] ; then
./buildus -s --maps=$maps
fi
else
echo buildus -s --maps=$maps
if [ $DRYRUN != 'Y' ] ; then
buildus -s --maps=$maps
fi
fi
fi