Linux and OSGB Web Map Tools v2.0

I've been spending some time recently installing a map server for a customer. This serves Ordnance Survey maps on his web site using a web interface we developed at The Hug. I've had some problems with the instructions provided so, as I can't track down who maintains that page, I've written up my notes here on what I had to do to get it working, especially with reference to where it differs from the notes.

  1. First and foremost you don't need a Windows PC to do this installation, despite what it claims in the instructions. It can all be done with Linux.

  2. OSGBWebMapTools - as instructed grab the ZIP file and unpack it somewhere on your hard drive.

  3. GDAL/OGR - you need the programs gdal_translate and gdalwarp which are in the gdal-bin package in Debian/Ubuntu. You need release 1.6 or later so Ubuntu's standard offering is too old. However there is a repository which has them. You can find details here.

  4. Data Preparation

    1. there is some mystery about Overview1 and Overview2 as Ordnance Survey denied they existed when I phoned them but as the implication of the instructions is that they are an even lower resolution than MiniScale® I ignored them as I couldn't see us needing anything further out than that.

    2. You can download the MiniScale®, 1:250,000 Scale Colour Raster TIFs and TFWs from the Ordnance Survey via their downloads page. If you want OS Street View® tiles this is also the place to order those (as they're only available on DVD).

    3. 1:50,000 Scale Colour Raster and 1:25,000 Scale Colour Raster is only available if you pay the Ordnance Survey a suitable sum and is supplied on DVDs.

    4. Step 4. of the instructions says:

      Create a folder c:\Data\OrdnanceSurvey\MiniScale and copy the MiniScale.tif and MiniScale.tfw files to it.

      in fact you will find four different MiniScale® TIF/TFW pairs in the ZIP file so you need to take a look at the TIFs and decide which you want to use, then copy the pair of files into ./Data/OrdnanceSurvey/MiniScale

    5. You will find that for the tiles for 1:250,000, and those for 1:50,000 and/or 1:25,000 tiles if you have purchased them from the Ordnance Survey, the TFW filenames are in upper case whereas the TIF filenames are in lower case (in whole or part). Here be dragons and you must fix this before converting the files. I used this command but there's probably more elegant ways:

      for F in *.TFW ; do mv $F `echo $F|tr [A-Z] [a-z]` ; done

    6. Steps 10 to 12 of the instructions describe the use of a BAT file to run the conversion. A similar shell script works for Linux and you can find my version of that here. It needs to be run from ./OSGBWebMapTools/Data/Tiles

    7. Note that my script renames the TIF files to be upper case with a lower case .tif extension. This is necessary because the DBF file in each directory which appears to be a database of the tiles refers to them using filename in that format.

    8. Step 11 of the instructions says:

      NOTE: This process will likely take over a day to run.

      On a 2.4GHz Core Duo PC with 3.5GB of RAM and not doing OS Street View® it took a two or three of hours and, as it only used one core, it didn't significantly impact on the PC it was running on.

  5. Tomcat and GeoServer

    1. The instructions want you to install release 6 of Tomcat but on the server I was offered the distribution came with tomcat 5.5.28. It seemed to work fine.

    2. In this section I need to refer to the Tomcat base directory a lot. On the server I was using it was /usr/local/jakarta/apache-tomcat-5.5.28 but I bet it will be different for you so I'll refer to it as TOMCAT from now on.

    3. I'm assuming you're sharing it with an instance of apache so the Tomcat instruction which says:

      Change port 8080 to port 80 in Tomcat's conf/server.xml file if you are intending to run an externally accessable website.

      should be ignored if you are also running Apache on the same server.

    4. The instructions gives a direct download link to version 1.7.6 of GeoServer. This is rather out of date however GeoServer 2.n has a significantly different set up so I don't recommend using it. Not the first time around anyway.

    5. Before you run tomcat for the first time change the admin password in TOMCAT/data/security/users.properties as otherwise your GeoServer is wide open to abuse.

    6. One last thing. If you're using Ubuntu Hardy Heron and you're seeing security issues you need to open /var/lib/tomcat5.5/conf/policy.d/04webapps.policy and add a line to it granting looser security permissions thus:

            permission java.security.AllPermission;

  6. Caching

    OS recommend GeoWebCache but I didn't get on with that at all so in the end I installed squid which does the job just fine. You need to configure it in accelerator mode and make Tomcat listen on localhost only by changing:

          <Connector port="8080" protocol="HTTP/1.1" ...

    in server.xml to:

          <Connector address="127.0.0.1" port="8080" protocol="HTTP/1.1" ...

    In squid.conf that lines that need changing or adding are:

    1. Set it into accelerator mode listening to port 8080:

        http_port your_server:8080 accel defaultsite=your_server

    2. Turn off the lines which makes it ignore URLs with "?" in:

        #hierarchy_stoplist cgi-bin ?

        #refresh_pattern -i (/cgi-bin/|\?) 0   0%   0

    3. Make it cache everything for 28 days, ignoring any headers telling squid not to cache:

        refresh_pattern . 40320 100% 40320 ignore-reload ignore-no-cache