Skip to content

Commit

Permalink
Merge pull request #275 from hotosm/hotfix/customexportsshp
Browse files Browse the repository at this point in the history
FIX : SRS Issue on custom Exports
  • Loading branch information
kshitijrajsharma authored Sep 12, 2024
2 parents 3192291 + 14e6eda commit 0e69632
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1462,7 +1462,22 @@ def process_export_format(export_format):
else ""
)
if USE_DUCK_DB_FOR_CUSTOM_EXPORTS is True:
executable_query = f"""COPY ({query.strip()}) TO '{export_file_path}' WITH (FORMAT {export_format.format_option}{f", DRIVER '{export_format.driver_name}'{f', LAYER_CREATION_OPTIONS {layer_creation_options_str}' if layer_creation_options_str else ''}" if export_format.format_option == 'GDAL' else ''})"""

format_option = export_format.format_option

driver_and_layer_options = ""
if format_option == "GDAL":
driver_and_layer_options = f", DRIVER '{export_format.driver_name}'"
if layer_creation_options_str:
driver_and_layer_options += f", SRS 'EPSG:4326', LAYER_CREATION_OPTIONS {layer_creation_options_str}"

executable_query = f"""
COPY ({query.strip()})
TO '{export_file_path}'
WITH (FORMAT {format_option}{driver_and_layer_options})
"""

# executable_query = f"""COPY ({query.strip()}) TO '{export_file_path}' WITH (FORMAT {export_format.format_option}{f", DRIVER '{export_format.driver_name}'{f", SRS 'EPSG:4326', LAYER_CREATION_OPTIONS {layer_creation_options_str}" if layer_creation_options_str else ''}" if export_format.format_option == 'GDAL' else ''})"""
self.duck_db_instance.run_query(
executable_query.strip(), load_spatial=True
)
Expand Down

0 comments on commit 0e69632

Please sign in to comment.