2.9. 在 Mapfile 中使用自定义样式¶
矢量数据可以分为三种类型:点、线和面。数据类型结构的简单性提供了表达的多样性。在MapServer中,可以设置各种尺寸的样式,例如点、线和曲面的颜色、大小(厚度)和透明度。
2.9.1. 点¶
使用的Mapfile为:
1MAP
2 IMAGETYPE "PNG"
3 EXTENT -180 -90 180 90
4 SIZE 600 300
5 SHAPEPATH "/gdata"
6 IMAGECOLOR 255 255 255
7 SYMBOL
8 NAME "circle"
9 TYPE ELLIPSE
10 FILLED TRUE
11 POINTS
12 10 10
13 END
14 END
15 LAYER
16 NAME "world-country"
17 DATA "wcountry.shp"
18 STATUS OFF
19 TYPE POLYGON
20 CLASS
21 NAME "The Upper Great Lakes States"
22 STYLE
23 COLOR 232 232 232
24 OUTLINECOLOR 32 32 32
25 END
26 END
27 END
28 LAYER
29 NAME "world-city"
30 DATA "world/cities.shp"
31 STATUS OFF
32 TYPE POINT
33 CLASS
34 NAME "cities"
35 SYMBOL "circle"
36 SIZE 6
37 COLOR 0 0 0
38 END
39 END
40END
2.9.2. 线条填充示例¶
使用的Mapfile为:
1MAP
2 IMAGETYPE "PNG"
3 EXTENT -180 -90 180 90
4 SIZE 600 300
5 SHAPEPATH "/gdata"
6 IMAGECOLOR 255 255 255
7 SYMBOL
8 NAME "hatch-test"
9 TYPE HATCH
10 END
11 LAYER
12 NAME "world-country"
13 DATA "wcountry.shp"
14 STATUS OFF
15 TYPE POLYGON
16 CLASS
17 NAME "The Upper Great Lakes States"
18 STYLE
19 SYMBOL "hatch-test"
20 COLOR 255 0 0
21 ANGLE 45
22 SIZE 10
23 WIDTH 3
24 END
25 END
26 END
27END
2.9.3. 圆形填充示例¶
使用的Mapfile为:
1MAP
2 IMAGETYPE "PNG"
3 EXTENT -180 -90 180 90
4 SIZE 600 300
5 SHAPEPATH "/gdata"
6 IMAGECOLOR 255 255 255
7 SYMBOL
8 NAME "circle"
9 TYPE ELLIPSE
10 FILLED TRUE
11 POINTS
12 1 1
13 END
14 END
15 LAYER
16 NAME "world-country"
17 DATA "wcountry.shp"
18 STATUS OFF
19 TYPE POLYGON
20 CLASS
21 NAME "The Upper Great Lakes States"
22 STYLE
23 SYMBOL "circle"
24 COLOR 255 0 0
25 ANGLE 45
26 SIZE 10
27 WIDTH 3
28 END
29 END
30 END
31END
2.9.4. 河水风貌¶
使用的Mapfile为:
1MAP
2 IMAGETYPE "PNG"
3 EXTENT -180 -90 180 90
4 SIZE 600 300
5 SHAPEPATH "/gdata"
6 IMAGECOLOR 255 255 255
7 FONTSET "../fonts/fonts.list"
8 WEB
9 METADATA
10 "wms_title" "WMS Demo Server"
11 "wms_onlineresource" "//webgis.cn/cgi-bin/mapserv?map=/owg/mfb1.map&"
12 "ows_onlineresource" "//webgis.cn/cgi-bin/mapserv?map=/owg/mfb1.map&"
13 "wms_srs" "EPSG:4269 EPSG:4326"
14 "wms_enable_request" "* !GetFeatureInfo"
15 END
16 END
17 PROJECTION
18 "init=epsg:4326"
19 END
20 LAYER
21 NAME "states_poly"
22 DATA "wcountry.shp"
23 STATUS OFF
24 TYPE POLYGON
25 LABELITEM "NAME"
26 CLASS
27 NAME "States"
28 STYLE
29 COLOR 232 232 232
30 END
31 END
32 END
33 LAYER
34 NAME "states_line"
35 DATA "wcountry.shp"
36 STATUS OFF
37 TYPE LINE
38 CLASS
39 NAME "State Boundary"
40 STYLE
41 COLOR 132 132 32
42 END
43 END
44 END
45 LAYER
46 NAME "wriver"
47 DATA "wriver.shp"
48 STATUS OFF
49 TYPE LINE
50 CLASS
51 NAME "World River"
52 STYLE
53 COLOR 0 0 255
54 END
55 END
56 END
57 LAYER
58 NAME "wroads"
59 DATA "wroads.shp"
60 STATUS OFF
61 TYPE LINE
62 CLASS
63 NAME "World Road"
64 STYLE
65 COLOR 100 100 100
66 WIDTH 1
67 LINECAP BUTT
68 PATTERN
69 10 5
70 5 10
71 END
72 END
73 END
74 END
75END
GepMap
可以进一步使用以获得放大效果: