[GIS] MapServer WMS not configured properly

mapserverwms

This is related to another question I asked just recently:

Use OpenLayers WMSGetFeatureInfo on Mapserver Layer?

unicoletti indicated that he/she was able to use OpenLayer's WMS Layer declaration to generate and query MapServer WMS. However, when I attempt the same, I get a error response:

mapserv(): Web application error. Query mode needs a point, imgxy and mapxy are not set.

This error makes sense in that when I use OL's MapServer Layer declaration, the url string includes these options with values filled in. But using the WMS Layer declaration with standard WMS GetMap options, i.e. BBOX, WIDTH, HEIGHT, generates this error. The image is not correct either which I describe next.

Another symptom is that the entire extent of the data defined in the mapfile is displayed rather than what's indicated in the BBOX when just doing a standard WMS GetMap request via a URL rather than using OpenLayers.

So for example, here's the first part of my mapfile:

MAP 
  NAME "testgrib" 
  IMAGETYPE      PNG 
  EXTENT         -14000000 3000000 -7000000 7000000

And here's a GetMap request using standard WMS options:

http://localhost:8080/cgi-bin/mapserv?REQUEST=GetMap&SERVICE=WMS&VERSION=1.1.1&FORMAT=image%2Fpng&MODE=map&MAP=wxmap%2Fglmpvis.map&LAYERS=mosaic&SRS=EPSG%3A3857&TRANSPARENT=TRUE&STYLES=&BBOX=-13807095.590531,3308267.5857033,-12241665.251469,4482340.3400001&WIDTH=640&HEIGHT=480

As you can see, the BBOX extent values are different from those in the mapfile. But, MapServer returns an image with the extent values in the mapfile no matter what BBOX values are passed. I've changed the mapfile extent to match the BBOX values and sure enough, an image of only that area is returned.

Hence this leads me to believe we've missed something during our MapServer installation, some setting or configuration. I've checked to see that WMS was supported and received SUPPORTS=WMS_SERVER when making a GetCapabilities request as well as a -v on the MapServer executable.

I considered attaching the options to the query function that I can see are used to generate images using OL's MapServer Layer declaration to get around this issue. But, as we eventually want our customers to access our data through the WMS, solving that would seem to be the main goal here.

I've searched the web and MS docs for a possible setting/configuration, but nothing really stood out as being critical. I do have "wms_enable_request" "*" in the map file and, as indicated, I am receiving images from MapServer, albeit for the max extent of the data vs the viewing area. And I'm receiving a response back to the query, so this doesn't look like a cross domain/proxy issue. Also, this occurs with displaying an image for raster data as well as an image of point data. The only thing that works is to use OL's MapServer declaration to generate the images properly for the viewing area. But, that's not what we want for a long term solution with our customers accessing the data via WMS.

So, open to suggestions as to what we should either configure differently or what we might've missed to enable standard WMS in our MapServer.

Thanks!

Best Answer

[SOLVED] Posting my last comment as the answer because it really did solve the problem. Found out the MapServer User forum that a proper WMS call does not use the "MODE=map" option. When one does that, it's not a WMS call but a MapServer call. Therefore, MapServer specific values are required (e.g. imgext, mapext). Taking out the "MODE=map" and then using a point layer vs the raster I started to work with did indeed use the BBOX, HEIGHT, and WIDTH values in the WMS options to properly display the layer over the map area. The reason I had thought "MODE=map" was needed was that I would get an error with the raster layer I started to work with and it would go away if I put it back in. But, I then tried with a points layer with the same EPSG as the map (raster was different and real cause of that error) and that worked when I didn't use the "MODE=map" in the options. unicoletti was essentially correct that the mapserver link provided the answer. But, I couldn't see this detail in the doc due to the other error I was getting with the raster layer. A person on the MapServer User forum I asked the question to told me outright that including "MODE=map" makes the call a MapServer call and that expects different parameters (i.e. imgext, mapext), whereas taking MODE=map out and using the WMS options for GetMap makes it a WMS call. BTW, I also solved the problem with the raster layer. I was getting an error indicating the SRS had to be the same for the layers which didn't initially make sense according to the MapServer docs and how I had structured the mapfile. But, searched for the error, reread the MapServer docs, saw other possible answers on the user forums, changed around the mapfile, and finally got it to work. Thanks for the comments and to all for considering this problem!

Related Question