mapscript generic variable substitution syntax

rich.fromm nospam420 at YAHOO.COM
Mon Jan 7 17:41:22 EST 2008


I have a map file that I am reading in via Java mapscript:

         map = new mapObj(mapfile);

What I do is read the somewhat generic map file in, then substitute some
variables based on the particular request.

I'm trying to figure out what is the proper way to specify the variables in
the map file in this instance.

The following describes using [SquareBrackets] for HTML templates for CGI
Mapserver:
http://mapserver.gis.umn.edu/docs/reference/templatereference/templatereference

The following describes using %PercentageSigs% for run time substitution,
again for CGI Mapserver:
http://mapserver.gis.umn.edu/docs/howto/runsub

Neither of these precisely pertain to my situation, since I'm using
Mapscript.  

The latter URL says:
  Within MapScript this is easy to do since the developer has complete
control over how input is handled.

But that's not entirely the case, since I want some input from map files and
some to be programmatic.  I tried a few things.

For variable substitutions of numeric values, neither forms like %var% nor
[var] works.  For instance, here are pairs of input lines from my map file
and
the corresponding output error messages:

    EXTENT		%minx% %miny% %maxx% %maxy%
[Mon Jan  7 13:00:21 2008].149387 getDouble(): Symbol definition error.
Parsing error near (%):(line 34)

    SIZE  		%width% %height%
[Mon Jan  7 13:01:08 2008].196475 getInteger(): Symbol definition error.
Parsing error near (%):(line 45)

    EXTENT		[minx] [miny] [maxx] [maxy]
[Mon Jan  7 13:01:59 2008].337825 getDouble(): Symbol definition error.
Parsing error near (minx] [miny] [maxx] [maxy):(line 34)

    SIZE  		[width] [height]
[Mon Jan  7 13:03:24 2008].715273 getInteger(): Symbol definition error.
Parsing error near (width] [height):(line 47)

A workaround here is to just specify some bogus values, and then directly
set
the keys I want to the values I want in the mapscript code:

    EXTENT  	-180 -90 180 90
    SIZE		   1 1

For variable substitutions within numeric strings, I can get it to work with
something like the following:

        FILTER		"the_geom && 'SRID=4326;LINESTRING(%minx% %miny%, %maxx%
%maxy%)' AND feat_cod=2000123"

I do end up getting the following error:

[Mon Jan  7 13:15:35 2008].866125 getSymbol(): Symbol definition error.
Parsing error near (the_geom && 'SRID=4326;LINESTRING(-122.3019062479681
37.83351284250283, -122.28009375203187 37.84648658222045)' AND
feat_cod=2000123):(line 39)

But I get that even if I don't use variable substitution here and specify
the
values directly, so I think it's probably a separate issue.  But it doesn't
seem to affect the output, so I think it's a false error msg and I'm not
worrying too much about it, although I would be happier if it went away.

I searched the mailing list a bit trying to find an answer, but most of what
I
found pertains to using mapserver via CGI, not mapscript.

Thanks for any advice that anyone might have.

-- 
View this message in context: http://www.nabble.com/mapscript-generic-variable-substitution-syntax-tp14677879p14677879.html
Sent from the Mapserver - User mailing list archive at Nabble.com.



More information about the mapserver-users mailing list