lint scripts
This commit is contained in:
parent
e9b41aefb6
commit
c3ee8f70a8
|
@ -1,2 +1,3 @@
|
|||
*.pbf
|
||||
*.json
|
||||
*.log
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
# execute the runner with a preset of parameters
|
||||
$(dirname $0)/runner feature "--tuples-only --file=config/geojson.sql" "$@"
|
||||
"$(dirname "$0")"/runner feature "--tuples-only --file=config/geojson.sql" "$@"
|
||||
|
||||
exit $?;
|
||||
|
|
18
bin/merge
18
bin/merge
|
@ -7,14 +7,24 @@ reports=$1
|
|||
feature=$2
|
||||
format=${3:-topojson}
|
||||
|
||||
# root path project
|
||||
__root="$(cd "$(dirname "$(dirname "${BASH_SOURCE[0]}")")" && pwd)"
|
||||
|
||||
# temporary file
|
||||
tmpfile="${__root}"/reports.merged.csv
|
||||
|
||||
# handle kill signs
|
||||
trap "echo; exit 1" INT TERM
|
||||
|
||||
# remove previous report
|
||||
rm --force reports.merged.csv
|
||||
rm --force "${tmpfile}"
|
||||
|
||||
# join all reports into a single file
|
||||
awk '(NR == 1) || (FNR > 1)' $reports > reports.merged.csv
|
||||
awk '(NR == 1) || (FNR > 1)' ${reports} > "${tmpfile}"
|
||||
|
||||
# run mapshaper transforming the data
|
||||
npx mapshaper -i $feature -clean -join reports.merged.csv string-fields=id keys=id,id fields=id,name calc='tmp = collect({ [date]: percentage }), values = (tmp || []).reduce((acc, item) => ({ ...acc, ...item }), {}), delete tmp' -o format=$format "1calle1nombre.json"
|
||||
rm --force reports.merged.csv
|
||||
npx mapshaper -i "${feature}" -clean -join "${tmpfile}" string-fields=id keys=id,id fields=id,name calc='tmp = collect({ [date]: percentage }), values = (tmp || []).reduce((acc, item) => ({ ...acc, ...item }), {}), delete tmp' -o format="${format}" "1calle1nombre.json"
|
||||
|
||||
rm --force "${tmpfile}"
|
||||
|
||||
exit 0;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
# execute the runner with a preset of parameters
|
||||
$(dirname $0)/runner report "--csv --file=config/1calle1nombre.sql" "$@"
|
||||
"$(dirname "$0")"/runner report "--csv --file=config/1calle1nombre.sql" "$@"
|
||||
|
||||
exit $?;
|
||||
|
|
45
bin/runner
45
bin/runner
|
@ -1,8 +1,8 @@
|
|||
#!/bin/bash
|
||||
|
||||
# get the preset from the wrapper scripts
|
||||
TYPE=$1
|
||||
OPTS=$2
|
||||
type=$1
|
||||
opts=$2
|
||||
|
||||
shift 2
|
||||
|
||||
|
@ -14,8 +14,8 @@ elif [[ "${1,,}" == "prov" ]]; then
|
|||
REGIONS=(C A AB AL VI AV BA B BI BU CC CA CS CE CR CO CU SS GI GR GU H HU J GC LE L LU MA ML OR P PO SA TF SG SE SO T TE TO V VA ZA Z)
|
||||
fi
|
||||
|
||||
ERR=error.log
|
||||
rm --force $ERR
|
||||
err=error.log
|
||||
rm --force "${err}"
|
||||
|
||||
# handle kill signs
|
||||
trap "echo; exit 1" INT TERM
|
||||
|
@ -23,29 +23,36 @@ trap "echo; exit 1" INT TERM
|
|||
for region in "${REGIONS[@]}"
|
||||
do
|
||||
# feature or report must set the query param "region" in order to get the proper results
|
||||
VAR="REGION="
|
||||
[ $# -gt 0 ] && VAR+=\'$region\'
|
||||
var="REGION="
|
||||
[ $# -gt 0 ] && var+=\'${region}\'
|
||||
|
||||
if [ $TYPE == "feature" ]; then
|
||||
echo -ne "Creando GeoJSON para $region... \t\t\t"
|
||||
FILE=./features/"$region".geojson
|
||||
elif [ $TYPE == "report" ]; then
|
||||
echo -ne "Creando informe para $region... \t\t\t"
|
||||
FILE=./reports/$(date +%Y%m)/"$region".csv
|
||||
if [ "${type}" == "feature" ]; then
|
||||
echo -ne "Creando GeoJSON para ${region}... \t\t\t"
|
||||
file=./features/"${region}".geojson
|
||||
elif [ "${type}" == "report" ]; then
|
||||
echo -ne "Creando informe para ${region}... \t\t\t"
|
||||
file=./reports/$(date +%Y%m)/"${region}".csv
|
||||
fi
|
||||
|
||||
mkdir --parents $(dirname "$FILE")
|
||||
mkdir --parents "$(dirname "${file}")"
|
||||
|
||||
# run psql with the corresponding variables
|
||||
psql --dbname=osm --single-transaction --variable="ON_ERROR_STOP=1" --variable="$VAR" $OPTS > "$FILE" 2>> $ERR
|
||||
if psql --dbname=osm --single-transaction --variable="ON_ERROR_STOP=1" --variable="${var}" "${opts}" > "${file}" 2>> "${err}"; then
|
||||
echo -ne "[\033[0;32mOK\033[0m]\t\t\t"
|
||||
else
|
||||
echo -ne "[\033[0;31merror\033[0m]\t\t\t"
|
||||
fi
|
||||
|
||||
[ $? -eq 0 ] && echo -ne "[\033[0;32mOK\033[0m]\t\t\t" || echo -ne "[\033[0;31merror\033[0m]\t\t\t"
|
||||
echo -ne $(basename "$FILE")"\t"$(wc -c "$FILE" | cut -d ' ' -f 1 | numfmt --to=si)
|
||||
|
||||
echo
|
||||
echo -ne "$(basename "${file}")$(printf '\t')$(wc -c "${file}" | cut -d ' ' -f 1 | numfmt --to=si)\n"
|
||||
done
|
||||
|
||||
# display the errors, if any
|
||||
[ -s $ERR ] && echo && cat $ERR && exit 1 || rm --force $ERR
|
||||
if [ -s "${err}" ]; then
|
||||
echo
|
||||
cat "${err}"
|
||||
exit 1
|
||||
else
|
||||
rm --force "${err}"
|
||||
fi
|
||||
|
||||
exit 0;
|
||||
|
|
|
@ -5,6 +5,6 @@ rm --force spain-latest.osm.pbf
|
|||
# fetch the latest dump
|
||||
curl --progress-bar --remote-name https://download.geofabrik.de/europe/spain-latest.osm.pbf
|
||||
# load the dump into osm database
|
||||
osm2pgsql --create --slim --cache=2048 --multi-geometry --proj=4326 --style=config/1calle1nombre.style --database=osm --username=$(whoami) spain-latest.osm.pbf
|
||||
osm2pgsql --create --slim --cache=2048 --multi-geometry --proj=4326 --style=config/1calle1nombre.style --database=osm --username="$(whoami)" spain-latest.osm.pbf
|
||||
|
||||
exit $?;
|
||||
|
|
Loading…
Reference in New Issue