[mapserver-users] runtime CONNECTION string partial substitution

Rahkonen Jukka (MML) jukka.rahkonen at maanmittauslaitos.fi
Mon May 16 04:24:30 PDT 2016


Hi,

I made a test with your VALIDATION and CONNECTION and changing  db on-the-fly works. How did you test?  If you use some WMS client for testing it is good to remember that variable substitution does not have an effect on the GetCapabilities document so that the GetMap URL would be updated automatically. Therefore WMS clients like QGIS or OpenJUMP will drop the &db= parameter from the GetMaps if you do not tell them not to trust the advertised GetMap URL.

According to documentation http://mapserver.org/cgi/runsub.html  it should also be possible to use variable substitution also in MAP- WEB: METADATA. I tried
to use
"wms_onlineresource" “http://localhost:8060/cgi-bin/mapserv.exe?map=c:\ms4w\apps\wms-wfs.map&%db%<http://localhost:8060/cgi-bin/mapserv.exe?map=c:\ms4w\apps\wms-wfs.map&%db%25>”

but GetCapabilities response contains the variable %db% literally
<OnlineResource xlink:href="http://localhost:8060/cgi-bin/mapserv.exe?map=c:\ms4w\apps\wms-wfs.map&%db%&"/>

It seems that for getting a proper error message when &db= is missing or it is wrong a WMS GetMap request is required. WFS GetFeature triggers the error
and is easier to write by hand, for example:
http://localhost:8060/cgi-bin/mapserv.exe?map=c:/ms4w/apps/wms-wfs.map&service=wfs&version=2.0.0&request=getfeature&typename=states&db=foo
sends an error
<ows:ExceptionText>
msOGRFileOpen(): OGR error. Open failed for OGR connection in layer `states'.  File not found or unsupported format.
</ows:ExceptionText>

Document http://www.mapserver.org/optimization/debugging.html contains good advice for debugging.

-Jukka Rahkonen-


G. Allegri wrote:


Hello,
I'm trying to define a layer where the Sqlite DB connection should be set dynamically through runtime sustitution.

e.g.

LAYER
    NAME mylayer
    TYPE POINT
    CONNECTIONTYPE OGR
    VALIDATION
        "db" "[a-z]+"
    END
    CONNECTION "/var/www/dbs/%db%.sqlite"
    DATA "mytable"
END

The point layers works fine if  %db% is set statically but if I try to define it through get query values nothing is returned:

http://localhost/cgi-bin/mapserv?map=mymapfile.map&db=mydb

The documentation says that runtime sustitution should work for CONNECTION param too. What am I doing wrong?

Thanks,
Giovanni

--
Giovanni Allegri
http://about.me/giovanniallegri
Gis3W - http://gis3w.it
Ikare - http://ikare.it
Twitter: https://twitter.com/_giohappy_
blog: http://blog.spaziogis.it
GEO+ geomatica in Italia http://bit.ly/GEOplus
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20160516/61afb25f/attachment-0001.html>


More information about the mapserver-users mailing list