UMN Mapserver - WMS Layer

Topics: General Topics
Aug 23, 2006 at 7:21 PM
Hi...

I was trying to figure out how to implement a WMS Layer with sharpmap, but all examples are based on "DEMIS WMS".

I´m using my own WMS (UMN Mapserver), but I still downt know how to get map.

Any help/ideia?

Thanks,

Evandro
Coordinator
Aug 23, 2006 at 9:56 PM
Hi,

Is your UMN Mapserver WMS working in your browser?

Please post some code snippets of your problem!
We can't guess what the problem may be.

BR
/Christian
Aug 23, 2006 at 11:25 PM
Yeah!! its working ;)

Some examples are installed and running.

The thing I have to know is how I can add a WMS Layer on sharpmap and with wich parameters.

I can access my map through my browser with a url like this:
http://localhost/cgi-bin/mapserv.exe?MAP=/ms4w/apps/teste/teste.map&layer=quadra&mode=map

But I dont know how to grab this data with WMS Layers with ShapMap.

On SharpMap, Im using this code:
public SharpMap.Layers.WmsLayer layWms = new SharpMap.Layers.WmsLayer("teste", "http://localhost/cgi-bin/mapserv.exe?MAP=/ms4w/apps/teste/teste.map&layer=quadra&mode=map");

When running the application, it returns the following exception:
The remote server returned an error: (404) Not Found.

Any idea??

Thank You,

Evandro
Developer
Aug 24, 2006 at 8:29 AM
I really don't understand why you get a file-not-found error. Could there be any reason that where SharpMap is running it cannot access localhost?
Btw, you shouldn't include the layers parameter. SharpMap will add this itself.
Instead you should add the layers after declaring the object:
layWms.AddLayer("quadra");
Aug 24, 2006 at 12:29 PM
Your request seems not to be a wms request (it looks like the native Mapserver request), is your mapserver configured as a wms server?
/J
Aug 24, 2006 at 5:59 PM
But how can I check this??

Is there any parameter that changes the mapserver behavior?

Thanks,

Evandro

Aug 24, 2006 at 6:06 PM
Morten...

I guess access rights is not the problem.
Have you ever used SharpMap with UMN Mapserver?

I guess its something very simple, but I didnt figure out what it is...

Any idea?

Thank you,

Evandro

Aug 24, 2006 at 7:59 PM
There is a HOWTO for configuring UMN Mapserver as a WMS Server: http://mapserver.gis.umn.edu/docs/howto/wms_server
/J
Developer
Aug 24, 2006 at 9:37 PM
Even though MapServer isn't configured as WMS, if the URL exists it sounds very weird that the server returns "404" if the URL exists (and different querystrings usually doesn't result in '404').
Aug 25, 2006 at 1:47 AM
Its weird...

My mapfile is above:

NAME QUADRA
WEB
METADATA
"wms_title" "teste wmss"
"wms_onlineresource"
"http://10.1.1.20/cgi-bin/mapserv.exe?map=/ms4w/apps/quadra/quadra.map&"
"wms_srs" "EPSG:4326"
END
END

PROJECTION
"init=epsg:4326"
END

MAP
IMAGETYPE PNG
EXTENT 671200 7174400 672000 7175000
SIZE 800 600
SHAPEPATH "/ms4w/apps/quadra/data/"
IMAGECOLOR 255 245 235

LAYER
NAME quadra
DATA quadra
STATUS ON
TYPE LINE
CLASS
NAME "quadra"
STYLE
COLOR 22 72 232
OUTLINECOLOR 55 132 32
END
END
END
END


I tryed the following codes (on at a time):

SharpMap.Layers.WmsLayer layer = new SharpMap.Layers.WmsLayer("QUADRA", "http://10.1.1.20/cgi-bin/mapserv.exe?SERVICE=WMS&VERSION=1.1.1&layer=quadra&map=/ms4w/apps/quadra/quadra.map");

SharpMap.Layers.WmsLayer layer = new SharpMap.Layers.WmsLayer("QUADRA", "http://10.1.1.20/cgi-bin/mapserv.exe");

SharpMap.Layers.WmsLayer layer = new SharpMap.Layers.WmsLayer("QUADRA", "http://10.1.1.20/cgi-bin/mapserv.exe?SERVICE=WMS&VERSION=1.1.1");

