Skip to content

Commit a689b4f

Browse files
authored
[Fixes #255] Fix encoding for Shapefile uploads (#289)
Use SHAPE_ENCODING parameter to inform the ogr2ogr command of the encoding for the Shapefile so it can transform accordingly.
1 parent 928669a commit a689b4f

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

importer/handlers/shapefile/handler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def create_ogr2ogr_command(files, original_name, ovverwrite_layer, alternate):
164164
):
165165
additional_options.append("-nlt PROMOTE_TO_MULTI")
166166
if encoding:
167-
additional_options.append(f"-lco ENCODING={encoding}")
167+
additional_options.append(f"--config SHAPE_ENCODING {encoding}")
168168

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

importer/handlers/shapefile/tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def test_should_create_ogr2ogr_command_with_encoding_from_cst(self):
121121
actual = self.handler.create_ogr2ogr_command(shp_with_cst, "a", False, "a")
122122

123123
_file.assert_called_once_with(cst_file, "r")
124-
self.assertIn("ENCODING=UTF-8", actual)
124+
self.assertIn("--config SHAPE_ENCODING UTF-8", actual)
125125

126126
@patch("importer.handlers.common.vector.Popen")
127127
def test_import_with_ogr2ogr_without_errors_should_call_the_right_command(

0 commit comments

Comments
 (0)