GeoWebCache under GeoServer

Few months back I wrote about GeoWebCache in my post “GeoWebCache under GeoNode“. Today I noticed a strange beheaviour from GeoWebCache as some of my newly added layers were not being cached.

If GeoWebCache is working properly, when ever a layer is published in GeoServer, by default a cached layer is created with the same name (one can check this by looking in Tile Layers list under Tile Caching GeoServer menu (left side)). Plus a folder is created with similar name to hold tiles in main cache path (e.g. …./geowebcache/workspace_tree_layer). Now if some one views this layer, GeoWebCache will cache tiles generated by GeoServer (and on next request, these pre-generated tiles will be served, if you want to know more read “Tile Caching and Seeding – GeoWebCache” ). Tiles are stores in their respective folder in main cached path.

Now back to my problem, when I checked cached folder (on server), I found that individual cached folders for each newly  created layer were being generated. But all of these folders were empty (no tiles inside any of the folders). Hmmmmmmmmmmm

As my last resort, I started looking at GeoServer logs and found “no such style” error again and again (it must have been generated when I was seeding these specific layers). I looked at style descriptors (SLDs) and found that when ever I assign SLDs to a specific workspace (no matter if it is the same one of the layer to which this SLD belongs to), the SLD is not available to GeoWebCache. When I removed the workspace information, the GeoWebCache found the SLD and worked perfectly.

Although, I solved the issue but I do not understand why under the same workspace, GeoWebCacbe cannot find style information. I am using GeoServer 2.4 (under GeoNode 2.0).

Advertisements

Web GIS application development step by step Part 3

I promised that I will publish 4 to 5 tutorials in this series and I will, however there was a bit of gap between this and the last post 😦 but here I am keeping my promise, beware this part is a big one.

This tutorial is divided into three parts, in first part, I will discuss OpenLayers, second part, GeoServer, and finally in the last part, I will show an example. But before I can start, I want to bring your attention to another excellent blog post at mangomap.com, its title is “5 things GIS professional need to know about web“. Good to know these things no matter at what level you are.

Now the above tips covered, lets discuss Client-Server architecture because web GIS is based on this architecture. In Client-Serve architecture, a software at server side waits for clients to make requests and returns specific information based on request for example like a web site. Thats it for now, you can read more about it here.

Lets move to OpenLayers. What is OpenLayers and Why I am interested in it, in fact I recommended it to many of my colleges in the past few years. OpenLayers is a JavaScript API that lets you show your maps on the web. It is the most essential part of client side when it comes to web GIS. One must know few things about web GIS to know the working the of OpenLayers.

In web GIS, we need a software (on server side) to read our data (software has to understand the source format of data in order to read), render it in memory (unless raw data is required at client side) and then pass it on to us over the internet. Now, if our data is in shape file format or it is in GeoTif format, it should not be passed due to the client side limitations e.g. shape file is not a web GIS format (plus it will actually be raw data) and GeoTiff could take a lot of time due to size. Thus, this software should send the rendered images in the form of internet friendly formats and we know that there are two image formats which are perfect for internet i.e. JPEG and PNG. Thus, this software should render our data in JPEG/PNG format and pass it on to us over the internet. Ideally, this software should know what area of map we are looking at to render it and send it back to us to avoid rendering all the map, plus this way the size of the image will be small. Thus, when ever we pan or zoom, a new image should be generated and passed on to us. Such a software is called GIS Server and the mapping service is called Web Map Serivce (WMS, read more about it on OGC). Don’t worry, I am not going to ask you to write GIS Server (and implement WMS) because it already exists, in fact we have a lot of good GIS Servers available for example GeoServer, MapServer, Mapnik, QGIS Server and ESRI GIS Server is also in the list (but its not free).

There is a problem over here (I hope you have noticed), what if the JPEG/PNG size is big, it will also take some time to download from server. Well, its true and I have covered it in one of my earlier post,  its better if you have a look at it now. In Summery, a GIS Server does the following (these are the high lights remember)

  • Reads the source data
  • Renders it according to the users viewing bounding box. The rendering is performed based on the styling information provided (default or custom)
  • perform tiling
  • send back the data

