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

Vector sources ban raster #399

Merged
merged 7 commits into from
Jun 22, 2021
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
### Changes
- [#167](https://github.com/LayerManager/layman/issues/167) Allow publishing also raster geospatial data from `GeoTiff` and `JPEG2000` formats using [POST Workspace Layers](doc/rest.md#post-workspace-layers) and [PATCH Workspace Layer](doc/rest.md#patch-workspace-layer).
- [#167](https://github.com/LayerManager/layman/issues/167) Add `file_type` item to `file` item in [GET Workspace Layer](doc/rest.md#get-workspace-layer) response to distinguish raster and vector layer.
- [#167](https://github.com/LayerManager/layman/issues/167) Raster layers are not stored in DB table, for WFS and for WMS. Also bounding box is not calculated for them.
- [#367](https://github.com/LayerManager/layman/issues/367) Upgrade gdal from 2.4 to 3.3. Use docker image from [osgeo/gdal@hub.docker.com](https://hub.docker.com/r/osgeo/gdal), source is located at [osgeo/gdal@github.com](https://github.com/OSGeo/gdal/tree/master/gdal/docker).
- [#367](https://github.com/LayerManager/layman/issues/367) Upgrade also
- python from 3.6 to 3.8
Expand Down
17 changes: 9 additions & 8 deletions doc/rest.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,15 @@ Publish vector data file as new layer of WMS and WFS.
Processing chain consists of few steps:
- save file to workspace directory within Layman data directory
- save basic information (name, title, access_rights) into PostgreSQL
- import the file to PostgreSQL database as new table into workspace schema, including geometry transformation to EPSG:3857
- publish the table as new layer (feature type) within appropriate WFS workspaces of GeoServer
- save bounding box into PostgreSQL
- for layers with SLD or none style:
- publish the table as new layer (feature type) within appropriate WMS workspaces of GeoServer
- else for layers with QML style:
- create QGS file on QGIS server filesystem with appropriate style
- publish the layer on GeoServer through WMS cascade from QGIS server
- for vector layers import the file to PostgreSQL database as new table into workspace schema, including geometry transformation to EPSG:3857
- for vector layers publish the table as new layer (feature type) within appropriate WFS workspaces of GeoServer
- for vector layers save bounding box into PostgreSQL
- for vector layers
- for layers with SLD or none style:
- publish the table as new layer (feature type) within appropriate WMS workspaces of GeoServer
- else for layers with QML style:
- create QGS file on QGIS server filesystem with appropriate style
- publish the layer on GeoServer through WMS cascade from QGIS server
- generate thumbnail image
- publish metadata record to Micka (it's public if and only if read access is set to EVERYONE)
- update thumbnail of each [map](models.md#map) that points to this layer
Expand Down
12 changes: 10 additions & 2 deletions src/layman/layer/db/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from layman.celery import AbortedException
from layman.common import empty_method_returns_true
from layman.layer.filesystem.input_file import get_layer_main_file_path
from layman import celery_app
from layman import celery_app, util as layman_util, settings
from layman.http import LaymanError
from .. import db
from .. import db, LAYER_TYPE
from .table import delete_layer


Expand All @@ -30,6 +30,14 @@ def refresh_table(
db.ensure_workspace(username)
if self.is_aborted():
raise AbortedException

file_type = layman_util.get_publication_info(username, LAYER_TYPE, layername, context={'keys': ['file']})['file']['file_type']
if file_type != settings.FILE_TYPE_VECTOR:
return

if self.is_aborted():
raise AbortedException

main_filepath = get_layer_main_file_path(username, layername)
process = db.import_layer_vector_file_async(username, layername, main_filepath, crs_id)
while process.poll() is None and not self.is_aborted():
Expand Down
66 changes: 36 additions & 30 deletions src/layman/layer/geoserver/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

from geoserver import util as gs_util
from layman.celery import AbortedException
from layman import celery_app, settings
from layman import celery_app, settings, util as layman_util
from layman.common import empty_method_returns_true
from . import wms, wfs, sld
from .. import geoserver
from .. import geoserver, LAYER_TYPE

logger = get_task_logger(__name__)

Expand All @@ -30,35 +30,37 @@ def refresh_wms(
ensure_user=False,
access_rights=None,
):
if description is None:
description = layername
if title is None:
title = layername
geoserver_workspace = wms.get_geoserver_workspace(username)
if ensure_user:
geoserver.ensure_workspace(username)
file_type = layman_util.get_publication_info(username, LAYER_TYPE, layername, context={'keys': ['file']})['file']['file_type']
if file_type == settings.FILE_TYPE_VECTOR:
if description is None:
description = layername
if title is None:
title = layername
geoserver_workspace = wms.get_geoserver_workspace(username)
if ensure_user:
geoserver.ensure_workspace(username)

if self.is_aborted():
raise AbortedException
if store_in_geoserver:
gs_util.delete_wms_layer(geoserver_workspace, layername, settings.LAYMAN_GS_AUTH)
gs_util.delete_wms_store(geoserver_workspace, settings.LAYMAN_GS_AUTH, wms.get_qgis_store_name(layername))
geoserver.publish_layer_from_db(username,
layername,
description,
title,
access_rights,
geoserver_workspace=geoserver_workspace,
)
else:
gs_util.delete_feature_type(geoserver_workspace, layername, settings.LAYMAN_GS_AUTH)
geoserver.publish_layer_from_qgis(username,
layername,
description,
title,
access_rights,
geoserver_workspace=geoserver_workspace,
)
if self.is_aborted():
raise AbortedException
if store_in_geoserver:
gs_util.delete_wms_layer(geoserver_workspace, layername, settings.LAYMAN_GS_AUTH)
gs_util.delete_wms_store(geoserver_workspace, settings.LAYMAN_GS_AUTH, wms.get_qgis_store_name(layername))
geoserver.publish_layer_from_db(username,
layername,
description,
title,
access_rights,
geoserver_workspace=geoserver_workspace,
)
else:
gs_util.delete_feature_type(geoserver_workspace, layername, settings.LAYMAN_GS_AUTH)
geoserver.publish_layer_from_qgis(username,
layername,
description,
title,
access_rights,
geoserver_workspace=geoserver_workspace,
)
wms.clear_cache(username)

if self.is_aborted():
Expand All @@ -80,6 +82,10 @@ def refresh_wfs(
ensure_user=False,
access_rights=None,
):
file_type = layman_util.get_publication_info(username, LAYER_TYPE, layername, context={'keys': ['file']})['file']['file_type']
if file_type != settings.FILE_TYPE_VECTOR:
return

if description is None:
description = layername
if title is None:
Expand Down
8 changes: 6 additions & 2 deletions src/layman/layer/geoserver/wfs_tasks.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from geoserver import util as gs_util
from layman import celery_app, settings
from layman import celery_app, settings, util as layman_util
from layman.celery import AbortedException
from . import wfs
from .. import geoserver
from .. import geoserver, LAYER_TYPE

headers_json = geoserver.headers_json

Expand All @@ -20,6 +20,10 @@ def patch_after_feature_change(
if self.is_aborted():
raise AbortedException

file_type = layman_util.get_publication_info(workspace, LAYER_TYPE, layer, context={'keys': ['file']})['file']['file_type']
if file_type != settings.FILE_TYPE_VECTOR:
return

bbox = geoserver.get_layer_bbox(workspace, layer)
gs_util.patch_feature_type(workspace, layer, auth=settings.LAYMAN_GS_AUTH, bbox=bbox)
wfs.clear_cache(workspace)
Expand Down
16 changes: 9 additions & 7 deletions src/layman/layer/geoserver/wms_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ def patch_after_feature_change(
if self.is_aborted():
raise AbortedException

bbox = geoserver.get_layer_bbox(workspace, layer)
geoserver_workspace = wms.get_geoserver_workspace(workspace)
style_type = layman_util.get_publication_info(workspace, LAYER_TYPE, layer, context={'keys': ['style_type'], })['style_type']
if style_type == 'sld':
gs_util.patch_feature_type(geoserver_workspace, layer, auth=settings.LAYMAN_GS_AUTH, bbox=bbox)
elif style_type == 'qml':
gs_util.patch_wms_layer(geoserver_workspace, layer, auth=settings.LAYMAN_GS_AUTH, bbox=bbox)
file_type = layman_util.get_publication_info(workspace, LAYER_TYPE, layer, context={'keys': ['file']})['file']['file_type']
if file_type == settings.FILE_TYPE_VECTOR:
bbox = geoserver.get_layer_bbox(workspace, layer)
geoserver_workspace = wms.get_geoserver_workspace(workspace)
style_type = layman_util.get_publication_info(workspace, LAYER_TYPE, layer, context={'keys': ['style_type'], })['style_type']
if style_type == 'sld':
gs_util.patch_feature_type(geoserver_workspace, layer, auth=settings.LAYMAN_GS_AUTH, bbox=bbox)
elif style_type == 'qml':
gs_util.patch_wms_layer(geoserver_workspace, layer, auth=settings.LAYMAN_GS_AUTH, bbox=bbox)

wms.clear_cache(workspace)

Expand Down
1 change: 1 addition & 0 deletions src/layman/layer/micka/util_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ def test_fill_xml_template():


@pytest.mark.usefixtures('app_context', 'ensure_layman', 'client')
@pytest.mark.irritating
def test_num_records():
publs_by_type = uuid.check_redis_consistency()
num_publications = sum([len(publs) for publs in publs_by_type.values()])
Expand Down
4 changes: 3 additions & 1 deletion src/layman/layer/prime_db_schema/bbox_tasks.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from celery.utils.log import get_task_logger

from layman.celery import AbortedException
from layman import celery_app
from layman import celery_app, util as layman_util, settings
from .. import LAYER_TYPE
from ..db import get_bbox as db_get_bbox
from ...common.prime_db_schema.publications import set_bbox
Expand All @@ -22,6 +22,8 @@ def patch_after_feature_change(
if self.is_aborted():
raise AbortedException

file_type = layman_util.get_publication_info(username, LAYER_TYPE, layername, context={'keys': ['file']})['file']['file_type']
assert file_type == settings.FILE_TYPE_VECTOR
bbox = db_get_bbox(username, layername)

if self.is_aborted():
Expand Down
8 changes: 6 additions & 2 deletions src/layman/layer/prime_db_schema/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from layman.celery import AbortedException
from layman.common import empty_method_returns_true
from layman import celery_app
from layman import celery_app, util as layman_util, settings
from .. import LAYER_TYPE
from ..db import get_bbox as db_get_bbox
from ...common.prime_db_schema.publications import set_bbox
Expand All @@ -25,7 +25,11 @@ def refresh_bbox(
if self.is_aborted():
raise AbortedException

bbox = db_get_bbox(username, layername)
file_type = layman_util.get_publication_info(username, LAYER_TYPE, layername, context={'keys': ['file']})['file']['file_type']
if file_type == settings.FILE_TYPE_VECTOR:
bbox = db_get_bbox(username, layername)
else:
bbox = None

if self.is_aborted():
raise AbortedException
Expand Down
2 changes: 1 addition & 1 deletion test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ rm -rf tmp/artifacts/*

if [ "$CI" == "true" ]
then
python3 src/assert_db.py && python3 src/wait_for_deps.py && python3 src/clear_layman_data.py && python3 -m pytest -m "not irritating" -W ignore::DeprecationWarning -xvv
python3 src/assert_db.py && python3 src/wait_for_deps.py && python3 src/clear_layman_data.py && python3 -m pytest -m "not irritating" --timeout=60 -W ignore::DeprecationWarning -xvv
else
python3 src/assert_db.py && python3 src/wait_for_deps.py && python3 src/clear_layman_data.py && python3 -m pytest -W ignore::DeprecationWarning -xvv
fi
Expand Down