Skip to content

Commit

Permalink
feat: add open option FORCE_SRS_DETECTION in case of gml files and if…
Browse files Browse the repository at this point in the history
… source_srs is not set

ING-4473
  • Loading branch information
kapil-agnihotri committed Oct 29, 2024
1 parent 10705a1 commit 3769a5e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

```
Expand All @@ -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 <local_path_to_folder_to_be_mounted>:/data wetransform/conversion-gdal:latest ./ogr-convert.sh --source /data/<example.gml> --target-dir /data/target --target-name test.shp -f "ESRI Shapefile"
```
11 changes: 11 additions & 0 deletions scripts/ogr-convert.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

0 comments on commit 3769a5e

Please sign in to comment.