MapServer6.4.1教程学习--显示图层内类别(1-3)
来源:互联网 发布:c语言中的完全数 编辑:程序博客网 时间:2024/05/20 19:28
示例1.3
显示层内类别
(http://www.mapserver.org/tutorial/example1-3.html#example1-3)
利用数据内非空间属性信息,我们可以生成一幅如下所示地图:
MapFile结构
下面是示例1.3的mapfile文件:
#The annotated map file (sort of)
#Created by Pericles S. Nacionales for the MapServer tutorial
#20050408
#
#MapServer map file uses the pound sign (#) to denote the start of a line
#comment--each line that needs to be commented has to be prepended with a"#".
#
#Map files begin with MAP keyword to signify the start of the map object.
#Well, the entire map file is THE map object. Enclosed between MAP and END
#at the very bottom of this map file, are keyword/value pairs and other
#objects.
MAP
IMAGETYPE PNG
EXTENT -97.238976 41.619778 -82.122902 49.385620
SIZE 400 300
SHAPEPATH "../data"
IMAGECOLOR 255 255 255
# Layer objects are defined beneath the mapobject. You need at least one
# layer defined in your map file before youcan display a map... You can
# define as many layers as you'd likealthough a limit is typically hard-coded
# in map.h in the MapServer source. The default limit is set at 100. You'd
# have to have a very specialized applicationto need more than 100 layers in
# your application.
# Start of LAYER DEFINITIONS---------------------------------------------
LAYER # States polygon layer begins here
NAME states_poly
DATA states_ugl
STATUS OFF
TYPE POLYGON
# CLASSITEM defines the non-spatialattribute that you will be using to
# separate a layer into classes. This attribute will be in the DBF file
# of your shapefile (it will be differentfor each data format). In this
# example the shapefile states_ugl has anassociated database
# (states_ugl.dbf) that contains anattribute called "CLASS". Youwill be
# using two values in the CLASS attributeto separate the classes (also
# called themes) used in this layer--landand water. CLASSITEM is used in
# association with the EXPRESSION parameterin the CLASS object. See below.
CLASSITEM "CLASS"
# The class object is defined within thelayer object. You can define as
# many classes as you need (well, there arelimits as with layers, but it's
# senseless to define more than ten on a"normal" layer. There are
# situations, however, where you might haveto do it.)
CLASS
NAME 'States'
EXPRESSION 'land' # Only polygons where"CLASS" = 'land' will be drawn.
# There are styles in a class, just likethere are classes in a layer,
# just like there are layers in amap. You can define multiple styles in
# a class just as you can define multipleclasses in a layer and multiple
# layers in a map.
STYLE
COLOR 232 232 232
END
END
CLASS
NAME 'Water'
EXPRESSION 'water' # Only polygons where"CLASS" = 'water' will be drawn.
STYLE
COLOR 198 198 255
END
END
END # States polygon layer ends here
LAYER # States line layer begins here
NAME states_line
DATA states_ugl
STATUS OFF
TYPE LINE
CLASSITEM "CLASS"
CLASS
NAME 'State Boundary'
EXPRESSION 'land'
STYLE
COLOR 32 32 32
END
END
END # States line layer ends here
# End of LAYER DEFINITIONS-------------------------------
END# All map files must come to an end just as all other things must come to.
Mapfile的对象结构如下所示:
MAP
(states_poly)LAYER----------|---------LAYER (states_line)
| |
(land)CLASS---|---CLASS (water) |-CLASS
| | |
STYLE-| |-STYLE |-STYLE
关键字:
Mapfile仍只有两个层,但是多边形层被拆分为两个不同类型。让我们看一看增加的参数:
CLASSITEM
这个关键字用来指定拆分类对象时用到的属性。此例中这个属性是”CLASS”.如果你打开这层shapefile文件关联的数据库文件,你就看发现这里面有一例(属性)是“CLASS”。
我们是如何知道要用哪个属性呢?shapefile文件的数据库记录是存在DBF文件里面的。你可以用Openoffice组织的Calc之类的电子表格软件,和QGIS,Thuban或ArcView之类的桌面GIS软件打开它。如果你的数据带有元数据(本应如此),你可以通过元数据文件来浏览属性信息。复习下示例1.1(Layer SRS WKT之后的最后几行显示了属性名称和类型),你也可以用ogrinfo工具来显示shapefile文件中的基本属性信息。
EXPRESSION
指定使用类中的哪个属性值。这是EXPRESSION最简单的形式。EXPRESSION在使用正则表达式或逻辑表达式后会比这个更加复杂。请查看mapfile参考手册中的Expressions看看你能够用EXPRESSION做些什么。
PS:中文版权为asswclw所有,请尊重劳动成果,转载将注明出处。
- MapServer6.4.1教程学习--显示图层内类别(1-3)
- MapServer6.4.1教程学习--单图层地图(1-1)
- MapServer6.4.1教程学习--标注地图(1-4)
- MapServer6.4.1教程学习--添加栅格图层(1-5)
- MapServer6.4.1教程学习--定义投影和范围(1-6)
- MapServer6.4.1教程学习--改变地图输出格式(1-8)
- MapServer6.4.1教程学习--包含二个图层的静态地图(1-2)
- MapServer6.4.1教程学习--添加OGC WMS图层(1-7)
- MapServer6.4.1教程学习--地图交互和浏览器模式(1-9)
- MapServer6.4.1教程学习--缩放和漫游控件(2-1)
- MapServer6.4.1教程学习--图层控制(2-2)
- MapServer6.4.1教程学习--CGI变量和用户接口(2-0)
- 学习CSS使用技巧教程(5)自定义类别
- ArcGIS教程:类别概率
- 分层显示类别层次
- 分层显示类别层次
- 显示规格类别
- CMFCRibbonBar 类别 显示 隐藏
- [1]C++智能指针详解
- 排序算法之插入排序
- Opencv2.4.9源码分析——MSER
- c# split函数使用
- javascript网页富文本编辑器:kindedit富文本编辑器插件的使用
- MapServer6.4.1教程学习--显示图层内类别(1-3)
- markdown常用语法总结
- openwrt代码框架
- 产品经理之原型范围
- MapServer6.4.1教程学习--标注地图(1-4)
- OpenCV学习笔记(四十六)——FAST特征点检测features2D
- EasyUI学习之RSSReader应用的学习笔记(一)
- 在openwrt平台,开发自己的模块
- MySql中的视图重写