Skip to content

Commit

Permalink
Update count_overlaps.py: Add GeoJSON and QGIS project to ZIP
Browse files Browse the repository at this point in the history
  • Loading branch information
mhhd2020 committed Jul 11, 2023
1 parent 3f84ab7 commit 46813cb
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions sketch_map_tool/upload_processing/count_overlaps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from tempfile import NamedTemporaryFile
from qgis.core import (QgsProject, QgsVectorLayer, QgsCoordinateReferenceSystem, QgsApplication,
QgsProcessingFeatureSourceDefinition, QgsProcessingFeedback)
from zipfile import ZipFile


def create_qgis_project(markings: BytesIO):
Expand All @@ -16,5 +17,9 @@ def create_qgis_project(markings: BytesIO):
project.setCrs(reference_system)
outfile = NamedTemporaryFile(suffix=".qgs")
project.write(outfile.name)
with open(outfile.name, "rb") as f:
return BytesIO(f.read())
buffer = BytesIO()
with ZipFile(buffer, "w") as zip_file, open(infile.name, "rb") as f_markings, open(outfile.name, "rb") as f_qgis:
zip_file.writestr(infile.name.replace("tmp/", "./"), f_markings.read())
zip_file.writestr(f"project.qgs", f_qgis.read())
buffer.seek(0)
return buffer

0 comments on commit 46813cb

Please sign in to comment.