In this series, I will only work with GeoServer. Now, I am not going to teach you how to install GeoServer, read part 1 (link ) of this series for “how to install and configure development environment”. However, I just want to past below a paragraph I wrote in first part (I liked it :)).

“Finally it is time to install the most important component of Web GIS application i.e. GIS Server. It is important to know what a GIS Server Is? It is a software that listens for specific request (by clients). These requests could be for different services  (read OGC specification on GIS server for details) e.g. getMap request etc. A GIS server loads a dataset (e.g. a shape file or a Geo-Tiff) renders it, cut image into tiles and sends it back to the requesting client. Every time a client pans or zooms, GIS server receives requests and sends image tiles as response. Format of image tiles is specifically selected due to its size. In Free and Open Source Software for Geo  (FOSS4Geo) there are multiple choices for GIS Servers e.g. MapServer, GeoServer, mapnik. qGIS server, MapGuide etc. Some are written in C and some are in Java.”

OpenLayers, as mapping API (remember it is for client side), requests map (actually JPEG/PNG tiles) from GIS Server and when GIS Server (like GeoServer) returns OpenLayers shows them in a mapping area (basically in a HTML Div element). When ever we pan or zoom in/out, OpenLayers send a new bounding box to GIS Server requesting for a new tiles.

Why I have selected GeoServer, because of its admintration application. The last time I worked with MapServer was in 2010 and the experience was painful. I have not seen a decent administration application for MapServer but GeoServer has address this issue excellently. Plus the GeoWebCache is also integrated into the GeoServer and can be accessed through admin application (I will talk about it at the end of this tutorial).

Data prepartion 
We will be needing a shape file for out test application. Make sure 
that your shape file is in spherical Mercator projection because we 
will be overlaying it on OSM base map which is in spherical Mercator.

Enough of the explaining, If you have installed GeoServer, stat it by using the following command

 sudo ./startup.sh

The startup.sh script is in /your_path/geoserver_version_number/bin folder (see the GeoServer Section for details in part 1 of this tutorial series). Let GeoServer load properly and then open your web browser and type http://localhost:8080/geoserver and login with default user name “admin” and “geoserver” as password, you should be seeing a web page like the one below

admin_panelGeoServer has excellent user manual, read it (it will help a lot). Read more about the admin panel at here. In this part, I will focus on WMS. See the video below on how to create a WMS (just the first 15 minutes are enough for this part of the tutorial)

or see Lession 4 of Pennsylvania State University “Open Web Mapping” course (its good).

Summery is

  • Create a workspace (not necessarily every time)
  • Create a datastore (every time because this is where you are linking you data (shape file, geoTif, database etc) to GeoServer
  • Create layer (for each dataset, styles etc)

By using the above resources, I hope you have created/published a layer (have EPSG:3857) by now. Lets see how it looks, in GeoServer menu, click “Layer Preview”, this page has all the layers arranged in five columns (type, Name, Title, Comman Formats and All Formats).Search your layers through the list and click on OpenLayers (forth column i.e. Common Formats) link (in the same line). A new web page will open with an interface similar to the one below (but with your dataset of course ;))

layer_preview

What you are looking at is a web GIS application (Yes it is, simple and small but “A web GIS application”). It has controls (or components) like Map, zoom/ pand , mouse control and few more. All these controls are provided by OpenLayers API. But wait! We haven’t installed OpenLayers, when was it installed. When you installed GeoServer, the installation has its own web server and OpenLayers, thus, it is using these two to show preview pages (see I told you, GeoServer has it all).

Now lets look at the code behind this layer preview page, right click on the page (the one showing your layer), and click “view page source”. WOW, HTML+JavaScript, its 400 lines of code. But we are only interested in the section where our layer is being added to the map (it is at line 145). Search your layer’s name in the code, it should look some thing like the code below

// setup tiled layer
     tiled = new OpenLayers.Layer.WMS(
                    "cite:Africa_boundaries_3857 - Tiled", "http://localhost:8080/geoserver/cite/wms",
     {
        LAYERS: 'cite:Africa_boundaries_3857',
        STYLES: '',
        format: format,
        tiled: true,
        tilesOrigin : map.maxExtent.left + ',' + map.maxExtent.bottom
      },
      {
        buffer: 0,
        displayOutsideMaxExtent: true,
        isBaseLayer: true,
        yx : {'EPSG:3857' : false}
       } 
   );

The first line is creating an object tiled (just a variable name) of WMS class (of parent class Layer), the constructor for WMS class takes layer’s title, URL , name, format, isBaseLayer, transparent etc as arguments (don’t worry with time and a lot of reading you will understand all of it ;)).

Now we will use the same code above, to add this layer to our previously created web application (remember we created a web application in part 2). Lets look at the init() function again

<script type="text/javascript">
 
 function init()
 {

    var map, layer;

    // connect OLs map object with DIV map
    map = new OpenLayers.Map('map');

    // create a layer object
    layer = new OpenLayers.Layer.O SM( "Simple OSM Map");

    // add layer object to map object
    map.addLayer(layer);

    // Zoom to level 2 and set 0,0 as map center
    map.setCenter(new OpenLayers.LonLat(0 ,0),2);
}
</script>

The init function

  1. Creats a map object and assigns it to the web page’s map DIV
  2. Creats a layer object and attaches it to the map object
  3. Sets map center and zoom level

We need to add our layer’s code  below the OSM layer and add it on to the map but first we need to make two changes to our code.

  1. Instead of format variable , use ‘image/png’
  2. isBaseLayer:true , change it to false

Finally add the layer’s code to init()  function like I have done below


 function init()
 {

    var map, layer;

    // connect OLs map object with DIV map
    map = new OpenLayers.Map('map');

    // create a layer object
    layer = new OpenLayers.Layer.OSM( "Simple OSM Map");

    // add layer object to map object
    map.addLayer(layer);

     // setup tiled layer
    var tiled = new OpenLayers.Layer.WMS(
                    "cite:Africa_boundaries_3857 - Tiled", "http://localhost:8080/geoserver/cite/wms",
     {
            LAYERS: 'cite:Africa_boundaries_3857',
            STYLES: '',
            format: 'image/png',
            tiled: true,
            transparent: true,
            //tilesOrigin : map.maxExtent.left + ',' + map.maxExtent.bottom
      },
      {
           buffer: 0,
           displayOutsideMaxExtent: true,
           isBaseLayer: false,
           //yx : {'EPSG:3857' : false}
       } 
   );

   // add new layer object to map object
   map.addLayer(tiled);

  // Zoom to level 2 and set 0,0 as map center 
  map.setCenter(new OpenLayers.LonLat(0 ,0),2); 

}

I have also added “tiled” layer to map object (fourth line from bottom). Now save code and open http://localhost/myapp/myapp.html in any web browser (as discussed in part 2) and when I did, I got the following output.

part3_final_map

In next part, I will discuss more about GeoServer and layer styles.

See you next time.

GeoWebCache under geonode and the /tmp folder

GeoWebCache (GWC) is integrated into GeoServer and GeoServer is the GIS server in geonode running under tomcat. In our geonode implementation, I noticed that the size of GWC folder is small even after couple of months of tiling. Some of the layers which should appear faster are still appearing slower as if they are being served from GeoServer rather than from GWC.

I found that geonode keeps GWC tile folder at location /tmp/tomcat7-tomcat7-tmp. Now the /tmp will be cleaned on reboot (you can clean it without reboot as well, read this answer) and every time tomcat is restarted, thus, our cached folder is being deleted every time we restart tomcat server.

