|
1 | 1 | #!/bin/bash |
2 | 2 |
|
3 | | -# update ENV vars to point to the first available file on disk |
4 | | -export PBF2JSON_FILE=$(ls ${OSMPATH}/*.osm.pbf | head -n 1) |
5 | | -export POLYLINE_FILE=$(ls ${POLYLINEPATH}/*.0sv | head -n 1) |
| 3 | +# ensure environment variables are set |
| 4 | +if [[ -z "${OSMPATH}" ]]; then |
| 5 | + 2>&1 echo "error: environment variable OSMPATH not set" |
| 6 | + exit 1 |
| 7 | +fi |
| 8 | +if [[ -z "${POLYLINEPATH}" ]]; then |
| 9 | + 2>&1 echo "error: environment variable POLYLINEPATH not set" |
| 10 | + exit 1 |
| 11 | +fi |
| 12 | + |
| 13 | +# read a list of available pbf/0sv files |
| 14 | +shopt -s nullglob |
| 15 | +PBF_FILES=(${OSMPATH}/*.pbf) |
| 16 | +POLYLINE_FILES=(${POLYLINEPATH}/*.0sv) |
| 17 | +shopt -u nullglob |
| 18 | + |
| 19 | +# ensure at least one *.pbf file exists, warn if more than one was found |
| 20 | +if [[ ${#PBF_FILES[@]} -eq 0 ]]; then |
| 21 | + 2>&1 echo "error: no .pbf files found in ${OSMPATH}" |
| 22 | + exit 1 |
| 23 | +elif [[ ${#PBF_FILES[@]} -gt 1 ]]; then |
| 24 | + 2>&1 echo "warning: multiple .pbf files found in ${OSMPATH}, only ${PBF_FILES[0]} was used" |
| 25 | +fi |
| 26 | + |
| 27 | +# ensure at least one *.0sv file exists, warn if more than one was found |
| 28 | +if [[ ${#POLYLINE_FILES[@]} -eq 0 ]]; then |
| 29 | + 2>&1 echo "error: no .0sv files found in ${POLYLINEPATH}" |
| 30 | + exit 1 |
| 31 | +elif [[ ${#POLYLINE_FILES[@]} -gt 1 ]]; then |
| 32 | + 2>&1 echo "warning: multiple .0sv files found in ${POLYLINEPATH}, only ${POLYLINE_FILES[0]} was used" |
| 33 | +fi |
| 34 | + |
| 35 | +# update ENV vars to point to the first available files on disk |
| 36 | +export PBF2JSON_FILE="${PBF_FILES[0]}" |
| 37 | +export POLYLINE_FILE="${POLYLINE_FILES[0]}" |
6 | 38 |
|
7 | 39 | # run the build |
8 | 40 | exec ./script/build.sh |
0 commit comments