Skip to content

Commit 1c3b715

Browse files
authored
[Fixes #12981] Fix encoding for Shapefile uploads (#12982)
Use SHAPE_ENCODING parameter to inform the ogr2ogr command of the encoding for the Shapefile so it can transform accordingly.
1 parent bf4bd71 commit 1c3b715

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

geonode/upload/handlers/shapefile/handler.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def create_ogr2ogr_command(files, original_name, ovverwrite_layer, alternate):
165165
if layer is not None and "Point" not in ogr.GeometryTypeToName(layer.GetGeomType()):
166166
additional_options.append("-nlt PROMOTE_TO_MULTI")
167167
if encoding:
168-
additional_options.append(f"-lco ENCODING={encoding}")
168+
additional_options.append(f"--config SHAPE_ENCODING {encoding}")
169169

170170
return (
171171
f"{base_command } -lco precision=no -lco GEOMETRY_NAME={BaseVectorFileHandler().default_geometry_column_name} "

geonode/upload/handlers/shapefile/tests.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def test_should_create_ogr2ogr_command_with_encoding_from_cst(self):
137137
actual = self.handler.create_ogr2ogr_command(shp_with_cst, "a", False, "a")
138138

139139
_file.assert_called_once_with(cst_file, "r")
140-
self.assertIn("ENCODING=UTF-8", actual)
140+
self.assertIn("--config SHAPE_ENCODING UTF-8", actual)
141141

142142
@patch("geonode.upload.handlers.common.vector.Popen")
143143
def test_import_with_ogr2ogr_without_errors_should_call_the_right_command(self, _open):

0 commit comments

Comments
 (0)