更改地图的输出格式

查看示例

根据您选择的格式,图像可能不会显示在您的浏览器。如果链接无法显示在您的浏览器中,右键单击上图中,看一下 MapFile 中指定何种保存格式。

下面是本例中使用的Mapfile(xmfa8.map):

01 MAP
02     NAME "EX1.8_"
03     EXTENT 201621.496941 -294488.285333 1425518.020722 498254.511514
04     SIZE 400 300
05     IMAGECOLOR 255 255 255
06     SHAPEPATH "../data"
07     SYMBOLSET "../symbols/symbols35.sym"
08     FONTSET "../fonts/fonts.list"
09     IMAGETYPE "PNG24"
10     OUTPUTFORMAT
11         NAME "png"
12         DRIVER "GD/PNG"
13         MIMETYPE "image/png"
14         IMAGEMODE PC256
15         EXTENSION "png"
16     END
17     OUTPUTFORMAT
18         NAME "png24"
19         DRIVER "GD/PNG"
20         MIMETYPE "image/png"
21         IMAGEMODE RGBA
22         EXTENSION "png"
23     END
24     OUTPUTFORMAT
25         NAME "GTiff"
26         DRIVER "GDAL/GTiff"
27         MIMETYPE "image/tiff"
28         IMAGEMODE RGB
29         EXTENSION "tif"
30     END
31     OUTPUTFORMAT
32         NAME "AGG"
33         DRIVER "AGG/PNG"
34         IMAGEMODE RGB
35     END
36     OUTPUTFORMAT
37         NAME "AGGA"
38         DRIVER "AGG/PNG"
39         IMAGEMODE RGBA
40     END
41     OUTPUTFORMAT
42         NAME "AGGJ"
43         DRIVER "AGG/JPEG"
44         IMAGEMODE RGB
45     END
46     WEB
47         IMAGEPATH "/ms4w/tmp/ms_tmp/"
48         IMAGEURL "/ms_tmp/"
49     END
50     PROJECTION
51         "init=epsg:2163"
52     END
53     LAYER
54         NAME "states"
55         DATA "states_ugl"
56         STATUS OFF
57         TYPE POLYGON
58         PROJECTION
59             "init=epsg:4326"
60         END
61         CLASSITEM "CLASS"
62         CLASS
63             EXPRESSION "land"
64             STYLE
65                 SYMBOL 0
66                 COLOR 232 232 232
67             END
68         END
69     END
70     LAYER
71         NAME "modis"
72         DATA "raster/mod09a12003161_ugl_ll_8bit.tif"
73         STATUS OFF
74         TYPE RASTER
75         PROCESSING "BANDS=1,2,3"
76         OFFSITE 71 74 65
77         PROJECTION
78             "init=epsg:4326"
79         END
80     END
81     LAYER
82         NAME "modis_jpl"
83         TYPE RASTER
84         OFFSITE 0 0 0
85         STATUS OFF
86         CONNECTIONTYPE WMS
87         CONNECTION "http://wms.jpl.nasa.gov/wms.cgi?"
88         METADATA
89             "wms_srs" "EPSG:4326"
90             "wms_name" "modis"
91             "wms_server_version" "1.1.1"
92             "wms_format" "image/jpeg"
93         END
94         PROJECTION
95             "init=epsg:4326"
96         END
97     END
98     LAYER
99         NAME "states"
100         DATA "states_ugl"
101         STATUS OFF
102         TYPE LINE
103         PROJECTION
104             "init=epsg:4326"
105         END
106         CLASSITEM "CLASS"
107         CLASS
108             EXPRESSION "land"
109             STYLE
110                 COLOR 32 32 32
111             END
112         END
113     END
114     LAYER
115         NAME "states"
116         DATA "states_ugl"
117         STATUS OFF
118         TYPE POLYGON
119         PROJECTION
120             "init=epsg:4326"
121         END
122         CLASSITEM "CLASS"
123         LABELITEM "STATE"
124         CLASS
125             EXPRESSION "land"
126             STYLE
127                 COLOR -1 -1 -1
128             END
129             LABEL
130                 COLOR 255 255 255
131                 TYPE TRUETYPE
132                 FONT "arial-bold"
133                 SIZE 12
134                 ANTIALIAS TRUE
135                 POSITION CL
136                 PARTIALS FALSE
137                 MINDISTANCE 300
138                 BUFFER 4
139             END
140         END
141     END
142 END

