You are on page 1of 12

Geoserver Tutorial

Installing Geoserver Ive tried different times and the only sure way to get Geoserver to run is to install from an Administrator account. This is especially true in Windows Vista. Windows 7 ensures that at least one user on the computer has an Administrator account. If you have a User account, log in as Administrator. To create and login as an administrator do the following in Vista. Login into the new Administrator Account Download and install jdk Java (I you dont already have it). Note that jre Java Runtime is not enough, need jdk. This is really important for other programs as well that causes alot of grief. Needs EMPHASIS. http://java.sun.com/javase/downloads/index.jsp Windows is 32-bit and Windows x64 is 64-bit. Next you have to Set JAVA_HOME environment variable In Vista and Windows 7 Right click on My Computer Go to Properties---Advanced System Settings Under the Advanced tab go to Environmental Settings Under System Variables click new

Im using Update 16 so the Variable Value will depend on installation date. (jdk1.6.0_16) In Windows XP, Right click on My Computer, Go to System Properties, Click the advanced Tab and go to Environmental Variables. Note: If you are running a 64 bit operating system the service install of Geoserver will not work. Install the Web Archive version instead. Install instructions here Download and install Geoserver 2.0 Follow instructions on the install and accept all defaults.

Geoserver will run as a service. To enable to service to start automatically right click on the bottom taskbar and select Task Manager. Click the Services Tab then the Services button (bottom right)

Set to Automatic and click Start (if not already) Adding Maple lake data Extract the data to c:\Programs Files\Geoserver XXX\data_dir\data

Extract the files from maple.zip to this folder Start Geoserver Web Admin Page

Next lets add a new Workspace Workspaces: A workspace is a folder-like collection of layers. A workspace can represent a database connection, a folder on disk (containing shapefiles, GeoTIFFs, etc.), or a collection of remote OGC services (cascading WMS for example).

A URI is similar to URLs, except URIs need not point to a location on the web, and only need to be a unique identifier. For a Workspace URI, we recommend using a URL associated with your project, with perhaps a different trailing identifier, such as http://www.openplans.org/topp for the topp workspace.

Add a new Store

A store connects to a data source that contains raster or vector data. A data source can be a file or group of files such as a table in a database, a single file (such as a shapefile), or a directory (such as Vector Product Format library). The store construct is used so that connection parameters are defined once, rather than for each piece of data in a source. As such, it is

necessary to register a store before loading any data.

You can manage the layer now or exit and go to Layersadd new resourcemaplelake

Lets add the water layer Enter some keywords

http://spatialreference.org/ref/epsg/4269/ Click FIND for EPSG, enter 4269 and then click on it when it comes up. Then click on Compute from data and Compute from native bounds Click Publishing (Tab at the top)

Pick Polygon for Style (more on styles later)

Finally click save Go to Layer Preview to see how it worked. Add two more layers; contours (not lake contours) and buildings

Openlayers
Download Openlayers and place in your wwwroot folder (I renamed to c:\wwwroot\openlayers) Enter this url in your browser to the capabilities fil http://localhost:8080/geoserver/web/?service=wms&version=1.1.1&request=GetCapabilities Click on WMS 1.1.1 View the lakes, buildings, and contours entries. In c:\wwwroot\openlayers\example modify the wms.html file as shown below html xmlns="http://www.w3.org/1999/xhtml"> <head> <link rel="stylesheet" href="../theme/default/style.css" type="text/css" /> <link rel="stylesheet" href="style.css" type="text/css" /> <script src="../lib/OpenLayers.js"></script> <script type="text/javascript"> var lon = -79.7876; var lat = 45.36981; var zoom = 13; var map, layer; function init(){ map = new OpenLayers.Map( 'map' ); layer = new OpenLayers.Layer.WMS("MapleLake", "http://localhost:8080/geoserver/wms?service=wms", {layers: 'maplelake:water,maplelake:Contour_line,maplelake:Buildings'} ); map.addLayer(layer); map.setCenter(new OpenLayers.LonLat(lon, lat), zoom); map.addControl( new OpenLayers.Control.LayerSwitcher() ); } </script> </head> <body onload="init()"> <h1 id="title">WMS Example</h1> <div id="tags"> </div> <p id="shortdesc"> Shows the basic use of openlayers using a WMS layer </p> <div id="map" class="smallmap"></div>

<div id="docs"> This is an example of how to add an WMS layer to the OpenLayers window. The images are tiled in this instance if you wanted to not use a tiled WMS please use this example and pass the option singleTile as true. </div> </body> </html>

To see if it works enter: http://localhost/maps/OpenLayers/examples/wms.html

Colours are awful! Next we will look at SLD

You might also like