[ms4w-users] msEvalRegex(): Regular expression error. String () failed expression test.

Jeff McKenna jmckenna at dmsolutions.ca
Mon Oct 15 10:47:32 EDT 2007


Try the following:

1) Use the shp2img commandline utility (it is included in MS4W) to 
verify that your mapfile works and that it is not an application problem:

    C:\ms4w> setenv.bat

    cd apps\myapp

    shp2img -m mymap.map -o mymapimage.png -map_debug 3

That utility just takes a mapfile and creates a map image, or reports 
mapfile errors.

2) Again remove all layers until only the problem layer is left.  Or 
remove ALL layers and see if you still get that error with shp2img, and 
keep removing other mapfile objects until you don't get an error with 
shp2img.


Jagdesh Singh wrote:
> Dear All,
> 
> This is my first question to the mailing list and I am afraid is a 
> familiar one. I believe Mr. Tony Gangemi last posted the same question 
> in October 2006, but I am not sure if he has made any progress since.
> 
> I am currently doing the exercises from Bill Kropla’s book “Beginning 
> MapServer: Open Source GIS Development”. Like Mr. Gangemi, despite the 
> book having a slant towards the UNIX environment, I made the necessary 
> adjustments to the map and html files to suit my windows configuration.
> 
> However, I am stuck at chapter 4 example. When I execute the source code 
> in IE 6, I received the familiar message “msEvalRegex(): Regular 
> expression error. String () failed expression test.” I am not sure what 
> this mean, since the problem layer is not specified in the error message 
> returned to IE.
> 
> However, without any luck, I attempted to debug the mapfile by removing 
> one layer at a time to try to isolate the problem layer, as suggested by 
> Mr. Jeff  McKenna. This did not solve my problem. What I observed though 
> is that even if the map file has one layer, the same error message is 
> returned to the browser. I am not sure if it is a problem with the 
> mapfile or the html file. Hopefully someone else has experienced this 
> problem and can provide some guidance. I have pasted below, for your 
> reference, the codes from the mapfile and the html files and the map 
> layers I am using in the example.
> 
> Look forward to hearing from you.
> 
> Best regards,
> 
> Jag
> 
> MapLayer Source: http://nationalatlas.gov/atlasftp.html_ 
> <http://lists.maptools.org/pipermail/ms4w-users/2006-October/_http:/nationalatlas.gov/atlasftp.html_>
> 
> citiesx020.tar.gz
> 
> _http://nationalatlas.gov/atlasftp.html#citiesx/citiesx020.tar.gz__
> 
> roadtrl020.tar.gz
> 
> _http://nationalatlas.gov/atlasftp.html#citiesx/roadtrl020.tar.gz__
> 
> statesp020.tar.gz
> 
> _http://nationalatlas.gov/atlasftp.html#citiesx/statesp020.tar.gz__
> 
> hydrogm020.tar.gz
> 
> _http://nationalatlas.gov/atlasftp.html#citiesx/hydrogm020.tar.gz_
> 
> urbanap020.tar.gz
> 
> http://nationalatlas.gov/atlasftp.html#citiesx/urbanap020.tar.gz_
> 
> *_MapFile_*
> 
> *_third.map_*
> 
>  
> 
> # This is our third map file
> 
> NAME "third"
> 
> UNITS DD
> 
> EXTENT -180.00 0.00 -60.00 90.00
> 
> SIZE 640 480
> 
> IMAGECOLOR 189 202 222
> 
> IMAGETYPE PNG
> 
> SHAPEPATH "/ms4w/apps/firstmap/mapdata/"
> 
> FONTSET "/ms4w/apps/firstmap/fonts/fonts.txt"
> 
> #####################################
> 
> # Symbol for drawing fat lines
> 
> #
> 
> SYMBOL
> 
>      NAME "BigLine"
> 
>      TYPE ELLIPSE
> 
>      POINTS 1 1 END
> 
> END
> 
> #####################################
> 
> # Symbol for drawing dashed lines
> 
> #
> 
> SYMBOL
> 
>      NAME "DashedLine"
> 
>      TYPE ELLIPSE
> 
>      POINTS 1 1 END
> 
>      STYLE 10 10 END  
> 
> END
> 
> #####################################
> 
> # Symbol for drawing spots
> 
> #
> 
> SYMBOL
> 
>      NAME "Circle"
> 
>      FILLED true
> 
>      TYPE ellipse
> 
>      POINTS 1 1 END
> 
> END
> 
> #####################################
> 
> # Web object
> 
> #
> 
> WEB
> 
>      TEMPLATE  "c:/ms4w/apps/firstmap/htdocs/third.html"
> 
>      IMAGEPATH "c:/ms4w/apps/firstmap/tmp"
> 
>      IMAGEURL  "c:/ms4w/tmp/"
> 
> END
> 
> #####################################
> 
> # Reference map
> 
> #
> 
> REFERENCE
> 
>      IMAGE "c:/ms4w/apps/firstmap/htdocs/third_usaref.gif"
> 
>      SIZE 300 225
> 
>      EXTENT -180.00 0.00 -60.00 90.00
> 
>      STATUS ON
> 
>      COLOR -1 -1 -1
> 
>      OUTLINECOLOR 255 0 0
> 
> END
> 
> #####################################
> 
> # Scalebar
> 
> #
> 
> SCALEBAR
> 
>      LABEL
> 
>           COLOR 0 0 0
> 
>           ANTIALIAS true
> 
>           SIZE small
> 
>      END
> 
>      POSITION lr
> 
>      INTERVALS 5
> 
>      STATUS embed
> 
>      SIZE 144 5
> 
>      STYLE 0
> 
>      UNITS miles
> 
>      BACKGROUNDCOLOR 255 0 0
> 
>      IMAGECOLOR 255 255 255
> 
>      COLOR 128 128 128    
> 
>      OUTLINECOLOR 0 0 255
> 
>      TRANSPARENT off
> 
> END
> 
> #####################################
> 
> # Legend
> 
> #
> 
> LEGEND
> 
>      STATUS on
> 
>      IMAGECOLOR 230 230 230
> 
>      LABEL
> 
>           TYPE truetype
> 
>           FONT "arial"
> 
>           COLOR 0 0 0
> 
>           SIZE 10
> 
>           ANTIALIAS true
> 
>      END
> 
> END
> 
> #####################################
> 
> # State boundaries layer - polygon (for shading)
> 
> #
> 
> LAYER
> 
>      NAME "states"
> 
>      DATA "statesp020"
> 
>      STATUS on
> 
>      TYPE polygon
> 
>      LABELCACHE on
> 
>      LABELITEM "STATE"
> 
>      CLASS
> 
>           STYLE
> 
>                COLOR 255 246 189
> 
>           END
> 
>      END
> 
> END
> 
> #####################################
> 
> # State boundaries layer - line (for fat boundary)
> 
> #
> 
> LAYER
> 
>      NAME "states"
> 
>      DATA "statesp020"
> 
>      STATUS on
> 
>      TYPE line
> 
>      LABELCACHE on
> 
>      LABELITEM "STATE"
> 
>      CLASS
> 
>           NAME "State Line"
> 
>           STYLE
> 
>                SYMBOL "BigLine"
> 
>                SIZE 2
> 
>                COLOR 0 0 0
> 
>           END
> 
>      END
> 
> END
> 
> #####################################
> 
> # Urban areas layer
> 
> #
> 
> LAYER
> 
>      NAME "urbanareas"
> 
>      DATA "urbanap020"
> 
>      STATUS on
> 
>      TYPE polygon
> 
>      LABELCACHE on
> 
>      LABELITEM "NAME"
> 
>      MAXSCALE 1999999
> 
>      CLASS
> 
>           STYLE
> 
>                COLOR 212 192 100
> 
>                OUTLINECOLOR 0 0 0
> 
>           END
> 
>           LABEL
> 
>                TYPE truetype
> 
>                FONT "arialbd"
> 
>                SIZE 10
> 
>                OUTLINECOLOR 255 255 255
> 
>                COLOR 0 0 0
> 
>                POSITION auto
> 
>           END
> 
>      END
> 
> END
> 
> #####################################
> 
> # hydrographic layer - lakes
> 
> #
> 
> LAYER
> 
>      NAME "lakes"
> 
>      DATA "hydrogp020"
> 
>      STATUS on
> 
>      TYPE polygon
> 
>      LABELCACHE on
> 
>      LABELITEM "NAME"
> 
>      CLASSITEM "FEATURE"
> 
>      CLASS
> 
>           EXPRESSION ('[FEATURE]' eq 'Lake')
> 
>           STYLE
> 
>                SIZE 1
> 
>                COLOR 189 202 222
> 
>                OUTLINECOLOR 0 0 0
> 
>           END
> 
>           LABEL
> 
>                TYPE truetype
> 
>                FONT "arial"
> 
>                SIZE 8
> 
>                OUTLINECOLOR 255 255 255
> 
>                COLOR 0 0 0
> 
>                MINDISTANCE 100
> 
>                POSITION lr
> 
>                MINFEATURESIZE auto
> 
>                WRAP ' '
> 
>           END
> 
>      END
> 
> END
> 
> #####################################
> 
> # Road layer - interstates only at large scale
> 
> #
> 
> LAYER
> 
>      NAME "interstate1"
> 
>      GROUP "roads"
> 
>      DATA "roadtrl020"
> 
>      STATUS on
> 
>      TYPE line
> 
>      LABELCACHE on
> 
>      LABELITEM "NAME"
> 
>      CLASSITEM "FEATURE"
> 
>      MINSCALE 7500001
> 
>      CLASS
> 
>           NAME "Interstate Hwy"
> 
>           EXPRESSION /Limited Access*/
> 
>           STYLE
> 
>                SYMBOL "BigLine"
> 
>                SIZE 1
> 
>                COLOR 0 0 0
> 
>           END
> 
>           LABEL
> 
>                TYPE truetype
> 
>                FONT "arial"
> 
>                SIZE 8
> 
>                OUTLINECOLOR 255 255 255
> 
>                COLOR 0 0 0
> 
>                MINDISTANCE 200
> 
>                POSITION auto
> 
>                ANGLE auto
> 
>                MINFEATURESIZE 50
> 
>           END
> 
>      END
> 
> END
> 
> #####################################
> 
> # Road layer - interstates only
> 
> #
> 
> LAYER
> 
>      NAME "interstate2"
> 
>      GROUP "roads"
> 
>      DATA "roadtrl020"
> 
>      STATUS on
> 
>      TYPE line
> 
>      LABELCACHE on
> 
>      LABELITEM "NAME"
> 
>      CLASSITEM "Feature"
> 
>      MAXSCALE 7500000
> 
>      CLASS
> 
>           NAME "Interstate Hwy"
> 
>           EXPRESSION /Limited Access*/
> 
>           STYLE
> 
>                SYMBOL "BigLine"
> 
>                SIZE 3
> 
>                COLOR 0 0 0
> 
>           END
> 
>           OVERLAYSYMBOL "DashedLine"
> 
>           OVERLAYSIZE 1
> 
>           OVERLAYCOLOR 255 255 255
> 
> #         TEXT ([FEATURE],[NAME])
> 
>           LABEL
> 
>                TYPE truetype
> 
>                FONT "arial"
> 
>                SIZE 8
> 
>                OUTLINECOLOR 255 255 255
> 
>                COLOR 0 0 0
> 
>                MINDISTANCE 200
> 
>                POSITION auto
> 
>                ANGLE auto
> 
>                MINFEATURESIZE 50
> 
>                WRAP ' '
> 
>           END
> 
>      END
> 
> END
> 
> #####################################
> 
> # Road layer -  principal highways
> 
> #
> 
> LAYER
> 
>      NAME "principal"
> 
>      GROUP "roads"
> 
>      DATA "roadtrl020"
> 
>      STATUS on
> 
>      TYPE line
> 
>      LABELCACHE on
> 
>      LABELITEM "NAME"
> 
>      CLASSITEM "Feature"
> 
>      MAXSCALE 4000000
> 
>      CLASS
> 
>           NAME "Principal Hwy"
> 
>           EXPRESSION /Principal Highway*/
> 
>           STYLE
> 
>                SYMBOL "BigLine"
> 
>                SIZE 3
> 
>                COLOR 197 129 65
> 
>           END
> 
>           OVERLAYSYMBOL "DashedLine"
> 
>           OVERLAYSIZE 1
> 
>           OVERLAYCOLOR 255 255 255
> 
> #         TEXT ([FEATURE],[NAME])
> 
>           LABEL
> 
>                TYPE truetype
> 
>                FONT "arial"
> 
>                MINFEATURESIZE 50
> 
>                MINDISTANCE 100
> 
>                ANGLE auto
> 
>                COLOR 0 0 0
> 
>                SIZE 8
> 
>           END
> 
>      END
> 
> END
> 
> #####################################
> 
> # Road layer -  other through highways
> 
> #
> 
> LAYER
> 
>      NAME "thru"
> 
>      GROUP "roads"
> 
>      DATA "roadtrl020"
> 
>      STATUS on
> 
>      TYPE line
> 
>      LABELCACHE on
> 
>      LABELITEM "NAME"
> 
>      CLASSITEM "Feature"
> 
>      MAXSCALE 1000000
> 
>      CLASS
> 
>           NAME "Through Hwy"
> 
>           EXPRESSION /Other Through*/
> 
>           STYLE
> 
>                SYMBOL "BigLine"
> 
>                SIZE 3
> 
>                COLOR 197 129 65
> 
>           END
> 
>           OVERLAYSYMBOL "DashedLine"
> 
>           OVERLAYSIZE 1
> 
>           OVERLAYCOLOR 0 255 0
> 
>           LABEL
> 
>                TYPE truetype
> 
>                FONT "arial"
> 
>                MINFEATURESIZE 100
> 
>                MINDISTANCE 100
> 
>                ANGLE auto
> 
>                COLOR 0 0 0
> 
>                SIZE 8
> 
>           END
> 
>      END
> 
> END
> 
> #####################################
> 
> # Road layer -  other highways
> 
> #
> 
> LAYER
> 
>      NAME "other"
> 
>      GROUP "roads"
> 
>      DATA "roadtrl020"
> 
>      STATUS on
> 
>      TYPE line
> 
>      LABELCACHE on
> 
>      LABELITEM "NAME"
> 
>      CLASSITEM "FEATURE"
> 
>      MAXSCALE 500000
> 
>      CLASS
> 
>           NAME "Other Hwy"
> 
>           EXPRESSION /Other Highway*/
> 
>           STYLE
> 
>                SYMBOL "BigLine"
> 
>                SIZE 2
> 
>                COLOR 197 129 65
> 
>           END
> 
>           LABEL
> 
>                TYPE truetype
> 
>                FONT "arial"
> 
>                ANGLE auto   # requires ttfonts
> 
>                MINFEATURESIZE 100
> 
>                MINDISTANCE 100
> 
>                ANGLE auto
> 
>                COLOR 0 0 0
> 
>                SIZE 6
> 
>           END
> 
>      END
> 
> END
> 
> #####################################
> 
> # Hydrographic layer - streams & rivers
> 
> #
> 
> LAYER
> 
>      NAME "rivers"
> 
>      DATA "hydrogl020"
> 
>      STATUS DEFAULT
> 
>      TYPE line
> 
>      LABELCACHE on
> 
>      LABELITEM "NAME"
> 
>      CLASSITEM "FEATURE"
> 
>      MAXSCALE 1000000
> 
>      CLASS
> 
>           EXPRESSION ('[FEATURE]' eq 'Stream')
> 
>           STYLE
> 
>                SYMBOL "BigLine"
> 
>                SIZE 1
> 
>                COLOR 156 182 205
> 
>           END
> 
>           LABEL
> 
>                TYPE truetype
> 
>                FONT "arial"
> 
>                COLOR 0 0 0
> 
>                ANGLE auto
> 
>                SIZE 7
> 
>                ANTIALIAS true
> 
>           END
> 
>      END
> 
> END
> 
> #####################################
> 
> # Cities layer - State capitals and cities pop. > 1000000
> 
> #
> 
> LAYER
> 
>      NAME "majorcities"
> 
>      DATA "citiesx020"
> 
>      STATUS default
> 
>      TYPE point
> 
>      LABELITEM "NAME"
> 
>      LABELCACHE on
> 
>      LABELMAXSCALE 15000000
> 
>      CLASSITEM "FEATURE"
> 
>      MINSCALE 2000000
> 
>      CLASS
> 
>           NAME "State Capitals"
> 
>           EXPRESSION /State*/
> 
>           STYLE
> 
>                SYMBOL "Circle"
> 
>                SIZE 6
> 
>                COLOR 0 255 0
> 
>           END
> 
>           LABEL
> 
>                TYPE truetype
> 
>                FONT "arialbd"
> 
>                SIZE 9
> 
>                POSITION auto
> 
>                OUTLINECOLOR 255 255 255
> 
>                COLOR 0 0 0
> 
>           END
> 
>      END
> 
>      CLASS
> 
>           EXPRESSION ([Pop_2000] > 1000000)
> 
>           NAME "Major Cities"
> 
>           STYLE
> 
>                SYMBOL "Circle"
> 
>                SIZE 10
> 
>                COLOR 255 0 0
> 
>           END
> 
>           LABEL
> 
>                TYPE truetype
> 
>                FONT "arialbd"
> 
>                SIZE 10
> 
>                OUTLINECOLOR 255 255 255
> 
>                COLOR 0 0 0
> 
>                POSITION auto
> 
>           END
> 
>      END
> 
> END
> 
> #####################################
> 
> # Cities layer - Large cities, pop. < 1000000
> 
> #
> 
> LAYER
> 
>      NAME "largecities"
> 
>      DATA "citiesx020"
> 
>      STATUS default
> 
>      TYPE point
> 
>      LABELCACHE on
> 
>      LABELITEM "NAME"
> 
>      MINSCALE 2000000
> 
>      CLASS
> 
>           EXPRESSION(([Pop_2000]>100000)and([Pop_2000]<=1000000))
> 
>           NAME "Cities"
> 
>           STYLE
> 
>                SYMBOL "Circle"
> 
>                SIZE 4
> 
>                COLOR 255 0 0
> 
>                BACKGROUNDCOLOR 255 0 0
> 
>           END
> 
>           LABEL
> 
>                TYPE truetype
> 
>                FONT "arialbd"
> 
>                SIZE 8
> 
>                POSITION auto
> 
>                OUTLINECOLOR 255 255 255
> 
>                COLOR 0 0 0
> 
>           END
> 
>      END
> 
> END
> 
> #####################################
> 
> # City layer - Cities
> 
> LAYER
> 
>      NAME "cities"
> 
>      DATA "citiesx020"
> 
>      STATUS default
> 
>      TYPE point
> 
>      LABELCACHE on
> 
>      LABELITEM "NAME"
> 
>      LABELMAXSCALE 500000
> 
>      MAXSCALE 2000000
> 
>      CLASS
> 
>           NAME "Small Cities"
> 
>           EXPRESSION ([Pop_2000] < 100000)
> 
>           STYLE
> 
>                SYMBOL "Circle"
> 
>                SIZE 3
> 
>                COLOR 255 0 0
> 
>           END
> 
>           LABEL
> 
>                TYPE truetype
> 
>                FONT "arialbd"
> 
>                SIZE 7
> 
>                POSITION auto
> 
>                OUTLINECOLOR 255 255 255
> 
>                COLOR 0 0 0
> 
>           END
> 
>      END
> 
> END
> 
> #####################################
> 
> # State boundaries layer - annotation (for labels)
> 
> #
> 
> LAYER
> 
>      NAME "states"
> 
>      DATA "statesp020"
> 
>      STATUS on
> 
>      TYPE annotation
> 
>      LABELCACHE on
> 
>      LABELITEM "STATE"
> 
>      LABELMINSCALE 2000000
> 
>      CLASS
> 
>           LABEL
> 
>                TYPE truetype
> 
>                FONT "arialbd"
> 
>                SIZE 14                               
> 
>                OUTLINECOLOR 255 255 255
> 
>                COLOR 0 0 0
> 
>                MINDISTANCE 200
> 
>                MINFEATURESIZE 10
> 
>           END
> 
>      END
> 
> END
> 
> END # mapfile
> 
> *_Html Codes_*
> 
> *_Third.html_*
> 
> <html>
> 
> <head><title>Third Map</title></head>
> 
> <body bgcolor="#E6E6E6">
> 
>  <form name="the_form" method=GET action="[program]">
> 
>   <table width="100%" border="1">
> 
>    <tr><td width="60%" rowspan="6">
> 
>        <input name="img" type="image" src="[img]"
> 
>                width=640 height=480 border=2>
> 
>        </td>
> 
>        <td width="40%" align="center" colspan="3">
> 
>        <img SRC="[ref]" width=300 height=225 border=1>
> 
>        </td>
> 
>    </tr>
> 
>    <tr><td align="left" colspan="3"><font size="-1">
> 
>        Map scale:&nbsp &nbsp &nbsp 1:[scale]</font></td></tr>
> 
>    <tr><td align="left" colspan="3"><font size="-1">
> 
>        Click x,y:&nbsp &nbsp &nbsp &nbsp [mapx], [mapy]</font></td></tr>
> 
>    <tr><td align="left" colspan="3"><font size="-1">
> 
>        Map Extent:&nbsp [mapext]</font></td></tr>
> 
>    <tr><td><B><center>Legend</center></B></td>
> 
>        <td><B><center>Navigation</center></B></td>
> 
>        <td><B><center>Layers</center></B></td></tr>
> 
>    <tr><td rowspan="2"><img src="[legend]"></td>
> 
>        <td align="left"><font size="-1">
> 
>        <input type=radio name=zoomdir value=0 [zoomdir_0_check]>
> 
>           Pan<BR>
> 
>        <input type=radio name=zoomdir value=1 [zoomdir_1_check]>
> 
>           Zoom In<BR>
> 
>        <input type=radio name=zoomdir value=-1 [zoomdir_-1_check]>
> 
>           Zoom Out<BR>
> 
>        <input type=text name=zoomsize size=1 value=[zoomsize]>
> 
>           Size<BR>
> 
>        <center><input type="submit" value="Refresh"></center>
> 
>        </td>
> 
>        <td align="top">
> 
>        <input type="checkbox" name="layer" value="urbanareas"
> 
>           [urbanareas_check]>
> 
>           Urban Areas<BR>
> 
>        <input type="checkbox" name="layer" value="lakes" [lakes_check]>
> 
>           Lakes<BR>
> 
>        <input type="checkbox" name="layer" value="states" [states_check]>
> 
>           State Boundaries<BR>
> 
>        <input type="checkbox" name="layer" value="roads" [roads_check]>
> 
>           Roads<BR></font>
> 
>        </td>
> 
>    </tr>
> 
>   </table>
> 
>    <input type="hidden" name="imgxy" value="320 240">
> 
>    <input type="hidden" name="imgext" value="[mapext]">
> 
>    <input type="hidden" name="map" value="[map]">
> 
>    <input type="hidden" name="program" value="[program]">
> 
>    <input type="hidden" name="map_web_imagepath" 
> value="[map_web_imagepath]">
> 
>  </form>
> 
> </body>
> 
> </html>
> 
>  
> *_third_i.html_*
> 
>  
> <html>
> 
>  <head> <title>MapServer Third Map</title></head>
> 
>  <body>
> 
>   <form method=POST action="/cgi-bin/mapserv.exe">
> 
>     <input type="submit" value="Click to initialize">
> 
>     <input type="hidden" name="program" value="/cgi-bin/mapserv.exe">
> 
>     <input type="hidden" name="map" 
> value=""c:/ms4w/apps/firstmap/htdocs/third.map">
> 
>     <input type="hidden" name="map_web_imagepath" value="/ms4w/tmp/">
> 
>     <input type="hidden" name="mapext" value="-180.00 0.00 -60.00 90.00">
> 
>     <input type="hidden" name=zoomsize size=2 value=2>
> 
>     <input type="hidden" name="layers"
> 
>         value="urbanareas lakes states roads capitals">
> 
>   </form>
> 
>  </body>
> 
> </html>
> 
> 
> Jagdesh Singh
> 
> Head - Forest Resources Information Unit
> 
> Guyana Forestry Commission
> 
> 1 Water Street, Kingston, Georgetown,
> 
> Guyana, South America
> 
> Tel: + (592) 226-7271/4 (ext 232), Mobile: (592) 641-1451
> 
> Fax: + (592) 226-8956
> 
> Email: jagdesh_singh at hotmail.com 
> <mailto:Project.Coordinator at forestry.gov.gy>
> 


-- 
Jeff McKenna
DM Solutions Group Inc.
http://www.dmsolutions.ca


More information about the ms4w-users mailing list