SharpMap.Layers.WmsLayer layer = new SharpMap.Layers.WmsLayer("QUADRA", "http://10.1.1.20/cgi-bin/mapserv.exe?SERVICE=WMS&VERSION=1.1.1&map=/ms4w/apps/quadra/quadra.map");

and a lot more...
and, in almost all of them, the result was the following exception:

System.ApplicationException
Could now download capabilities

InnerException System.Net.WebException
The remote server returned an error: (404) Not Found.


I can get the map on the browser through the following URLs:

http://10.1.1.20/cgi-bin/mapserv.exe?VERSION=1.1.1&map=/ms4w/apps/quadra/quadra.map&layers=quadra&request=getmap

and

http://10.1.1.20/cgi-bin/mapserv.exe?VERSION=1.1.1&map=/ms4w/apps/quadra/quadra.map&layers=quadra&request=getmap&service=wms


Any idea??

Thank you,

Evandro
Developer
Aug 25, 2006 at 7:36 AM
Weird, but in any case the VERSION and SERVER parameters are not needed. SharpMap will automatically determine the values to use here. I would think you only need the MAP parameter (although this doesn't explain your 404 error).
Try setting up the client and check the result from the following method:
layerWms.GetRequestUrl(map.Envelope, map.Size)

This should return the URL that SharpMap uses for the current setup. Maybe that can give you a hint on what is going on.
Aug 25, 2006 at 11:51 AM
Hi,
this looks like Sharpmap cannot get the capabilities document, this might depend on the fact, that your map file isn't correct, which might cause Mapserver to fail to return a valid capabilities document. This might even explain the weird 404 error... Here is a map file with the corrected errors, that I found.
/J


MAP ##error 1: the map definition starts with map

NAME QUADRA
WEB
METADATA
"wms_title" "teste wmss"
"wms_onlineresource"
"http://10.1.1.20/cgi-bin/mapserv.exe?map=/ms4w/apps/quadra/quadra.map&"
"wms_srs" "EPSG:4326"
END
END


PROJECTION
"init=epsg:4326"
END


IMAGETYPE PNG
EXTENT 671200 7174400 672000 7175000
SIZE 800 600
SHAPEPATH "/ms4w/apps/quadra/data/"
IMAGECOLOR 255 245 235


LAYER
NAME quadra
METADATA
"wms_title" "quadra" ##error 2, this is required
END
DATA quadra
STATUS ON
TYPE LINE
CLASS
NAME "quadra"
STYLE
COLOR 22 72 232
OUTLINECOLOR 55 132 32
END
END
END
END


Aug 25, 2006 at 2:49 PM
Its a kind of weird..

Using public WMS server I can get the maps with no problem!
So, the problem seem to be is in the UMN Mapserver (just mine, of cource hahaha).

Do you guys know any other WMS Server??

I started trying tryGeoServer WMS Server. Do you know it?

Regards,

Evandro
Aug 28, 2006 at 12:22 PM
Hi,
SharpMap can afaik be configured as a WMS server. Then there is MonoGIS and I think even MapGuide OpenSource can serve as a WMS.
/Johannes
Developer
Aug 28, 2006 at 1:31 PM
Yeah judging from your very simple map-file, SharpMap should have no problem serving the same data, instead of using MapServer.
Mar 27, 2007 at 6:15 PM
I know its been a while, but I was wondering if you ever found a solution for using Mapserver? I can get a map created out of Mapserver WMS with a URL. But when I try to use it with SharpMap it's not getting the Capabilities. Here's the urls that are working for me.

GetMap:
http://69.20.67.60:8080/cgi-bin/mapserv.exe?MAP=/ms4w/apps/pmapper-dev/arkwms2.map&VERSION=1.1.1&REQUEST=getmap&LAYERS=Counties,Imagery2006&bbox=517666.4133,3841237.6779,521884.4888,3844733.2619&SERVICE=WMS&

GetCapabilities: (it will prompt you to download the mapserv.exe....just rename it to .xml to see the capabilities)
http://69.20.67.60:8080/cgi-bin/mapserv.exe?MAP=/ms4w/apps/pmapper-dev/arkwms2.map&VERSION=1.1.1&REQUEST=getcapabilities&LAYERS=Counties,Imagery2006&bbox=517666.4133,3841237.6779,521884.4888,3844733.2619&SERVICE=WMS&