elpaso / qgis3-server-vagrant

qgis3 server vagrant
26 stars 7 forks source link

QGIS projects stored on Postgres provider #8

Open jgrocha opened 4 years ago

jgrocha commented 4 years ago

@elpaso If I install ServerSimpleFilter and issue a request, it will fail.

The URL used is: http://brgqgis.cm-braga.pt/cgi-bin/qgis_mapserv.fcgi?LAYERS=Concelho&FORMAT=application/openlayers&SRS=EPSG%3A3763&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&STYLES=&BBOX=-56570.5,192759.7,4021.8,223746.5&WIDTH=1009&HEIGHT=516&MAP=postgresql%3A%3Fservice%3Durbanismo%26sslmode%3Ddisable%26schema%3Dprocessos%26project%3Dteste_um

The MAP parameter is received properly. But the generated Javascript will have the MAP parameter decoded and it will not work.

 var wmsSource = new ol.source.ImageWMS({
            url: 'http://brgqgis.cm-braga.pt:80/cgi-bin/qgis_mapserv.fcgi?MAP=postgresql:?service=urbanismo&sslmode=disable&schema=processos&project=teste_um',
            params: {'LAYERS': 'Concelho'},
            serverType: 'qgis'
        });

Since the MAP parameter value is decoded, when OpenLayers tries to fetch it from the server, it will fail.

Debug output:

17:09:03 INFO Server[31433]: Request finished in 165 ms
17:09:04 INFO Server[31433]: ******************** New request ***************
17:09:04 INFO Server[31433]: Request URL: http://brgqgis.cm-braga.pt/cgi-bin/qgis_mapserv.fcgi?MAP=postgresql:?service=urbanismo&sslmode=disable&schema=processos&project=teste_um&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=Concelho&CRS=EPSG%3A4326&STYLES=&WIDTH=1511&HEIGHT=771&BBOX=207710.859375%2C-27336.4453125%2C208795.078125%2C-25212.3046875
17:09:04 INFO Server[31433]: Environment:
17:09:04 INFO Server[31433]: ------------------------------------------------
17:09:04 INFO Server[31433]: SERVER_NAME: brgqgis.cm-braga.pt
17:09:04 INFO Server[31433]: REQUEST_URI: /cgi-bin/qgis_mapserv.fcgi?MAP=postgresql:?service=urbanismo&sslmode=disable&schema=processos&project=teste_um&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=Concelho&CRS=EPSG%3A4326&STYLES=&WIDTH=1511&HEIGHT=771&BBOX=207710.859375%2C-27336.4453125%2C208795.078125%2C-25212.3046875
17:09:04 INFO Server[31433]: SCRIPT_NAME: /cgi-bin/qgis_mapserv.fcgi
17:09:04 INFO Server[31433]: REMOTE_ADDR: 192.168.2.105
17:09:04 INFO Server[31433]: SERVER_PORT: 80
17:09:04 INFO Server[31433]: QUERY_STRING: MAP=postgresql:?service=urbanismo&sslmode=disable&schema=processos&project=teste_um&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=Concelho&CRS=EPSG%3A4326&STYLES=&WIDTH=1511&HEIGHT=771&BBOX=207710.859375%2C-27336.4453125%2C208795.078125%2C-25212.3046875
17:09:04 INFO Server[31433]: REQUEST_METHOD: GET
17:09:04 INFO Server[31433]: HTTP_ACCEPT: image/webp,*/*
17:09:04 INFO Server[31433]: HTTP_USER_AGENT: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0
17:09:04 WARNING [31433]: formatString is: image/png
17:09:04 INFO Server[31433]: BBOX:207710.859375,-27336.4453125,208795.078125,-25212.3046875
17:09:04 INFO Server[31433]: CRS:EPSG:4326
17:09:04 INFO Server[31433]: FORMAT:image/png
17:09:04 INFO Server[31433]: HEIGHT:771
17:09:04 INFO Server[31433]: LAYERS:Concelho
17:09:04 INFO Server[31433]: MAP:postgresql:?service=urbanismo
17:09:04 INFO Server[31433]: PROJECT:teste_um
17:09:04 INFO Server[31433]: REQUEST:GetMap
17:09:04 INFO Server[31433]: SCHEMA:processos
17:09:04 INFO Server[31433]: SERVICE:WMS
17:09:04 INFO Server[31433]: SSLMODE:disable
17:09:04 INFO Server[31433]: STYLES:
17:09:04 INFO Server[31433]: TRANSPARENT:true
17:09:04 INFO Server[31433]: VERSION:1.3.0
17:09:04 INFO Server[31433]: WIDTH:1511
17:09:04 CRITICAL Server[31433]: Error when loading project file 'postgresql:?service=urbanismo': Unable to open postgresql:?service=urbanismo

The URI encoding for database stored projects is problematic. QGIS client is not able to handle it also.

What do you think? Should we keep this database encode syntax with & on it?

elpaso commented 4 years ago

I guess it needs to be encoded back here: https://github.com/elpaso/qgis3-server-vagrant/blob/master/resources/web/plugins/ServerSimpleBrowser/ServerSimpleBrowser.py#L52

What do you think? Should we keep this database encode syntax with & on it?

Honestly I don't care much, I don't think any professional will ever disclose such information inside an URI, the right way to select a project is using a rewrite module and set QGIS_PROJECT_FILE in the FCGI environment.

So that a path like http://mywms/urbanismo/proceso/teste_um/?SERVICE=.... will internally set QGIS_PROJECT_FILE to the right string.

Note that this will be the only supported way in WFS3 which does not admit any extra argument in the query string.