in this week i had lows and downs.  i realised once again why the open source community has such a long way to go still.  i was tasked to put together a ‘demo-able’ map server with client.

after about two days of reading i noticed there might be much more to google maps than just a couple of javascript command called to place a marker.  mapping, and most important, correct, standards based mapping is a beast.

and i will show you how to tame it  how to make it more tame…

so the important things to read up on is: map standards, shapefiles, cartesian coordinates, latitudes and longitudes, and spatial stuff in general.  :-)

a good place to start would be the The Open Source Geospatial Foundation.  they are a bunch of guys who run a non-profit organisation to  help promote the collaborative development of open geospatial technologies and data.

from there i went into researching web map services.  here is where i really started to discover all the components that make up a web map service (wms), and all the extras you can add to it.  and as it is in life, it certainly is in map services, the more components you add, the more complex it gets.  luckily having shifted my focus lately to doing all things in a more loosely coupled way, i noticed that the whole system could be broken down into a lovely little diagram of components.

Map Diagram

this diagram is copyrighted by me – since i haven’t seen any diagram like this on the web – i have to call dibs on it.  it took me a good ten minutes using splashup to do this.  anyways – as you can see the diagram has a certain flow to it.

it starts with the datastore (albeit a database, shapefiles etc.) where you would store your spatial information.  from there the spatial data would flow to the map server, which in turn would interpret the spatial data and draw a nice little map.  (i’m sure there is a lot more involved to the process, so my apologies to any map server developers).  the map server ofcourse has multitudes of settings and configurations which you could use to make your life easier, from choosing image types, to raster sizes etc.  (depending on which map server you use)

now a map clients is sort of a middleware application which one could use to manipulate the map server.  map servers can be used to view the maps, in the case of desktop software, or could be a javascript api which is used to do usefull stuff as turning on and off layers on the fly, panning to different regions, displaying map attributes and info etc.

then finally the end result is delivered to the user browser.

on the diagram you would see that there is a little light arrow between the datastore and client.  that is due to the fact that some clients can directly interpret data from the datastore – and the path with least resistance is sometimes not a bad one to walk.  for e.g. openlayers can interpret xml route data and use the map server to convert them to a layer to display on your maps.

after getting a better understanding of how everything is glued together – you can start with the most important variable in the equation – the map server.

there are really only two that stood out for me, and within my limited time frame, the only two i could half decently evaluate.  mapserver and geoserver.

the map server

so whats the difference between the two servers – well, fundamentally there is a bit of a difference.  geoserver is java based and mapserver is c# based.  i can already see all the tomcat lovers outside smiling at the thought of a java web app.  :-)

mapserver is done by Minnesota University and geoserver by a community of java developers who loves spatial services i guess.  the important part ofcourse is that they both support web map service (wms), which is the service i primarily use to handle all mapserver calls.  using it as a service would also allow one to ‘theoretically’ switch map servers without too much hassle.

there is a comparison between mapserver and geoserver online, mapserver handles shapefiles better, but geoserver handles postgis data better, so in the end i guess its a personal choice of how you wish to use this system.

i went for geoserver, due to the fact that i liked the admin screen.  :-)   only joking, geoserver was installed first using this helpful guide, seemed to be very standards aware and from there on i just ran with it.  only later on i read some perfomance comparisons, and still geoserver seems to come out tops.

the datastore

spatial data can be stored in two different ways, shapefiles and postgis data.  postgis spatially enables postgresql, as described on the postgis site.  this means there was probably clever ways used to calculate and work with coordinates like creating a boundary box to only work with smaller sets of data at one time.

shapefiles is a popular geospatial vector data format for geographic information systems software.  it is a popular geospatial vector data format for geographic information systems services.  in the comparison used between geoserver and mapserver, postgis data was a bit slower in general, but with increasing the dataset the shapefiles performance degrades a bit.

at this point of time for testing purposes and ease of use i’m using shapefiles and importing it to geoserver in the admin section.

also  if you want to convert shapefiles to postgis sql – just run the command shp2pgsql
and to convert postgis sql to shapefiles use – pgsql2shp

map client

or as i like to refer to it as the middleware – there is a multitude more map clients than map servers out there – choosing the right one might be a choice of personal preference and what you wish to do with it.  i’ve chosen openlayers -my main motivation was that it played well with pgrouting, a routing application which i will discuss a bit later.

it has a nice javascript api, which seems easy to use and would allow me to plug in layers from different map servers/providers.  it has built in support for yahoo maps, google maps and a couple extra.  it can also handle xml data from the datastore and with that be able to layer your routing into it.

the routing

this was my easiest choice, due to the fact that there isn’t a lot of open source solutions out there, except pgrouting really.  it works in conjunction with postgis, which is a plug-in that spatially enables postgresql.  this comes quite handy, since all the routing calculations will be done for you, with the help of some sql queries.

you can view some examples on there website.

for now

so for now i’ve researched all i need to get started – and got some very basic examples working.  i’ll try and get my sandbox sorted so i can get the demos with some source code up and running.

if you have some questions – post a comment – and i will see if i can help you so long in the meantime.