[OpenLayers-Dev] Topology proposal

Björn Harrtell bjorn.harrtell at gmail.com
Wed Apr 22 07:14:14 EDT 2009


Hi devs,

I want to make an effort to implement a topology restriction in
OpenLayers (specifically that polygons must share vertices). The ideal
would be something that is reusable for other topology rules than the
one I want to implement at first and my intent is to build it so that
it can be contributed as a patch. I've discussed the matter with Tim
briefly and here is my rough initial design proposal. Any feedback
will of course be appreciated.

I wanted to add this to the wiki at Proposal/Topology but seems I
can't create new wikipages even when I'm logged in, or I'm missing
something. So here is it:

* Represent topology rules as classes in namespace
OpenLayers.Topology.Rule with a base class OpenLayers.Topology.Rule (I
don't really like using the same identifier as a namespace and class,
but I think this is the convention in OpenLayers?). The base class
should provide an interface for checking feature(s) for topology
errors and optionally set the render intent and return the violating
features.

* Add a render intent for indicating topology violation

* Add topologyRules property to OpenLayers.Layer.Vector as an optional
array of topology classes to associate with the layer

* Add topologyAutoCheck boolean property to OpenLayers.Layer.Vector to
indicate if a vector layer automatically should update the topology
render intent on feature changes (default false)

* Add enforceTopology boolean property to
OpenLayers.Control.ModifyFeature to restrict edits to follow the
topology rule by either automatically snapping stuff (if possible) or
disallowing the interaction.

* The first rule to be implemented is that polygons must share
vertices, suggested name is
OpenLayers.Topology.Rules.PolygonsMustShareVertices

Motivations:

* Topology rules could be constant enums instead of classes, the
reasons for suggesting classes are to make it more clear that the rule
should contain as much of the implementation as possible and that one
might want to make OL-builds containing only the rules that are
relevant for the use case.

Uncertainties:

* Where to put the logic that restricts editing - I'm not sure if it's
possible to separate it without creating a dependency mess between
ModifyControl and the topology rule.

With regards,

Björn Harrtell



More information about the Dev mailing list