Kontrolli MapServer CGI

variablat

Emrat e variablave nuk janë çështje të ndjeshme.

BUFFER [distance]

Një distancë, në të njëjtin sistem koordinativ si skedarin e hartes, e përdorur në lidhje me MAPXY për të krijuar një hartë shtrirjen të re.

CLASSGROUP [name]
The name of a LAYER CLASSGROUP. Set the LAYER CLASSGROUP to name for all layers that have at least one CLASS that is using the given CLASSGROUP name.
CONTEXT [filename]
Path to a context file. Path is relative to the map file to be used, or can also be a URL path (See the section “Map Context Support Through CGI” below for more details).
ICON [layername],[classindex]
Used in MODE=legendicon to generate a legend icon for a layer. The class index value is optional and defaults to 0.
ID [id-string]
By default MapServer generates a unique session id based on system time and process id. This parameter overwrites the default.
IMG

The name associated with the inline map image used to record user clicks. What actually is passed are two variables, img.x and img.y.

For the CGI Applications this is an essential variable, see the examples for sample usage.

IMGBOX [x1] [y1] [x2] [y2]
Coordinates (in pixels) of a box drag in the image. Most often used in conjunction with Java based front ends to the MapServer.
IMGEXT [minx] [miny] [maxx] [maxy]
The spatial extent of the existing inline image, that is, the image the users can see in their browser.
IMGSHAPE [x1 y1 x2 y2 x3 y3 ...] | [WKT]

An arbitrary polygon shape (specified using image coordinates) to be used for query purposes.

The polygon is specified by listing its coordinates (multiple instances simply add parts to the shape so it is possible to construct a shape with holes) or by specifying the WKT (Well Known Text) representation.

Used with the NQUERY mode.

IMGSIZE [cols] [rows]
The size (in pixels) of the exiting inline image.
IMGXY [x] [y]
Coordinates (in pixels) of a single mouse click. Used most often in conjunction with Java based front ends to the MapServer.
LAYER [name]
The name of a layer as it appears in the map file. Sending mapserv a layer name sets that layer’s STATUS to ON.
LAYERS [name name ...]

The names of the layers to be turned on. Layer names must be separated by spaces.

Version 4.4 and above: passing ‘LAYERS=all’ will automatically turn on all layers.

MAP [filename]
Path, relative to the CGI directory, of the map file to be used.
MAPEXT [minx] [miny] [maxx] [maxy] , MAPEXT (shape)

The spatial extent of the map to be created.

Can be set to shape as an alternative option. In this case mapextent is set to the extent of a selected shape. Used with queries.

MAPSHAPE [x1 y1 x2 y2 x3 y3 ...] | [WKT]

An arbitrary polygon shape (specified using map coordinates) to be used for query purposes.

The polygon is specified by listing its coordinates (multiple instances simply add parts to the shape so it is possible to construct a shape with holes) or by specifying a WKT (Well Known Text) representation of the polygon.

Used with the NQUERY mode.

MAPSIZE [cols] [rows]
The size (in pixels) of the image to be created. Useful for allowing users to change the resolution of the output map dynamically.
MAPXY [x] [y] , MAPXY (shape)

A point, in the same coordinate system as the shapefiles, to be used in conjunction with a buffer or a scale to construct a map extent.

Can be set to shape as an alternative option. In this case mapextent is set to the extent of a selected shape. Used with queries.

MINX | MINY | MAXX | MAXY [number]
Minimum/Maximum x/y coordinate of the spatial extent for a new map/query. This set of parameters are the pieces of MAPEXT.
MODE [value]

Mode of operation. The following options are supported:

BROWSE
Fully interactive interface where maps (and interactive pages) are created. This is the default mode.
COORDINATE

Returns a string of map coordinates based on a user click on an image.

mapserv.exe?map=/mapfiles/gmap75.map&MODE=coordinate&IMGEXT=0 0 100 100&IMGXY=10 10
FEATURENQUERY
A spatial search that uses multiple features from SLAYER to query other layers.
FEATUREQUERY
A spatial search that uses one feature from SLAYER to query other layers.
INDEXQUERY
Looks up a feature based on the values of SHAPEINDEX and TILEINDEX parameters. SHAPEINDEX is required, TILEINDEX is optional and is only used with tiled shapefile layers.
ITEMFEATURENQUERY
A text search of attribute data is triggered using a QSTRING. Returns all matches. Layer to be searched is defined using slayer parameter. The results of this search are applied to other searchable layers (which can be limited using the QLAYER parameter).
ITEMFEATUREQUERY
A text search of attribute data is triggered using a QSTRING. Returns first match. Layer to be searched is defined using slayer parameter. The results of this search are applied to other searchable layers (which can be limited using the QLAYER parameter).
ITEMNQUERY
A text search of attribute data is triggered using a QSTRING. Returns all matches.
ITEMQUERY
A text search of attribute data is triggered using a layer QSTRING. Returns 1st match.
LEGEND
The created legend is returned. Used within an <img ... > tag.
LEGENDICON

