GREATWALL : MapFileReference

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

MapFile? 参考手册 - MapServer 4.0



Jean-François Doyon
加拿大自然资源
地球科学部
加拿大遥感中心
GeoAccess?
<jdoyon@ccrs.nrcan.gc.ca>

参加中文翻译的人员列表:
火箭人 thegreatwall@email.com.cn


摘要
本文件是MapServer4?.0版的MapFile?文件语法参考手册。
本文最后一次更新于: 2003-07-02


目录
MapFile? 参考
说明
Map Object 地图对象
Label Object 标签对象
Layer Object 层对象
Class Object 类对象
Style Object 风格对象
Feature Object 特性对象
Legend Object 图例对象
QueryMap? Object 地图查询对象
Join Object 联接对象
Reference Map Object 基准图对象
Scalebar Object 比例尺对象
Web Object Web对象
Projection Object 投影对象
OutputFormat Object 输出格式对象
Variable Substitution 变量替代
Symbology Reference 符号表示法参考
Notes 说明
Syntax 语法
Examples 例子

MapFile? Reference MapFile? 参考



  MapFile?文件是Mapserver基本的配置机制。虽然很多选项可以通过web表单(CGI变量)来修改,与某个特定应用相关的所有对象都会在此文件中进行定义。

说明



· Mapfile文件不区分大小写。
· 含有非文字或数字符号的字符串,必须用引号括起来。一般情况下建议所有的字符串都用双引号括起来。
· 每个mapfile中最多包含50层。这个参数可以通过修改map.h文件中的MS_MAXLAYERS来修改,修改后需要重新编译。
· 文件的路径需要一个绝对路径,或一个以mapfile位置为基准的相对路径。另外,数据文件则以SHAPEPATH 为准给出相对关系。
· 文件内部是按层次分级的结构,Map对象是根对象,其他的所有对象都被归纳在里面。
· 注释标记是#。
· 属性通过下面的语法来指定:[属性名称]。注意方括号内的内容是大小写敏感的。一般情况下ESRL创建shapefile文件是用的都是大写(如dbf列的名称),而PostGIS一般用的是小写。
· MapServer正则表达式是通过操作系统c库来使用的。如果想了解在你的操作系统上如何并书写正则表达式,你需要读一下c库提供的文件。在Linux上,是GlibC?,你能读到"man 7 regex"… 这个man页在很多UNIX系统商业可以得到。因为这些RegEx?'s都是兼容POSIX标准的,他们在windows上也类似,所以windows用户可以试着在网上搜一下"man 7 regex"。



Map Object 地图对象



  定义MapFile?文件的主要对象,它支撑/制约了所有的其他对象(类似与"根")。 它定义了应用/地图的各种参数。

DATAPATTERN [regular expression] 数据模式 [正则表达式]
  定义一个正则表达式,以用于通过URL 请求改变DATA参数 (例如: map_layername_data=...). If a pattern doesn't exist then web users can't monkey with support files via URLs. This allows you to isolate one application from another if you desire, with the default operation being very conservative. 参见TEMPLATEPATTERN。

DEBUG
  打开地图对象进行调试。系统将产生详细的输出并送至标准错误输出(STDERR)或者MapServer日志文件(当Web对象中设置使用了LOG参数时)。

EXTENT [minx] [miny] [maxx] [maxy]
  被创建的地图的空间范围。 如果您不指定的话,mapserver将推断一个范围。

FONTSET [filename]
  要使用的字体文件的全名。

IMAGECOLOR [r] [g] [b]
Color to initialize the map with (i.e. background color). When transparency is enabled (TRANSPARENT ON) for the typical case of 8-bit pseudocolored map generation, this color will be marked as transparent in the output file palette. Any other map components drawn in this color will also be transparenct, so for map generation with transparency it is best to use an otherwise unused color as the background color.
初始化地图时的颜色(如:背景颜色)。 明确度被使成为可能(TRANSPARENT ON)适合典型箱那儿的8 一点儿代地图pseudocolored的, 这种颜色将被在输出文件调色板里标明为明晰。 吸进来这种颜色的任何其他地图组成部分也将是transparenct, 因此为有明确度的地图产生它适宜使用一种不这样未使用的颜色作为背景颜色。

IMAGEQUALITY [int]
Compression quality for JPEG output. This keyword is now deprecated in favour of using FORMATOPTION "QUALITY=n" in the OUTPUTFORMAT declaration.
  JPEG产量的压缩质量。 这关键字现在反对赞成使用FORMATOPTION"质量= n"在OUTPUTFORMAT 宣告内。

IMAGETYPE [gif|png|jpeg|wbmp|gtiff|swf|userdefined]
Output format to generate. See details in the OUTPUTFORMAT section for available formats. The name here must match the 'NAME' of a user defined or internally generated OUTPUTFORMAT section.
要产生的输出格式。 为可得到的形式看见在OUTPUTFORMAT 部分里的细节。 名字这里必须匹配确定或者内部产生OUTPUTFORMAT 部分的一个用户的'名字'。

INTERLACE [on|off]
Should output images be interlaced? Default is [on]. This keyword is now depcrecated in favour of using the FORMATOPTION "INTERLACE=ON" line in the OUTPUTFORMAT declaration.
  输出的图像是否需要交错?默认是[on]。

LAYER
  LAYER 对象开始标记。

LEGEND
  LEGEND 对象开始标记。

NAME [name]
  设定地图、比例尺、图例的文件名的前缀。这个前缀请不要很长。

PROJECTION
  PROJECTION 对象开始标记。

QUERYMAP
  QUERYMAP 对象开始标记。

REFERENCE
  REFERENCE MAP 对象开始标记。

RESOLUTION [int] 解析度
  设置每英寸输出像素值,仅影响比例计算,默认为72。

