MapFishSample installation
MapFish SVN repository includes MapFishSample. MapFishSample is an example of a MapFish project. This page describes how to install and set up that sample project. It assumes that the reader is familiar with PostGIS. The instructions apply to Linux, users of other operating systems will have to adapt the instructions.
Prerequisite
You must install MapFish first. Install it from source as described in the first two sections of How ToInstall Map Fish From Source, you don't need to follow the steps of the third section (Installing the client plugin).
Now check out MapFish client:
$ svn checkout http://www.mapfish.org/svn/mapfish/framework/client/trunk client
Below we assume that MapFish client was checked out in /client.
Download MapFishSample
Check out the sample application :
$ svn checkout http://www.mapfish.org/svn/mapfish/sample/trunk sample
Below we assume that the sample application was checked out in /sample.
Data
The MapFishSample project relies on geographic data in PostGIS.
First thing is therefore to install PostgreSQL and the PostGIS extension.
The database schema and data are available in http://dev.mapfish.org/data/v1.2
- download the .sql files and the helper bash scripts and place them in some directory
- make sure the bash scripts (.bash) are executable and that user postgres can execute them (chmod a+x *.bash)
- edit create_database.bash and set the variables DBNAME, DBUSER, and PG_VERSION appropriately
- log in as postgres (PostgreSQL admin user)
The following steps apply to UNIX users. Windows users must adapt them as appropriate.
- create a database user (e.g. "www-data"):
createuser -SDRP www-data
- execute the main bash script:
$ bash ./create_database.bash -p
Setup
Edit the Pylons configuration file (located in /sample/development.ini).
First change the document_root variables to make it refer to the MapFish mfbase and examples directories (/client/mfbase and /client/examples):
... [app:mfbase] use = egg:Paste#static # Set here the path to your MapFish directory: document_root = /client/mfbase/ ... [app:examples] use = egg:Paste#static # Set here the path to your MapFish client/examples directory: document_root = /client/examples/ ...
Now change the database configuration by replacing the value of sqlalchemy.mapfishsample.url. For example:
sqlalchemy.url = postgres://www-data:password@localhost/v1.2_mapfishsample
where:
- password is the password of the www-data user
- localhost the database host name
- v1.2_mapfishsample the name of the database
Now edit /client/examples/examples.js, comment the OpenLayers.ProxyHost and mapfish.PROXY_HOST variables, and set mapfish.SERVER_BASE_URL to "../../".
// The geostat and search examples use XMLHttpRequest to read features from
// the server. If those XMLHttpRequest's target a different domain than
// that serving the page, some proxy is needed. So do not set ProxyHost
// (and comment this line) if the example pages are served by the same
// domain than that responding to the XMLHttpRequest's. Otherwise set up a
// proxy script (for example using the provided proxy.cgi script) and
// adjust the OpenLayers.ProxyHost variable accordingly.
//OpenLayers.ProxyHost = "/cgi-bin/proxy.cgi?url=";
// The editing-panel example also uses XMLHttpRequest to create, read,
// update and delete features. Because proxy.cgi does not support other
// HTTP verbs than GET and POST another proxy is needed for this example to
// work correctly. Such a proxy is provided in the examples/ directory.
//mapfish.PROXY_HOST = '/proxy/http-proxy.py';
// Define a constant with the base url to the MapFish web service. If you
// want to rely on the MapFish services provided on demo.mapfish.org/trunk,
// leave this variable untouched; otherwise modify it appropriately. You
// may want to use ''.
mapfish.SERVER_BASE_URL = '../../';
Run
First, make sure the virtual Python environment is activated. Your prompt should look like:
(env) $
(If unsure see How ToInstall Map Fish From Source.)
Then:
(env) $ cd /sample (env) $ paster serve development.ini
After that, the Web application will be available at the http://localhost:5000/ URL.