We changed the cached folder from/tmp/tomcat7-tomcat7-tmp to an other location and now things are fine. Here is the solution.

  • Create a folder (but not in tmp), make sure that it has read/write privileges.
  • Stop tomcat.
  • Edit web.xml (…/geoserver/WEB-INFS/) and add following lines (from GeoServer documentation).
<context-param> 
       <param-name>GEOWEBCACHE_CACHE_DIR</param-name> 
       <param-value>/my/location/folder/</param-value> 
</context-param>
  • Save web.xml
  • Start tomcat service

Now if you look inside new cached folder, you will see geowebcache.xml file and tmp folder indicating that the changes are applied.

Have Fun 🙂

Tile Cache and Seeding – Geo Web Cache

AutoTrac21

Ever wonder how come we can view contents of a web map in few seconds when the actual corresponding datasets are in GBs. The web maps we see are basically pngs/jpegs generated and then cut into small portions by GIS servers. These small portions of pngs/jpegs are called tiles and it is due to this technique we can view big datasets within few seconds in a web mapping application. Now, if ten users are viewing a layer (with almost same extent) through a similar GIS server, the GIS server have to perform rendering of image and tiling for each user. What if tiles can be saved and served from storage rather than rendering and slicing.

Good new is that such software exists which perform the above mentioned process and are called tile cache. Some of the options in Open Source are TileCache and Geo Web Cache (GWC). I like GWC becuase of its ease of use and seamless integration with GeoServer. GWC is java based and since it is integrated into GeoServer thus for GeoServer users it automatically caches and serves tiles (provided that you have not switched off the option in layer’s Tile Caching tab).

Now, how a tile cache (to be precise GWC) works. Client software (qGIS, web based and mobile) sends a request (Get Map) for a map with standard parameters like name, EPSG, extent , format. GIS Server performs the following operations

  1. Reads the required data source
  2. Generates the required format,
  3. Cuts the newly generated image into tiles
  4. Sends it back to client.

For every client, this process is repeated.

Now we introduce tile cache into this architecture. Before step 1, a tile cache will check if it has tiles for required map (extent and format). If it does, GIS Server is bypassed and tiles are served from cache. If it does not, same process is followed till step 3 and then tiles are stored in a separate location before response operation (step 4). For first client of a dataset, the process is same  as above (except before step 1 and between step 3 and 4 ), but for  second client (and third and so on and on) response of a map request will be much more faster. Now for each zoom level, tiles are generated and for higher zoom levels more tiles are generated than the lower zoom levels. It is like a pyramid, top level contains few tiles and bottom level contains few hundred (to few thousand) tiles.

pyramid

Since GWC is integrated into GeoServer, thus the above process is just one click for end users. GWC generates tiles only in EPSG 4326 (WGS84) and 900913 (Spherical Mercator aka Google) projections. Another good thing about tile cache software is that administrators can generate tiles in advance for faster response. The process is know as seeding. Seeding will increase the performance (faster maps) but at the cost of memory, thus, administrators usually go for a hybrid solution. For first few zoom level seeding is used and for rest of the zoom levels (remember tiles could be in thousands) tiles are generated on the fly and cached. This saves a lot of memory as tiles for detailed zoom level will be generated only if a user requests them and only for a specific extent (although GWC can generated tiles for specific extents as well, e.g. if an administrator thinks that his users are interested in Africa he can generated detailed level tiles for Africa Continent only).

Few weeks back, I seeded one of the layers on our GeoServer (it was around 10 GB). Before seeding, this layer was very slow. I decided to seed till level 08. It took a lot of time but our efforts paid with faster layer response. Next time, I will divide my big layer’s seeding on  multiple Virtual machines (based on different zoom levels e.g. 01 to 04 on one vm, 05 to 07 on an other etc) to speed up the seeding process.

Web GIS application development step by step Part 2

As promised, here is the second part of web GIS development tutorial. What we have done till now

  1. Installed Ubuntu
  2. Installed synaptic package installer (to make installation job easy)
  3. Installed PostgreSQL
    1.  Created Role, user and database
    2. Changed config files to make server listen on localhost and other IPs
  4. Installed apache web server
    1. Installed php module
    2. Installed PostgreSQL driver for php
  5. Installed Java
  6. Installed GeoServer

