understanding runtime substitution usage

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

understanding runtime substitution usage

umbertofilippo
Good day list!

I am trying to do a runtime substitution to pass a parameter from a form to my mapfile, but cannot geti t to work.

Let's say I have a mapfile which looks like (only relevant part):

        LAYER
          NAME zone
          ...
          FILTER ('[vitigni]' = '%vitigni%')
              END

I have a form in my HTML with a dropdown list where some values are listed.
I'd like to pick the value selected by the user and pass it to my FILTER, in place of the %vitigni%.

I tried with the below form.

                <form name="mapserv" method="GET" action="http://localhost/cgi-bin/mapserver/mapserv.exe?">
                <input type="hidden" name="map" value="//nbgis01/mapserver/umbe/mapfile/test10_runtimesubstitution.map">
                <select name="[vitigni]">
                        <option value="Chardonnay, Pinot nero, Pinot bianco">Chardonnay, Pinot nero, Pinot bianco</option>
                        <option value="Marzemino, Barbera, Schiava gentile, Cabernet">Marzemino, Barbera, Schiava gentile, Cabernet</option>
                        <option value="Trebbiano di Soave">Trebbiano di Soave</option>
                        <option value="Groppello, Marzemino, Barbera, Sangiovese.">Groppello, Marzemino, Barbera, Sangiovese.</option>
                    </select>
                <br><br>
                <input type="submit" value="Click Me">
                </form>

Only thing I receive is: http://localhost/cgi-bin/mapserver/mapserv.exe?map=%2F%2Fnbgis01%2Fmapserver%2Fumbe%2Fmapfile%2Ftest10_runtimesubstitution.map&%5Bvitigni%5D=Chardonnay%2C+Pinot+nero%2C+Pinot+bianco
I know this is not the right way the request should be created.
If I manually replace %vitigni% with one of the values provided in the form modifying the mapfile, everything works, proving the mapfile is correct (es. FILTER ('[vitigni]' = ' Chardonnay, Pinot nero, Pinot bianco ')).

Any suggestion would be very appreciated! Thanks

_______________________________________________
mapserver-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-users
Reply | Threaded
Open this post in threaded view
|

Re: understanding runtime substitution usage

Jörg Thomsen (WhereGroup)
Hi,

does it work without the brackets in your form?
<select name="vitigni">

because your URL is
http://localhost/cgi-bin/mapserver/mapserv.exe?map=//nbgis01/mapserver/umbe/mapfile/test10_runtimesubstitution.map&[vitigni]=Chardonnay...

and should be
http://localhost/cgi-bin/mapserver/mapserv.exe?map=//nbgis01/mapserver/umbe/mapfile/test10_runtimesubstitution.map&vitigni=Chardonnay...

Jörg

Am 28.11.2017 um 14:38 schrieb [hidden email]:

> Good day list!
>
> I am trying to do a runtime substitution to pass a parameter from a form to my mapfile, but cannot geti t to work.
>
> Let's say I have a mapfile which looks like (only relevant part):
>
> LAYER
>  NAME zone
>  ...
>  FILTER ('[vitigni]' = '%vitigni%')
>               END
>
> I have a form in my HTML with a dropdown list where some values are listed.
> I'd like to pick the value selected by the user and pass it to my FILTER, in place of the %vitigni%.
>
> I tried with the below form.
>
>                 <form name="mapserv" method="GET" action="http://localhost/cgi-bin/mapserver/mapserv.exe?">
> <input type="hidden" name="map" value="//nbgis01/mapserver/umbe/mapfile/test10_runtimesubstitution.map">
> <select name="[vitigni]">
>                         <option value="Chardonnay, Pinot nero, Pinot bianco">Chardonnay, Pinot nero, Pinot bianco</option>
>                         <option value="Marzemino, Barbera, Schiava gentile, Cabernet">Marzemino, Barbera, Schiava gentile, Cabernet</option>
>                         <option value="Trebbiano di Soave">Trebbiano di Soave</option>
>                         <option value="Groppello, Marzemino, Barbera, Sangiovese.">Groppello, Marzemino, Barbera, Sangiovese.</option>
>                     </select>
> <br><br>
> <input type="submit" value="Click Me">
>                 </form>
>
> Only thing I receive is: http://localhost/cgi-bin/mapserver/mapserv.exe?map=%2F%2Fnbgis01%2Fmapserver%2Fumbe%2Fmapfile%2Ftest10_runtimesubstitution.map&%5Bvitigni%5D=Chardonnay%2C+Pinot+nero%2C+Pinot+bianco
> I know this is not the right way the request should be created.
> If I manually replace %vitigni% with one of the values provided in the form modifying the mapfile, everything works, proving the mapfile is correct (es. FILTER ('[vitigni]' = ' Chardonnay, Pinot nero, Pinot bianco ')).
>
> Any suggestion would be very appreciated! Thanks
>
> _______________________________________________
> mapserver-users mailing list
> [hidden email]
> https://lists.osgeo.org/mailman/listinfo/mapserver-users
>


