From b50dbc93964ab9ac74c6943e3f4074caf9399616 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Brunner?= Date: Wed, 27 Nov 2024 15:08:33 +0100 Subject: [PATCH] Fix OGC API features --- ci/mapserver.conf | 15 ----- ci/test-app | 1 - ...fecfe_update_the_ogc_server_for_ogc_api.py | 65 +++++++++++++++++++ commons/c2cgeoportal_commons/models/main.py | 4 +- .../docker-compose.override.sample.yaml | 5 ++ .../{{cookiecutter.project}}/env.default | 2 +- .../geoportal/vars.yaml | 2 +- .../mapserver/mapserver.conf | 1 + .../mapserver/mapserver.map.tmpl | 2 +- .../geoportal/CONST_vars.yaml | 4 +- .../scripts/create_demo_theme.py | 7 +- 11 files changed, 82 insertions(+), 26 deletions(-) delete mode 100644 ci/mapserver.conf create mode 100644 commons/c2cgeoportal_commons/alembic/main/2e57710fecfe_update_the_ogc_server_for_ogc_api.py diff --git a/ci/mapserver.conf b/ci/mapserver.conf deleted file mode 100644 index e60d9b3e91..0000000000 --- a/ci/mapserver.conf +++ /dev/null @@ -1,15 +0,0 @@ -# Documentation: https://mapserver.org/mapfile/config.html - -CONFIG - - ENV - END - - # - # Map aliases - # - MAPS - mapserver "/etc/mapserver/mapserver.map" - END - -END diff --git a/ci/test-app b/ci/test-app index f3cf887b94..04bbaa35c7 100755 --- a/ci/test-app +++ b/ci/test-app @@ -13,7 +13,6 @@ touch "${HOME}/workspace/testgeomapfishapp/qgisserver/project.qgs.raster" cp ci/tileindex/* "${HOME}/workspace/testgeomapfishapp/mapserver/" cp -r ci/test-app-db "${HOME}/workspace/testgeomapfishapp/ci/" cp -r ci/test-external-db "${HOME}/workspace/testgeomapfishapp/ci/" -cp ci/mapserver.conf "${HOME}/workspace/testgeomapfishapp/mapserver/" cd "${HOME}/workspace/testgeomapfishapp/" diff --git a/commons/c2cgeoportal_commons/alembic/main/2e57710fecfe_update_the_ogc_server_for_ogc_api.py b/commons/c2cgeoportal_commons/alembic/main/2e57710fecfe_update_the_ogc_server_for_ogc_api.py new file mode 100644 index 0000000000..e8ca298721 --- /dev/null +++ b/commons/c2cgeoportal_commons/alembic/main/2e57710fecfe_update_the_ogc_server_for_ogc_api.py @@ -0,0 +1,65 @@ +# Copyright (c) 2024, Camptocamp SA +# All rights reserved. + +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: + +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. + +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +# The views and conclusions contained in the software and documentation are those +# of the authors and should not be interpreted as representing official policies, +# either expressed or implied, of the FreeBSD Project. + +# pylint: disable=invalid-name + +""" +Update the OGC server for OGC API. + +Revision ID: 2e57710fecfe +Revises: a4558f032d7d +Create Date: 2024-11-27 12:47:20.234376 +""" + +from alembic import op +from c2c.template.config import config + +# revision identifiers, used by Alembic. +revision = "2e57710fecfe" +down_revision = "a4558f032d7d" +branch_labels = None +depends_on = None + + +def upgrade() -> None: + """Upgrade.""" + schema = config["schema"] + + # Instructions + + # default 'image/jpeg', 'image/png' + op.execute(f"UPDATE {schema}.ogc_server SET name = 'MapServer' WHERE name = 'source for image/png'") + op.execute(f"UPDATE {schema}.ogc_server SET name = 'MapServer_JPEG' WHERE name = 'source for image/jpeg'") + + +def downgrade() -> None: + """Downgrade.""" + schema = config["schema"] + + # Instructions + op.execute(f"UPDATE {schema}.ogc_server SET name = 'source for image/png' WHERE name = 'MapServer'") + op.execute(f"UPDATE {schema}.ogc_server SET name = 'source for image/jpeg' WHERE name = 'MapServer_JPEG'") diff --git a/commons/c2cgeoportal_commons/models/main.py b/commons/c2cgeoportal_commons/models/main.py index 0ad033a1dd..ffc87dd9f4 100644 --- a/commons/c2cgeoportal_commons/models/main.py +++ b/commons/c2cgeoportal_commons/models/main.py @@ -747,7 +747,9 @@ class OGCServer(Base): # type: ignore info={ "colanderalchemy": { "title": _("Name"), - "description": _("The name of the OGC Server"), + "description": _( + "The name of the OGC Server, should contains only no unaccentuated letters, numbers and _" + ), } }, ) diff --git a/geoportal/c2cgeoportal_geoportal/scaffolds/create/{{cookiecutter.project}}/docker-compose.override.sample.yaml b/geoportal/c2cgeoportal_geoportal/scaffolds/create/{{cookiecutter.project}}/docker-compose.override.sample.yaml index d69e0d8cc1..c5650e2592 100644 --- a/geoportal/c2cgeoportal_geoportal/scaffolds/create/{{cookiecutter.project}}/docker-compose.override.sample.yaml +++ b/geoportal/c2cgeoportal_geoportal/scaffolds/create/{{cookiecutter.project}}/docker-compose.override.sample.yaml @@ -36,6 +36,11 @@ services: # environment: # - LOG_LEVEL=DEBUG + mapserver: + environment: + - MS_DEBUGLEVEL=5 + - MAPSERVER_CATCH_SEGV=1 + # qgisserver: # # volumes: # # - './../c2cgeoportal/docker/qgisserver/geomapfish_qgisserver/:/var/www/plugins/geomapfish_qgisserver/' diff --git a/geoportal/c2cgeoportal_geoportal/scaffolds/create/{{cookiecutter.project}}/env.default b/geoportal/c2cgeoportal_geoportal/scaffolds/create/{{cookiecutter.project}}/env.default index 69c9f0635f..7f3abf01ff 100644 --- a/geoportal/c2cgeoportal_geoportal/scaffolds/create/{{cookiecutter.project}}/env.default +++ b/geoportal/c2cgeoportal_geoportal/scaffolds/create/{{cookiecutter.project}}/env.default @@ -44,7 +44,7 @@ TILECLOUDCHAIN_INTERNAL_URL=http://tilecloudchain:8080 TILECLOUDCHAIN_INTERNAL_HOST=tilecloudchain TILECLOUDCHAIN_INTERNAL_PORT=8080 # For internal print -MAPSERVER_URL=http://mapserver:8080/ +MAPSERVER_URL=http://mapserver:8080/mapserv_proxy TINYOWS_URL=http://tinyows:8080/ QGISSERVER_URL=http://qgisserver:8080/mapserv_proxy QGIS_VERSION=3.34-gdal3.8 diff --git a/geoportal/c2cgeoportal_geoportal/scaffolds/create/{{cookiecutter.project}}/geoportal/vars.yaml b/geoportal/c2cgeoportal_geoportal/scaffolds/create/{{cookiecutter.project}}/geoportal/vars.yaml index d6b2de1592..6eefd30f75 100644 --- a/geoportal/c2cgeoportal_geoportal/scaffolds/create/{{cookiecutter.project}}/geoportal/vars.yaml +++ b/geoportal/c2cgeoportal_geoportal/scaffolds/create/{{cookiecutter.project}}/geoportal/vars.yaml @@ -13,7 +13,7 @@ vars: # - vars.interfaces_config.default.constants.gmfVectorTilesOptions.tileGrid.origin srid: &srid {{cookiecutter.srid}} - main_ogc_server: source for image/png + main_ogc_server: MapServer alternate_projections: &alternate_projections - EPSG:4326 diff --git a/geoportal/c2cgeoportal_geoportal/scaffolds/create/{{cookiecutter.project}}/mapserver/mapserver.conf b/geoportal/c2cgeoportal_geoportal/scaffolds/create/{{cookiecutter.project}}/mapserver/mapserver.conf index 61302736ff..4ef61cb001 100644 --- a/geoportal/c2cgeoportal_geoportal/scaffolds/create/{{cookiecutter.project}}/mapserver/mapserver.conf +++ b/geoportal/c2cgeoportal_geoportal/scaffolds/create/{{cookiecutter.project}}/mapserver/mapserver.conf @@ -10,6 +10,7 @@ CONFIG # Map aliases # MAPS + MapServer_PNG "/etc/mapserver/mapserver.map" END END diff --git a/geoportal/c2cgeoportal_geoportal/scaffolds/create/{{cookiecutter.project}}/mapserver/mapserver.map.tmpl b/geoportal/c2cgeoportal_geoportal/scaffolds/create/{{cookiecutter.project}}/mapserver/mapserver.map.tmpl index 042270edc9..c632df76e8 100644 --- a/geoportal/c2cgeoportal_geoportal/scaffolds/create/{{cookiecutter.project}}/mapserver/mapserver.map.tmpl +++ b/geoportal/c2cgeoportal_geoportal/scaffolds/create/{{cookiecutter.project}}/mapserver/mapserver.map.tmpl @@ -68,7 +68,7 @@ MAP METADATA "wms_title" "changeme" "wms_abstract" "changeme" - "ows_onlineresource" "${VISIBLE_WEB_PROTOCOL}://${VISIBLE_WEB_HOST}${VISIBLE_ENTRY_POINT}mapserv_proxy?ogcserver=source%20for%20image%2Fpng" + "ows_onlineresource" "${VISIBLE_WEB_PROTOCOL}://${VISIBLE_WEB_HOST}${VISIBLE_ENTRY_POINT}mapserv_proxy?ogcserver=MapServer" "wms_srs" "EPSG:{{cookiecutter.srid}}" "wms_enable_request" "*" "wfs_enable_request" "!*" diff --git a/geoportal/c2cgeoportal_geoportal/scaffolds/update/{{cookiecutter.project}}/geoportal/CONST_vars.yaml b/geoportal/c2cgeoportal_geoportal/scaffolds/update/{{cookiecutter.project}}/geoportal/CONST_vars.yaml index 04ac052ca7..412393c7ae 100644 --- a/geoportal/c2cgeoportal_geoportal/scaffolds/update/{{cookiecutter.project}}/geoportal/CONST_vars.yaml +++ b/geoportal/c2cgeoportal_geoportal/scaffolds/update/{{cookiecutter.project}}/geoportal/CONST_vars.yaml @@ -2,7 +2,7 @@ vars: # The package name package: '{{cookiecutter.package}}' - main_ogc_server: source for image/png + main_ogc_server: MapServer srid: EPSG:-1 @@ -1206,7 +1206,7 @@ vars: - '{VISIBLE_WEB_PROTOCOL}://{VISIBLE_WEB_HOST}' # Checker configuration - checker_ogc_server: source for image/png + checker_ogc_server: MapServer checker: forward_host: False base_internal_url: http://localhost:8080 diff --git a/geoportal/c2cgeoportal_geoportal/scripts/create_demo_theme.py b/geoportal/c2cgeoportal_geoportal/scripts/create_demo_theme.py index 5ba752f3d9..74ab6f6847 100644 --- a/geoportal/c2cgeoportal_geoportal/scripts/create_demo_theme.py +++ b/geoportal/c2cgeoportal_geoportal/scripts/create_demo_theme.py @@ -55,12 +55,11 @@ def main() -> None: ) interfaces = session.query(Interface).all() - ogc_jpeg = session.query(OGCServer).filter(OGCServer.name == "source for image/jpeg").one() + ogc_jpeg = session.query(OGCServer).filter(OGCServer.name == "MapServer_JPEG").one() session.delete(ogc_jpeg) - ogc_server_mapserver = session.query(OGCServer).filter(OGCServer.name == "source for image/png").one() - ogc_server_mapserver.name = "mapserver" - ogc_server_mapserver.url = "config://mapserver/mapserv_proxy/mapserver?map=mapserver" + ogc_server_mapserver = session.query(OGCServer).filter(OGCServer.name == "MapServer").one() + ogc_server_mapserver.url = "config://mapserver/mapserv_proxy/MapServer?map=MapServer" layer_borders = LayerWMS("Borders", "borders") layer_borders.interfaces = interfaces