Its time to create a web GIS application. When I installed apache web server, a folder was created in /var folder i.e. www. I created a new folder in /var/www folder named it myapp and inside my app I created an other folder known as lib (/var/www/myapp/lib). All libraries will go into this folder (keeping our code manageable).

The most important library required for a web GIS application is mapping library. For beginners, mapping library is the one which shows map (tiles to precise), allows zoom in/out, pan, adding overlayer and many other functionaries. For mapping libraries multiple options are available, some are based on JavaScript and some are based on Flash etc. I like the ones based on JavaScript and particularly like OpenLayers for its richness.

I downloaded OpenLayers from its web site. Unzipped it into my lib folder (/var/www/myapp/lib/openlayers). I wrote a small html web page (myapp.html) and added OpenLayers to it for demo web GIS application, following is an explanation of it.

We need to load OpenLayers library into our html page, for this we will use the following line in header section of our html page.


<script type="text/javascript" src="http://localhost/myapp/lib/openlayers/lib/OpenLayers.js"></script>
<link rel="stylesheet" type="text/css" href="http://localhost/myapp/lib/openlayers/theme/default/style.css" />

When this code will run on side browser, link element will set styles for zoom buttons etc. and script element will fetching OpenLayers JavaScript library.

Note: You can link OpenLayers library from their web site but I think serving it from your own local web server is better.

A DIV element is required to embed map into an html page. Why DIV because contents inside DIV can be updated without updating the host html page, thus, when we zoom in on a map only contents of DIV are updated. Following is html code for DIV element.


<div id="map"></div>

Now that DIV is created (named ‘map’),  we need to create a JavaScript function that can create map inside this DIV (basically link OpenLayers library to this DIV). I added following code in head section of my html page.

 function init()
 {
    // variables
    var map, layer;

    // connect OLs map object with DIV map
    map = new OpenLayers.Map('map');

    // create a layer object
    layer = new OpenLayers.Layer.O SM( "Simple OSM Map");

    // add layer object to map object
    map.addLayer(layer);

   // Zoom to level 2 and set 0,0 as map center
   map.setCenter(new OpenLayers.LonLat(0 ,0),2);

}

Wait we are not finished yet (please be patient 🙂 ). We need to call the JavaScript function (init()) when ever our myapp.html page loads. For this, I called init() function on page load (see below)

<body onload = "init()">

Now, when myapp.html will be loaded, init() function will be called and map will appear in web browser. Now every thing was set, I opened http://localhost/myapp/myapp.html in my web browser and got the following output.

Screenshot from 2014-06-01 15:49:13

I know that init() function needs explanation, thus, lets dissect it.

First are two variables map and layer. Both are simple JavaScript variables which will be used to pint to OpenLayers map and layer objects. Always use var keyword while defining variable inside a function otherwise they take global scope.

Second line creates an OpenLayer map object and pass our DIV map as argument. Now our DIV will be a canvas for drawing tiles and will also respond to mouse drag and double click (along with my more functionalities).

Third line creates a layer object and this layer object is specific to OpenStreetMap (OSM). What is happening at the backend is that code is requesting OSM mapping servers for maps (basically WMS). Don’t worry I will explain WMS in next tutorial.

Fourth line is adding the newly created layer to map (see reference to newly created layer is passed in the addLayer()).

Finally, in fifth line, map was centered at 0,0 and zoom level 2 was set.

For all OpenLayers functions, please have a look at OpenLayes API documentation. I wish they can add one liner examples to each function’s help. For JavaScript, have a look at codeadademy and w3schools  web sites.

In Next tutorial, I will talk about GeoServer’s role in a web GIS application (with example) and its further use. PostGIS installation, configuration and usage and some JS GUI libraries.

Full code for the demo myapp.html is below


