Make a temp path for the GeometryFactory
This commit is contained in:
parent
e7e23fccd9
commit
ae8885aede
33
input_geojson_content.py
Normal file
33
input_geojson_content.py
Normal file
@ -0,0 +1,33 @@
|
||||
"""
|
||||
input_geojson_content module
|
||||
Returns a temporary path to input the GeometryFactory
|
||||
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
||||
Copyright © 2024 Concordia CERC group
|
||||
Project developers: Alireza Adli alireza.adli@mail.concordia.ca
|
||||
"""
|
||||
import tempfile
|
||||
import json
|
||||
|
||||
|
||||
class InputGeoJsonContent:
|
||||
def __init__(self, content):
|
||||
self.content = content
|
||||
|
||||
@property
|
||||
def content(self):
|
||||
return self._content
|
||||
|
||||
@content.setter
|
||||
def content(self, content):
|
||||
if isinstance(content, str):
|
||||
self._content = content
|
||||
else:
|
||||
temp_file = \
|
||||
tempfile.NamedTemporaryFile(
|
||||
delete=False, suffix='.geojson', mode='w', encoding='utf8')
|
||||
try:
|
||||
json.dump(content, temp_file)
|
||||
temp_file.flush()
|
||||
self._content = temp_file.name
|
||||
finally:
|
||||
temp_file.close()
|
Loading…
Reference in New Issue
Block a user