From a7cbcfa6b76bf3abcf27f5105b4f8c32e00389a0 Mon Sep 17 00:00:00 2001 From: Florian Necas Date: Thu, 23 May 2024 14:34:14 +0200 Subject: [PATCH 1/2] feat: can deactivate nlt param --- README.md | 10 ++++++++++ vrt.sh | 6 +++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 80b4763..67c96d4 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,16 @@ The `vrt.sh` script is meant to be called regularly via a Cronjob (every 5 hours or more, as the datasets will be downloaded and published again at each run), with the previous variables defined. +## Optional variables + +The following environment variables are optional: + +``` +# export ACTIVATE_GEOMETRY_TYPE=false +True by default +``` + + # Docker The provided `Dockerfile` is meant to build the `vrt-bot` image, and a build can be diff --git a/vrt.sh b/vrt.sh index 99ec377..e70ced4 100755 --- a/vrt.sh +++ b/vrt.sh @@ -31,6 +31,10 @@ touch ${SOURCEDIR}/vrtbot.log then cd "${SOURCEDIR}" + params=() + if [[ ${ACTIVATE_GEOMETRY_TYPE:-true} == true ]]; then + params=(-nlt PROMOTE_TO_MULTI) + fi # cycle vrt for vrt in *.vrt; do @@ -38,7 +42,7 @@ touch ${SOURCEDIR}/vrtbot.log /usr/bin/ogr2ogr \ -f Postgresql \ -overwrite \ - PG:"active_schema=${ACTIVESCHEMA}" "${vrt}" -lco SCHEMA=${ACTIVESCHEMA} -lco OVERWRITE=yes -lco GEOMETRY_NAME=geometry -nlt PROMOTE_TO_MULTI -lco DESCRIPTION="import par ${JOB_NAME}/${BUILD_NUMBER} le ${DATE} - ${SOURCEDIR}/${vrt}" 2>&1 | tee -a vrtbot.log + PG:"active_schema=${ACTIVESCHEMA}" "${vrt}" -lco SCHEMA=${ACTIVESCHEMA} -lco OVERWRITE=yes -lco GEOMETRY_NAME=geometry "${params[@]}" -lco DESCRIPTION="import par ${JOB_NAME}/${BUILD_NUMBER} le ${DATE} - ${SOURCEDIR}/${vrt}" 2>&1 | tee -a vrtbot.log # post import sql if [ -f "${vrt}.sql" ]; then echo "script sql après import trouvé" | tee -a vrtbot.log From b6faee52ec16235b73ec5227fba63be22524b31f Mon Sep 17 00:00:00 2001 From: Florian Necas Date: Thu, 23 May 2024 15:33:32 +0200 Subject: [PATCH 2/2] feat: change variable name, add docs, add + for params extension --- README.md | 11 +++++++++-- vrt.sh | 4 ++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 67c96d4..aefdc40 100644 --- a/README.md +++ b/README.md @@ -47,8 +47,15 @@ with the previous variables defined. The following environment variables are optional: ``` -# export ACTIVATE_GEOMETRY_TYPE=false -True by default +/** +* PROMOTE_TO_MULTI can be used to automatically promote layers that mix polygon or multipolygons to multipolygons, +* and layers that mix linestrings or multilinestrings to multilinestrings. +* Can be useful when converting shapefiles to PostGIS +* and other target drivers that implement strict checks for geometry types +* +* Enabled by default +**/ +# export PROMOTE_TO_MULTI=false ``` diff --git a/vrt.sh b/vrt.sh index e70ced4..1e88027 100755 --- a/vrt.sh +++ b/vrt.sh @@ -32,8 +32,8 @@ touch ${SOURCEDIR}/vrtbot.log cd "${SOURCEDIR}" params=() - if [[ ${ACTIVATE_GEOMETRY_TYPE:-true} == true ]]; then - params=(-nlt PROMOTE_TO_MULTI) + if [[ ${PROMOTE_TO_MULTI:-true} == true ]]; then + params+=(-nlt PROMOTE_TO_MULTI) fi # cycle vrt for vrt in *.vrt;