sfMapFishPlugin - 1.0.2
You are currently browsing
the website for symfony 1
MapFish is an easy-to-use and extensible web 2.0 mapping application framework.
|Camptocamp||lead||moc.pmacotpmac <<ta>> tba.eniotna|
* Copyright (c) 2009, Camptocamp
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the University of California, Berkeley nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
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
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 sfMapFishTable
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).
Troubleshooting: You may need to manually set the java path to get it working:
All classes have full API documentation.
You will also find some information on the MapFish website:
If you want to contribute, follow these steps:
sfMapFishPluginas the component
Ready for core team
This plugin is realeased under a BSD license.