What is MapFile? - Map Server

random

What is MapFile? - Map Server

What is Map Server?

Map Server is an engine for geographic (spatial) data rendering. It allows you create geographic map image on web. It's an open source platform and runs on all major systems (Windows,Linux,Mac).
map server tutorial, web map server, map server drive,map server demo
Web Map Server

.Map file format - MapServer

The Mapfile is the heart of Map Server. A Map File is used by Map-Server for configuration, data access, projection, and more. 
mapserver mapfile, mapserver mapfile editor, mapserver mapfile expression
MapServer Configuration File
The Map File is parsed every time a map image is requested. It has a hierarchical structure such that some objects fall under other objects, on top of this hierarchy is the MAP object, all other objects belong to it. There is a hierarchy of objects.

MAP
 |-LAYER
    |-CLASS
       |-STYLE

We define each object in the map file with the object name and we close it with END and we precede comments with a pound(#) sign.

MapServer Configuration File Sample

# Map file created from QGIS project file C:/Users/lepton/Desktop/My Docs/Development/GIS Testing/Delhi_State.qgs
# Edit this file to customize for your map interface
# (Created with PyQgis MapServer Export plugin)
MAP
  NAME "QGIS-MAP"
  # Map image size
  SIZE 100 100
  UNITS meters

  EXTENT 76.539494 28.183606 78.143364 28.907036
 
  PROJECTION
    'proj=longlat'
    'datum=WGS84'
    'no_defs'
  END


  # Background color for the map canvas -- change as desired
  IMAGECOLOR 255 255 255
  IMAGEQUALITY 95
  IMAGETYPE png

  OUTPUTFORMAT
    NAME png
    DRIVER 'AGG/PNG'
    MIMETYPE 'image/png'
    IMAGEMODE RGBA
    EXTENSION 'png'
  END
  # Legend
  LEGEND
      IMAGECOLOR 255 255 255
    STATUS ON
    KEYSIZE 18 12
    LABEL
      TYPE BITMAP
      SIZE MEDIUM
      COLOR 0 0 89
    END
  END

  # Web interface definition. Only the template parameter
  # is required to display a map. See MapServer documentation
  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'           'QGIS-MAP'
      'ows_onlineresource'  'http://localhost/cgi-bin/mapserv.exe?map=C:/Users/lepton/Desktop/My Docs/Development/GIS Testing/Delhi_State_Boundary.map'
      'ows_srs'             'EPSG:4326'
      'ows_enable_request'   '*'
    END

    #Scale range at which web interface will operate
    # Template and header/footer settings
    # Only the template parameter is required to display a map. See MapServer documentation
    TEMPLATE 'fooOnlyForWMSGetFeatureInfo'
  END

  LAYER
    NAME 'DL_STATE'
    TYPE POLYGON
    DUMP true
    TEMPLATE fooOnlyForWMSGetFeatureInfo
  EXTENT 76.539494 28.183606 78.143364 28.907036
  CONNECTIONTYPE OGR
    CONNECTION "C:/Users/lepton/Desktop/My Docs/Development/GIS Testing/Delhi/DL_STATE.TAB"   
    METADATA
      'ows_title' 'DL_STATE'
    END
    STATUS OFF
    TRANSPARENCY 100
    PROJECTION
    'proj=longlat'
    'datum=WGS84'
    'no_defs'
    END
    CLASS
       NAME 'DL_STATE'
       STYLE
         WIDTH 0.91
         OUTLINECOLOR 0 0 0
         COLOR 255 170 0
       END
    END
  END
END

Map Object
There are following objects in a map file:

MAP :- Every mapfile must start with the MAP object – the entire mapfile is the MAP object.

IMAGETYPE:- The keyword IMAGETYPE is used to define which image format the MapServer CGI program should use for output.

EXTENT:- This parameter specifies the output extent of our map–the bounding box of our initial map. The EXTENT values are given in this format:
<Lower Left X> <Lower Left Y> <Upper Right X> <Upper Right Y>

with spaces separating each value. This needs to be in the same units as the data or, if specifying a different output projection, in the same units as the output projection.

SIZE:- This is the size of the image (the map) that Map Server will generate, in pixels. So our map is 400 pixels wide by 300 pixels high.

SHAPEPATH:- This is the path to your data layers. You can provide absolute paths (i.e. “/ms4w/apps/tutorial/data” or “C:/ms4w/apps/tutorial/data”) or paths relative to your mapfile’s location (in this example, you’d use ”../data”). Just make sure that the user running the web server (usually “nobody” or “apache” in the *nix world) can READ the data in the SHAPEPATH.

IMAGECOLOR:- This is the background color of your map. The values are RGB values so 255 Red, 255 Green, and 255 Blue which results in a white background

METADATA :- It contains WMS or WFS settings

LAYER Object
LAYER:- Marks the beginning of a LAYER within the MAP object. You can specify as many layers as you like

NAME :- This is the layer identifier. Map Server uses this name to toggle the layer on and off.

DATA :- The name of the data (Shapefile dataset or .TAB file in this case).

TYPE :- What type of data is it? If it’s a vector data, you can specify whether it is a POLYGON, LINE (you use LINE even if your data is technically a POLYLINE), or a POINT. You can also specify RASTER or ANNOTATION data. Here we want to display POLYGON.

STATUS:- Layers are turned on or off based on their STATUS. DEFAULT is always on. ON or OFF works when the LAYER name is passed as part of the query string.

CLASS Object
CLASS:- You can specify as many classes within a layer.

NAME:- The descriptive identifier  for this CLASS. LAYER objects can have multiple classes, just like MAP objects can have multiple layers.

STYLE Object:
STYLE:- You can define multiple styles within a class. This is useful when you want to overlay a style over another.

COLOR:- This is the fill color of the polygon. In case the TYPE is LINE, this is the line color. The values are in RGB format.

OUTLINECOLOR:- This is the outline color of the polygons. The values are in RGB format. MapServer doesn’t draw polygon outlines by default, so if you want to see polygon boundaries, you will want to define an OUTLINECOLOR.



Download File

I hope you will enjoy the Map server tutorial. I would like to have feedback from my blog readers. Your valuable feedback, question, or comments about this article are always welcome. 

Also If you like this article, don't forget to share this article with your friends and colleagues.
What is MapFile? - Map Server Reviewed by Ravi Kumar on 5:00 PM Rating: 5

No comments:

All Rights Reserved by Etechpulse © 2012 - 2017

Contact Form

Name

Email *

Message *

Powered by Blogger.