OpenLayers OpenLayers

Ticket #1085 (closed bug: fixed)

Opened 1 year ago

Last modified 11 months ago

DragFeature not working on Rectangle geometries

Reported by: pvalsecc Assigned to:
Priority: minor Milestone: 2.6 Release
Component: general Version: 2.5
Keywords: Cc:
State:

Description

The "move" method is not implemented for this kind of geometry. Patch:

Index: lib/OpenLayers/Geometry/Rectangle.js
===================================================================
--- lib/OpenLayers/Geometry/Rectangle.js        (revision 4930)
+++ lib/OpenLayers/Geometry/Rectangle.js        (working copy)
@@ -87,7 +87,21 @@
     getArea: function() {
         var area = this.width * this.height;
         return area;
-    },
+    },

+    /**
+     * APIMethod: move
+     * Moves a rectangle
+     *
+     * Parameters:
+     * x - {Float}
+     * y - {Float}
+     */
+    move: function(x, y) {
+        this.x = this.x + x;
+        this.y = this.y + y;
+        this.clearBounds();
+    },
+
     CLASS_NAME: "OpenLayers.Geometry.Rectangle"
 });

Attachments

Geometry_Rectangle_move.00.patch (1.6 kB) - added by fredj on 11/12/07 02:31:41.
add the move() function to OpenLayers.Geometry.Rectangle and unit tests

Change History

10/17/07 03:35:46 changed by pvalsecc

  • type changed from feature to bug.

10/17/07 07:14:03 changed by crschmidt

  • milestone set to 2.6 Release.

11/12/07 02:31:41 changed by fredj

  • attachment Geometry_Rectangle_move.00.patch added.

add the move() function to OpenLayers.Geometry.Rectangle and unit tests

11/12/07 02:32:23 changed by fredj

  • keywords set to review.

11/12/07 11:44:19 changed by elemoine

Patch looks good to me.

12/02/07 08:34:55 changed by elemoine

Do we decide to remove Geometry.Rectangle? Once done, this bug should be closed.

12/19/07 23:28:17 changed by tschaub

  • state changed from Review to Awaiting User Feedback.

Well, we could deprecate Geometry.Rectangle. Can you guys (or pvalsecc) comment on whether you are still using rectangles?

12/20/07 03:07:13 changed by pvalsecc

Since you said you where going to remove this class, I stopped using it.

But I still think it's a mistake to limit ourself only to the kind of geometries defined by the OGC. Especially if the work is already done and if the workaround means more work for the browser and the developper.

Anyway... less code means less bugs...

12/20/07 04:21:35 changed by tschaub

Yeah, it's not about the OGC for me. It's about code duplication. I don't necessarily like the idea of writing custom methods for things like move, resize, rotate, transform, and intersects. And then having to put conditions in the renderers and the vector format classes. Then what happens if you're writing to a version of GML that doesn't take a circle? Or what happens when you transform a rectangle (I assume it becomes a regular old polygon again). Anyway, a rectangle seems pretty well supported right now (in terms of drawing and modifying) by just using a polygon. I'm happy to be told otherwise if others want this.

12/20/07 08:06:58 changed by crschmidt

  • state changed from Awaiting User Feedback to Needs Discussion.

I think the biggest problem is (as Tim described) the fact that if we want to support this, we really have to go through and do a lot more work than just this. Things I can think of off the top of my head:

  • Serializing to GML, GeoJSON (which doesn't have a rectangle), GeoRSS (where we've avoided georss:box so far), WKT (no rectangle either?), etc.
  • Rendering rules in more places
  • blah, blah, blah

It's not about OGC vs. non OGC, but simply about our feature model. Since we have a way to transform rectangle-like things into geometries that we can actually just use with all our regular tools, I'm hesitant to extend our feature model for this.

Is there something that the rectangle provides that we dn't provide in any other way? Perhaps regular rectangular polygons need a getWidth/getHeight, for example? If so, I'm happy to figure out how to deal with that...

01/22/08 17:19:02 changed by crschmidt

  • status changed from new to closed.
  • state deleted.
  • resolution set to fixed.

We will never make rectangles do more than they currently do. Use regular polygons.