<html xmlns="http://www.w3.org/1999/xhtml">
<head>
 <meta http-equiv="content-type" content="text/html; charset=UTF8" />
 <meta name="content-language" content="en" />
 <title>Web Map Application</title>

 <script src="http://maps.google.com/maps/api/js?v=3&amp;sensor=false"></script>

 <script type="text/javascript" src="http://localhost/myapp/lib/openlayers/lib/OpenLayers.js"></script>
 <link rel="stylesheet" type="text/css" href="http://localhost/myapp/lib/openlayers/theme/default/style.css" />

		
<script type="text/javascript">

 function init()
 {

    var map, layer;

    // connect OLs map object with DIV map
    map = new OpenLayers.Map("map");

    // create a layer object
    layer = new OpenLayers.Layer.OSM( "Simple OSM Map");

    // add layer object to map object
    map.addLayer(layer);

     // setup tiled layer
    var tiled = new OpenLayers.Layer.WMS(
                    "cite:Africa_boundaries_3857 - Tiled", "http://localhost:8080/geoserver/cite/wms",
     {
            LAYERS: 'cite:Africa_boundaries_3857',
            STYLES: '',
            format: 'image/png',
            tiled: true,
            transparent: true,

      },
      {
           buffer: 0,
           displayOutsideMaxExtent: true,
           isBaseLayer: false,
           
       } 
   );

   // add new layer object to map object
   map.addLayer(tiled);

  // Zoom to level 2 and set 0,0 as map center 
  map.setCenter(new OpenLayers.LonLat(0 ,0),2); 

}

</script>
</head>
<body onload = "init()">


<div id="map" style="width:100%;height:95%; z-index: 0" > </div>


</body>
</html>


Web GIS application development step by step Part 1

GeoNetwork2

Many people asked me about web GIS  development and from where to start. Some questions were basic like ‘how to show a shape file on Google maps’ to advance level as ’tiles are coming from local tile cache or GIS server’. Since I am into Open Source web GIS application development, thus, I decided to write a blog about it that can help the beginners and answer some medium to advance level questions.

First step is to setup a development environment. Keeping the development environment Open source and free from end to end (from Operating system to client side APIs), I selected Ubuntu as the operating system. I installed Ubuntu 12.04 and rest of the story is as follows

Package updates are required, thus, do the following.

sudo apt-get update
sudo apt-get upgrade

this will take some time, depends on your internet speed. I found synaptic package manager missing from my newly installed Ubuntu 12.04 (desktop), thus, I Installed synaptic package manager using commands

Note: Remember, answers to questions on console are case sensitive.

 sudo apt-get install synaptic

I like Google Chrome because it has an easy to use debugger, thus, installed Chrome using synaptic package installer. Keep in mind, chrome for Ubuntu 64 bit is only available for AMD by-default.

To keep a backup backup of some important files, I always use Dropbox. To install Dropbox, python-gpgme package needs to be installed (again using synaptic package installer) for verification of binary signature. Finally, I downloaded Dropbox installation package and installed it.

Behind every successful web application there is a database :). Not that we will be needing a database for spatial purposes (in this tutorial) but it is required for many other purposes in a web application e.g. keeping users details etc. Few choices from Open Source community are MySQL, SQLite and PostgreSQL. PostgreSQL is the best Open Source database especially when it comes to spatial functions. Again, I used synaptic package manager to install postgreSQL (as you can see in in the image below, I installed postgreSQL 9.1.x)

postgreSQL

 

At this moment, postgreSQL is installed but One has to create a role, user and database, thus, I executed following commands through terminal

sudo -u postgres createuser

following questions required user response

Enter name of role to add: scriptNdebug
Shall the new role be a superuser? (y/n) y
Shall the new role be allowed to create databases? (y/n) y
Shall the new role be allowed to create more new roles? (y/n) y
CREATE ROLE 

The above command will create a user, now for database

sudo -u postgres createdb myDB

response will be

CREATE DATABASE

