2012-10-21 16:16:12 +02:00
|
|
|
#!/bin/bash
|
|
|
|
# usage make-contour-tile.sh input-file output-directory
|
|
|
|
|
|
|
|
# directory for python tools
|
|
|
|
TOOL_DIR="."
|
|
|
|
# temporary directory
|
|
|
|
TMP_DIR="/var/tmp/"
|
|
|
|
|
|
|
|
# ---------------------------------------------
|
|
|
|
# check arguments and build absolute filenames
|
|
|
|
# ---------------------------------------------
|
|
|
|
|
|
|
|
if [ $# -ne 2 ]; then
|
|
|
|
echo "Error: 2 arguments needed"
|
|
|
|
echo "Usage: "$(basename $0) "[input-file] [output-directory/]"
|
|
|
|
exit 2
|
|
|
|
fi
|
2012-10-26 15:09:28 +02:00
|
|
|
if [ $# -eq 3]; then
|
|
|
|
tmpfile="tmp"$3
|
|
|
|
else
|
|
|
|
tmpfile="tmp"
|
|
|
|
fi
|
2012-10-21 16:16:12 +02:00
|
|
|
if [ ! -f $1 ]; then
|
|
|
|
echo "input file not found"
|
|
|
|
exit 3
|
|
|
|
fi
|
|
|
|
if [ ! -d $2 ]; then
|
|
|
|
echo "output directory not found"
|
|
|
|
exit 3
|
|
|
|
fi
|
|
|
|
working_dir=$(pwd)
|
|
|
|
inpath=$(dirname $1)
|
|
|
|
cd $inpath
|
|
|
|
filename=$(basename $1)
|
|
|
|
infile=$(pwd)/$filename
|
|
|
|
fileroot=${filename%.*}
|
|
|
|
|
|
|
|
cd $working_dir
|
|
|
|
cd $2
|
|
|
|
outdir=$(pwd)/
|
|
|
|
outfile=$outdir$fileroot.osm
|
|
|
|
|
|
|
|
|
|
|
|
# ---------------------------------------------
|
|
|
|
# process
|
|
|
|
# ---------------------------------------------
|
2012-10-21 23:43:00 +02:00
|
|
|
#if [ ! -f $outfile.bz2 ]
|
|
|
|
#then
|
2012-10-21 23:09:25 +02:00
|
|
|
echo "----------------------------------------------"
|
|
|
|
echo "Processing"$fileroot
|
|
|
|
echo "----------------------------------------------"
|
|
|
|
echo "Extracting shapefile …"
|
2012-10-26 15:09:28 +02:00
|
|
|
if [ -f ${TMP_DIR}${tmpfile}.shp ]; then rm ${TMP_DIR}${tmpfile}.shp ${TMP_DIR}${tmpfile}.dbf ${TMP_DIR}${tmpfile}.prj ${TMP_DIR}${tmpfile}.shx; fi
|
|
|
|
gdal_contour -i 10 -snodata -32768 -a height $infile ${TMP_DIR}${tmpfile}.shp
|
2012-10-21 23:09:25 +02:00
|
|
|
if [ $? -ne 0 ]; then echo $(date)' Error creating shapefile' & exit 4;fi
|
|
|
|
|
|
|
|
echo "Building osm file …"
|
2012-10-26 15:09:28 +02:00
|
|
|
${working_dir}/srtmshp2osm.py -q -f $TMP_DIR/${tmpfile}.shp -o $outfile
|
2012-10-21 23:09:25 +02:00
|
|
|
if [ $? -ne 0 ]; then echo $(date)' Error creating OSM file' & exit 5;fi
|
|
|
|
|
|
|
|
echo "Compressing to osm.bz2 …"
|
|
|
|
bzip2 -f $outfile
|
|
|
|
if [ $? -ne 0 ]; then echo $(date)' Error compressing OSM file' & exit 6;fi
|
2012-10-21 23:43:00 +02:00
|
|
|
#else
|
|
|
|
#echo "Skipping, already existing file"
|
|
|
|
#fi
|