GIS and the Internet - University of Minnesota
Download
Report
Transcript GIS and the Internet - University of Minnesota
GIS and the Internet
MapServer Application Development
Web Browse Applications
Web Object
WEB
IMAGEPATH path
IMAGEURL url
TEMPLATE file|url
MINSCALEDENOM n (MAXSCALEDENOM)
MINTEMPATE file|url (MAXTEMPLATE)
ERROR
url
EMPTY
url
HEADER
file
FOOTER
file
END
MapServer Templates...
• Defined in the Web Object
• Can be HTML files or fully qualified URLs
• HTML files can contain anything including
Javascript or Java
• File templates names must end with
.html/.html/.xml/.wml
• Substitutions in URL templates are escaped,
this is not the case with file templates
…MapServer Templates
• Substitution strings delinitiated by [ ]’s
• Substitutions are case sensitive
• Escaped versions are retrieved by
appending _esc to the parameter [foo_esc]
• Any parameter passed into the server can be
retrieved, that is a variable named foo can
be retrieved in template using [foo]
Zooming
• Use zoom: factors from -25 to 25
• Use zoomsize/zoomdir in combination
– zoomsize: factors from 1 to 25
– zoomdir: -1, 0 or 1
• Panning default (zoom = 0/1, zoomdir = 0)
Panning
You can create pan tools
(images or text) by
simulating mouse clicks
outside the image. See
IMGXY parameter in the
online MapServer CGI
reference.
(0,0)
Image
Maintaining State
• Pass thru CGI vars
• Layer and zoom replacement strings
Examples:
• Javascript
[name_select|check]
[zoom_n_select|check]
[zoomdir_-1|0|1_select|check]
Web Query Applications
Many Modes of MapServer
• All queries are accompanied by a mode
change: query, nquery and many others
• Extension of a pan/zoom interface, that is,
same form variables are used
• Queries allow you to get at the attributes for
a feature(s) and present them via templates
Extension to Layer/Class Objects
CLASS
...
TEMPLATE file|url
END
LAYER
...
HEADER file
FOOTER file
TEMPLATE file|url
END
Query Mode
• Single result is sought in one or more layers
(restrict query using qlayer)
• Uses point input
• Uses layer TOLERANCE to determine
success or failure for each feature
• Single template return, as defined in the
layer or class object
nQuery Mode...
• Multiple results are sought in one or more
layers (restrict query using qlayer)
• Uses point or area of interest input
• Uses layer TOLERANCE to determine
success or failure for each feature
• multiple template return, as defined in
several places in the map file
…nQuery Mode
Template parsing sequence:
1) header (web object)
2) layer header (layer object)
3) query template (query object)
-- repeat 3) for each feature --
4) layer footer (layer object)
-- repeat 2) to 4) for each layer --
5) footer (web object)
Query Templates
• Identical to browse templates in concept
• Add substitutions for attribute values, syntax is
[ITEMNAME] and is case sensitive
• Attributes are HTML-escaped by default, […_raw]
and […_esc] versions are available
• Add substitutions for query result parameters (e.g.
number of results, number of layers)
• Access to shape parameters (e.g. bounding box or
centroid)
Escaping
Let’s say the column NAME contains ‘Lakes & Rivers’:
[NAME] outputs ‘Lakes & Rivers’
[NAME_esc] outputs ‘Lakes%20%26%20Rivers’
[NAME_raw] outputs ‘Lakes & Rivers’
Other Query Modes
• ItemQuery - identify features based on
attribute values (datasource specific)
• Feature{n}Query - identify polygon
features to use to select against other layers
• ItemFeature{n}Query - identify polygons
using attributes to use against other layers
• IndexQuery - pull features based on a
unique id value (not an attribute)
Query Maps
• Allow visualization of query results
QUERYMAP
COLOR r g b
STATUS ON|OFF
SIZE x y
STYLE HILITE|SELECTED|NORMAL
END
Cached Queries
• Performing query operations can be *very*
expensive. It’s possible to cache (i.e. save) a
query for future use.
• Set CGI variable “savequery”, creates a .qy
file in the temporary directory.
• Retrieve query using CGI variable
“queryfile” and process as if the query was
done from scratch.