![]() |
|
sfMapFishPlugin - 1.0.3MapFish Server |
|
The sfMapFishPlugin packages useful libraries and tools to publish and interact with your vector GIS data in a PostgreSQL/PostGIS database.
It is a PHP implementation for the MapFish framework, targeted at the popular Symfony framework and Doctrine ORM.
Install the plugin
$ symfony plugin:install sfMapFishPlugin
Clear the cache
$ symfony cache:clear
Build (or rebuild the model)
$ symfony doctrine:build-model
At this step, your geometry column should be set as a blob in your schema.
the_geom: { type: blob }
It's quite simple to generate a module which exposes your geographic data through a RESTful API, via the MapFish Protocol.
Say you want to be able to CREATE/READ/UPDATE/DELETE geographic features in a table with a geographic column. Just follow these three easy steps:
In lib/model/doctrine/YourModelClass.php, specify your table's geometric column name and its EPSG code, by adding such a line:
public static $geometryColumn = array('the_geom' => 4326);
Here, we have a table with a geometric column whose name is 'the_geom', and its projection code is EPSG:4326
Make YourModelTable extend sfMapFishTable instead of Doctrine_Table: in lib/model/doctrine/YourModelTableClass.php, you should have:
YourModelTable extends sfMapFishTableUnset the geometric column from the configure method of the form in lib/form/doctrine/YourModelForm.class.php:
unset($this['the_geom']);
You're now ready to generate a MapFish module tied to this Model, by the way of the mapfish:generate-module built-in task:
$ ./symfony mapfish:generate-module --generate-route frontend your_module YourModel
The --generate-route will update the routing.yml file for the frontend application, by adding the corresponding sfMapFishRoute. In this example, the resulting module will be named "your_module". You may want to customize this !
Once this is done, clear your cache, and check you've got some GeoJSON data out of /index.php/your_module
This being done, you may want to have a look at MapFish client side software, which plays well with this REST API. Just check out http://www.mapfish.org/svn/mapfish/trunk/MapFish/client/mfbase/ into your project's web/js directory, and read the doc or browse the examples ;-)
For quick CRUD operations on your data, you can take advantage of the existing mapfish.widgets.editing.FeatureEditingPanel widget, which is being showcased here.
In case of problems, feel free to drop us a line on the dedicated MapFish mailing list, or IRC
sfMapFishPlugin comes with a built-in controller for the MapFish print protocol, which you can optionally activate if you want your app to produce nice PDF with your maps. (see MapFish PrintModuleDoc)
You'll need to have Sun's JRE installed to make this working.
Enable this module in your app
all:
.settings:
enabled_modules: [default, mfPrint]
Copy the mandatory config file from the plugin to your config directory
$ cp plugins/sfMapFishPlugin/data/print/print.yml config/print.yml
The print module should be ready & responding to /index.php/mfPrint/info to get print configuration. Don't forget to configure the config.yml (see configuration. For instance, you should at least allow the print service to access the WMS services you're using. The provided print.yml example fiel has 3 mandatory fields in the spec: title, comment & mapTitle. If you're getting errors, check your symfony log file to get debug information (if enabled in your application environment).
Once this is done, you can integrate the MapFish print widgets into your client application, which give you the ability to output nice customizable PDF with your maps. Examples can be found here.
Troubleshooting: You may need to manually set the java path to get it working:
sfConfig::set('mf_jre_path', '/usr/bin/');
All classes have full API documentation.
You will also find some information on the MapFish website:
If you want to contribute, follow these steps:
sfMapFishPlugin as the componentReady for core teamThis plugin is realeased under a BSD license.