Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer 1

up vote 5 down vote accepted

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.

share|improve this answer
    
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 Jun 26 '11 at 2:53
    
Ah! I figured it out, I think. A PNG raster must have a world file. –  peter Jun 26 '11 at 3:06
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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