文件变动如下:

f1MAPf1MAP
n2    IMAGETYPE "PNG24"n2    NAME "EX1.8_"
3    EXTENT 201621.496941 -294488.285333 1425518.020722 498254.5115143    EXTENT 201621.496941 -294488.285333 1425518.020722 498254.511514
4    SIZE 400 3004    SIZE 400 300
nn5    IMAGECOLOR 255 255 255
5    SHAPEPATH "../data"6    SHAPEPATH "../data"
7    FONTSET "../fonts/fonts.list"8    FONTSET "../fonts/fonts.list"
nn9    IMAGETYPE "PNG24"
10    OUTPUTFORMAT
11        NAME "png"
12        DRIVER "GD/PNG"
13        MIMETYPE "image/png"
14        IMAGEMODE PC256
15        EXTENSION "png"
16    END
17    OUTPUTFORMAT
18        NAME "png24"
19        DRIVER "GD/PNG"
20        MIMETYPE "image/png"
21        IMAGEMODE RGBA
22        EXTENSION "png"
23    END
24    OUTPUTFORMAT
25        NAME "GTiff"
26        DRIVER "GDAL/GTiff"
27        MIMETYPE "image/tiff"
28        IMAGEMODE RGB
29        EXTENSION "tif"
30    END
31    OUTPUTFORMAT
32        NAME "AGG"
33        DRIVER "AGG/PNG"
34        IMAGEMODE RGB
35    END
36    OUTPUTFORMAT
37        NAME "AGGA"
38        DRIVER "AGG/PNG"
39        IMAGEMODE RGBA
40    END
41    OUTPUTFORMAT
42        NAME "AGGJ"
43        DRIVER "AGG/JPEG"
44        IMAGEMODE RGB
45    END
46    WEB
47        IMAGEPATH "/ms4w/tmp/ms_tmp/"
48        IMAGEURL "/ms_tmp/"
49    END
8    PROJECTION50    PROJECTION
9        "init=epsg:2163"51        "init=epsg:2163"
n10    ENDn
11    WEB
12        IMAGEPATH "/ms4w/tmp/"
13        IMAGEURL "/tmp/"
14    END52    END
24        CLASS62        CLASS
n25            NAME "States"n
26            EXPRESSION "land"63            EXPRESSION "land"
27            STYLE64            STYLE
nn65                SYMBOL 0
28                COLOR 232 232 23266                COLOR 232 232 232
69        CLASS107        CLASS
n70            NAME "State Boundary"n
71            EXPRESSION "land"108            EXPRESSION "land"
72            STYLE109            STYLE
n73                SYMBOL "line5"n
74                COLOR 32 32 32110                COLOR 32 32 32
n75                SIZE 1n
76            END111            END
79    LAYER114    LAYER
n80        NAME "states_label"n115        NAME "states"
81        DATA "states_ugl"116        DATA "states_ugl"
94            LABEL129            LABEL
n95                COLOR 132 31 31n
96                SHADOWCOLOR 218 218 218130                COLOR 255 255 255
97                SHADOWSIZE 1 1
98                TYPE TRUETYPE131                TYPE TRUETYPE
103                PARTIALS FALSE136                PARTIALS FALSE
t104                MINDISTANCE 200t137                MINDISTANCE 300
105                BUFFER 4138                BUFFER 4

现在我们的 MapFile 包含一个新对象 OUTPUTFORMAT 。此对象定义的 MAP 对象内,和在与关键字 IMAGETYPE 一起使用。根据MapServer的编译的库,你可以有多种输出格式选择 - GD库提供 PNG (8 - 位和24位),GIFJPEGWBMP,GDAL库,源许多MapServer的输入格式,也可以提供输出 PNGJPEGTIFF/GeoTIFF 的,和其他栅格格式;pdflib 库提供PDF输出。

有看看通过更改关键字 IMAGETYPE 你MAPFILE的对象和实验 OUTPUTFORMAT 。应该被用作你 IMAGETYPE 的值(例如: IMAGETYPE pngPNG24 IMAGETYPE ),输出格式的名称。

请咨询的 OUTPUTFORMAT 对象引用:

http://www.mapserver.org/mapfile/outputformat.html#outputformat