MapServer6.4.1教程学习--改变地图输出格式(1-8)

示例1.8改变地图输出格式

(http://www.mapserver.org/tutorial/example1-8.html#example1-8)


基于你选择的格式,图像在浏览器上可能显示不出来。如果浏览器链接失败,右键单击上图然后将它保存为mapfile中指定的任何格式。

MapFile

下面是示例1-8的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

  NAME           EX1.8_

  EXTENT         201621.496941 -294488.2853331425518.020722 498254.511514 # LAEA

  #EXTENT         -97.5 41.619778 -82.122902 49.38562 #Geographic

  SIZE           400 300

  IMAGECOLOR     255 255 255

  SHAPEPATH      "../data"

  SYMBOLSET      "../symbols/symbols35.sym"

  FONTSET        "../fonts/fonts.list"

 

  IMAGETYPE PNG

 

  OUTPUTFORMAT

    NAME pnggd

    DRIVER "GD/PNG"

    MIMETYPE "image/png"

    IMAGEMODE PC256

    EXTENSION "png"

  END

  OUTPUTFORMAT

    NAME pnggd24

    DRIVER "GD/PNG"

    MIMETYPE "image/png"

    IMAGEMODE RGBA

    EXTENSION "png"

  END

  OUTPUTFORMAT

    NAME jpeggd

    DRIVER "GD/JPEG"

    FORMATOPTION "QUALITY=75"

    MIMETYPE "image/jpeg"

    IMAGEMODE RGB

    EXTENSION "jpg"

  END

  OUTPUTFORMAT

    NAME GTiff

    DRIVER "GDAL/GTiff"

    MIMETYPE "image/tiff"

    IMAGEMODE RGB

    EXTENSION"tif"

  END

  #OUTPUTFORMAT

  # NAME pdf

  # MIMETYPE "application/x-pdf"

  # DRIVER cairo/pdf

  # #FORMATOPTION "OUTPUT_TYPE=RASTER" # not mandatory but neededfor WMS layer

  #END

  OUTPUTFORMAT

    NAME AGG

    DRIVER "AGG/PNG"

    IMAGEMODE RGB

  END

  OUTPUTFORMAT

    NAME AGGA

    DRIVER "AGG/PNG"

    IMAGEMODE RGBA

  END

  OUTPUTFORMAT

    NAME AGGJ

    DRIVER "AGG/JPEG"

    IMAGEMODE RGB

  END

 

  # The web object is defined at the levelbelow the map object.  All

  # web-related parameters (I interchange"parameters" and "keyword/value

  # pairs" quite frequently, sorryabout that) are defined in this object.

  WEB

    IMAGEPATH '/ms4w/tmp/ms_tmp/'

    IMAGEURL  '/ms_tmp/'

  END

 

  # The projection object is typically usedwithin the map and the layer

  # objects. You only define it once withinthe map object and this definition

  # becomes your outputprojection--MapServer will render your maps in this

  # projection.  You also use the projection object within thelayer object to

  # define your input projection.  Your layers can be in different

  # projections--MapServer will reprojectthem into your output projection.

  # If no projection is defined within thelayer object, MapServer assumes

  # your input projection is the same as youroutput projection.  This is not

  # a required object unless you're creatinga map file that supports one of

  # the OGC interoperability web servicesspecifications (WMS/WFS/WCS).

  #

  # This is the output PROJECTION definition------

  PROJECTION

    #Projection parameters can be defined in two ways...

    # This is the traditional Proj.4definition of Lambert Azimuthal Equal-Area

    # projection for the Continental U.S.

    # "proj=laea"

    # "ellps=clrk66"

    # "lat_0=45"

    # "lon_0=-100"

    #

    # Alternatively, you can specify an EPSGcode.

    # This is the EPSG code for LambertAzimuthal Equal-Area

    # projection for the U.S.

    "init=epsg:2163"

  END

 

  # Layer objects are defined beneath themap object.  You need at least one

  #layer defined in your map file before you can 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 specializedapplication to need more than 100 layers in

  # your application.

  #

  # Start of LAYER DEFINITIONS---------------------------------------------

  LAYER # States polygon layer beginshere

    NAME         states

    DATA         states_ugl

    STATUS       OFF

    TYPE         POLYGON

 

    # Here's an example of the inputprojection definition.

    # EPSG:4326 is code for geographic(latlong) projection

    # using the WGS84 datum.

    #

    # PROJECTION objects within the LAYERobject define the input

    # projection--this is the nativeprojection of your data.

    PROJECTION

      "init=epsg:4326"

    END

 

    # 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 bedifferent for each data format).  In this

    # example the shapefile states_ugl hasan associated database

    # (states_ugl.dbf) that contains anattribute called "CLASS".  Youwill be

    # using two values in the CLASSattribute to separate the classes (also

    # called themes) used in thislayer--land and water.  CLASSITEM is usedin

    # association with the EXPRESSIONparameter in the CLASS object.  Seebelow.

    CLASSITEM    "CLASS"

 

    # The class object is defined within thelayer object.  You can define as

    # many classes as you need but it isgood cartographic practice to limit

    # classes to 8 to 10 per layer. (Thereare also limits as with layers and

    # it's senseless to define more than tenon a "normal" layer.  There are

    # situations, however, where you mighthave to do it.)

    CLASS

      EXPRESSION 'land'

      STYLE

        SYMBOL     0

        COLOR      232 232 232

      END

    END

  END # States polygon layer ends here

 

  # In addition to vector data (shapefilesare vector data), MapServer supports

  # a host of raster formats.  In GIS world, one of the most common raster

  # formats is GeoTIFF, a TIFF image withgeospatial headers.  MapServer also

  # supports JPEG, PNG, GIF, and othercommon formats.  Other raster formats

  # supported by MapServer include ESRIArc/Info grid, HDF and HDF-EOS, NetCDF,

  # Generic raster binaries, OGC Web MapService (WMS) layers, etc.  Pretty much

  # any raster format you can think of isprobably supported, thanks to the

  # impressive Geospatial Data AbstractionLibrary (GDAL, pronounced "GOODALL"

  # or GOODLE?).  More information on GDAL is available athttp://www.gdal.org.

  #

  # MapServer 4.x can read and displaybitmapped (like GIFs), RGB/A (true

  # color), and multispectral (images withmore than 3 bands, like raw LandSat

  # images) rasters.

  LAYER # MODIS raster layer beginshere

    NAME         modis

    DATA        "raster/mod09a12003161_ugl_ll_8bit.tif"

    STATUS       OFF

    TYPE         RASTER

    PROCESSING   "BANDS=1,2,3"

    OFFSITE      71 74 65

 

    PROJECTION

      "init=epsg:4326"

    END

  END # MODIS raster layer ends here

 

  LAYER # MODIS WMS map from JPL

    NAME         modis_jpl

    TYPE         RASTER

    OFFSITE      0 0 0

    STATUS       OFF

    CONNECTIONTYPE WMS

    CONNECTION"http://wms.jpl.nasa.gov/wms.cgi?"

 

    METADATA

      "wms_srs" "EPSG:4326"

      "wms_name" "modis"

      "wms_server_version""1.1.1"

      "wms_format""image/jpeg"

    END

 

    PROJECTION

      "init=epsg:4326"

    END

  END # Modis WMS image ends here

 

  LAYER # States line layer beginshere

    NAME         states

    DATA         states_ugl

    STATUS       OFF

    TYPE         LINE

 

    PROJECTION

      "init=epsg:4326"

    END

 

    CLASSITEM    "CLASS"

    CLASS

      EXPRESSION 'land'

      STYLE

        #SYMBOL     'line1'

        COLOR      32 32 32

        #SIZE       1

      END

    END

  END # States line layer ends here

 

  LAYER # States label layer beginshere

    NAME         states

    DATA         states_ugl

    STATUS       OFF

    TYPE         ANNOTATION

 

    PROJECTION

      "init=epsg:4326"

    END

 

    CLASSITEM    "CLASS"

    LABELITEM    "STATE"

    CLASS

      EXPRESSION 'land'

      STYLE

        COLOR      -1 -1 -1

      END

      LABEL

        COLOR    255 255 255

        TYPE     TRUETYPE

        FONT     arial-bold

        SIZE     12

        ANTIALIAS    TRUE

        POSITION     CL

        PARTIALS     FALSE

        MINDISTANCE  300

        BUFFER       4

      END # end of label

            END # end of class

  END # States label layer ends here

  # End of LAYER DEFINITIONS-------------------------------

 

END # end of map file

 

OUTPUTFORMAT对象

Mapfile现有包含了一个新对象,OUTPUTFORMAT。这个对象在MAP对象中定义,与IMAGETYPE关键字结合使用。依据编译MapServer时选择的三方库,你可以有很多种输出格式选项。AGG库提供 PNG,PNG8和JPEG支持。GD库支持GIF。GDAL库,MapServer输入格式的来源,也支持输出PNG,JPEG,TIFF/GeoTIFF以及其他栅格格式。Cario库支持PDF,PNG和SVG的输出。仔细看看OUTPUTFORMAT对象然后改变mapfile文件中的IMAGETYPE关键字来体验一下。OUTPUT格式的名称必须用作IMAGETYPE值,如IMAGETYPEpng 或IMAGETYPE png24.

请参阅OUTPUTFORMAT对象手册(OUTPUTFORMATobject reference)。

 

PS:中文版权为asswclw所有,请尊重劳动成果,转载将注明出处。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值