+ All Categories
Home > Documents > Mapserver Intro

Mapserver Intro

Date post: 05-Apr-2018
Category:
Upload: olivia-sherlyta
View: 237 times
Download: 0 times
Share this document with a friend

of 30

Transcript
  • 8/2/2019 Mapserver Intro

    1/30

    GIS and the Internet

    Getting started with the

    UMN MapServer

  • 8/2/2019 Mapserver Intro

    2/30

    MapServer Origins

    Developed at UMN Remote Sensing Lab

    Funded by NASA Mission to Planet Earth

    Started as Arc/Info AML generation script

    Built on top of standard OpenSource

    projects like GD, Flex, Bison, FreeType,

    Proj.4 and libTIFF

  • 8/2/2019 Mapserver Intro

    3/30

    System Characteristics

    OpenSource software

    Implemented as a CGI program

    Written in ANSI C/C++

    Source distribution

    UNIX: autoconf and automake

    95/98/NT: VC++ makefiles

  • 8/2/2019 Mapserver Intro

    4/30

    Basic Functionality

    Map creation

    Map component (eg. legend, scalebar and

    reference map) automation

    Web application building

    Simple feature query

    Basic Demonstration Application

    http://maps.dnr.state.mn.us/mapserver_demos/workshop/http://maps.dnr.state.mn.us/mapserver_demos/workshop/
  • 8/2/2019 Mapserver Intro

    5/30

    Advanced Functionality ...

    On-the-fly projection (w/Proj.4)

    Feature annotation including scaling,

    rotation, outlines and drop shadows

    TrueType labels and symbols (w/FreeType)

    Feature classification- string comparision,

    regex and logical expressions

    Scale dependent display and query

  • 8/2/2019 Mapserver Intro

    6/30

    Advanced Functionality...

    Query by point, area or feature across

    multiple layers

    Quad-tree spatial indexing for shapefiles

    Support for tiled datasets (raster or vector)

    Label collision removal

    URL based configuration

  • 8/2/2019 Mapserver Intro

    7/30

    Advanced Functionality

    OpenGIS specification support for WMS,

    Context and WFS (partial)

    Programmatic access to underlying C API-

    MapScript (available for Perl, Python,

    Tk/Tcl, PHP and Java)

    24-bit output support, including GDAL-based output (e.g. GeoTIFF)

  • 8/2/2019 Mapserver Intro

    8/30

    Supported File Formats

    Vector Formats

    ESRI Shapefiles and SDE layers

    Inline vector features

    Database sources- SDE, Oracle Spatial, PostGIS

    Raster Formats (8-bit only)

    TIFF*/GeoTIFF

    EPPL7

    WMS

    Numerous additional formats via GDAL/OGR

    * indicates files that must be accompanied by an ESRI world file for georeferencing

    http://www.remotesensing.org/gdal/http://www.remotesensing.org/gdal/
  • 8/2/2019 Mapserver Intro

    9/30

    MapServer Output Formats

    varies based upon software build configuration

    image formats include GIF, PNG (8/24 bit),

    JPEG, WBMP, and GDAL vector formats include GML (via WMS/WFS

    or templates), PDF, SWF (Flash) and SVG

    (via templates) templates can be any text-based format

    (default is HTML)

  • 8/2/2019 Mapserver Intro

    10/30

    So, how does it work?

    Each application is configured using a textfile called a map file

    A user adds to the configuration using anHTML form (e.g. layers, area of interest)

    Program results are run through a series oftemplates depending on the application (e.g.data browse, feature query)

    And the process begins again

  • 8/2/2019 Mapserver Intro

    11/30

    How MapServer Works

    web server

    MapServer CGI

    HTTP

    spatialdata

    configfiles

    templatefiles

    HTTP

    MapServer application

  • 8/2/2019 Mapserver Intro

    12/30

    How MapServer Works

    MapServer CGI

    request (HTTP)

    response (HTTP)

    configfiles

    augment config with userinput via request (e.g.what layers and where)

    spatialdata

    create map componentsand/or execute a query,

    write components totemporary web space

    templatefiles

  • 8/2/2019 Mapserver Intro

    13/30

    System Installation

    Build from source

    Install mapserv(.exe) in CGI directory

    Create writable (by the user the web server

    runs as) temporary image store

    build your application

  • 8/2/2019 Mapserver Intro

    14/30

    Typical Application Layout

    test (whole application stored in one place)test.map file graphics (images used in application) symbols (symbol files and icons) fonts (font files and index list) data (GIS data)*.html (supporting HTML and templates)

    Map file is referred to using its full path relative to the

    location of the MapServer CGI binary.

  • 8/2/2019 Mapserver Intro

    15/30

    MapServer Map Files

    Text based, hierarchical

    Control all aspects of an application

    legends, scalebars, reference mapslayer definitions

    web template definitions

    simple one layer example

    http://terrasip.gis.umn.edu/projects/tutorial/example1-1.htmlhttp://terrasip.gis.umn.edu/projects/tutorial/example1-1.html
  • 8/2/2019 Mapserver Intro

    16/30

    Map File Caveats

    Case insensitive (with few exceptions)

    Paths for files are given relative to the map

    file location

    Strings must start with a letter and can

    contain a-z, A-Z, 0-9, - and _. All other

    strings must be quoted.

    Order of layers is significant - FIFO.

  • 8/2/2019 Mapserver Intro

    17/30

    Map Object

    MAP

    NAME application name

    STATUS ON|OFFIMAGECOLOR r g b

    UNITS METERS|FEET|INCHES|

    FONTSET filename

    SYMBOLSET filename

    SIZE x y

    Layers, Scalebar, Legend

    END

  • 8/2/2019 Mapserver Intro

    18/30

    Basic Layer Object

    LAYER

    NAME name

    GROUP name

    DATA filename

    STATUS ON|OFF|DEFAULT

    TYPE ANNOTATION|POINT|LINE|POLYGON|RASTER|QUERY

    MINSCALEDENOM n (MAXSCALEDENOM)

    CLASSITEM column nameCLASS parameters END

    LABELITEM column name

    END

  • 8/2/2019 Mapserver Intro

    19/30

    Basic Class Object

    CLASS

    NAME full name for legend

    EXPRESSION string

    STYLE parameters END

    LABEL parameters END

    TEXT string

    END

  • 8/2/2019 Mapserver Intro

    20/30

    Basic Style Object

    STYLE

    ANTIALIAS TRUE|FALSE

    BACKGROUNDCOLOR r g b

    COLOR r g b

    OFFSET dx dy

    OUTLINECOLOR r g b

    SIZE n

    SYMBOL n|nameEND

  • 8/2/2019 Mapserver Intro

    21/30

    Basic Label Object

    LABEL

    TYPE BITMAP|TRUETYPE

    FONT name

    COLOR r g bOUTLINECOLOR r g b

    SIZE n|TINY|SMALL|MEDIUM|LARGE|GIANT

    POSITION UL|CC|LR||AUTO

    ANGLE n|AUTOBUFFER n

    ANTIALIAS TRUE|FALSE

    END

  • 8/2/2019 Mapserver Intro

    22/30

    Legend Object

    LEGEND

    STATUS ON|OFF

    KEYSIZE x y

    KEYSPACING x y

    LABEL parameters END

    IMAGECOLOR r g b

    END

  • 8/2/2019 Mapserver Intro

    23/30

    Scalebar Object

    SCALEBAR

    STATUS ON|OFF

    STYLE 0|1

    INTERVALS nCOLOR r g b

    BACKGROUNDCOLOR r g b

    OUTLINECOLOR r g b

    UNITS KILOMETERS|MILES|METERS|

    LABEL parameters END

    IMAGECOLOR r g b

    END

  • 8/2/2019 Mapserver Intro

    24/30

    Reference Map Object

    REFERENCE

    STATUS ON|OFF

    SIZE x y

    EXTENT minx miny maxx maxy

    COLOR r g b

    OUTLINECOLOR r g b

    IMAGE filename

    END

  • 8/2/2019 Mapserver Intro

    25/30

    In a nut shell

    This is controlled bythe LAYER objects(and sub-objects),and a few MAP levelparameters like SIZEand EXTENT.

    These are controlled bythe SCALEBAR objectand its LABEL object.

    Controlled by theREFERENCE object.This is a template

    AFTER it has beenprocessed byMapServer andreturned to the users

    browser.

  • 8/2/2019 Mapserver Intro

    26/30

    Class Object Expressions

    Used to group features according to

    attribute table values

    Each layer can have multiple classes eachwith its own expression

    3 expression types supported: string, regex

    and logical (can mix and match)

    Order of classes is significant

  • 8/2/2019 Mapserver Intro

    27/30

    String Expressions

    Fastest to evaluate, based on pure equality

    Denote using quotes

    Case sensitive

    Attribute identified using CLASSITEM

    Examples: EXPRESSION ForestEXPRESSION 10

  • 8/2/2019 Mapserver Intro

    28/30

    Regular Expressions

    Fairly quick, advanced pattern matching

    Most useful with character data

    Denote using forward slashes

    Attribute identified using CLASSITEM

    Examples: EXPRESSION /[Ff]orest/EXPRESSION /hardwood|conifer/

    EXPRESSION /2{2}/

    EXPRESSION /./

  • 8/2/2019 Mapserver Intro

    29/30

    Logical Expressions...

    Slowest, but most flexible

    SQLlike syntax, can use multiple attributes

    Logical operators: eq, gt, lt, le, ge, ne, and, or

    Math operators: +, -, /, * and ^

    Grouping using ()s

    Strings must be qouted

    Denote using ()s

  • 8/2/2019 Mapserver Intro

    30/30

    [ ]s must be used to delineate attributes,

    this is case sensitive

    Use of CLASSITEM not required

    ...Logical Expressions

    Examples:

    EXPRESSION ([AREA] > 10000)

    EXPRESSION ([AREA]/[PERIMETER] ge .5)

    EXPRESSION ([NAME] eq St. Paul or [ID] != 10)


Recommended