Report abuse

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
#!/bin/sh

# TODO: Keep Qadastre2OSM --list cache

Qadastre2OSM="/home/stereo/qadastre2osm/Qadastre2OSM"

usage ()
{
     echo "qadafi - Qadastre2OSM For Idiots"
     echo "usage: qadafi département commune"
     echo "for example: qadafi 06 Saint-Jean-Cap-Ferrat"
     echo $1
     exit
}

# test if we have two arguments on the command line
if [ $# != 2 ]
then
    usage
fi

dept='0'$1

commune=`echo $2 | tr a-z A-Z`

#codelist=`$Qadastre2OSM --list $dept`

code=`$Qadastre2OSM --list $dept | grep $commune | awk '{print $2}'`


if [ $? != 0 ]
    then
    usage "Could not fetch list of communes for département $dept."
fi

if [ z$code = 'z' ]
    then
    usage "Could not find commune $commune in département $dept."
fi

echo "Found commune $commune in département $dept with code $code!"

echo Downloading...

downloadstatus=`$Qadastre2OSM --download $dept $code $commune || exit 1`

if [ $? != 0 ]
    then
    usage "Found code $code but could not download $commune. Weird problem on the Cadastre side? Qadastre2OSM returned: $downloadstatus"
fi

echo Converting...

convertstatus=`$Qadastre2OSM --convert-with-lands $code $commune || exit 1`

if [ $? != 0 ]
    then
    usage "Downloaded $commune but could not convert: Qadastre2OSM returned: $downloadstatus"
fi

echo "Done! Here's your prize:"

ls -l $code-$commune-*.osm