SCALE [double]
  地图的计算比例,常常由应用来设置。

SCALEBAR
  SCALEBAR对象开始标记。

SHAPEPATH [filename]
  Shapefiles存储目录的路径。There can be further subdirectories under SHAPEPATH.


SIZE [x][y]
  用像素表示的输出图片的大小(如地图)

STATUS [on|off]
  地图是激活的么?有时候你希望能关闭地图而仅希望用参考图或比例尺。

SYMBOLSET [filename]
  要使用的symbolset的文件全名。

SYMBOL
  SYMBOL 对象开始标记。

TEMPLATEPATTERN [regular expression]
This defines a regular expression to be applied to requests to change TEMPLATE parameters via URL requests (i.e. map_layername_template=...). If a pattern doesn't exist then web users can't monkey with support files via URLs. This allows you to isolate one application from another if you desire, with the default operation being very conservative. See also DATAPATTERN.
这确定一正规表达式被用于请求兑换参数通过URL 请求(即地图的模板 _ layername _ 模板= ...). 一图案不存在那时用户不能与支援文件通过URL 一起胡闹的网。 这允许你把一申请和如果你想要,随着默认操作非常保守的另一个隔离。 也看见DATAPATTERN。

TRANSPARENT [on|off] 透明
Should the background color for the maps be transparent. This flag is now deprecated in favour of declaring transparency within OUTPUTFORMAT declarations. Default is off. 地图的背景色是否透明。

UNITS[feet|inches|kilometers|meters|miles|dd] [英尺|英吋|公里|米|英里|dd]
Units of the map coordinates. Used for scalebar and scale computations.地图坐标的单位。用于比例尺和比例计算。

WEB
  WEB对象开始标记。


Label Object 标签对象



  这个对象是用来定义一个标签——一段用来注释特性的文字。同过使用TrueType?字体,标签也可以用来当作标记使用。

ANGLE [double] 角度 [双精度型]
  角度,用度数来表示,用来画标签,或者用AUTO属性,允许软件来计算角度,AUTO属性只对LINE层有效。

ANTIALIAS [true|false] 平滑
  文字是否要平滑? Note that this requires more available colors and results in slightly larger output images.

BACKGROUNDCOLOR [r] [g] [b]
  画一个背景框(如布告栏)的颜色. 默认是关闭(OFF)。

BACKGROUNDSHADOWCOLOR [r] [g] [b]
  画一个背景框(如布告栏)阴影的颜色. 默认是关闭(OFF)。

BACKGROUNDSHADOWSIZE [x][y]
  背景框需要偏移多少?默认是1。

BUFFER [integer]
Padding, in pixels, around labels. Useful for maintaining spacing around text to enhance readability. Available only for cached labels. Default is 0.

COLOR [r] [g] [b]
  文字的颜色。

FONT [name]
  标签所用的字体名(在FONTSET中定义的)。

FORCE [true|false]
Forces labels for a particular class on, regardless of collisions. Available only for cached labels. Default is false.

MAXSIZE [integer]
Maximum font size to use when scaling text (pixels). Default is 256.

MINDISTANCE [integer]
Minimum distance between duplicate labels. Given in pixels.

MINFEATURESIZE [integer|auto]
Minimum size a feature must be to be labeled. Given in pixels. For line data the overall length of the displayed line is used, for polygons features the smallest dimension of the bounding box is used. "Auto" keyword tells MapServer to only label features that are larger than their corresponding label. Available for cached labels only.

MINSIZE [integer]
Minimum font size to use when scaling text (pixels). Default is 4.

OFFSET [x][y]
Offset values for labels, relative to the lower left hand corner of the label and the label point. Given in pixels. In the case of rotated text specify the values as if all labels are horizontal and any rotation will be compensated for.

OUTLINECOLOR [r] [g] [b]
Color to draw a one pixel outline around the text.

PARTIALS [true|false]
Can text run off the edge of the map? Default is true.

POSITION [ul|uc|ur|cl|cc|cr|ll|lc|lr|auto]
Position of the label relative to the labeling point (layers only). First letter is "Y" position, second letter is "X" position. "Auto" tells MapServer to calculate a label position that will not interfere with other labels. With points and polygons, MapServer selects from the 8 outer positions (i.e. excluding cc). With lines, it only uses lc or uc, until it finds a position that doesn't collide with labels that have already been drawn. If all positions cause a conflict, then the label is not drawn (Unless the label's FORCE a parameter is set to "true"). "Auto" placement is only available with cached labels.

SHADOWCOLOR [r] [g] [b]
Color of drop shadow.

SHADOWSIZE [x][y]
Shadow offset in pixels.

SIZE [integer]|[tiny|small|medium|large|giant]
Text size. Use "integer" to give the size in pixels of your TrueType? font based label, or any of the other 5 listed keywords to bitmap fonts.

TYPE [bitmap|truetype]
Type of font to use. Generally bitmap fonts are faster to draw then TrueType? fonts. However, TrueType? fonts are scalable and available in a variety of faces. Be sure to set the FONT parameter if you select TrueType?.

WRAP [character]
Character that represents an end-of-line condition in label text, thus resulting in a multi-line label.


Layer Object



The most used object in a MapFile?, this one describes layers used to make up a map. Layers are drawn in their order of appearance in the MapFile? (first layer is at the bottom, last in on top).

CLASS
Signals the start of a CLASS object.

CLASSITEM [attribute]
Item name in attribute table to use for class lookups.

CONNECTION [string]
Database connection string to retrieve remote data.
An SDE connection string consists of a hostname, instance name, database name, username and password separated by commas.
A PostGIS connection string is basically a regular PostgreSQL connection string, it takes the form of "user=nobody password= dbname=dbname host=localhost port=5432"
An Oracle connection string: user/pass[@db]

