#!/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$1exit}# 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."fiif [ z$code = 'z' ]
then
usage "Could not find commune $commune in département $dept."fiecho"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"fiecho Converting...
convertstatus=`$Qadastre2OSM --convert-with-lands $code$commune||exit 1`if [ $?!= 0 ]
then
usage "Downloaded $commune but could not convert: Qadastre2OSM returned: $downloadstatus"fiecho"Done! Here's your prize:"
ls -l $code-$commune-*.osm