Skip to content

Commit

Permalink
Merge pull request #8 from georchestra/can-deactivate-nlt
Browse files Browse the repository at this point in the history
Can deactivate nlt param
  • Loading branch information
f-necas authored May 23, 2024
2 parents e94c39d + b6faee5 commit c0ec5e9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,23 @@ 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:

```
/**
* 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
```


# Docker

The provided `Dockerfile` is meant to build the `vrt-bot` image, and a build can be
Expand Down
6 changes: 5 additions & 1 deletion vrt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,18 @@ touch ${SOURCEDIR}/vrtbot.log
then
cd "${SOURCEDIR}"

params=()
if [[ ${PROMOTE_TO_MULTI:-true} == true ]]; then
params+=(-nlt PROMOTE_TO_MULTI)
fi
# cycle vrt
for vrt in *.vrt;
do
echo "import de ${SOURCEDIR}/${vrt} dans le schema ${ACTIVESCHEMA} de la base ${PGDATABASE}" | tee -a 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
Expand Down

0 comments on commit c0ec5e9

Please sign in to comment.