Viele Grüße,
Jörg Thomsen

--

***********************************
Where2B Konferenz 2017
14. Dezember 2017 in Bonn
www.where2b-conference.com
***********************************

Jörg Thomsen
WhereGroup GmbH & Co. KG
Gillweg 3
14193 Berlin
Germany

Fon: +49 (0)30 / 5130 278 74
Fax: +49 (0)30 / 89 09 53 21

[hidden email]
www.wheregroup.com
Amtsgericht Bonn, HRA 6788
-------------------------------
Komplementärin:
WhereGroup Verwaltungs GmbH
vertreten durch:
Olaf Knopp, Peter Stamm
-------------------------------
Folgen Sie der WhereGroup auf twitter: http://twitter.com/WhereGroup_com
_______________________________________________
mapserver-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-users
Reply | Threaded
Open this post in threaded view
|

R: understanding runtime substitution usage

umbertofilippo
In reply to this post by umbertofilippo
I tried that but that did not do the trick.
I removed it from the HTML, but I keep it in the mapfile (as if I remove it
it does not work anymore).

So, what I am trying to do is showing my WMS filtered with the value
specified in the form.

From what I've read in the docs
(http://www.mapserver.org/cgi/runsub.html#filters), VALIDATION is also
mandatory from version 6 onward, so I've included it.
I simplified my testcase to this:

mapfile

        LAYER
          NAME zone
          ...
          FILTER ('[vitigni]' = '%vitigni%')
          VALIDATION
            "vitigni" "^[a-zA-Z\-]+$"
          END
              END

Form

                <form name="mapserv" method="GET"
action="http://localhost/cgi-bin/mapserver/mapserv.exe?">
                <input type="hidden" name="map"
value="//nbgis01/mapserver/umbe/mapfile/test10_runtimesubstitution.map">
                <select name="vitigni">
                        <option value="Groppello"> Groppello
</option>
                    </select>
                <br><br>
                <input type="submit" value="Click Me">
                </form>

When I click "Click Me" I receive:
        mapserv(): Web application error. Traditional BROWSE mode requires a
TEMPLATE in the WEB section, but none was provided.

And the URL looks like (obviously wrong):
       
http://localhost/cgi-bin/mapserver/mapserv.exe?map=%2F%2Fnbgis01%2Fmapserver
%2Fumbe%2Fmapfile%2Ftest10_runtimesubstitution.map&vitigni=Groppello

-----Messaggio originale-----
Da: [hidden email] [mailto:[hidden email]] Per conto
di Trond Michelsen
Inviato: martedì 28 novembre 2017 15:04
A: Mapserver <[hidden email]>
Cc: [hidden email]
Oggetto: Re: [mapserver-users] understanding runtime substitution usage

Try to remove the brackets from the parameter name

<select name="[vitigni]">

should be

<select name="vitigni">

--
Trond Michelsen

On Tue, Nov 28, 2017 at 02:38:36PM +0100, [hidden email] wrote:
> Good day list!
>
> I am trying to do a runtime substitution to pass a parameter from a form
to my mapfile, but cannot geti t to work.

>
> Let's say I have a mapfile which looks like (only relevant part):
>
> LAYER
>  NAME zone
>  ...
>  FILTER ('[vitigni]' = '%vitigni%')
>               END
>
> I have a form in my HTML with a dropdown list where some values are
listed.
> I'd like to pick the value selected by the user and pass it to my FILTER,
in place of the %vitigni%.
>
> I tried with the below form.
>
>                 <form name="mapserv" method="GET"
action="http://localhost/cgi-bin/mapserver/mapserv.exe?">
> <input type="hidden" name="map"
value="//nbgis01/mapserver/umbe/mapfile/test10_runtimesubstitution.map">
> <select name="[vitigni]">
>                         <option value="Chardonnay, Pinot
nero, Pinot bianco">Chardonnay, Pinot nero, Pinot bianco</option>
>                         <option value="Marzemino, Barbera,
Schiava gentile, Cabernet">Marzemino, Barbera, Schiava gentile,
Cabernet</option>
>                         <option value="Trebbiano di
Soave">Trebbiano di Soave</option>
>                         <option value="Groppello, Marzemino,
Barbera, Sangiovese.">Groppello, Marzemino, Barbera, Sangiovese.</option>
>                     </select>
> <br><br>
> <input type="submit" value="Click Me">
>                 </form>
>
> Only thing I receive is:
http://localhost/cgi-bin/mapserver/mapserv.exe?map=%2F%2Fnbgis01%2Fmapserver
%2Fumbe%2Fmapfile%2Ftest10_runtimesubstitution.map&%5Bvitigni%5D=Chardonnay%
2C+Pinot+nero%2C+Pinot+bianco
> I know this is not the right way the request should be created.
> If I manually replace %vitigni% with one of the values provided in the
form modifying the mapfile, everything works, proving the mapfile is correct
(es. FILTER ('[vitigni]' = ' Chardonnay, Pinot nero, Pinot bianco ')).
>
> Any suggestion would be very appreciated! Thanks
>
> _______________________________________________
> mapserver-users mailing list
> [hidden email]
> https://lists.osgeo.org/mailman/listinfo/mapserver-users

_______________________________________________
mapserver-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-users
Reply | Threaded
Open this post in threaded view
|

Re: R: understanding runtime substitution usage

Lime, Steve D (MNIT)
The error you're getting is because no mode is set. That's the output from the form supposed to be? If it's just the resulting map then add a hidden variable called mode with a value of map. The filter and validation look ok to me. --Steve

-----Original Message-----
From: mapserver-users [mailto:[hidden email]] On Behalf Of [hidden email]
Sent: Tuesday, November 28, 2017 8:24 AM
To: 'Trond Michelsen' <[hidden email]>; 'Mapserver' <[hidden email]>
Subject: [mapserver-users] R: understanding runtime substitution usage

I tried that but that did not do the trick.
I removed it from the HTML, but I keep it in the mapfile (as if I remove it
it does not work anymore).

So, what I am trying to do is showing my WMS filtered with the value
specified in the form.

From what I've read in the docs
(http://www.mapserver.org/cgi/runsub.html#filters), VALIDATION is also
mandatory from version 6 onward, so I've included it.
I simplified my testcase to this:

mapfile

        LAYER
          NAME zone
          ...
          FILTER ('[vitigni]' = '%vitigni%')
          VALIDATION
            "vitigni" "^[a-zA-Z\-]+$"
          END
              END

Form

                <form name="mapserv" method="GET"
action="http://localhost/cgi-bin/mapserver/mapserv.exe?">
                <input type="hidden" name="map"
value="//nbgis01/mapserver/umbe/mapfile/test10_runtimesubstitution.map">
                <select name="vitigni">
                        <option value="Groppello"> Groppello
</option>
                    </select>
                <br><br>
                <input type="submit" value="Click Me">
                </form>

When I click "Click Me" I receive:
        mapserv(): Web application error. Traditional BROWSE mode requires a
TEMPLATE in the WEB section, but none was provided.

And the URL looks like (obviously wrong):
       
http://localhost/cgi-bin/mapserver/mapserv.exe?map=%2F%2Fnbgis01%2Fmapserver
%2Fumbe%2Fmapfile%2Ftest10_runtimesubstitution.map&vitigni=Groppello

-----Messaggio originale-----
Da: [hidden email] [mailto:[hidden email]] Per conto
di Trond Michelsen
Inviato: martedì 28 novembre 2017 15:04
A: Mapserver <[hidden email]>
Cc: [hidden email]
Oggetto: Re: [mapserver-users] understanding runtime substitution usage

Try to remove the brackets from the parameter name

<select name="[vitigni]">

should be

<select name="vitigni">

--
Trond Michelsen

On Tue, Nov 28, 2017 at 02:38:36PM +0100, [hidden email] wrote:
> Good day list!
>
> I am trying to do a runtime substitution to pass a parameter from a form
to my mapfile, but cannot geti t to work.

>
> Let's say I have a mapfile which looks like (only relevant part):
>
> LAYER
>  NAME zone
>  ...
>  FILTER ('[vitigni]' = '%vitigni%')
>               END
>
> I have a form in my HTML with a dropdown list where some values are
listed.
> I'd like to pick the value selected by the user and pass it to my FILTER,
in place of the %vitigni%.
>
> I tried with the below form.
>
>                 <form name="mapserv" method="GET"
action="http://localhost/cgi-bin/mapserver/mapserv.exe?">
> <input type="hidden" name="map"
value="//nbgis01/mapserver/umbe/mapfile/test10_runtimesubstitution.map">
> <select name="[vitigni]">
>                         <option value="Chardonnay, Pinot
nero, Pinot bianco">Chardonnay, Pinot nero, Pinot bianco</option>
>                         <option value="Marzemino, Barbera,
Schiava gentile, Cabernet">Marzemino, Barbera, Schiava gentile,
Cabernet</option>
>                         <option value="Trebbiano di
Soave">Trebbiano di Soave</option>
>                         <option value="Groppello, Marzemino,
Barbera, Sangiovese.">Groppello, Marzemino, Barbera, Sangiovese.</option>
>                     </select>
> <br><br>
> <input type="submit" value="Click Me">
>                 </form>
>
> Only thing I receive is:
http://localhost/cgi-bin/mapserver/mapserv.exe?map=%2F%2Fnbgis01%2Fmapserver
%2Fumbe%2Fmapfile%2Ftest10_runtimesubstitution.map&%5Bvitigni%5D=Chardonnay%
2C+Pinot+nero%2C+Pinot+bianco
> I know this is not the right way the request should be created.
> If I manually replace %vitigni% with one of the values provided in the
form modifying the mapfile, everything works, proving the mapfile is correct
(es. FILTER ('[vitigni]' = ' Chardonnay, Pinot nero, Pinot bianco ')).
>
> Any suggestion would be very appreciated! Thanks
>
> _______________________________________________
> mapserver-users mailing list
> [hidden email]
> https://lists.osgeo.org/mailman/listinfo/mapserver-users

_______________________________________________
mapserver-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-users
_______________________________________________
mapserver-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-users
Reply | Threaded
Open this post in threaded view
|

Re: R: understanding runtime substitution usage

umbertofilippo
Hi.


The output of the form is supposed to be a value to pass to a filter
specified in my mapfile.

Actually, I think I am close to the solution, but I also think I
misunderstood the way I am supposed to do what I need.

Basically, the output of the form should replace the value '%vitigni%'
in the string:

     FILTER ('[vitigni]' = '%vitigni%') # MAPFILE

I also forgot to mention I am doing everything with openlayers, so I
think I should use ol API rather than ms templating.

Am I on the right track?

Actually, by my last tests I got something positive by specifying the
'params' option using ol's " ol.source.ImageWMS"
(http://openlayers.org/en/latest/apidoc/ol.source.ImageWMS.html).

The thing I need I guess is to get user choice from the form and pass it
in the filter updating the 'params' option (using the "updateParams()"
method?, see
http://openlayers.org/en/latest/apidoc/ol.source.ImageWMS.html#updateParams).

Do you think this is correct?

Sorry for messing up a bit but it's really new stuff for me...


On 28/11/2017 21:30, Lime, Steve D (MNIT) wrote:

> The error you're getting is because no mode is set. That's the output from the form supposed to be? If it's just the resulting map then add a hidden variable called mode with a value of map. The filter and validation look ok to me. --Steve
>
> -----Original Message-----
> From: mapserver-users [mailto:[hidden email]] On Behalf Of [hidden email]
> Sent: Tuesday, November 28, 2017 8:24 AM
> To: 'Trond Michelsen' <[hidden email]>; 'Mapserver' <[hidden email]>
> Subject: [mapserver-users] R: understanding runtime substitution usage
>
> I tried that but that did not do the trick.
> I removed it from the HTML, but I keep it in the mapfile (as if I remove it
> it does not work anymore).
>
> So, what I am trying to do is showing my WMS filtered with the value
> specified in the form.
>
>  From what I've read in the docs
> (http://www.mapserver.org/cgi/runsub.html#filters), VALIDATION is also
> mandatory from version 6 onward, so I've included it.
> I simplified my testcase to this:
>
> mapfile
>
> LAYER
>  NAME zone
>  ...
>  FILTER ('[vitigni]' = '%vitigni%')
>  VALIDATION
>    "vitigni" "^[a-zA-Z\-]+$"
>  END
>                END
>
> Form
>
>                  <form name="mapserv" method="GET"
> action="http://localhost/cgi-bin/mapserver/mapserv.exe?">
> <input type="hidden" name="map"
> value="//nbgis01/mapserver/umbe/mapfile/test10_runtimesubstitution.map">
> <select name="vitigni">
>                           <option value="Groppello"> Groppello
> </option>
>                       </select>
> <br><br>
> <input type="submit" value="Click Me">
>                  </form>
>
> When I click "Click Me" I receive:
> mapserv(): Web application error. Traditional BROWSE mode requires a
> TEMPLATE in the WEB section, but none was provided.
>
> And the URL looks like (obviously wrong):
>
> http://localhost/cgi-bin/mapserver/mapserv.exe?map=%2F%2Fnbgis01%2Fmapserver
> %2Fumbe%2Fmapfile%2Ftest10_runtimesubstitution.map&vitigni=Groppello
>
> -----Messaggio originale-----
> Da: [hidden email] [mailto:[hidden email]] Per conto
> di Trond Michelsen
> Inviato: martedì 28 novembre 2017 15:04
> A: Mapserver <[hidden email]>
> Cc: [hidden email]
> Oggetto: Re: [mapserver-users] understanding runtime substitution usage
>
> Try to remove the brackets from the parameter name
>
> <select name="[vitigni]">
>
> should be
>
> <select name="vitigni">
>

_______________________________________________
mapserver-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-users