WMS Server
In last time i was instaled a Mapserver+nginx and show a wms layer in browser. Now i want to make a wms server. For this just needed make a correct map file. But before for make sure that MapServer installed correctly run this command in console:
$ ./mapserv -v
Output:
MapServer version x.x.x OUTPUT=GIF OUTPUT=PNG OUTPUT=JPEG OUTPUT=WBMP OUTPUT=PDF OUTPUT=SWF OUTPUT=SVG SUPPORTS=PROJ SUPPORTS=FREETYPE SUPPORTS=WMS_SERVER SUPPORTS=WMS_CLIENT SUPPORTS=WFS_SERVER SUPPORTS=WFS_CLIENT SUPPORTS=WCS_SERVER INPUT=JPEG INPUT=POSTGIS INPUT=OGR INPUT=GDAL INPUT=SHAPEFILE DEBUG=MSDEBUG
If SUPPORTS=WMS_SERVER is here - go ahead.
1.WMS Server map file:
MAP NAME "Simple map" # Map image size SIZE 256 256 UNITS METERS CONFIG PROJ_LIB "/usr/share/proj/" #Path to PROJ lib if needed SHAPEPATH "/srv/www/maps/shp" #Path to shape files EXTENT 60.4 56.7 60.7 56.9 #Output projection PROJECTION "proj=latlong" "ellps=WGS84" "datum=WGS84" END # Background color for the map canvas -- change as desired IMAGECOLOR 255 255 255 IMAGEQUALITY 95 IMAGETYPE png #Output file format OUTPUTFORMAT NAME "png" EXTENSION "png" MIMETYPE "image/png" DRIVER AGG/PNG IMAGEMODE RGBA FORMATOPTION "INTERLACE=OFF" END # Legend LEGEND IMAGECOLOR 255 255 255 STATUS ON KEYSIZE 18 12 LABEL TYPE BITMAP SIZE MEDIUM COLOR 0 0 89 END END WEB # Set IMAGEPATH to the path where MapServer should # write its output. IMAGEPATH '/tmp/' # Set IMAGEURL to the url that points to IMAGEPATH # as defined in your web server configuration IMAGEURL '/tmp/' # WMS server settings METADATA 'ows_title' 'Simple map' ows_onlineresource 'http://MyHost/map/?map=/srv/www/maps/rew.map&' "wms_srs" "EPSG:4326 EPSG:3857" "wms_abstract" "atlands demo WMS" "wms_enable_request" "*" "wms_encoding" "utf-8" END # Template and header/footer settings TEMPLATE 'fooOnlyForWMSGetFeatureInfo' END LAYER NAME 'test' TYPE POLYGON DUMP true TEMPLATE fooOnlyForWMSGetFeatureInfo #EXTENT 34.59 49.58 34.63 49.6 DATA my METADATA 'ows_title' 'test' wms_srs "EPSG:4326" END STATUS OFF TRANSPARENCY 100 #Layer projection PROJECTION "proj=latlong" "ellps=WGS84" "datum=WGS84" END CLASS NAME 'test' STYLE WIDTH 0.91 OUTLINECOLOR 0 0 0 COLOR 214 205 104 END END END END
You can use another projection defenition:
PROJECTION "init=epsg:4326" ENDBut i it evoke an error:
msProcessProjection(): Projection library error. no system list, errno: 13For TEMPLATE block using for GetFeatureInfo(). You can find template samples here and extract tamplates,symbols,images and fonts folders into map files directory.
You can try generate a map file using a MapManager.
Check what we have:
http://MyHost/map/?map=/srv/www/maps/rew.map&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetCapabilitiess
In answer you get a xml file with you wms server settings.
2.Client side
On client side i have a application useing Leaflet so i just add a new layer:
var wms_server = "http://MyHost/map/?map=/srv/www/maps/rew.map&" var NewLayer = new L.tileLayer.wms(wms_server, { layers: 'limite', format: 'image/png', transparent: true, srs:"EPSG:4326" }); map.addLayer(NewLayer);
Used materials:
1. www.http://gis-lab.info/qa/mapserver-wms.html
2. www.http://en.it-usenet.org/thread/12216/6154/
3. www.http://www.cybervox.ru/wiki/Docs/GIS/Mapserver
4. www.http://profmarcello.blogspot.ru/2013/06/configuracao-de-layers-wms-do-mapserver.html