GREATWALL : MapServerCGIReference

首页 :: 索引 :: 修订历史 :: 最新评论 :: 待建页面 :: 登陆/注册 你好,3.239.90.61

MapServer CGI Reference



原作:
Stephen Lime
Minnesota Department of Natural Resources
<steve.lime@dnr.state.mn.us>

Frank Koormann
Intevation GmbH?
<frank.koormann@intevation.de>

翻译人员列表:
火箭人

简介



这是一个介绍mapserv CGI 4.0版的参考文档

最新更新:2004-05-07



目录



MapServer - 文档:CGI参考
注意
更改
格式
CGI变量
ROSA-Applet specific
Changing map file parameters via a form or a URL


MapServer文档:CGI参考


Mapserv是MapServer包的CGI部分。它处理用户的输入,指挥图形的创建或完成查询。这个程序即可通过"GET"也可通过"POST"机制接受输入,它可以交互式使用,也可以制作为图形引擎。


注意:


变量名称不是大小写敏感的。

如果一个变量包含多个值(如:mapext),那么这些值需要用空格分开(或者其他分割符,当用GET机制时)

变量内容在被加载的时侯会被检查:数据格式是否正确?数据范围是否符合要求?

所有的CGI变量可以通过一个templete文件储存和引用。


更改


完成属性查询的新方法:不是通过设置层过滤,而是传递一个查询字符串(和随意的一个查询项)给查询功能。2个新的CGI参数QSTRING和QITEM已经加入MapServer以实现上述方法。

SAVEMAP被关闭:SAVEMAP功能被认为是不安全的,因为保存下来的文件可以被任何人读取。

TEMPLATE已经被移掉,因为map_web_template语法可以被用来改变一个template文件。Simplifies security maintenance by only having to deal with this option in a single place. Note that the TEMPLATEPATTERN of the mapfile has to be used to enable this feature.


格式


Mapserv接受以CGI变量形式的输入,详细见后。


CGI变量


BUFFER [distance]
一个间隔,和map文件采用相同的坐标系,与 MAPXY一起使用来创建一个新的地图范围;

ID [id-string]
默认情况下,MapServer基于系统的时间和线程id产生唯一的session id. 这个参数将覆盖默认值。

IMG
与内嵌地图图片相关的变量名字,用于记录用户点击,实际传递的是两个变量:img.x 和 img.y。

对于CGI程序来说,这个一个基本变量,请看样例。

IMGBOX [x1] [y1] [x2] [y2]
图片中被托拽的方形选区坐标(以像素为单位)。经常与Java前端联合使用。

IMGEXT [minx] [miny] [maxx] [maxy]
现有内嵌图片的空间范围,也就是说,用户在他的浏览器中看到的图片的范围。

IMGSHAPE [x1 y1 x2 y2 x3 y3 ...]
以图片坐标给出的形状。

一个任意的多边形被用来查询。

IMGSIZE [cols] [rows]
当前内嵌图象的尺寸(像素单位)

IMGXY [x] [y]
一次鼠标点击的坐标(像素单位)。经常用于MapServer与Java客户端联络。

LAYER [name]
图层(LAYER)的名称,需和Map文件中的名称一致。发送给mapserv一个图层的名字可以设置该图层的状态(STATUS)为开。

LAYERS [name name ...]
多个需要打开的图层的名字。这些图层的名字间以空格分隔。

MAP [filename]
被使用的map文件相对于CGI目录的路径。

MAPEXT [minx] [miny] [maxx] [maxy], MAPEXT (shape)
设置被创建的地图的空间范围。

或者也可以设置一个形状,在这种情况下,地图的范围被设为一个被选择的形状的范围。这个需要通过查询来使用。

MAPSIZE [cols] [rows]
被创建的图片大小(像素单位)。允许用户动态改变输出地图的分辨率。

MAPSHAPE [x1 y1 x2 y2 x3 y3 ...]
采用图片坐标系描绘的指定形状。

