mark-p-thomas : Polyline Property Updates

Sections

Introduction

Polyline data structures have the problem of property updates. Vertices and segments each have properties that may be derived from neighboring segments & vertices, so each modification of a polyline requires property updates. However, re-deriving properties for the entire polyline with each modification is expensive & undermines the value gained in representing one as a cross-linked double linked list.

With some careful consideration, it can be seen that such updates can easily be limited to a very small number of vertices & segments. Since one has access to these through the modification process, there is no need to traverse the list. As such, after a modification, property updates of ONLY the affected elements can be done with references at hand as a cleanup process.

In this library, such an updating process is handled by overriding an empty method in the base class (addProperties()). This allows derived classes to hook into the updating process for customization of what properties to update & how.

Base Observations

When a polyline is modified, properties need to be updated:

  1. Base vertex properties do not need to be updated as they are provided with the vertices. For example, coordinates. However, 2nd order properties will need to be updated.

  2. No updates are needed on new segments as properties are generated upon segment creation from the adjoining vertices' base properties.

  3. Modified segments must be updated.

  4. 2nd order vertex properties must be updated for any vertex adjacent to a new or updated segment, after all segment updates.

Update Cases

The following table illustrates the modification action & which segments & vertices need to be updated.

Case

Sub-Case

Insert

Before/Prepend

Middle (Before/After)

After/Append

Remove

Before/Trim

Middle (At/Between/FromTo)

After/Trim

Replace

Spit

Copy Range