The edit
plugin allows users to edit geographical data from their web browser.
Here are the options that can be set on the client:
- general.allowedRoles: comma separated list of the roles that are allowed to use the edit plugin
- insertedFeaturesMaxNumber: integer, number of new features that user is allowed to draw for insertion in the database Set it to 0 if user is only allowed to update or delete features.
- editLayers: comma separated list of layers that are editable
- editResultNbCol: number of columns to use to display the attributes table
-
editDisplayAction:
this string parameter is used to tell if the "validate" and "cancel" buttons
have to be displayed also under the attributes table. If empty or
both
, buttons will be displayed both in the folder and under the attributes table. Iffolder
, buttons will be displayed only in the folder.
Specific metadatas must be set in the mapfile for the editable layers
METADATA ... 'edit_table' 'edit_poly' # PostGIS table 'edit_geometry_column' 'the_geom' # PostGIS geometry column 'edit_geometry_type' 'polygon' # PostGIS geometry type 'edit_srid' '-1' 'edit_attributes' 'parc_id,name|string,culture|string,surf,parc_type|integer' # list of the editable fields 'edit_rendering' ',,textarea,hidden,' # OPTIONAL! list of visual rendering of inputs in the form END
- edit_table: string, name of the postGIS table to edit
- edit_geometry_column: string, name of the geometry field in the table
- edit_geometry_type: string, type of the geometry of the features for the layerpossible values are point, line, polygonMay differ from the msLayer type (rendering)
- edit_srid: integer (optional), id of the SRID
-
edit_attributes:
string, comma separated list of attributes used for edition.Each value represents the attribute name and type separated by a
pipe symbol. Only attributes with type set are editable.
Warning
Attribute types available values are 'string' and 'integer'.
-
edit_rendering:
OPTIONAL! string, comma separated list of rendering type used when displaying the edition form. Each value represents the type of input the user will see in the form when editing a feature. Attribute type available values are:
- (empty) : if no type is set, an input type text is displayed. This is the default behaviour.
- hidden : input type hidden.
- textarea : textarea element.
Warning
edit_rendering is absolutly optional. If edit_rendering is not set, all inputs will be simple text input.
In this section are described the steps to get the edit plugin working on a cartoweb project.
-
First, you need a PostgreSQL database with postGIS enabled. Let's say, it is named "edit_db" for the following explanations.
At that point, you may launch demoEdit_schema.sql and demoEdit_data.sql. located in the
<CARTOWEB_HOME>/projects/demoEdit/
directory. This will create 3 sample geometry tables, one for each type of geometry.-
In CartoWeb, you'll have to load the edit plugin in your project on both client and server sides.
loadPlugins = [...], edit
-
Then, you'll need to configure the plugin by setting the layer_ids in the editLayers parameter in the edit.ini file.
editLayers = edit_poly, edit_line, edit_point
-
In your mapfile, in the corresponding LAYER, you'll have to set the specific metadatas as following :
LAYER NAME "edit_poly" STATUS ON TYPE POLYGON CONNECTIONTYPE POSTGIS CONNECTION 'dbname=edit_db user=www-data password=www-data host=localhost' DATA 'the_geom from (select the_geom, oid, parc_id, name, culture, surf, parc_type from edit_poly) as foo' TEMPLATE 'ttt' [...] LABELITEM "name" CLASS NAME "class" STYLE COLOR 50 50 255 OUTLINECOLOR 255 50 50 END LABEL [...] END END METADATA 'id_attribute_string' 'parc_id' # query 'query_returned_attributes' 'parc_id name culture surf parc_type' 'edit_table' 'edit_poly' # PostGIS table 'edit_geometry_column' 'the_geom' # PostGIS geometry column 'edit_geometry_type' 'polygon' # PostGIS geometry type 'edit_srid' '-1' 'edit_attributes' 'parc_id,name|string,culture|string,surf,parc_type|integer' # list of the editable fields 'edit_filter' '' # mapserver filter END END
Warning
Make sure that your
edit_attributes
list does not include spaces between attributes.

