##
PostGIS

PostGIS, developed by
is possibly the most far-reaching addition to MapServer. It adds GIS functionality to the
database system. In time to come this will make it possible to construct complete server-side GIS Operating systems, with MapClient as a possible browser front-end. Functions offered are:

- Maps as database objects (tables), with new spatial SQL queries
- Creation of new map elements by new SQL operators like join and intersect
- Writing programs within the database in C and various scripting languages
- Embedding other applications in the database, like plr for the R statistics package.

PostGIS maps can be generated directly from MapServer CGI or by way of PHP. In both cases the binding element is the DATA element of the map layer. Once you understand how this is built up (especially subqueries), creating dynamic maps from a datase and linking them with all kinds of attribute information is pretty straightforward.
To give an impression of MapClient's use with advanced PostGIS, I'll sketch the setup for a study on Dutch railroads, in which maps based on proximity (e.g. housing near railroads) are to be analyzed and compared with regular maps. Distance maps are very costly to compute, and one map generally servers as a base for many others and for statistical analyses. Changing a parameter in the base map requires regenerating all the dependant maps. With MapClient, three sets of serverframes can be used. The first set creates one or more base distance maps as temporary tables in the database. The second set does the analysis on the base maps (with PL/R and custom PHP scripts and even some custom C functions written within the database), and designs the derived maps and graphics (with MapServer and PHP graphics). The third set deletes the temporary tables from the database. The three sets are scheduled one after another with the "scheduleAfter()" method.