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