[mapserver-users] URL encoding for map file classexpressions
Armin Burger
armin.burger at territoriumonline.com
Wed Oct 31 11:08:50 PST 2001
Andrew,
I did probably not describe exactly what I wanted to do, sorry. I would like
to use the CGI version of mapserver and change map file parameters, like
FILTER/EXPRESSION for queries, 'on-the-fly' using javascript to create the
new URL and get back the query results this way. I assume that these kind of
things are in principal better done via PHP or Perl, but first I will try it
with the cgi version. For that I would need to know how to code the map file
parameters for CLASS - EXPRESSION in the URL.
Thanks
Armin
> Armin,
> I think that I understand your question. Pardon me if this is not what
you
> were asking:
> The way that I got around this is to use URL friendly characters and then
> use the PHP function explode(). Following is a snippet of code (pardon
the
> poor coding):
> if ($addto)
> {
> if ($expr)
> {
> $routeid = $routeid . "_" . $expr;
> }
> }
> $epr = explode("_", $routeid);
> for($i = "0"; $i < sizeof($epr); $i++)
> {
> if ($i == 0 )
> {
> $newexpr = "(";
> }
> $newexpr = str_replace ("))", ") or ", $newexpr);
> $newexpr = $newexpr . "([ID] eq " . $epr[$i] . ")";
> if ($i == sizeof($epr));
> {
> $newexpr = $newexpr . ")";
> }
> }
> echo ("<input type=\"hidden\" name=\"expr\" value=" . $routeid . ">\n");
> $oLayer = $map->GetLayerbyName("allbuiltQ");
> $FirstClass = $oLayer->GetClass(0);
> $FirstClass->setExpression($newexpr);
> $oLayer->set("status", 1);
> The first part of the code checks to see if the user wants to add to the
> selection and the $routeid is the value from the attribute table for the
> feature clicked. Then it explodes the $epr which is the class expression
> and loops through the resulting array to build the expression string.
Then
> I set a hidden form variable to be the new expression value so it will be
> returned on the next form submit and set the class expression. It works
> really well and seems to be quite fast.
> I hope this helps. Let me know if you have questions.
> Andrew
> Andrew Wooley
> GIS Operations Manager
> Mountainland Association of Governments
> Orem, UT
> phone: 801.229.3844
> fax: 801.229.3801
> email: awooley at mountainland.org
> web: www.maps.mountainland.org
>>>> Armin Burger <armin.burger at territoriumonline.com> 10/31/01 08:47AM >>>
> Hi all,
> I would like to do a query on a layer with a combination of FILTER and
> EXPRESSION using the query definition via the URL. If I want to query more
> than one expression, how would I encode these expressions in the URL?
> For example:
> I have the URL part for the LAYER - FILTER tag for the layer 'landcoverq'
> &map_landcoverq_filter=%22313%22
> searching for the number 313 in the field defined with FILTERITEM in the
> mapfile.
> and I would like to have the corresponding URL encoding for the EXPRESSION
> tag of the class section
> EXPRESSION ('[LANCOV_CD]'='215/1' or '[LANCOV_CD]'='215/2' or
> '[LANCOV_CD]'='220' )
> Adding all the expressions one by one in the URL with
> &map_landcoverq_class_expression=%22215/1%22...
> selects always only the last one.
> I think it should be possible but don't how to achieve it. Thanks for any
> help.
> Has anyone experiences how queries like that are facilitated using the
> functionality of PostGIS?
> Armin
> --
> Armin Burger
> Territorium Online
> Via Siemens 19 - 39100 Bolzano - Italy
> _
More information about the MapServer-users
mailing list