A legend icon is returned. The ICON parameter must also be used to specify the layername and a class index. Class index value is optional and defaults to 0. For example:

mapserv.exe?map=/mapfiles/gmap75.map&MODE=legendicon&ICON=popplace,0
MAP
The created map is returned. Used within an <img ... > tag.
NQUERY
A spatial search (finds all) is triggered by a click in a map or by user-define selection box.
QUERY
A spatial search (finds closest) is triggered by a click in a map.
REFERENCE
The created reference map is returned. Used within an <img ... > tag.
SCALEBAR
The created scalebar is returned. Used within an <img ... > tag.
TILE
Generate a map tile. See Tile Mode for details.
ZOOMIN
Switch to mode BROWSE with ZOOMDIR=1
ZOOMOUT
Switch to mode BROWSE with ZOOMDIR=-1

Note

The previously available map-only query modes, e.g. ITEMQUERYMAP, are no longer supported. The QFORMAT parameter is now used instead.

QFORMAT [outputformat | mime/type] (optional)

The OUTPUTFORMAT name or mime/type to be used to process a set of query results (corresponds to the WEB object’s QUERYFORMAT parameter). The parameter is optional and used in conjunction with query MODEs. The default is text/html.

Example (map output):

...&mode=nquery&qformat=png24&...
QITEM [name] (optional)
The name of an attribute in a layer attribute table to query on. The parameter is optional and used in conjunction with the QSTRING for attribute queries.
QLAYER [name]
Query layer. The name of the layer to be queried as it appears in the map file.
QSTRING [expression]
Attribute queries: Query string passed to the query function. Since 5.0, qstring will have to be specified in the VALIDATION parameter of the LAYER for qstring queries to work (qstring_validation_pattern LAYER-level METADATA for MapServer versions prior to 5.4).
QUERYFILE [filename]
Used with BROWSE or NQUERY mode. This option identifies a query file to load before any regular processing. In BROWSE mode this result in a query map being produced instead of a regular map. This is useful when you want to hilite a feature while still in a pan/zoom mode. In NQUERY mode you’d gain access to any of the templates used in normally presenting the query, so you have access to query maps AND attribute information. See the SAVEQUERY option.
REF

The name associated with the inline reference map image used to record user clicks. What actually is passed are two variables, ref.x and ref.y.

For the CGI Applications this is an essential variable when reference maps are used, see the examples for sample usage.

REFXY [x] [y]
Coordinates (in pixels) of a single mouse click in the reference image. Used in conjunction with Java based front ends to the MapServer.
SAVEQUERY
When used with any of the query modes this tells the MapServer to save the query results to a temporary file for use in subsequent operations (see QUERYFILE). Useful for making queries persistent.
SCALEDENOM [number]
Scale to create a new map at. Used with mapxy. Scale is given as the denominator of the actual scale fraction, for example for a map at a scale of 1:24,000 use 24000. Implemented in MapServer 5.0, to replace the deprecated SCALE parameter.
SCALE [number] - deprecated
Since MapServer 5.0 the proper parameter to use is SCALEDENOM instead. The deprecated SCALE is the scale to create a new map at. Used with mapxy. Scale is given as the denominator of the actual scale fraction, for example for a map at a scale of 1:24,000 use 24000.
SEARCHMAP
It is possible to do pan/zoom interfaces using querymaps. In these cases you will likey want information about the contents of the new map rather than the previous map which is the normal way queries work. When searchmap is specified the new map is created and it’s extent is used to query layers. Useful with NQUERY mode only.
SHAPEINDEX [index]
Used for index queries (in conjunction with INDEXQUERY).
SLAYER [name]
Select layer. The name of the layer to be used for any of the feature (i.e. staged) query modes. The select layer must be a polygon layer. The selection feature(s) are available for presentation to the user.
TILEINDEX [index]
Used for index queries (in conjunction with INDEXQUERY), used with tiled shapefile layers.
ZOOM [number]

Zoom scaling to apply to the creation of the new map. Values greater than 0 resulting in zooming in, 0 is a pan, and values less than zero are for zooming out. A value of 2 means “zoom in twice”.

ZOOM can be used as a shortcut for the combination ZOOMDIR/ZOOMSIZE. The zoom is limited by the MINZOOM/MAXZOOM settings compiled into the MapServer (-25/25) by default.

