Future/AdvancedEditing

Version 6 (modified by jachym, 6 years ago)

More detailed attribute management

Advanced Editing

Existing code

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/

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
  • Point Array Snapping : This means that when used (ctrl key down in the demo), the mouse pointer coordinates are compared to each vertex coordinates of bounds matching features geometries.
    • Pros :
      • This allows to snap on features from different layers,
      • Performances are not bad
    • Cons :
      • Snapping on segments doesn't seem possible

Create Island/Donut Polygons

Attribute management

Eeach feature should get new data: {} atribute, which could be used for attribute management. I have some nearly working example, just ask, if you are interested -- Jachym

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: {}