Why do we need Mapserver/Geoserver to present data from spatial database to web browser?

The simple answer is that you don't need them, but it makes life much easier. You have to have some sort of server element between your database and the web browser: so you can either write your own server in PhP (or java or whatever) and handle all the vagaries of the database you are using and sort out the wire transfer formats etc and do the debugging and testing. Or you can stand on the 131 person-years that have gone in to GeoServer's development ( or the 53 person years of MapServer) and start serving maps this afternoon.

And all that is before I start my standard rant about standards and why letting anyone who can implement the standard consume your maps in their client with out any extra coding on your or their part is a good thing.


It really depends what you need to do with the data.

For example if you only need to display vector points on top of a base map then you can create a very simple server-side script (in Python, .NET, PHP) to publish spatial data from your database. The ability of PostGIS to serve GeoJSON makes this trivial.

Serving single features as KML and creating bounding boxes may also be more easily handled directly with a simple script and a database. Premade tilecaches also allow (possibly) simpler server side software such as TileStache.

MapServer or GeoServer in these cases would be a huge overhead for little benefit. And there is a huge overhead in configuring and maintaining either of these applications and their associated dependencies - especially if you need to deploy on a shared server or have restricted access.

As Ian mentions there are lots of benefits of using map server software. Probably the main benefit is the cartographic options for displaying data dynamically. OGC standards, projections, attribute queries, legends, metadata, caching, security, different spatial formats, different image formats, printing etc. are also then available.


Using a framework like Geomajas, you could also directly pull the features from database and send the features to the browser using SVG/VML for rendering/editing in the browser. There is also a rasterizing plugin which allows rasterizing on the server.