Now user scriptNdebug needs to have access to myDB database, thus, logged in to command line tool of PostgreSQL

i.e. psql using super user postgres

sudo -u postgres psql 
postgres=# alter user scriptNdebug with encrypted password 'password';

response is

ALTER ROLE
postgres=# grant all privileges on database myDB to scriptNdebug;

response is

GRANT

What if I want to stop PostgreSQL database server. Following are some useful commands (use them from terminal)

Start

/etc/init.d/postgresql start

Stop

/etc/init.d/postgresql stop

Restart

/etc/init.d/postgresql restart

If you want server to listen on a specific IP, then change pg_hba_config file. If the file does not exists, then simply rename pg_hba_config.sample at location /usr/share/postgresql/9.1/ to pg_hba_config and make the following changes

TYPE    DATABASE   USER    ADDRESS            METHOD
host    all        all     192.168.0.1/32     @authmethod@

 the above change will make the server listen on IPs from 192.168.0.1 to 192.168.0.32. I want to list on all IPs for all users and ‘password’ as authentication method, thus, I made the following changes

TYPE    DATABASE   USER    ADDRESS METHOD
 host    all       all     all     password 

Similarly, if you want to listen on localhost, then make the following changes in file postgresql.config. If the file does not exists, then simply rename postgresql.config.sample at location /usr/share/postgresql/9.1/ to postgresql.config and make the following changes

listen_addresses = 'localhost'

This file is to be changed if one wants to change port 5432. Do not forget to restart PostgreSQL server load the new settings.

Now web server needs to be installed, I selected apache, used synaptic package manager to install apache (version 2.2.22-1ubuntu1.4). This will create a folder ‘www’ in folder /var/. We will use the www folder when we will create a test web GIS application later in this tutorial. If you want to use php as server side development language, install php module for apache server. Just use synaptic to install libapache2-mod-php5. Also install (using synaptic) php5-pgsql module to use postgreSQL with php. Restart apache (use command below) to load these modules.

sudo /etc/init.d/apache2 restart

Finally it is time to install the most important component of Web GIS application i.e. GIS Server. It is important to know what a GIS Server Is? It is a software that listens for specific request (by clients). These requests could be for different services  (read OGC specification on GIS server for details) e.g. getMap request etc. A GIS server loads a dataset (e.g. a shape file or a Geo-Tiff) renders it, cut image into tiles and sends it back to the requesting client. Every time a client pans or zooms, GIS server receives requests and sends image tiles as response. Format of image tiles is specifically selected due to its size. In Free and Open Source Software for Geo  (FOSS4Geo) there are multiple choices for GIS Servers e.g. MapServer, GeoServer, mapnik. qGIS server, MapGuide etc. Some are written in C and some are in Java.

GeoServer has an edge over others because of its administration tool i.e. web based administration interface. With GeoServer, deploying a dataset (let say a shape file) as a WMS is very easy. Thus I decided to install GeoServer. Before installing GeoServer, Java needs to be installed as GeoServer require Java. I used  synaptic package manager to install openjdk-6-jre.  Then downloaded GeoServer from its web site. Unzipped the downloaded file into a folder. Moved to bin folder and edited startup.sh file to add JAVA_HOME variable as shown below (your path might be different).

JAVA_HOME="/usr/lib/jvm/java-6-openjdk-i386"

All is set now, started GeoServer from terminal by using the following command

 sudo ./startup.sh

Note: Do not close this terminal this terminal window because it will shutdown GeoServer.

Started a web browser, and typed http://localhost/geoserver to open administration application and used admin as user name and geoserver as password. Application menu is on left side, clicked on Layer preview to view sample WMS layers. One can click on Open Layers link against any sample layer (as shown in figure below) to open it in a new tab.

geoserver

 

Please read GeoServer user manual to know how to deploy your datasets as WMS layers (I will create a WMS in next part of this tutorial). In next part, I will also create a web GIS sample application using Open Layers and explain web GIS application functionality.