Future/AdvancedEditing

Advanced Editing

Miscelaneous Discussions

Steven M. Ottens and Tim Schaub point of view :  http://www.nabble.com/editing-controls%2C-preserve-selection-tf4311375.html

Existing code

camptocamp Sandbox

A basic 'snap to vertex' and 'snap to edge' example is available:  http://dev.openlayers.org/sandbox/camptocamp/feature/examples/modify-feature.html

The code is based on  Tim's feature sandbox

The snapping method is 100% algorithmic (no browser events) and implemented is a handler ( OpenLayers.Handler.Snapping ), this handler is used in OpenLayers.Handler.Point to snap the cursor while drawing.

Vector Branch

Some of the following elements have already been implemented in the old vector branch.

See :

Tim Sandbox

Future code must be based on Tim's code.

See:  http://dev.openlayers.org/sandbox/tschaub/feature/examples/modify-feature.html

Jachym Sandbox

Jachym Cepicky wrote some great code based on Tim's work to provide drag/add/remove vertices tools and snapping functionnality.

It has to be improved in some way but this is probably a good start.

The snapping implementation doesn't feel good to me though because it requires a server-side service.
No, it does not: the functions are designed, so that no server-side services are required. Empty method customSnap(event) is defined, which can be modified according to users needs (I use it for server-side snapping). -- Jachym

See:  http://www.bnhelp.cz/mapserv/pokusy/openlayers/digitalizace/ and #954

Detailed (Needed) Functionnalities

Drag/Add/Remove Vertex

We should consider the "unique tool for everything" available in google "my maps". For example, user doesn't have to change tool to remove a vertex. Adding a new point is as simple as dragging the center point of a segment.

Stvn (on IRC) said :

I don't understand why you don't draw the vertices AND nodes when editing
this way it is easy to drag nodes, you don't need to switch editing mode
like google does nowadays with 'my maps'

Drag Vertex

We should be able to drag a vertex.

Add Vertex

We should be able to add a vertex on a segment between two vertices.

Remove Vertex

We should be able to remove a vertex by clicking on it.

Snapping

In the old vector sandbox, 2 different snapping mode were implemented :

  • Vector Snapping : It was divided into PointSnapping and SegmentSnapping. At first, this mode was used to help editing tools. For example, the add vertex tool calls it to place the point.
    • Pros :
      • Allows to snap on segments,
      • Takes advantage of the vector renderer
      • So really fast
    • Cons :
      • Can't provide snapping on different layers

Create Multi-Line/Multi-Polygon/Polygons with inner rings

The key here is to create a transaction mode. With point/line/polygon/multipoint, you only need a single digitization operation. For this use case you need to allow multiple ones. Therefore you have to have a start and end operation. Once you are digitizing multiple geometry parts, the only question is with a multipolygon whether additional parts are new polygons or inner rings for existing polygons. One way to do this is by figuring out if the first vertex is inside or outside an existing polygon. Leica Geosystems/IONIC Enterprise has written code to do this and if they would ever sign a contributor's agreement, they would get their code up here.

Attribute management

Steps needed to be performed:

  • Defining attribute table, columns, their names, size, type
  • After new feature is digitized, displaying the attribute empty form
  • After old feature is selected, displaying the attribute filled form

New methods (accesable from OpenLayers.Handler.Point, OpenLayers.Handler.Path, OpenLayers.Handler.Polygon) needed to work with attributes:

  • makeAttributeForm() {} -- returns <form></form> with all <input></input>s according to data:{}
  • updateAttributes(form) {} -- stores attributes to data{} structure according to filled HTML form
  • setAttributes(attributes){} -- while feature initialization, the data = {}, this method should provide something like data = {att1:, att2:, att3:,...)

New attributes (Point/Path,Polygon):

  • data: {}