This is the challenge for this week.
PostgreSQL + PostGIS + MapServer + MapProxy + Quantum GIS on Windows 7 32-bit
The aim is to create a scalable mapping solution based on open-source software that is easy to use and maintain, is fast and responsive and that can provide data in a number of different formats. Windows installers are available for most of the applications I wanted to use which made life a bit easier. Doing the same thing on Linux might be even easier. The corporate proxy and firewall certainly made things more complicated than they should have been.
PostgreSQL – can be downloaded from http://www.enterprisedb.com/products-services-training/pgdownload#windows. Make sure you download the correct version for your machine (32-bit or 64-bit). The Windows installer runs Stack Builder after installing the database with options to install additional components including PostGIS. Behind a firewall and proxy this does not work as Stack Builder is not proxy authentication aware and the download of the applications_v2.xml file fails. Better is to install the PostGIS binaries.
PostGIS – this is available in two forms. Installers and binaries. Installers are executable files designed for specific versions of PostGIS, PostgresSQL and Windows [http://postgis.refractions.net/download/windows/pg91/postgis-pg91-setup-2.0.1-1.exe]. Binaries are zipped archives for specific versions of PostGIS, PostgreSQL and Windows [http://postgis.refractions.net/download/windows/pg91/postgis-pg91-binaries-2.0.1w32.zip].
MapServer – there are two methods to install. Either an executable that pulls down all the dependencies and modules from the Internet [http://maptools.org/dl/ms4w/ms4w-3.0.6-setup.exe] or a zip archive containing all requirements [http://maptools.org/dl/ms4w/ms4w_3.0.6.zip]. Behind a firewall and proxy the zip archive is the way to go. Easy as extracting into the root of a drive (e.g. C:\ or D:\).
Quantum GIS (QGIS) – is available on Windows, MacOS X, Linux and Android. Binary packages are provided for the current version. The current version is QGIS 1.8.0 and was released in June 2012 [http://qgis.org/downloads/QGIS-OSGeo4W-1.8.0-1-Setup.exe].
MapProxy – MapProxy is an open source proxy for geospatial data. It caches, accelerates and transforms data from existing map services and serves any desktop or web GIS client. Installing on Windows has specific instructions – http://mapproxy.org/docs/latest/install_windows.html. Again, behind a firewall and proxy the “pip” or “easy_install” processes don’t work and so a workaround has to be found.
**Note: run the various executables and batch files as Administrator which is available through the right-click context menu. It’s a Windows7 thing**
This is reasonably straightforward. Start with PostgreSQL and run the .exe file. You’ll need to specify an installation directory, a data directory and a password for the default user, “postgres”. Accept the default port of 5432 and set the locale for the new database cluster. Start the install after configuration is complete and it will finish shortly after the uninstaller is created.
You are then asked if you want to launch the Stack Builder. This will help you install additional software to complement the PostgreSQL installation. In this instance we want to add the PostGIS extensions. However, I never managed to get this to work and after some digging realised that the Stack Builder could not authenticate against the proxy server.
So, install PostGIS separately. Run the executable, agree to the GNU General Public Licence and select the components to install. I elected to create a spatial database as this could be used to create other databases using it as a template. The installation folder is the same as the PostgreSQL database. Add your connection details as set up in the PostgreSQL install. Give your new spatial database a name. Hit the install button and wait for the installation to complete. My installation failed when trying to create the template database as the system appeared to get confused as to whether I was running 32-bit or 64-bit apps.
In this case, I downloaded the PostGIS binaries (PostgreSQL 9.1, PostGIS 2.0.1, Win32) and extracted the zip archive. Inside there are a number of README files which explain exactly what to do. Quoting them:
If you want to use the new PostgreSQL 9.1 extensions approach for installing -- use the makepostgisdb_using_extensions.bat script instead of makepostgisdb.bat. Follow the upgrade instructions in README_EXTENSIONS.txt. -- create a postgis/raster/topology enabled database -- 1) Edit the batch script changing ports etc. to your settings 2) You should uncomment the dattemplate line to make it a template database if you want 3) Run the batch script.
MapServer 4 Windows (MS4W) is as easy as unpacking the zipped archive to the root of one of your drives (in my case C:\) and running the apache-install.bat file. Importantly, this needs to be run as Administrator in Windows7.
Installing MapProxy, in the end, turned out to be reasonable easy. It gets installed into the root of your drive in C:\mapproxy_venv\. This directory is created by installing the Python virtualenv package. All the dependencies had to be downloaded as the firewall and proxy stopped the automatic download. [The links to pypi.python.org present a list of all available packages.]
- virtualenv – http://pypi.python.org/simple/virtualenv/ – sets up the virtual environment required for MapProxy and installs easy_install.exe
Running “easy_install.exe MapProxy” it asked for:
- MapProxy – http://pypi.python.org/simple/MapProxy/
- lxml – http://pypi.python.org/simple/lxml/
- PyYAML – http://pypi.python.org/simple/PyYAML/
- PIL – http://pypi.python.org/simple/PIL/
Running “easy_install.exe pyproj” asked for:
Running “mapproxy-util.exe –version” confirmed that 1.4.0 was installed.
Configuration will have to be another post. I now have a partly configured PostgreSQL PostGIS database (loaded with some sample OS Opendata layers), MapServer 4 Windows, MapProxy and QGIS all up and running. Installation would have been simpler without things like firewalls and content filtering (filters out mapproxy) but there are ways around that. Thanks to @Dragons8mycat for tips and suggestions.