CONNECTIONTYPE [local|sde|ogr|postgis|oraclespatial|wms]
Type of connection. Default is local. See additional documentation for any other type.

DATA [filename]|[sde parameters][postgis table/column][oracle table/column]
Full filename of the spatial data to process. No file extension is necessary for shapefiles. Can be specified relative to the SHAPEPATH option from the Map Object.
If this is an SDE layer, the parameter should include the name of the layer as well as the geometry column, i.e. "mylayer,shape".
If this is a PostGIS layer, the parameter should be in the form of "<columnname> from <tablename>", where "columnname" is the name of the column containing the geometry objects and "tablename" is the name of the table from which the geometry data will be read.
For Oracle, use "shape FROM table" or "shape FROM (SELECT statement)" or even more complex Oracle compliant queries! Note that there are important performance impacts when using spatial subqueries however. Try using MapServer's FILTER whenever possible instead. You can also see the SQL submitted by forcing an error, for instance by submitting a DATA parameter you know won't work, using for example a bad column name.

DEBUG
Enables debugging of the layer object. Verbose output is generated and sent to the standard error output (STDERR) or the MapServe? r logfile if one is set using the LOG parameter in the WEB object.


DUMP [true|false]
Switch to allow mapserver to return data in GML format. Usefull when used with WMS GetFeatureInfo? operations. "false" by default

FEATURE
Signals the start of a FEATURE object.

FILTER [string]
This parameter allows for data specific attribute filtering that is done at the same time spatial filtering is done, but before any CLASS expressions are evaluated. For OGR and shapefiles the string is simply a mapserver regular expression. For spatial databases the string is a SQL WHERE clause that is valid with respect to the underlying database.
For example: FILTER "type='road' and size <2"

FILTERITEM [attribute]
Item to use with simple FILTER expressions. OGR and shapefiles only.

FOOTER [filename]
Template to use after a layer's set of results have been sent. Multiresult query modes only.

GROUP [name]
Name of a group that this layer belongs to. The group name can then be reference as a regular layer name in the template files, allowing to do things like turning on and off a group of layers at once.

HEADER [filename]
Template to use before a layer's set of results have been sent. Multiresult query modes only.

LABELANGLEITEM [attribute]
Item name in attribute table to use for class annotation angles. Values should be in degrees.

LABELCACHE [on|off]
Specifies whether labels should be drawn as the features for this layer are drawn, or whether they should be cached and drawn after all layers have been drawn. Default is on. Label overlap removal, auto placement etc... are only available when the label cache is active.

LABELITEM [attribute]
Item name in attribute table to use for class annotation (i.e. labeling).

LABELMAXSCALE [double]
Maximum scale at which the layer is labeled.

LABELMINSCALE [double]
Minimum scale at which the layer is labeled.

LABELREQUIRES [expression]
Sets context for labeling this layer, for example:

LABELREQUIRES ([orthoquads] != 1)
means that this layer would NOT be labeled if a layer named "orthoquads" is on. The expression consists of a boolean expression based on the status of other layers, each [layer name] substring is replaced by a 0 or a 1 depending on that layers STATUS and then evaluated as normal. Logical operators AND and OR can be used.

LABELSIZEITEM [attribute]
Item name in attribute table to use for class annotation sizes. Values should be in pixels.

MAXFEATURES [integer]
Specifies the number of features that should be drawn for this layer in the CURRENT window. Has some interesting uses with annotation and with sorted data (i.e. lakes by area).

MAXSCALE [double]
Maximum scale at which this layer is drawn.

METADATA
This keyword allows for arbitrary data to be stored as name value pairs. This is used with OGC WMS to define things such as layer title. It can also allow more flexibility in creating templates, as anything you put in here will be accessible via template tags.

Example:

METADATA
title "My layer title"
author "Me!"
END

MINSCALE [double]
Minimum scale at which this layer is drawn.

NAME [string]
Short name for this layer. Limit is 20 characters. This name is the link between the mapfile and web interfaces that refer to this name. They must be identical. The name should be unique, unless one layer replaces another at different scales. Use the GROUP option to associate layers with each other.

OFFSITE [r] [g] [b]
Sets the color index to treat as transparent for raster layers.

POSTLABELCACHE [true|false]
Tells MapServer to render this layer after all labels in the cache have been drawn. Useful for adding neatlines and similar elements. Default is false.

PROCESSING [string]
Passes a processing directive to be used with this layer. The supported processing directives vary by layer type, and the underlying driver that processes them. Currently the SCALE,BANDS and DITHER directives are supported for raster layers processed via the GDAL driver. This is further explained in the Raster HOWTO.

Example:
PROCESSING "SCALE_1=AUTO"
PROCESSING "SCALE_2=AUTO"
PROCESSING "SCALE_3=AUTO"
PROCESSING "BANDS=3,2,1,4"

PROJECTION
Signals the start of a PROJECTION object.

REQUIRES [expression]
Sets context for displaying this layer (see LABELREQUIRES).

