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

Patrick Valsecchi patrick.valsecchi at camptocamp.com
Fri Nov 16 03:25:23 EST 2007

Hi Tim,

On Thursday 15 November 2007, Tim Schaub wrote:
> 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.

Why would that be a mistake? Because there is no rectangle in the OGC spec? 
Why should we limit ourself to what the OGC defines? I'm sorry, but I can see 
rectangles and circles in the OGC spec. Maybe not as features, but in the 
OpenGIS standard, I see rectangles and circles in the form of "bounding box" 
and "WHERE ST_DISTANCE(center, geometry)<radius".

Yes, you can represent a rectangle with a polygon, but you loose the 
information its a polygon. Yes, you can approximate a circle with a polygon, 
but you loose information and precision. Yes you can add some info to the 
polygon to tell it is regular or it is a rectangle, but it's going to be hard 
to interpret this information.

In the application I'm working on, it's not features the user is drawing, its 
a query. That's why I need circles (all the features in a certain distance) 
and rectangles (they want rectangles). And no, a polygon cannot replace a 
circle in this case. So I have to translate the polygon into a circle. And 
event with 30 nodes, the "circle" in my map looks ugly when you zoom in. And 
I don't mention the performance problems with SVG.

For me, we should support all the shapes the end user (the one behind his 
browser and that don't care about the limitations of the OGC) will need. That 
means circles, bezier curves, ... .  And if "crazy" shapes like that have to 
be sent to a WFS service, then they can be translated into approximative 
polygons or polylines by the formatter. But, again, you'll loose some 
information. But at least programmers dealing with less limited services 
won't suffer.

I would not have any problem with the absence of rectangles and circles if 
OpenLayers was allowing to easily add new shapes. But, the way it is now, 
it's very hard to do it. Maybe we should go more in the direction I took with 
my ModifyFeature patch proposal and allow the user to add "handlers" for 
non-standard shapes. That means stop doing series of "if"s on the CLASS_NAME 
in the renderers/formatters and start using a hashmap instead. That way, 
crazy users like me can add support for new shapes without bothering the 
others with stupid emails like this one. ;-)

By the way, if we really want to stick to the OGC definition of geometries, 
then we have a few bugs in OpenLayers. It shouldn't allow the creation of 
invalid polygons (for example self intersecting ones). But that one is going 
to be tough to implement in JS.


More information about the Dev mailing list