I had already configured Python to run through the Apache webserver on my development server, but after a few issues on the production server (Apache freezing / crashing) I wanted to test running Python scripts with IIS7. The principle aim was to run TileCache through IIS rather than requiring Apache.

Why Not CGI?

While IIS 7 has Fast-CGI installed (see this IIS forum), even better performance can be achieved using ISAPI. This answer from ServerFault has a good summary on why ISAPI should be preferred over than CGI. Not only  performance  should be considered – maintenance should also be taken into account. If a web master or hosting service  is familiar with IIS then they are also likely to be familiar with ISAPI.

From the PyISAPIe site:

The reason ISAPI applications have the capability of being better than CGI or FastCGI applications is mostly due to its tight integration with the web server environment. Instead of initializing an entire program from scratch (in this case, the Python interpreter) every time a request is made for a page, an ISAPI extension only has to provide a function that is called upon every request. For interpreting Python scripts on a per-request basis, this means that the interpreter can be initialized once and used many times, creating a very noticeable performance gain.

Read more…

This page has 72 external Javascript scripts. Try combining them into one.

My YSlow Firefox plug-in was telling me that I had included too may JavaScript files, and that they should be combined into a single-file, and minified. The default setup of Mapfish has a single script include (mfbase\mapfish\MapFish.js), but this script  automatically loads around 40 further scripts.

I tried a couple of unsuccessful attempts at copying and pasting various Mapfish JS files into an online JavaScript compressor. However when referencing the minified file I kept getting “undefined” errors from various Mapfish plugins and OpenLayer objects.

Initially I was looking to download a ready-made “compiled” MapFish file, but was unable to find a version online. I have uploaded a zipped version so if you want the file without going through the steps below you can download a copy. Note that if you have made any modifications to the MapFish files then these will not be available, and there are no guarantees it will work.

There are instructions on creating a single-file Mapfish client build on the Mapfish site. This process uses JSBuild which is part of JSTools“a collection of python scripts for packaging and efficiently serving javascript.”
Unfortunately these instructions require a Linux operating system, and I’m using Windows. I eventually managed to “translate” these into Windows commands, and have documented the steps below.

Read more…

This post details how the WMS GetCapabilities request can be used to create an automated report listing all the map layers available from a WMS server. The final sample page can be seen here.

The GetCapabilities Request

Web Mapping Services (WMS) is an open standard that all major GIS vendors implement in their server software (for example see the ESRI documentation). As a result applications built on these services are able to easily switch from one software package to another – allowing separation of code that allows for easier maintenance and reuse.

The GetCapabilities is one of three requests in the WMS specification. It “returns service-level metadata, which is a description of the service’s information content and acceptable request parameters.”

After eventually being able to see the results of a GetCapabilities request my aim was to generate a report listing the available map layers, and to check I had enetered all the required metadata. I had a look on the web to see if there were any stylesheets that would nicely format the data.

Read more…

For the majority of public GIS systems I’ve worked on all the data in a database is available to users via the mapping interface. If someone wanted to hack in and “steal” data the only concern would be the bandwidth they took up. Security for these systems is fairly low down on the list of priorities, if it’s on the list at all.

GIS systems with organisational data are often only accessible (in theory) through an Intranet, so if the network is well protected then so isthe GIS.

There have only been a few mapping systems I’ve worked on where there is a mix of public data and datasets with restrictive access in the same database. The location of rare bird species (people will go to some lengths for a rare egg) and hallucinogenic mushrooms in a Biodiversity GIS being an example.

I’m currenty designing a MapServer system that will serve out WMS layers to the public, and a few which are limited to certain IP address ranges. WMS and security was something I had never previously investigated. The rest of this post outlines the current situation, and an attempt to restrict WMS access on my server.

Read more…

I’m trying (and having) to start using Python more and more due to its ubiquity in the OpenSource GIS world. There are a number of add-ons and libraries for MapServer that require Python to function properly and/or quickly. It is also widely used for scripting both MapServer objects and for raster manipulation using GDAL. I initially set up Python under Apache to run the Tilecache tile server.