SIZEUNITS [pixels|feet|inches|kilometers|meters|miles|
Sets the unit of CLASS object SIZE values (default is pixels). Usefull for simulating buffering.

STATUS [on|off|default]
Sets the current status of the layer. Often modified by MapServer itself. Default turns the layer on permanently.

STYLEITEM [attribute]
Item to use for feature specific styling. This is *very* experimental and OGR only at the moment.

SYMBOLSCALE [double]
The scale at which symbols and/or text appear full size. This allows for dynamic scaling of objects based on the scale of the map. If not set then this layer will always appear at the same size. Scaling only takes place within the limits of MINSIZE and MAXSIZE as described above.

TEMPLATE [file|url]
Used as a global alternative to CLASS TEMPLATE

TILEINDEX [filename]
Full filename for the index or tile definition for this layer. Similar to an ArcInfo? library index, this shapefile contains polygon features for each tile. The item that contains the location of the tiled data is given using the TILEITEM parameter. If the DATA parameter contains a value then it is added to the end of the location. If DATA is empty then the location should contain the entire filename.

TILEITEM [attribute]
Item that contains the location of an individual tile, default is "location".

TOLERANCE [double]
Sensitivity for point based queries (i.e. via mouse and/or map coordinates). Given in TOLERANCEUNITS with a default of 3 pixels. To restrict polygon searches so that the point must occur in the polygon set the tolerance to zero.

TOLERANCEUNITS [pixels|feet|inches|kilometers|meters|miles|dd]
Units of the TOLERANCE value. Default is pixels.

TRANSPARENCY [integer]
Sets the transparency level of all classed pixels for a given layer. The value is a percentage (0-100) where 100 is opaque and 0 is fully transparent.

TRANSFORM [true|false]
Tells MapServer whether or not a particular layer needs to be transformed from some coordinate system to image coordinates. Default is true. This allows you to create shapefiles in image/graphics coordinates and therefore have features that will always be displayed in the same location on every map. Ideal for placing logos or text in maps. Remember that the graphics coordinate system has an origin in the upper left hand corner of the image, contrary to most map coordinate systems.

TYPE [point|line|polygon|circle|annotation|raster|query]
Specifies how the data should be drawn. Need not be the same as the shapefile type. For example, a polygon shapefile may be drawn as a point layer, but a point shapefile may not be drawn as a polygon layer. Common sense rules. Annotation means that a label point will be calculated for the features, but the feature itself will not be drawn although a marker symbol can be optionally drawn. this allows for advanced labeling like numbered highway shields. Points are labeled at that point. Polygons are labeled first using a centroid, and if that doesn't fall in the polygon a scanline approach is used to guarantee the label falls within the feature. Lines are labeled at the middle of the longest arc in the visible portion of the line. Query only means the layer can be queried but not drawn.
In order to differentiate between POLYGONs and POLYLINEs (which do not exist as a type), simply respectively use or ommit the COLOR keyword when classifying. If you use it, it's a polygon with a fill color, otherwise it's a polyline with only an OUTLINECOLOR.
A circle must be defined by a a minimum bounding rectangle. That is, 2 points that define the smallest square that can contain it. These 2 points are the two opposite corners of said box.


Class Object



Defines thematic classes for a given layer and each layer must have at least one class. In cases with more than one class, membership is determined using attribute values and expressions. Starts with the keyword CLASS and terminates with the keyword END.

BACKGROUNDCOLOR [r] [g] [b]
Color to use for non-transparent symbols.

COLOR [r] [g] [b]
Color to use for drawing features.

DEBUG
Enables debugging of the class object. Verbose output is generated and sent to the standard error output (STDERR) or the MapServe? r logfile if one is set using the LOG parameter in the WEB object.

EXPRESSION [string]
Three types of expressions are now supported to define class membership. String comparisons, regular expressions, and simple logical expressions. If no expression is given, then all features are said to belong to this class.
· String comparisons are case sensitive and are the fastest to evaluate. No special delimiters are necessary although string must be quoted if they contain special characters. (As a matter of good habit, it is recommended you quote all strings).
· Regular expressions function just like previous versions of MapServer. However, you must now delimit a regular expression using /regex/. No quotes should be used.
· Logical expressions allow you to build fairly complex tests based on one or more attributes and therefore are only available with shapefiles. Logical expressions are delimited by parentheses "(expression)". Attribute names are delimited by square brackets "[ATTRIBUTE]". These names are case sensitive and must match the items in the shapefile. For example: EXPRESSION ([POPULATION] > 50000 AND '[LANGUAGE]' eq 'FRENCH') ... The following logical operators are supported : =,>,<,<=,>=,=,or,and,lt,gt,ge,le,eq. As you might expect this level of complexity is slower to process.
String comparisons and regular expressions work from the classitem defined at the layer level. You may mix expression types within the different classes of a layer.

JOIN
Signals the start of a JOIN object.

LABEL
Signals the start of a LABEL object.

MAXSIZE [integer]
Maximum size in pixels to draw a symbol. Default is 50.

MINSIZE [integer]
Minimum size in pixels to draw a symbol. Default is 0.

NAME [string]
Name to use in legends for this class. If not set class won't show up in legend.

OUTLINECOLOR [r] [g] [b]
Color to use for outlining polygons and certain marker symbols. Line symbols do not support outline colors.

SIZE [integer]
Height, in pixels, of the symbol/pattern to be used. Only useful with scalable symbols. Default is 1.

STYLE
Signals the start of a STYLE object. A class can contain multiple styles.

SYMBOL [integer|string]
The symbol name or number to use for all features if attribute tables are not used. The number is the index of the symbol in the symbol file, starting at 1, the 5th symbol in the file is therefore symbol number 5. You can also give your symbols names using the NAME keyword in the symbol definition file, and use those to refer to them. Default is 0, which results in a single pixel, single width line, or solid polygon fill, depending on layer type.

TEMPLATE [filename]
Template file or URL to use in presenting query results to the user.

TEXT [string]
Static text to label features in this class with. This overrides values obtained from the LABELTIEM. The string may be given as an expression delimited using the ()'s. This allows you to concatenate multiple attributes into a single label. For example: ([FIRSTNAME],[LASTNAME]).
You can also "stack" 2 symbols to achieve interesting effects. You define the second symbol, which effectively sits "on top" of the symbol normally defined above.

The following parameters allow you to define the symbol, and they are equivalent to their non-overlay counterparts:
· OVERLAYBACKGROUNDCOLOR
· OVERLAYCOLOR
· OVERLAYOUTLINECOLOR
· OVERLAYSIZE
· OVERLAYMINSIZE
· OVERLAYMAXSIZE
· OVERLAYSYMBOL


Style Object



This object holds parameters for symbolization. Multiple styles may be applied within a class. This object is new in 4.0 and is intended to seperate logic from looks. The final intent is to have named styles (Not yet supported) that will be re-usable through the mapfile. This is the new, preferred way of defining the appearance of an object, notably a class.

ANTIALIAS [true|false]
Should TrueType? fonts be antialiased.

BACKGROUNDCOLOR [r] [g] [b]
Color to use for non-transparent symbols.

COLOR [r] [g] [b]
Color to use for drawing features.

MAXSIZE [integer]
Maximum size in pixels to draw a symbol. Default is 50.

MINSIZE [integer]
Minimum size in pixels to draw a symbol. Default is 0.

OFFSET [x][y]
Offset values for shadows, hollow symbols, etc ...

OUTLINECOLOR [r] [g] [b]
Color to use for outlining polygons and certain marker symbols. Line symbols do not support outline colors.

SIZE [integer]
Height, in pixels, of the symbol/pattern to be used. Only useful with scalable symbols. Default is 1.

SYMBOL [integer|string]
The symbol name or number to use for all features if attribute tables are not used. The number is the index of the symbol in the symbol file, starting at 1, the 5th symbol in the file is therefore symbol number 5. You can also give your symbols names using the NAME keyword in the symbol definition file, and use those to refer to them. Default is 0, which results in a single pixel, single width line, or solid polygon fill, depending on layer type.


Feature Object



Defines inline features. You can use inline features when it's not possible (or too much trouble) to create a shapefile. Inline features can also be built via urls or forms. Starts with the keyword FEATURE and terminates with the keyword END.
定义一个内嵌属性。当你不能创建一个shapefile或创建会有很多麻烦时,你可以使用一个内嵌属性。内嵌属性也能够通过url或表单创建。以关键词FEATURE开始,以END结束。

POINTS
A set of xy pairs terminated with an END, for example:
一组xy值,以END结尾,例如:
POINTS 1 1 50 50 1 50 1 1 END
Note that with POLYGON/POLYLINE layers POINTS must start and end with the same point (i.e. close the feature).
注意在POLYGON/POLYLINE 层中,POINTS必须以同一个点做为起止(例如:close the feature)。

TEXT [string]
String to use for labeling this feature.
用来标记特征的字符串。

Legend Object



Defines how a legend is to be built. Legend components are built automatically from class objects from individual layers. Starts with the keyword LEGEND and terminates with the keyword END. The size of the legend image is NOT known prior to creation so be careful not to hard-code width and height in the <IMG> tag in the template file.

IMAGECOLOR [r] [g] [b]
Color to initialize the legend with (i.e. the background).

INTERLACE [on|off]
Should the output image be interlaced? Default is [on]. This keyword is now depcrecated in favour of using the FORMATOPTION "INTERLACE=ON" line in the OUTPUTFORMAT declaration.

LABEL
Signals the start of a LABEL object

OUTLINECOLOR [r] [g] [b]
Color to use for outlining symbol key boxes.

POSITION [ul|uc|ur|ll|lc|lr]
Where to place an embedded legend in the map. Default is lr.

KEYSIZE [x][y]
Size of symbol key boxes in pixels. Default is 20 by 10.

KEYSPACING [x][y]
Spacing between symbol key boxes ([y]) and labels ([x]) in pixels. Default is 5 by 5.

POSTLABELCACHE [true|false]
Tells MapServer to render this legend after all labels in the cache have been drawn. Useful for adding neatlines and similar elements. Default is false.


STATUS [on|off|embed]
Is the legend image to be created.
是否创建图例图片。

TRANSPARENT [on|off]
Should the background color for the legend be transparent. This flag is now deprecated in favour of declaring transparency within OUTPUTFORMAT declarations. Default is off.
图例的背景色是否透明。默认是关闭。

QueryMap? Object



Defines a mechanism to map the results of a query. Starts with the keyword QUERYMAP and terminates with the keyword END.

COLOR [r] [g] [b]
Color in which features are highlighted. Default is yellow.

SIZE [x][y]
Size of the map in pixels. Defaults to the size defined in the map object.

STATUS [on|off]
Is the query map to be drawn ?

STYLE [normal|hilite|selected]
Sets how selected features are to be handled. Layers not queried are drawn as usual.
· Normal: Draws all features according to the settings for that layer.
· Hilite: Draws selected features using COLOR. Non-selected features are drawn normally.
· Selected: draws only the selected features normally.


Join Object



  定义一个特定的联接是如何操作的。以关键字JOIN开始并以关键字END结束。联接被一个查询对象定义。

FROM [item]
  Shapefile文件中的联接条目。

NAME [string]
  此联接的唯一名字。必须要有。

TABLE [file]
  要联接TO相应的Xbase文件名(DBF格式,必须一个完整的路径)

TEMPLATE [filename]
Template to use with one-to-many joins. The template is processed once for each record and can only contain substitutions for items in the joined table.
一对多联接使用的模版文件。

TO [item]
  表中被联接的条目

TYPE [multiple|single]
  联接类型,默认为单一联接,如一对一。


Reference Map Object 参考地图对象



Defines how reference maps are to be created. Starts with the keyword REFERENCE and terminates with the keyword END. Three types of reference maps are supported. The most common would be one showing the extent of a map in an interactive interface. It is also possible to request reference maps as part of a query. Point queries will generate an image with a marker (see below) placed at the query point. Region based queries will depict the extent of the area of interest. Finally, feature based queries will display the selection feature(s) used.
定义参考地图如何创建。以关键词REFERENCE开始并以END结束。支持三种类型的参考地图。一般

COLOR [r] [g] [b]
Color in which the reference box is drawn. Set any component to -1 for no fill. Default is red.

EXTENT [minx][miny][maxx][maxy]
The spatial extent of the base reference image.

IMAGE [filename]
Full filename of the base reference image. Must be a GIF image.

MARKER [integer|string]
Defines a symbol (from the symbol file) to use when the box becomes too small (see MINBOXSIZE and MAXBOXSIZE below). Uses a crosshair by default.

MARKERSIZE [integer]
Defines the size of the symbol to use instead of a box (see MARKER above).

MINBOXSIZE [integer]
If box is smaller than MINBOXSIZE (use box width or height) then use the symbol defined by MARKER and MARKERSIZE.

MAXBOXSIZE [integer]
If box is greater than MAXBOXSIZE (use box width or height) then draw nothing (Often the whole map gets covered when zoomed way out and it's perfectly obvious where you are).

OUTLINECOLOR [r] [g] [b]
Color to use for outlining the reference box. Set any component to -1 for no outline.

SIZE [x][y]
Size, in pixels, of the base reference image.

STATUS [on|off]
Is the reference map to be created? Default it off.


Scalebar Object



Defines how a scalebar should be built. Starts with the keyword SCALEBAR and terminates with the keyword END. Scalebars currently do not make use of TrueType? fonts. The size of the scalebar image is NOT known prior to rendering, so be careful not to hard-code width and height in the <IMG> tag in the template file. Future versions will make the image size available.

BACKGROUNDCOLOR [r] [g] [b]
Color to use for scalebar background, not the image background.

COLOR [r] [g] [b]
Color to use for drawing all features if attribute tables are not used.

IMAGECOLOR [r] [g] [b]
Color to initialize the scalebar with (i.e. background).

INTERLACE [true|false]
Should output images be interlaced? Default is [on]. This keyword is now depcrecated in favour of using the FORMATOPTION "INTERLACE=ON" line in the OUTPUTFORMAT declaration.

INTERVALS [integer]
Number of intervals to break the scalebar into. Default is 4.

LABEL
Signals the start of a LABEL object

OUTLINECOLOR [r] [g] [b]
Color to use for outlining individual intervals. Set any component to -1 for no outline which is the default.

POSITION [ul|uc|ur|ll|lc|lr]
Where to place an embedded scalebar in the image. Default is lr.

POSTLABELCACHE [true|false]
For use with embedded scalebars only. Tells the MapServer to embed the scalebar after all labels in the cache have been drawn. Default is false.

SIZE [x][y]
Size in pixels of the scalebar. Labeling is not taken into account.

STATUS [on|off|embed]
Is the scalebar image to be created, and if so should it be embedded into the image? Default is off. (Please note that embedding scalebars require that you define a markerset. In essence the scalebar becomes a custom marker that is handled just like any other annotation.)

STYLE [integer]
Chooses the scalebar style. Valid styles are 0 and 1.

TRANSPARENT [on|off]
Should the background color for the scalebar be transparent. This flag is now deprecated in favour of declaring transparency within OUTPUTFORMAT declarations. Default is off.

UNITS [feet|inches|kilometers|meters|miles]
Output scalebar units, default is miles. Used in conjunction with the map's units to develop the actual graphic. Note that decimal degrees are not valid scalebar units.


Web Object Web对象



Defines how a web interface will operate. Starts with the keyword WEB and terminates with the keyword END.
定义如何一个Web界面。以关键词WEB开始,END结束。

EMPTY [url]
URL to forward users to if a query fails. If not defined the value for ERROR is used
定义查询失败后跳转到的页面地址。如果没有定义这个url的话,ERROR(见下一条)将被使用。

ERROR [url]
URL to forward users to if an error occurs. Ugly old MapServer error messages will appear if this is not defined
如果出现错误,引导读者前往的页面地址。如果没有定义这一条的话,丑陋陈旧的MapServer错误信息将会出现。

FOOTER [filename]
Template to use AFTER anything else is sent. Multiresult query modes only.
所有内容输出后采用的模版。仅用于多结果查询模式。

HEADER [filename]
Template to use BEFORE everything else has been sent. Multiresult query modes only.
在一切被输出前使用的模版。仅用于多结果查询模式。

IMAGEPATH [path]
Path to the temporary directory fro writing temporary files and images. Must be writable by the user the web server is running as. Must end with a / or \ depending on your platform.
写临时文件和图片的临时目录路径。必须是web服务器的用户可写的。必须以“/”或“\”结尾。

IMAGEURL [path]
Base URL for IMAGEPATH. This is the URL that will take the web browser to IMAGEPATH to get the images.
IMAGEPATH的基准URL。这个URL将带领Web浏览器访问IMAGEPATH以正确显示图像。

LOG [filename]
File to log MapServer activity in. Must be writable by the user the web server is running as.
纪录MapServer行为的日志文件。必须是web服务器的用户可写的。

MAXSCALE [double]
Maximum scale at which this interface is valid. When a user requests a map at a bigger scale, MapServer automatically returns the map at this scale. This effectively prevents user from zooming too far out.

MAXTEMPLATE [file|url]
Template to be used if above the maximum scale for the app, useful for nesting apps.

METADATA
This keyword allows for arbitrary data to be stored as name value pairs. This is used with OGC WMS to define things such as layer title. It can also allow more flexibility in creating templates, as anything you put in here will be accessible via template tags.

Example:
METADATA
title "My layer title"
author "Me!"
END

MINSCALE [double]
Minimum scale at which this interface is valid. When a user reuqests a map at a smaller scale, MapServer automatically returns the map at this scale. This effectively prevents the user from zooming in too far.

MINTEMPLATE
Template to be used if above the minimum scale for the app, useful for nesting apps.

TEMPLATE [filename|url]
Template file or URL to use in presenting the results to the user in an interactive mode (i.e. map generates map and so on ... )


Projection Object 投影对象



To set up projections you must define two projection objects: one for the output image (In the MAP object) and one for each layer (In the LAYER objects) to be projected. Projection objects simply consist of a series of PROJ.4 keywords. Here is an example defining UTM zone 15, NAD83:
如要设置投影,你必须定义两种投影对象:一个是输出图像的投影(在MAP对象中),一个是每个图层的投影(在LAYER对象中)。投影对象由一系列PROJ.4关键词简单地构成。这里是一个定义UTM zone 15,NAD83的案例:

PROJECTION
"proj=utm"
"ellps=GRS80"
"zone=15"
"north"
"no_defs"
END
Geographic coordinates are defined as:
地理坐标被定义为:

PROJECTION
"proj=latlong"
END
See the PROJ.4 user guides for complete descriptions of supported projections and coordinate systems.
您可以查看PROJ.4用户手册以获得它所支持的投影与坐标体系的详细的资料。

提示:PROJ.4项目地址:External Linkhttp://www.remotesensing.org/proj/


Output Format Object



This section discusses how output formats are defined and selected.
A map file may have zero, one or more OUTPUTFORMAT object declarations, defining available output formats supported including formats like PNG, GIF, JPEG, GeoTIFF? and Flash (SWF).
If OUTPUTFORMAT sections declarations are not found in the map file, the following implicit declarations will be made. Only those for which support is compiled in will actually be available. The GeoTIFF? depends on building with GDAL support, and the Flash (SWF) depends on compiling with support for the MING library.

OUTPUTFORMAT
NAME gif
DRIVER "GD/GIF"
MIMETYPE "image/gif"
IMAGEMODE PC256
EXTENSION "gif"
END
OUTPUTFORMAT
NAME png
DRIVER "GD/PNG"
MIMETYPE "image/png"
IMAGEMODE PC256
EXTENSION "png"
END
OUTPUTFORMAT
NAME jpeg
DRIVER "GD/JPEG"
MIMETYPE "image/jpeg"
IMAGEMODE RGB
EXTENSION "jpg"
END
OUTPUTFORMAT
NAME wbmp
DRIVER "GD/WBMP"
MIMETYPE "image/wbmp"
IMAGEMODE PC256
EXTENSION "wbmp"
END
OUTPUTFORMAT
NAME swf
DRIVER "SWF"
MIMETYPE "application/x-shockwave-flash"
EXTENSION "swf"
IMAGEMODE PC256
FORMATOPTION "OUTPUT_MOVIE=SINGLE"
END
OUTPUTFORMAT
NAME GTiff
DRIVER "GDAL/GTiff"
MIMETYPE "image/tiff"
IMAGEMODE RGB
EXTENSION "tif"
END


NAME [name]
The name to use use in the IMAGETYPE keyword of the map file to select this output format.(optional)

DRIVER [name]
The name of the driver to use to generate this output format. Some driver names include the definition of the format if the driver supports multiple formats. For GD the possible driver names are "GD/Gif", "GD/PNG", "GD/WBMP" and "GD/JPEG". For flash the driver is just called "SWF". For output through GDAL the GDAL shortname for the format is appeneded, such as "GDAL/GTiff". Note that PNG, JPEG and GIF output can be generated with either GDAL or GD (GD is generally more efficient).(manditory)

IMAGEMODE [PC256/RGB/RGBA/INT16/FLOAT32]
Selects the imaging mode in which the output is generated. Does matter for non-raster formats like Flash. Not all formats support all combinations. For instance GD/GIF supports only PC256. (optional)
· PC256: Produced a pseudocolored result with up to 256 colors in the palette (traditional MapServer mode)
· RGB: Render in 24bit Red/Green/Blue mode. Supports all colors but does not support transparency.
· RGBA: Render in 32bit Red/Green/Blue/Alpha mode. Supports all colors, and alpha based transparency.
· INT16: Render one band of data in 16 bit integer depth. Only works for RASTER layers (through GDAL) and WMS layers currently.
· FLOAT32: Render one band of data in 32bit floating point depth. Only works for RASTER layers (through GDAL) and WMS layers currently.

MIMETYPE [type]
Provide the mime type to be used when returning results over the web. (optional)

EXTENSION [type]
Provide the extension to use when creating files of this type. (optional)

TRANSPARENT [ON/OFF]
Indicates whether transparency should be enabled for this format. Note that transparency does not work for IMAGEMODE RGB output. Not all formats support transparency (optional). When transparency is enabled for the typical case of 8-bit pseudocolored map generation, the IMAGECOLOR color will be marked as transparent in the output file palette. Any other map components drawn in this color will also be transparent, so for map generation with transparency it is best to use an otherwise unused color as the background color.

FORMATOPTION [option]
Provides a driver or format specific option. Zero or more FORMATOPTION statement may be present within a OUTPUTFORMAT declaration. (optional)
· GD/JPEG: The "QUALITY=n" option may be used to set the quality of jpeg produced (value from 0-100).
· GD/PNG: The "INTERLACE=[ON/OFF]" option may be used to turn interlacing on or off.
· GD/GIF: The "INTERLACE=[ON/OFF]" option may be used to turn interlacing on or off.
· GDAL/GTiff: Supports the TILED=YES, BLOCKXSIZE=n, BLOCKYSIZE=n, INTERLEAVE=[PIXEL/BAND] and COMPRESS=[NONE,PACKBITS,JPEG,LZW,DEFLATE] format specific options.
· GDAL/*: All FORMATOPTIONs are passed onto the GDAL create function. Options supported by GDAL are described in the detailed documentation for each GDAL format.
Variable Substitution
New in MapServer 4.0, variables can be substituted within mapfile parameter values. At this time, cookie and CGI parameter values are supported. This allows mapserver mapfiles to be aware of a user's cookies (Good for implementing security), or non-mapserver request parameters (Good for integrating with other systems).
Syntax: '%' + variable name + '%'
Example 1. Connecting securely to a Spatial Database
You want to map some senstitive data held in a PostGIS database. The username and password to be used for the database connection are held in 2 cookies previously set by a seperate authentication mechanism, "uid" and "passwd".
CONNECTION "user=%uid% password=%passwd% dbname=postgis"

Example 2. Handling temporary files
You have a user based discovery application that generates shapefiles and stores them in a user's home directory on the server. The "username" comes from a cookie, the "filename" comes from a request parameter.
DATA "/home/%username%/tempshp/%filename%"

This feature is only available in the CGI version of MapServer through a mapfile pre-processor. If you are using MapScript?, you will have to code the substitution logic into your application yourself (By writing your own pre-processor).


Symbology Reference符号表示法参考



This section explains how to work with and define symbology in MapServer.
这部分用来说明在MapServer中如何使用以及定义标记或符号。

说明


· 符号定义可以包含在主MapFile?文件中,或者更多情况下,放在一个单独的文件中。如果用单独的文件定义符号,需要在Map Object中用SYMBOLSET 关键词指定。如果你有多个应用同时在跑,建议用这种分离定义的方式以方便重复使用符号定义。
· MapServer中有3种主要的标记类型:里程碑、阴影设置与线条。
· 0标记一般是每类标记的极限情况。如点,0标记为一个单一的像素。若是阴影(如填充的多边形),0标记是一个实心填方。而对于线条来说,0标记是一个像素长的线条。
· 标记定义不含颜色信息,颜色信息在CLASS对象中定义。
· 每个文件最多可以定义64种标记。你可以通过编辑mapsymbol.h文件并改变MS_MAXSYMBOLS的值来修改该数值。

语法



ANTIALIAS [true|false] 平滑
  TrueType?是否应平滑显示。

CHARACTER [char]
Character used to reference a particular TrueType? font character. You'll need to figure out the mapping from the keyboard character to font character.

FILLED [true|false]
  设置标记或符号是否应该被用户定义的颜色(在CLASS对象中定义)填充满。For marker symbols, if OUTLINECOLOR was specified then the symbol is outlined with it.

FONT [string]
  要使用的TrueType?字体的名字,需在FONTSET中被定义。

GAP [int] 间距
  以像素为单位,定义标记间距,主要为TrueType?标记使用。

IMAGE [string]
  用来做标记或画笔的图片(GIF or PNG)。

NAME [string]
Alias for this font to be used in CLASS objects

POINTS [x y] [x y] ... END
Signifies the start of the definition of points that make up a vector symbol or that define the x and y radius of an ellipse symbol. The end of this section is signified with the keyword END. Coordinates are given in pixels and define the default size of the symbol before any scaling. You can create non-contiguous paths by inserting negative coordinates at the appropriate place. For ellipse symbols you provide a single point that defines the x and y radius of an ellipse. Circles are created when x and y are equal.

STYLE [num on] [num off] [num on] ... END
Defines a dash style or pattern.

TRANSPARENT [color index]
Sets a transparent color for the input GIF image for pixmap symbols, or determines whether all shade symbols should have a transparent background. For shade symbols it may be desirable to have background features "show through" a transparent hatching pattern, creating a more complex map. By default a symbol's background is the same as the parent image (i.e. color 0). This is user configurable.

TYPE [vector|ellipse|pixmap|truetype|simple]
· vector: a simple drawing is used to define the shape of the symbol.
· ellipse: radius values in the x and y directions define an ellipse.
· pixmap: a user supplied GIF image will be used as the symbol.
· truetype: TrueType? font to use as defined in the FONTSET.

例子



  这里有一些例子来说明在MapServer中有多种方式来创建标记。

Example 3. 虚线

SYMBOL
NAME 'dashed1'
TYPE ELLIPSE
POINTS 1 1 END
FILLED true
STYLE 10 5 5 10 END
END

  这个案例创建一条虚线:10 pixels on, 5 off, 5 on, 10 off ...

Example 4. TrueType? font marker symbol TrueType?字体标注记号

SYMBOL
NAME "natcap"
TYPE TRUETYPE
FONT geo
FILLED true
ANTIALIAS true
CHARACTER "r"
END
  这个标记是个星形,用来标记国家首都,因此叫那个名字。字体的名称在FONTSET 文件定义的范围内。编号114的变化,你可以在MS Windows的字符映射表中找出来或推出来。

Example 5. 矢量三角里程碑标记

SYMBOL
NAME "triangle"
TYPE vector
POINTS
0 4
2 0
4 4
0 4
END
END
This is fairly straight forward. Note that to have 3 sides you need 4 points, hence the first and last points are identical.

Example 6. Non-contiguous vector marker symbol (Cross)不相邻的矢量标记(十字交叉)

SYMBOL
NAME "cross"
TYPE vector
POINTS
2 0
2 4
-99 -99
0 2
4 2
END
END
This example draws a cross, that is 2 lines (vectors) that are not connected end-to-end (Like the triangle in the previous example). The negative values separate the two.

Example 7. 矢量圆标记

SYMBOL
NAME "circle"
TYPE ellipse
FILLED true
POINTS
1 1
END
END
  一个简单的充满的圆形。使用不对称的数值将给你一个椭圆。

Example 8. Downward diagonal fill 向下的斜纹填充

SYMBOL
NAME "downwarddiagonalfill"
TYPE vector
TRANSPARENT 0
POINTS
0 1
1 0
END
END
当前页面没有留言. [显示留言板]