[mapserver-users] Problem with Variable Substitution for EXPRESSION

Lime, Steve D (DNR) Steve.Lime at state.mn.us
Wed Nov 16 10:40:08 EST 2011


Well, that’s not good is it. Hmmm… I ran a quick test here using this mapfile:

MAP
  NAME 'test'
  SIZE 450 600
  EXTENT 125000 4785000 788000 5489000

  IMAGETYPE PNG8

  LAYER
    VALIDATION
      'area' '^[-+]?[0-9]*\.?[0-9]+$'
    END
    NAME 'county'
    STATUS DEFAULT
    TYPE POLYGON
    DATA ' bdry_counpy2'
    CLASS
      EXPRESSION ([area] > %area%)
      STYLE COLOR 212 212 212 OUTLINECOLOR 0 0 0 END
    END
  END
END

This is against 6.0 latest trunk although I don’t think there have been any changes in that area…

I can run something like:

mapserv -nh "QUERY_STRING=map=test.map&mode=map&area=500000000" > test.png

If ‘area’ parameter is provided as a non-double then the substitution isn’t done. I believe the substitution validation errors fail silently. This example works, how different is what you’re doing?

Steve

From: Prabu Raja [mailto:prab.raja at gmail.com]
Sent: Wednesday, November 16, 2011 5:16 AM
To: Lime, Steve D (DNR)
Cc: mapserver-users at lists.osgeo.org
Subject: Re: [mapserver-users] Problem with Variable Substitution for EXPRESSION

Thanks Steve.

Tried the following regular expression

"[-+]?[0-9]*\.?[0-9]+".

For which the internal server error is coming from Apache. No error logged in mapserver log.
"Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request."



On Tue, Nov 15, 2011 at 8:37 PM, Lime, Steve D (DNR) <Steve.Lime at state.mn.us<mailto:Steve.Lime at state.mn.us>> wrote:
See http://www.regular-expressions.info/floatingpoint.html for some good examples.

Steve

From: mapserver-users-bounces at lists.osgeo.org<mailto:mapserver-users-bounces at lists.osgeo.org> [mailto:mapserver-users-bounces at lists.osgeo.org<mailto:mapserver-users-bounces at lists.osgeo.org>] On Behalf Of Prabu Raja
Sent: Tuesday, November 15, 2011 4:29 AM
To: mapserver-users at lists.osgeo.org<mailto:mapserver-users at lists.osgeo.org>
Subject: [mapserver-users] Problem with Variable Substitution for EXPRESSION

Hi,

I need to compare one attribute from database table in "EXPRESSION" (under "LAYER") with six different values passed as Variable Substitution  for coloring the layer.

I did added validation for those variables in the map file, but for some reason I am getting the below error.

msValidateParameter(): Regular expression error. Parameter pattern validation failed.
msEvalRegex(): Regular expression error. String failed expression test.
msValidateParameter(): Regular expression error. Parameter pattern validation failed.

Could anyone help me with where I am wrong? Below is the map file content for this layer.

All the six variables would be numbers (may be a decimal number), Is my regular expression correct?

WEB
   VALIDATION
      value_one     "^[\d+(\.\d)]*$"
      value_two     "^[\d+(\.\d)]*$"
      value_three   "[^\d+(\.\d)]*$"
      value_four    "[^\d+(\.\d)]*$"
      value_five    "[^\d+(\.\d)]*$"
      value_six     "[^\d+(\.\d)]*$"
   END
END

LAYER
   NAME "state"
   TYPE polygon
   STATUS ON
   CONNECTIONTYPE POSTGIS
   CONNECTION  "user=postgres password=****** dbname=shpdb host=localhost port=5432"
   DATA "the_geom FROM  (SELECT gid, the_geom, totpop1 FROM state_shape) AS SUBQUERY using unique gid"
   PROCESSING "CLOSE_CONNECTION=DEFER"
   CLASSITEM "totpop1"
   OPACITY 100
   CLASS
 EXPRESSION ([TOTPOP1] >= %value_one% AND [TOTPOP1] < %value_two%)
 STYLE
COLOR 255 108 118
OUTLINECOLOR 255 255 255
 END
   END
   CLASS
      EXPRESSION ([TOTPOP1] >= %value_two% AND [TOTPOP1] < %value_three%)
 STYLE
COLOR 254 189 75
OUTLINECOLOR 255 255 255
 END
   END
   CLASS
 EXPRESSION ([TOTPOP1] >= %value_three% AND [TOTPOP1] < %value_four%)
 STYLE
COLOR 254 247 46
OUTLINECOLOR 255 255 255
 END
   END
   CLASS
 EXPRESSION ([TOTPOP1] >= %value_four% AND [TOTPOP1] < %value_five%)
 STYLE
COLOR 39 251 114
OUTLINECOLOR 255 255 255
 END
   END
   CLASS
 EXPRESSION ([TOTPOP1] >= %value_five% AND [TOTPOP1] <= %value_six%)
 STYLE
COLOR 108 111 205
OUTLINECOLOR 255 255 255
 END
   END
END
--
Regards,
Prabu Raja



--
Regards,
Prabu Raja
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapserver-users/attachments/20111116/cb46bdfe/attachment-0001.html


More information about the mapserver-users mailing list