[OpenLayers-Dev] ModifyFeature for Geometry.Rectangle and others

Patrick Valsecchi patrick.valsecchi at camptocamp.com
Mon Nov 12 05:10:35 EST 2007


Hi,

I'm in the process to write an application where the user can edit geometries 
like polygons, rectangles and circles. When I say edit I don't mean create. 
For example, the user takes an existing circle and changes its center or 
diameter.

With the current state of OpenLayers, I can use ModifyFeature to edit 
polygons. Works great. But for Geometry.Rectangle it's a no go. This class is 
not a Geometry.Collection and thus has no "components" attribute. Because of 
that, the ModifyFeature.collectVertices throws an error.

Now, for the circle, I know that it's not OGC material and I guess you guys 
don't want to add that in OpenLayers. So I need a way to be able to plugin 
external logics in the ModifyFeature to support other kind of shapes.

So here is my proposition:

  1) Change ModifyFeature.collectVertices to use a hash table (a new 
ModifyFeature attribute) that will give the method to use (equivalent of the 
current collectComponentVertices) in function of the geometry.CLASS_NAME 
value.

  2) Add the support for Geometry.Rectangle. The collectComponentVertices for 
this class would register 4 vertices which are Geometry.Point instances with 
a modified move method that would update the x, y, w and h attributes of the 
rectangle and update the 2 neighbor vertices so that they stay coherent (in a 
rectangular formation).

What do you think?
Does anybody see a better way to do it?
Can I go ahead and create a patch on tracker for that?

Thanks for your feedback.



More information about the Dev mailing list