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

Tim Schaub tschaub at openplans.org
Thu Nov 15 11:51:20 EST 2007


Hey-

I'm a bit behind here, but I'll throw in my opinion.

I don't want to support Geometry.Rectangle.  I think it was an accident 
to let it in the trunk, and I hope it goes away.

I'm very much in favor of adding properties to a polygon like "regular" 
(boolean) and "sides" (integer).

This way, controls could (optionally) respect these properties of a 
polygon - allowing for editing that would maintain the geometry "class."

A rectangle is a four sided irregular polygon.  A circle is a many 
(maybe 30, who knows) sided regular polygon.  Turning a circle into an 
ellipse is as easy as modifying while respecting the number of sides and 
ignoring the "regular" property.  As mentioned before, no need to create 
new classes when we can modify behavior with a few properties on an 
existing class.

Tim


Eric Lemoine wrote:
> On Nov 12, 2007 11:10 AM, Patrick Valsecchi
> <patrick.valsecchi at camptocamp.com> wrote:
>> 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?
> 
> Your approach sounds fine to, please open a ticket and possibly add a
> patch. I'll review it.
> 
> I'd like to add a few things:
> 
> To me regular polygons must be .Geometry.Polygons. However, polygons
> drawn with the RegularPolygon handler could have some shape-type
> property set. For example, a polygon could have its 'circle' property
> set to true. In this way, Control.ModifyFeature can recognize regular
> polygons and behave appropriately. For example, two virtual vertices
> (center + a vertex on the circle border) will be displayed when
> modifying polygons with their 'circle' property set to true.
> 
> Serialization/deserialization using OpenLayers.Format's won't be a
> problem as regular problems are polygons.
> 
> --
> Eric
> _______________________________________________
> Dev mailing list
> Dev at openlayers.org
> http://openlayers.org/mailman/listinfo/dev
> 
> !DSPAM:4033,4739eeb0264841015089218!
> 




More information about the Dev mailing list