From f74faef8f7213882d1ac519d09bc14811f516840 Mon Sep 17 00:00:00 2001 From: Jakob Miksch Date: Mon, 5 Aug 2024 22:17:28 +0200 Subject: [PATCH 1/2] wip --- Dockerfile | 2 +- qsa-api/qsa_api/project.py | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 1ce3aa1f..20d37756 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,6 @@ RUN apt-get update \ && rm -rf /var/lib/apt/lists/* WORKDIR /qsa -ADD qsa-api/qsa_api /qsa/qsa_api ADD qsa-api/pyproject.toml . RUN rm -rf venv \ @@ -16,6 +15,7 @@ RUN rm -rf venv \ && pip install gunicorn \ && poetry install +ADD qsa-api/qsa_api /qsa/qsa_api ENV PATH=/qsa/venv/bin:$PATH EXPOSE 5000 CMD ["gunicorn" , "-b", "0.0.0.0:5000", "--workers", "1", "--threads", "1", "qsa_api.app:app"] diff --git a/qsa-api/qsa_api/project.py b/qsa-api/qsa_api/project.py index c3972264..0039ae48 100644 --- a/qsa-api/qsa_api/project.py +++ b/qsa-api/qsa_api/project.py @@ -352,6 +352,7 @@ def add_layer( if t == Qgis.LayerType.Vector: self.debug("Init vector layer") lyr = QgsVectorLayer(datasource, name, provider) + self.debug(lyr) elif t == Qgis.LayerType.Raster: self.debug("Init raster layer") lyr = QgsRasterLayer(datasource, name, provider) @@ -396,6 +397,14 @@ def add_layer( project.read(self._qgis_project_uri, Qgis.ProjectReadFlag.DontResolveLayers) project.addMapLayer(lyr) + if t == Qgis.LayerType.Vector: + layer_id = lyr.id() + self.debug("layer_id") + self.debug(layer_id) + project.writeEntry( "WFSLayers", "/", [layer_id]) + geometry_precision = 8 + project.writeEntry( "WFSLayersPrecision", "/" + layer_id, geometry_precision) + self.debug("Write QGIS project") project.write() From d0d7c2937833dfd2d18bbc4695718a60a23a9a1e Mon Sep 17 00:00:00 2001 From: Jakob Miksch Date: Tue, 6 Aug 2024 11:31:03 +0200 Subject: [PATCH 2/2] WIP --- qsa-api/qsa_api/project.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/qsa-api/qsa_api/project.py b/qsa-api/qsa_api/project.py index 0039ae48..d9ba9b2d 100644 --- a/qsa-api/qsa_api/project.py +++ b/qsa-api/qsa_api/project.py @@ -397,14 +397,18 @@ def add_layer( project.read(self._qgis_project_uri, Qgis.ProjectReadFlag.DontResolveLayers) project.addMapLayer(lyr) - if t == Qgis.LayerType.Vector: - layer_id = lyr.id() - self.debug("layer_id") - self.debug(layer_id) - project.writeEntry( "WFSLayers", "/", [layer_id]) + def set_published_wfs_layers(qgis_project_instance, layer_ids): + qgis_project_instance.writeEntry( "WFSLayers" , "/", layer_ids) geometry_precision = 8 - project.writeEntry( "WFSLayersPrecision", "/" + layer_id, geometry_precision) + for layer_id in layer_ids: + qgis_project_instance.writeEntry( "WFSLayersPrecision", "/" + layer_id, geometry_precision) + qgis_project_instance.write() + # ensure all vector layers are published by default + if t == Qgis.LayerType.Vector: + vector_layer_ids = [layer.id() for layer in project.mapLayers().values() if isinstance(layer, QgsVectorLayer)] + set_published_wfs_layers(project, vector_layer_ids) + self.debug("Write QGIS project") project.write()