According to the ModPython site – “Python will run many times faster than traditional CGI and will have access to advanced features such as ability to retain database connections.”

Mod_python is an Apache module that embeds the Python interpreter within the server, and can be downloaded from their site. There are versions for both Unix and Windows, which makes it ideal for MapServer for Windows (MS4W). Ironically after saying that using Python for web applications is many times faster than CGI, the ModPython download page uses CGI..

Read more…

Yes, I’d like to see the map layers and capabilities available from my MapServer MAP file, and no I don’t want to download mapserv.exe..

Messing with Headers

I had the same problem with both Firefox and Internet Explorer 7 each time I issues a request such as:

http://localhost/cgi-bin/mapserv.exe?map=/ms4w/apps/my.map&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetCapabilities

The browser tried to download mapserv.exe. The “exe” did actually contain the GetCapabilities XML, but it is very annoying to have to manually open it in another program each time.

This is a FAQ on the MapServer site which suggested that a program needs to be manually associated with the MIME type returned by the requests – application/vnd.ogc.wms_xml.

Read more…

Mapfish is an open-source web mapping framework built using the Pylons Python web framework for “creating web services that allow querying and editing of geographic objects.” However the server-side functionality of the system I am currently working on is already handled by SQL Server 2008 Spatial and MapServer. What interested me more was that Mapfish “provides a complete RIA-oriented (Rich Internet Application) JavaScript toolbox.”

A couple of examples of the front-end interface can be found at the EU Inspire Geoportal, and the Marbled Murrelet Mashup. The Mapfish client combines three frameworks into one OpenLayers, GeoExt, and ExtJS.

The client JavaScript is available via downloaded from http://www.mapfish.org/downloads/. At the time of writing mapfish-client-1.2.tar.gz was the most recent version. The files can be unzipped using the open-source program 7-zip that handles both gzip and “tar ball” zip files. Once unzipped there are a number of samples that can be run and edited locally (look for the examples/map/index.html page). This alone is a huge step forward in creating a basic online mapping system that rivals proprietary offerings.

Further details on using the toolkit can be found at the Mapfish tutorial and this blog tutorial. I’ll also be writing some more technical posts, specifically around using Mapfish with Windows, as most of the current documentation assumes people are running Linux.

Errors…

After turning on logging to diagnose an issue with MapServer I found a more worrying error, that was causing the log file to fill up at a rate of about 2MB a minute! I was reusing a legend for five or six datasets, and it was causing the following debug notes:

[Thu Jan 07 15:28:21 2010].629000 msyyparse(): Expression parser error. syntax error
[Thu Jan 07 15:28:21 2010].629000 msEvalExpression: Expression parser error.
Failed to parse expression:  ( >= 2.251) AND ( <= 2.5)

Map Server Logging

To turn on logging in MapServer Read more…

Aim - to copy a table containing geometry fields between two database servers.filetransfer The task was made slightly trickier as the two servers are on two different domains.

I wanted to use SQL rather than FME, or a SQL Server wizard, as it would be easier to script the process for the several tables I had to copy.

The first task was to set up linked servers. I used the following SQL (when logged in to my destination server, and using SQL Server Management Studio) to add the source server:

EXEC sp_addLinkedServer 'MY_SOURCE_SERVER_NAME'

Read more…

The SQL Server 2008 plugin for MapServer is a “native driver modeled on the PostGIS driver to mapserversupport SQL Server 2008’s newly added spatial capabilities.” It works fine for displaying data as WMS layers in OpenLayers however I ran into all sorts of problems when trying to use the GetFeatureInfo WMS query.

With MapServer 5.2.1  (installed using MapServer for Windows – MS4W v2.3.1) no error message was returned, however neither was any data . I initially thought this was due to the following bug in the plugin, which was reported to have been fixed for MapServer 5.4.

Read more…