ZOOMDIR [1 | 0 | -1]
Direction to zoom. See above.
ZOOMSIZE [number]

Absolute magnitude of a zoom. Used with ZOOMDIR.

ZOOMDIR is limited to MAXZOOM compiled into the MapServer (25 by default).

Changing map file parameters via a form or a URL

Beginning with version 3.3 it is possible to change virtually any map file value from a form or a URL (see Run-time Substitution). The syntax for this is fairly straightforward, and depends on what version of MapServer you are using. One potentially very powerful use of this ability to change mapfile parameters through a URL involves changing class expressions on-the-fly. VALIDATION is used to control run-time substition. Try it out.

Warning

This functionality is only available via the mapserv CGI application. Within MapScript this is easy to do by yourself since the developer has complete control over how input is handled.

Using MapServer version >= 5

Previous versions of the MapServer CGI program allowed certain parameters to be changed via a URL using a cumbersome syntax such as map_layer_0_class_0_color=255+0+0 which changes the color in one classObj. So, in the past you had to change parameters one-at-a-time. Now you can pass chunks of mapfiles (with security restrictions) to the CGI interface. The map_object notation is still necessary to identify which object you want to modify but you can change multiple properties at one time. Note that you can use either a ‘_’ or a ‘.’ to separate identifiers.

Example 1, changing a scalebar object:

...&map.scalebar=UNITS+MILES+COLOR+121+121+121+SIZE+300+2&...

Example 2, changing a presentation style:

...&map.layer[lakes].class[0].style[0]=SYMBOL+crosshatch+COLOR+151+51+151+SIZE+15&...

Example 3, creating a new feature:

...&map_layer[3]=FEATURE+POINTS+500000+1000000+END+TEXT+'A+test+point'+END&...

Example 4, set multiple web object parameters:

...&map_web=imagepath+/ms4w/tmp/ms_tmp/+imageurl+/ms_tmp/

Example 5, set the map size:

...&map_size=800+400

The variable identifies an object uniquely (by name or index in the case of layerObj’s and classObj’s). The value is a snippet of a mapfile. You cannot create new objects other than inline features at this point.

Using MapServer version < 5

For MapServer version < 5, any value can be expressed using the hierarchy used in a map file. A map contains a layer, which contains a class, which contains a label, which has a color. This hierarchy is expressed as a sequence of MapServer keywords separated by underscores. For example to change the color of a layer called “lakes” with only one class defined you would use a form variable named “map_lakes_class_color” and could assign it a color like “0 0 255”. Layers can be referenced by index (i.e. map_layer_0...) or by name as shown above. Layer classes are referenced by index value (i.e. map_layer_0_class_2). If there is only 1 class for a layer then the index should be omitted. These variables must always begin with the sequence “map_”. Values assigned must conform to the syntax of a map file.

It is also possible to define inline features using this mechanism. This is the only case where you can add on to the map file. You can edit/change layer parameters but you cannot create a new layer. With inline features you have to first create a feature and then build upon it, however, the layer the feature belongs to must exist. Here’s a snippet from a GET request that adds a feature to a webuser layer:

...&map_webuser_feature=new&map_webuser_feature_points=12345.6789+12345.6789
      &map_webuser_feature_text=My+House!&...

The “map_webuser_feature=new” creates a new feature for the webuser layer. All subsequent calls to the feature object for that layer will modify the new feature. You can repeat the process to create additional features. This is really intended for very small (point, rectangle) amounts of data.

Specifying the location of mapfiles using an Apache variable

Apache variables can be used to specify the location of map files (instead of exposing full mapfile paths to the outside world).

  1. Set the variable (in this example MY_MAPFILE) in Apache’s httpd.conf:

    SetEnv MY_MAPFILE "/opt/mapserver/map1/mymapfile.map"
    
  2. Refer to the variable in the mapserver CGI URL:

    http://localhost/cgi-bin/mapserv?map=MY_MAPFILE&mode=...
    

ROSA-Applet Controls

note: Active development and maintenance of the ROSA Applet has stopped

The ROSA Applet parameters were added to the CGI MapServer in version 3.6. This Java Applet provides a more intuitive user interface to MapServer. The MapTools site provides detailed information on the ROSA Applet.

The parameters can also be used by other interfaces/tools, if set to the right values. Please note that the two parameters have to be handed over to te CGI application in the order identified below.

INPUT_TYPE (auto_rect | auto_point)
The INPUT_TYPE parameter is needed to identify if the coordinates handed over to the mapserver have to be interpreted as rectangular or point data.
INPUT_COORD [minx,miny;maxx,maxy]
The ROSA-Applet always fills the pair of coordinates. In case of a point (input_type=auto_point) min and max coordinate are equal (MapServer uses the min value).