一个被用来查询而设置的任意多边形。很多场合下简单地用来增加某个形状,所以可以用来构建带空洞的形状。在NQUERY和NQUERYMAP模式下使用。

MAPXY [x] [y], MAPXY (shape)
一个点,与shape文件采用相同的坐标系,用来连接一个缓冲或一个比率尺以创建一个图片的范围。

可以用来设置一个形状做为一个替代操作。在这种情况下,地图的范围被设为一个被选择的形状的范围。这个需要通过查询来使用。

MINX | MINY | MAXX | MAXY [number]
一个地图或查询的范围的最小/最大坐标值。这一系列参数是MAPEXT的组成部份。

MODE [value]
操作的模式,下面是被支持的操作类型(注意,所有的查询模式也都支持只图模式,如ITEMQUERYMAP,??)

BROWSE
当地图创建后的完全交互的界面。默认的模式。

QUERY
由在一幅地图上进行点击而触发的空间搜索(查找最靠近的)。

NQUERY
由在一幅地图上进行点击或用户定义的选择框而触发的空间搜索(查找所有的)。


ITEMQUERY
通过使用一个图层QSTRING来对属性数据进行文本搜索。返回第一个匹配值。

ITEMNQUERY
使用QSTRING来对属性数据进行文本搜索。返回所有匹配值。

FEATUREQUERY
A spatial search that uses one feature from SLAYER to query other layers.


FEATURENQUERY
A spatial search that uses multiple features from SLAYER to query other layers.

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).

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).

MAP
返回创建的地图网址。请使用<img ... >Html语言标记配合显示地图。

REFERENCE
返回创建的参考图网址。请使用<img ... >Html语言标记配合显示地图。

SCALEBAR
返回创建的比例尺图片网址。请使用<img ... >Html语言标记配合显示地图。

LEGEND
返回创建的图例图片网址。请使用<img ... >Html语言标记配合显示地图。

ZOOMIN
使用ZOOMDIR=1转换成放大浏览模式

ZOOMOUT
使用ZOOMDIR=-1转换成缩小浏览模式

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.

COORDINATE
声明坐标系。

QLAYER [name]
查询图层。要被查询的图层的名称(需和在map文件中被定义名称一致)。如果没有定义的话,那么所有的图层将依次被检索。

QITEM [name] (optional)
被查询的那个图层的属性表中的某个属性的字段名称。

QSTRING [expression]
Attribute queries: Query string passed to the query function.

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.

SCALE [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.

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]
缩放比例,以创建新的地图。数值如果大于0,则放大;如果为0,则为平移;如果小于0,则为缩小。如果数值为2,就是放大2倍。

ZOOM可以被视为ZOOMDIR/ZOOMSIZE联合使用的一个快速方法。

缩放操作的倍率被由MapServer编译时确定的MINZOOM/MAXZOOM设置所限制,默认值为正负25。

ZOOMDIR [1 | 0 | -1]
设置是缩小还是放大。参见上面一条。

ZOOMSIZE [number]
一个缩放的绝对值。和ZOOMDIR一起使用。

ZOOMDIR被MAXZOOM限制,默认为25。

ROSA-Applet specific


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 DM Solutions OWT pages provide 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).


Changing map file parameters via a form or a URL


Begining with version 3.3 it is now possible to change virtually any map file value from a form or a URL. The syntax for this is fairly straight forward. 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 seperated 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 ommited. 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.

It's quite possible that we'll come up with some shortcuts for this processing, but until we know how useful this is to users this is it. One potentially very powerful use involves changing class expressions on-the-fly. Anyway, try it out.






Copyright (C) 1996-2000 Regents of the University of Minnesota.
明尼苏达大学董事会 版权所有 1996-2000

本文原始地址:
External Linkhttp://mapserver.gis.umn.edu/doc40/cgi-reference.html


 
当前页面没有留言. [显示留言板]