4

I am trying to use MapServer to display a raster image (png). That's it for now at least. However, I am having no luck. When I visit my map by using a link like:

*http://myurl.com/cgi-bin/mapserv?map=/path/to/file.map&layer=base&mode=map

I get the following error:

msLoadMap(): Regular expression error. MS_DEFAULT_MAPFILE_PATTERN validation failed. msEvalRegex(): Regular expression error. String failed expression test.

When I use shp2img:

shp2img -m file.map -o myimage.png -all_debug 5

I get no errors, but the image that's produced is completely gray except for the upper right quadrant which is white. This is nothing like my raster image.

My mapfile:

MAP
    SHAPEPATH     "/home/name/public_html/dir"
    IMAGETYPE     PNG
    EXTENT        -180 -90 180 90
    SIZE          800 600
    IMAGECOLOR    155 155 155
    UNITS         DD
    STATUS        ON
    DEBUG         ON

    LAYER
        NAME      "base"
        DATA      "/home/name/public_html/dir/image.png"
        STATUS    ON
        TYPE      RASTER
    END 
END 

What am I doing wrong?

1 Answer 1

7

Your map file is fine.

I've seen the Regular expression error. MS_DEFAULT_MAPFILE_PATTERN validation failed error when the extension to the map file in the URL is incorrect e.g.

.map Works: http://myurl.com/cgi-bin/mapserv?map=/path/to/file.map&layer=base&mode=map

.map2 fails with above error: http://myurl.com/cgi-bin/mapserv?map=/path/to/file.map2&layer=base&mode=map

In the MapServer source code you can see the regular expression used to check for a valid mapfile (.xml is also now allowed):

#define MS_DEFAULT_MAPFILE_PATTERN "\\.map$"

If your path and mapfile are correctly defined then it must be something in your URL request. Do you have any URL rewriters active? Maybe try and look at the web server logs to see the exact URL it receives.

2
  • You're right, my url was wrong. However, I still have the problem that I'm getting a blank image using shp2img or the correct url. What could cause this?
    – peter
    Commented Jun 26, 2011 at 2:53
  • Ah! I figured it out, I think. A PNG raster must have a world file.
    – peter
    Commented Jun 26, 2011 at 3:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.