Skip to content

Commit

Permalink
Fix OGC API features
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner committed Nov 27, 2024
1 parent 99b39c1 commit 04186e3
Show file tree
Hide file tree
Showing 13 changed files with 82 additions and 46 deletions.
15 changes: 0 additions & 15 deletions ci/mapserver.conf

This file was deleted.

1 change: 0 additions & 1 deletion ci/test-app
Original file line number Diff line number Diff line change
Expand Up @@ -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/"

Expand Down
Original file line number Diff line number Diff line change
@@ -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'")
4 changes: 3 additions & 1 deletion commons/c2cgeoportal_commons/models/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 _"
),
}
},
)
Expand Down
16 changes: 0 additions & 16 deletions geoportal/c2cgeoportal_geoportal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -661,22 +661,6 @@ def handle(event: InvalidateCacheEvent) -> None:
pregenerator=C2CPregenerator(role=True),
request_method="POST",
)
# The two next views are used to serve the application on the URL /mapserv_proxy/<ogc server name>
# instead of /mapserv_proxy?ogcserver=<ogc server name>, required for QGIS server landing page
config.add_route(
"mapserverproxy_get_path",
"/mapserv_proxy/{ogcserver}/*path",
mapserverproxy=True,
pregenerator=C2CPregenerator(role=True),
request_method="GET",
)
config.add_route(
"mapserverproxy_post_path",
"/mapserv_proxy/{ogcserver}/*path",
mapserverproxy=True,
pregenerator=C2CPregenerator(role=True),
request_method="POST",
)
# OGC Api routes
config.add_route(
"mapserverproxy_ogcapi_mapserver",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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/'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ CONFIG
# Map aliases
#
MAPS
MapServer_PNG "/etc/mapserver/mapserver.map"
END

END
Original file line number Diff line number Diff line change
Expand Up @@ -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" "!*"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions geoportal/c2cgeoportal_geoportal/scripts/create_demo_theme.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions geoportal/c2cgeoportal_geoportal/views/mapserverproxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ def __init__(self, request: Request) -> None:

@view_config(route_name="mapserverproxy") # type: ignore
@view_config(route_name="mapserverproxy_post") # type: ignore
@view_config(route_name="mapserverproxy_get_path") # type: ignore
@view_config(route_name="mapserverproxy_post_path") # type: ignore
def proxy(self) -> Response:
if self.user is None and "authentication_required" in self.request.params:
_LOG.debug("proxy() detected authentication_required")
Expand Down Expand Up @@ -186,8 +184,6 @@ def proxy_ogcapi(self, subpath: str) -> Response:
_url = self._get_wfs_url(errors)
if _url is not None:
_url.path = "/".join([_url.path.rstrip("/"), subpath, *self.request.matchdict["path"]])
_LOG.warning("URL: %s", _url)
_LOG.warning(self.request.matchdict)

if _url is None:
_LOG.error("Error getting the URL:\n%s", "\n".join(errors))
Expand Down

0 comments on commit 04186e3

Please sign in to comment.