Extension:SpatialWiki

Introduction
The SpatialWiki extension parses the wiki text after a page is saved and extracts a coded spatial reference and stores it in a standalone geospatial database. The spatial references can be displayed in wiki articles with click-able links to other spatially referenced content. This extension was originally developed for use in a talk at the 2011 FOSS4G Conference.

A tutorial that walks through setting up the back-end architecture including PostgreSQL/PostGIS, GeoServer, and OpenLayers is maintained in the AuSpatial Blog.

Installation
The installation notes below are generally for a Linux Ubuntu instance.

This extension can be used to simply display maps, but to make full-use of the capabilities you have to do a fair bit of back-end work to setup a spatial database to store the spatial references, along with a map server and web extension to serve the points to the wiki pages. These steps are outlined in the following posts:


 * Installing PostgreSQL
 * Installing PostGIS
 * Setting up the Spatial Database
 * Installing GeoServer
 * Setting up a PostGIS Layer in GeoServer
 * Installing OpenLayers

The files for this extension are maintained on SourceForge, and can be downloaded from here:
 * Latest release as a zip file
 * Subversion source code access

Whether you download from the .zip file or Subversion you want to put the following files in an extensions/SpatialWiki folder: SpatialWiki.php SpatialWiki.body.php SpatialWiki.i18n.php SpatialWiki.js

Once the files are installed add the following to LocalSettings.php:

The extension utilizes a number of configuration parameters which are setup in LocalSettings.php, for example like this:

$wgSpatialWikiDebugMessages = false; $wgSpatialWikiDatabase = "spatialwiki"; $wgSpatialWikiUsername = "postgres"; $wgSpatialWikiPassword = "secret"; $wgSpatialWikiPointsTable = "wikipts"; $wgSpatialWikiOpenLayersPath = "http://[your server]/OpenLayers-2.11-rc3"; $wgSpatialWikiWmsPointsUrl = "http://[your server]:80/geoserver/spatialwiki/wms"; $wgSpatialWikiGeoServerPointsLayer = "spatialwiki:wikipts";

Configuration Parameter Notes

The following values should be setup in LocalSettings.php.

Usage
The extension both writes spatial references and can be used to display maps. These two activites are not necessarily related and are described individually below.

Writing Spatial References
The extension makes use of a subset of the Wikipedia Coord Template to read spatial references from an article so simply add a reference like the following to your article:

°N, °W

If you don't have a Coord template setup you can use something like the example shown below to nicely format the spatial reference for display on the page. The extension does nothing with formatting the reference, it just reads it from the page once it's been saved and adds it to the spatial database.

The required template parameters are the decimal latitude for the point, the decimal longitude, and the point type. The point type must be a valid point type that exists in the Spatial Database.

Displaying Maps
Note, to display maps you must have OpenLayers installed as a minimum.

The map display is based on a "magic" word, SpatialWikiMap defined in the extension so you use it like this:

This will display a basic map using default parameters as shown below.



The complete syntax for the SpatialWikiMap tag is:

Where:

Example Template
The SpatialWikiMap magic word can be used in a template that also formats the spatial reference for a page. For example you might setup your Template:Coord like this:

Which will display a map of the spatial location for the page along with a formatted box with the coordinates below the map like:

NEED IMAGE

Troubleshooting
The extension writes messages to the web server's error log. This will vary by OS, but for example under Ubuntu 10.04 this will be in  and you can look at the end of it (the most recent entries) with something like:

tail error.log -n20

Error messages will be written no matter what, to also include debug messages set  as noted above to true.

When working on this I also encountered page-refresh problems that didn't seem to get resolved via disabling the parser cache in the extension (this is still in there) so the recommended settings in LocalSetting.php to disable all caching are:

$wgMainCacheType = CACHE_NONE; $wgMessageCacheType = CACHE_NONE; $wgParserCacheType = CACHE_NONE; $wgCachePages = false;