Web Mapping Course Notes

download Web Mapping Course Notes

of 15

Transcript of Web Mapping Course Notes

  • 8/13/2019 Web Mapping Course Notes

    1/15

    Web Mapping- Why? How?1. Why Web Mapping?

    2. Explanation of stack/structure

    3. Data

    4. Map serer

    !. WM"/W#"

    $. Mapping %&'

    (. )ataloging

    Why web mapping?

    Web is *the* communication medium of our time. It's becoming more and more a

    part of every day life. Maps are inherently the best way of visualising geospatial data.

    It's a knock-out combination.

    Web mapping is about more than google maps, mashups, or rcIM!. It's possible to

    build your own "stack" #more later$ and control every aspect of your mapping

    application, to build it all with standards-compliant software and file formats, without

    worrying about licensing, and without costing a penny #other than your time, and time

    *is* money$.

    What's a stack?

    %he "stack" is the set of components needed to make a web-mapping application. %he

    formal name for the stack is a !patial &ata Infrastructure, or !&I. In some packages,

    various #or all$ aspects of the stack!&I are merged into one application. It can,

    however, be easier to maintain a stack if you choose a modular approach and choose a

    dedicated piece of software for each aspect.

    The stack components:

    In simple terms there are three layers to the stack. %he first is your data, vector or

    raster, stored in a file system or database. %he second is the map server, which

    translates your data into web-compatible formats. %hese are then delivered to your

    map on your web page.

    Why do I need to know all of this?

    (ecause if you build your own web-based map you need to understand eachcomponent of the stack.

    #)inally$ the point of this afternoon's session

    I will e+plain the different levels of the stack and talk about some #not all$ of the key

    packages that drive each component. t the end, you will set up your own map server,

    connect to some data, and display it on a web page.

    Data:

    &ata comes in two main forms- vector and raster, as discussed in the earlier sessions.

    If you're going to display it online, you need to make sure that it is stored somewhere

    the web server can access it. %his means it must be in folders that the web server can

    readwrite, and if it's stored in a database you need to make sure that the database is

  • 8/13/2019 Web Mapping Course Notes

    2/15

    configured for web access. It is even more necessary to ensure that your data is

    "clean" #topologically sound and so on$ and has the correct metadata and coordinate

    systems. %hat is all your web server has to go on- it can't come and ask where or what

    something is. %he cataloguing component #discussed later$ may help with this side of

    things.

    Map server:

    In simple terms, a map server takes a reuest from a web page and returns some data.

    It interprets bounding bo+ reuests to decide how much data to return, and ensures

    that it is in the correct proection. %he two main options for map servers are minnesota

    mapserver #mapserver to it's friends$ and geoserver.

    Mapserver, in it's simplest form, is a cgi application that lives on a web server. It takes

    reuests in the form of parameters tacked on to the end of a /0, consults a te+t-

    based configuration file known as a map file, and returns data to the web server. It is

    very easy to install and use- binaries are available for Windows and Mac 1!2,

    packages are available for many linu+ distributions, and the source code is publically

    available.

    )or windows, it is possible to download a web server and mapserver setup pre-

    configured and ready to go with all the support files #mapserver uses a set of open

    source libraries and tools for dealing with spatial references and format

    readwriteconversion$. %his can be downloaded at httpmaptools.orgms3w.

    lternatively it can be installed on an e+isting web server, although it's now uite

    hard to find the separate components in windows form4

    1nce installed, you can test mapserver is running correctly by calling it from acommand prompt

    C:\path\to\mapserv.exe #or in this case varwwwcgi-binmapserv$ should return the

    following output "%his script can only be used to decode form results and should be

    initiated as a 56I process via a httpd server".

    %his is good4

    7ou can also check the version by running mapserv.e+e -v. %his will show you all the

    options mapserver was compiled with, including the input and output file formats, and

    the server options that it supports.

    )inally you can check mapserver from the web by runninghttp://localhost/cgi-bin/mapserv.exe?

    or in this case

    http://www.maths.lancs.ac.uk/cgi-bin/mapserv?

    If mapserver is set up correctly you should get a web page saying "8o uery

    information to decode. 9:/7;!%/I86 is set, but empty.", in other words,

    mapserver is working but hasn't been supplied with any information. 8ote the synta+

    of the web reuest- using uni+ it should say mapserv, rather than mapserv.e+e, but

    you always need the uestion mark.

  • 8/13/2019 Web Mapping Course Notes

    3/15

    s well as serving data in web-compatible formats, mapserver can also be used to

    create the map itself, so contains a lot of options for creating reference maps and scale

    bars that are not relevant when using it primarily to serve data.

    %he important part of any mapserver installation is the map file. %his is a plain-te+t

    configuration file that lists the components of the map as obects. !ome are optional,some are not. %hese are nested within the main M< obect, and all finish with an

    :8& statement. 5omment lines are marked with a = sign. 8ote that te+t within the

    map file is *not* case-sensitive4

    %he basic components are as follows

    Me and e+tent #includes one

    or more 07:/ obects$

    07:/- defines the individual layers or data sources within the map, including their

    name and type #polygon, point, line$ #includes one or more 50!! obects$

    50!!- defines the set of obects relating to the way the features will be rendered,

    such as whether they will be labelled #includes one or more !%70: obects$!%70:- defines how symbols will be rendered, such as the colour of dots or the

    thickness of lines.

    %hese work as follows

    My maps you create. Web !ervices allow you to deploy your geospatial data from

    a central source via a /0. /ather than having many copies of your data in diverse

    files and worrying about version control and access rights, you can keep one copy of

    your data in a central location and have everyone access it via a /0. :ven desktop

    gis clients can access web mapping services. %he most common ones for use with

    mapserver are WM! #web mapping service$ and W)! #web feature service$.

    WM" WM! allows you to share and access vector and raster data as an image. It is

    useful for sharing background mapping data, or in situations where you need a static

    image rather than something interactive. Maps are reuested with a 6:%Mes a single map into several layers. %his part of the code tells

    openlayers that this layer is to be a new WM! layer, and that it can be referred toelsewhere as "wms". 0ayers have several parameters that sit within the #$ brackets-

    these change depending on the type of layer you are creating. %he first in this case is

    the name that it will be referred to in the legend on the page, and the second is the

    address of the wms server- this then has it's own parameters such as the layer name as

    per the wms getcapabilities return.

    Step , (p'ple!: ositioning the Map

    map.>oom%oMa+:+tent#$R

  • 8/13/2019 Web Mapping Course Notes

    11/15

    %his code tells the map to >oom out to its ma+imum e+tent, which by default is the

    entire world. It is possible to set a different ma+imum e+tent as an option in the Map

    constructor.

    1pen0ayers maps need to be told what part of the world they should display before

    anything will appear on the page. 5alling map.>oom%oMa+:+tent#$ is one way to do

    this. lternative ways that offer more precision include using >oom%o:+tent#$ andset5enter#$.

    Step . (geen!: $oading the Map

    Pbody onloadL"init#$"Q

    In order to ensure that your document is ready, it is important to make sure that the

    entire page has been loaded before the script creating the map is e+ecuted.

    We ensure this by putting the map-creating code in a function that is only called when

    the pageYs PbodyQ element receives the onload event.

    ayers in more !etai"

    WMS $ayes (oltest1/html!

    WM! layer is created in 1pen0ayers with four arguments #the fourth one being

    optional$. %hese are as follows

    name S!tringT name for the layer

    url S!tringT (ase url for the WM!

    params S1bectT n obect with keyvalue pairs representing the 6etMap uery

    string parameters and parameter valuesoptions S1bectT ?ashtable of e+tra options to tag onto the layer

    %he parameters defined as SobectsT take several options and enclose them in ST

    brackets. t the very least these will include the list of layers to return from the wms

    var wms L new 1pen0ayers.0ayer.WM!#"8! 6lobal Mosaic",

    "httpwms.pl.nasa.govwms.cgi",

    Slayers "modis,global;mosaic"T$R

    8ote that the you can only have one base mapping layer in openlayers. (y default,

    WM! layers are baselayers, but if you don't want your layer to be a base layer you

    need to add the following

    Sis(ase0ayer falseT

    after the Slayers...T parameter. )urthermore, to set the background of your wms tiles

    to be transparent you need to add the following key-pair WI%?I8 the layers

    parameter

    S#layers ...$, transparent trueT

  • 8/13/2019 Web Mapping Course Notes

    12/15

    +ommecial $ayes (oltest%/html0 oltestwms/html!

    1pen0ayers provides support for 6oogle Maps, 7ahoo Maps, Zirtual :arth, and

    MultiMap, so these can be used as background mapping for your own layers. sing

    any of the commercial layers reuires a further parameter in the PscriptQ section of

    the code, to include their api key. %his needs to be on one line with no spaces.

    )urthermore, commercial layers use spherical mercator proection, which means thatlayers probably have to be reproected from their original coordinate system #say

    (ritish 8ational 6rid$ to overlay correctly.

    Phtml +mlnsL"httpwww.wF.orgBDDD+html"Q

    PheadQ

    9script src:http//*aps.google.co*/*aps?

    fileapi;a*p

  • 8/13/2019 Web Mapping Course Notes

    13/15

    var wms L new 1pen0ayers.0ayer.WM!#"laska",

    "httpwww.maths.lancs.ac.ukcgi-

    binmapservmapLwebhomecookBtest;wms.map",

    Slayers "alaska"T,

    S'is(ase0ayer' falseT$RJreproect trueN

    $R

    &on't forget to tell openlayers to load this layer at startup as well

    map.add0ayers#Usatellite, wmsV$R

    7ou can also set the initial e+tent of your map so that it doesn't show the whole world

    by default. It can be difficult to get the values for the e+tent that you want, but luckily

    with firebug it's easy. 1pen your )irebug console #5trl[!hift[0 or 5md[!hift[0

    depending on your 1!$. In the console tab, enter the following

    map.get:+tent#$Rmapget5enter#$

    Make a note of the values you get from these commands. %o set the map to centre on

    your new location at startup, add a second argument to the options variable

    *axExtent ne 6penCayers.=oun8sK1(.(22 33.$@!3 1(.$( 4.(!(L

    and after the layers load

    *ap.set)enterKne 6penCayers.ConCatK1!2 $(L 3Loom level #in this case, F$.

    W2S $ayes

    %o use wfs layers in your map you may need to do some e+tra configuration at the

    server level. In your cgi-bin folder #where mapserv lives$ add a pro+y.cgi file #see

    httptrac.openlayers.orgwiki)reuentlysked9uestions=

  • 8/13/2019 Web Mapping Course Notes

    14/15

    %o overlay vector layers such as wfs on top of commercial layers, you may need to set

    the proection of each layer in your web page as well as the map itself. !ee

    httpcrschmidt.netAcrschmidtspherical;mercator.htmlfor details.

    A"ternative Mapping Packages%here are alternative mapping packages- for e+ample Map6uide 1pen !ource #http

    mapguide.osgeo.org$. %his was originally a commercial product from utodesk, but

    development was forked appro+ F years ago into open source and proprietary

    versions. &evelopment of the open source branch feeds into the development of the

    proprietary branch.

    (inaries and source code are available for all maor platforms, but activity is mainly

    focused on the windows version. Installation on all but a few linu+ distributions

    reuires compiling from source, which takes appro+imately B hours to work through

    from start to finish. It has options for using with apache or II! on windows, and for

    different programming languages such as php or .net.

    %he end result is a more sophisticated web application, but one with considerable

    overhead in terms of setup time and costs- and is only really an option if you have full

    root access to your web server.

    #ina""y: $ata"og%ing

    WhyN (ecause a catalogue is a much better way of storing your data, particularly

    once it's all web-enabled.

    6eonetwork #httpgeonetwork.open-source.org$ is a "spatial data managementsystem". In short, it allows you to upload, download, find and describe spatial data,

    belonging to you and others. It has a web-based interface, with a spatial browser and a

    search interface, and ensures that you fill in at least the bare minimum of metadata to

    make your data useful to you and others. (asically it's a content management system

    for spatial data.

    It's cross-platform and ava-based, and comes with binary installers and source code

    for all platforms. 1n windows you install the e+ecutable, and start the server from the

    programme menu. 7ou then access the catalogue via

    httplocalhostECECgeonetwork.

    When you upload data, you get the option to choose a particular metadata template,

    and assign access permissions for the data, ie is it read-only, can certa ingroups

    download it or ust view it on the web etc. It's important to note that you can use

    geonetwork to store other types of data, such as videos, and conference proceedings.

    &eference Materia":

    Web Mapping Illustrated #1'/eilly$ by %yler Mitchell I!(8 C-GDH-CCEHG-B

    Mapserver main website httpmapserver.gis.umn.edu

    Mapserver G tutorial httpbiometry.gis.umn.edututorial

    6eoserver website httpgeoserver.org1penlayers website httpopenlayers.org

    http://crschmidt.net/~crschmidt/spherical_mercator.htmlhttp://localhost:8080/geonetworkhttp://localhost:8080/geonetworkhttp://crschmidt.net/~crschmidt/spherical_mercator.htmlhttp://localhost:8080/geonetwork
  • 8/13/2019 Web Mapping Course Notes

    15/15

    Introduction to 1penlayers #Workshop, )1!!36 CCE$

    httpworkshops.opengeo.orgopenlayersintrodoc

    165 !tandards #for WM!W)! etc$ httpwww.opengeospatial.orgstandards

    6eonetwork website httpgeonetwork-opensource.org

    Koanne 5ook!enior I% !upport and &evelopment

    1&igital1+ford rchaeology

    .cook\thehumanourney.ney

    [33 #C$BG3 EECB

    %his work is licenced under the 5reative 5ommons ttribution-!hare like .C ]

    :ngland O Wales 0icense. %o view a copy of this licence, visit

    httpcreativecommons.orglicensesby-sa.Cuk or send a letter to 5reative

    5ommons, BJB !econd !treet, !uite FCC, !an )rancisco, 5alifornia D3BCG, !.

    mailto:[email protected]:[email protected]