From 3769a5e58bf3bf4035ce6ed74193c917d79f1656 Mon Sep 17 00:00:00 2001 From: kapil-agnihotri Date: Mon, 28 Oct 2024 17:50:36 +0100 Subject: [PATCH] feat: add open option FORCE_SRS_DETECTION in case of gml files and if source_srs is not set ING-4473 --- README.md | 12 ++++++++++++ scripts/ogr-convert.sh | 11 +++++++++++ 2 files changed, 23 insertions(+) mode change 100644 => 100755 scripts/ogr-convert.sh diff --git a/README.md b/README.md index 753c3ec..fc8b9aa 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,12 @@ The default command prints the script usage. Example calls ------------- +Build docker image after changes using command: + +``` +docker build -t wetransform/conversion-gdal:latest . +``` + Convert remote file, result is stored in internal container volume: ``` @@ -25,3 +31,9 @@ docker run -it --user=$(id -u):$(id -g) -v $(pwd):/data wetransform/conversion-g ``` Similarly, files from mounted volumes can be converted as well, by providing a file path resolvable in the container instead of a remote (http/https) location. + +Example to mount a volume and run docker image: + +``` +docker run -it -v :/data wetransform/conversion-gdal:latest ./ogr-convert.sh --source /data/ --target-dir /data/target --target-name test.shp -f "ESRI Shapefile" +``` diff --git a/scripts/ogr-convert.sh b/scripts/ogr-convert.sh old mode 100644 new mode 100755 index d77de5f..074b44d --- a/scripts/ogr-convert.sh +++ b/scripts/ogr-convert.sh @@ -94,7 +94,17 @@ if [ -n "$source_srs" ]; then # no target srs, but if s_srs is provided, t_srs must be as well target_srs=$source_srs fi +else + # Extract driverShortName + driverShortName=$(ogrinfo -json $source_loc | jq -r '.driverShortName') + echo "Driver Short Name: $driverShortName" + # Check if driverShortName is GML and source_srs is not set + if [ "$driverShortName" == "GML" ]; then + echo "GML driver detected and no source SRS provided, setting FORCE_SRS_DETECTION=YES" + convert_cmd="$convert_cmd -oo FORCE_SRS_DETECTION=YES" + fi fi + if [ -n "$target_srs" ]; then # target srs is provided # add as parameter @@ -123,5 +133,6 @@ fi # run echo "Executing conversion..." +echo "Command: $convert_cmd" eval $convert_cmd rc=$?; if [ $rc -ne 0 ]; then echo "ERROR: Conversion failed"; exit $rc; else echo "Conversion successful"; fi