< Views

Security Configuration >

14. Edition

The Edit plugin allows user to edit geographical data on the browser

14.1. Client-side Configuration

14.1.1. edit.ini

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 boolean parameter is used to tell if the "validate" and "cancel" buttons have to be displayed also under the attributes table

14.2. Related Elements in Mapfile

14.2.1. Metadatas

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
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.Attribute types available values are string and integer.

14.3. How to

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 demo_edit.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 EDITPOLY
      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
    

valid xhtml 1.0 valid css