[mapserver-users] runtime CONNECTION string partial substitution

G. Allegri giohappy at gmail.com
Mon May 16 05:38:59 PDT 2016


First of all thanks Jukka. I haven't tested it yet but I'm quite sure the
problem was the online resource url.

I agree with Jukka, the original regex should accept only lowercase
alphanumeric characters and nothing else. I will do some tests...

giovanni
Il 16/mag/2016 2:30 PM, "thomas bonfort" <thomas.bonfort at gmail.com> ha
scritto:

> Not sure I get it. Your regex requires a letter or a dash , and one of
> them is present, no?
> On May 16, 2016 2:28 PM, "Rahkonen Jukka (MML)" <
> jukka.rahkonen at maanmittauslaitos.fi> wrote:
>
>> Hi Thomas,
>>
>>
>>
>> I was testing with http://www.regexr.com/ and it does not agree totally:
>>
>>
>>
>> “wms-wfs” contains a dash and the test utility requires “[a-z-]+”
>>
>> WMS-WFS has capital letters and dash and test utility requires “[A-Z-]+”
>>
>>
>>
>> -Jukka-
>>
>>
>>
>>
>>
>> *Lähettäjä:* thomas bonfort [mailto:thomas.bonfort at gmail.com]
>> *Lähetetty:* 16. toukokuuta 2016 15:11
>> *Vastaanottaja:* Rahkonen Jukka (MML)
>> *Kopio:* MapserverList OSGEO; G. Allegri
>> *Aihe:* Re: [mapserver-users] runtime CONNECTION string partial
>> substitution
>>
>>
>>
>>
>> On May 16, 2016 2:02 PM, "Rahkonen Jukka (MML)" <
>> jukka.rahkonen at maanmittauslaitos.fi> wrote:
>> >
>> > Correction:
>> >
>> >
>> >
>> > Changing the WMS online resource does work if the mapfile is written
>> correctly. I had to add VALIDATION also into MAP->WEB
>> >
>> >
>> >
>> > WEB
>> >
>> >     METADATA
>> >
>> > "wms_onlineresource" "http://localhost:8060/cgi-bin/mapserv.exe?map=c
>> :\ms4w\apps\wms-wfs.map&db=%db%"
>> >
>> >     END #metadata
>> >
>> >      VALIDATION
>> >
>> >              "db" "[a-z]+"
>> >
>> >     END #validation
>> >
>> > END #WEB
>> >
>> >
>> >
>> > Now I can send
>> >
>> http://localhost:8060/cgi-bin/mapserv.exe?map=c:/ms4w/apps/wms-wfs.map&service=wms&version=1.3.0&request=getcapabilities&db=wms-wfs
>> >
>> >
>> >
>> > and get
>> > <OnlineResource xlink:href="
>> http://localhost:8060/cgi-bin/mapserv.exe?map=c
>> :\ms4w\apps\wms-wfs.map&db=wms-wfs&"/>
>> >
>> >
>> >
>> > What is interesting is that the validation rule “[a-z]+” should not
>> accept the name of my db “wms-wfs” but it does. Capital letters are
>> accepted as well “WMS-WFS”. Because I am on Windows I can even get data
>> with WMS-WFS though the name of the db is “wms-wfs.sqlite”.
>> >
>> That's because [a-z]+ means "there should be at least one alphabetic
>> character in the passed expression". The " correct" regex to use would be
>> ^[a-z]+$
>>
>> Thomas
>> >
>> >
>> > -Jukka Rahkonen-
>> >
>> >
>> >
>> >
>> >
>> > Lähettäjä: Rahkonen Jukka (MML)
>> > Lähetetty: 16. toukokuuta 2016 14:24
>> > Vastaanottaja: 'G. Allegri'; mapserver-users at lists.osgeo.org
>> > Aihe: Re: [mapserver-users] runtime CONNECTION string partial
>> substitution
>> >
>> >
>> >
>> > 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%”
>> >
>> >
>> >
>> > 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
>> >
>> >
>> > _______________________________________________
>> > mapserver-users mailing list
>> > mapserver-users at lists.osgeo.org
>> > http://lists.osgeo.org/mailman/listinfo/mapserver-users
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20160516/7176b991/attachment-0001.html>


More information about the mapserver-users mailing list