Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

publish WFS #7

Merged
merged 2 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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"]
13 changes: 13 additions & 0 deletions qsa-api/qsa_api/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -396,6 +397,18 @@ def add_layer(
project.read(self._qgis_project_uri, Qgis.ProjectReadFlag.DontResolveLayers)
project.addMapLayer(lyr)

def set_published_wfs_layers(qgis_project_instance, layer_ids):
qgis_project_instance.writeEntry( "WFSLayers" , "/", layer_ids)
geometry_precision = 8
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()

Expand Down
Loading