OpenLayers OpenLayers

Ticket #1698 (closed feature: fixed)

Opened 3 months ago

Last modified 3 months ago

sketch handler updates

Reported by: tschaub Assigned to: elemoine
Priority: minor Milestone: 2.7 Release
Component: Handler.Point Version: 2.6
Keywords: Cc:
State: Complete

Description

I've updated the sketch handlers in a couple sandboxes. I'm collecting changes here in hopes of getting them in to the trunk.

These changes include the following:

  • Sketch handlers get a multi property. If multi is true, the handlers return a multi-part geometry. This is not multi-part geometry editing, but it allows multi-part geometries to be created by the sketch handlers.
  • Sketch handlers get a persist property. If you want to use the sketch handlers for temporary drawing, and you want that sketch to stay drawn until the handler is deactivated or another sketch is drawn, set persist to true.
  • Point callback gets full geometry in addition to last added point. This allows a control that is using the handler to do something with the entire sketch each time a new point is added.

Attachments

sketch.patch (9.6 kB) - added by tschaub on 08/22/08 20:11:33.
update to sketch handlers
sketch.2.patch (10.4 kB) - added by tschaub on 09/04/08 19:18:54.
updates to sketch handlers

Change History

08/22/08 20:11:33 changed by tschaub

  • attachment sketch.patch added.

update to sketch handlers

08/22/08 20:12:47 changed by tschaub

I'm sure "needs tests" is the next comment, but I thought I would start with the code changes.

08/26/08 04:16:40 changed by euzuro

  • state set to Review.

(follow-up: ↓ 7 ) 09/03/08 10:53:19 changed by elemoine

Tim,

Handler/Point.js:

  • destroyFeature should check if the layer isn't null before doing layer.destroyFeatures(), I have a case where a featureAdded callback (set in a draw feature control) deactivates the draw feature control, and deactivating the draw feature control destroys the sketch layer

Thanks

09/03/08 18:18:55 changed by euzuro

  • owner changed from tschaub to elemoine.

09/04/08 00:35:40 changed by euzuro

warning: this is getting moved to 2.8 unless it can gets reviewed and committed in the next 30 hours or so....

(follow-ups: ↓ 8 ↓ 9 ) 09/04/08 04:12:50 changed by elemoine

  • state changed from Review to Needs More Work.

My final review comments.

Handler/Point.js:

  • destroyFeature should check if the layer isn't null before doing layer.destroyFeatures(), I have a case where a featureAdded callback (set in a draw feature control) deactivates the draw feature control, and deactivating the draw feature control destroys the sketch layer
  • why does createFeature now call layer.addFeatures (with a feature whose geometry has no coordinates)? I've seen issues with this and the new renderer code. The new renderer code does if (!feature.geometry.getBounds().intersectsBounds(this.extent)) { which is problematic if the geometry has no coordinates (getBounds() returns null)
  • because of the above (I think), the unit tests fail with current trunk
  • if we use addFeatures we should pass it {silent: true} to avoid featureadded and featuresadded events
  • layerOptions should be a class property

(in reply to: ↑ 3 ) 09/04/08 18:19:56 changed by tschaub

Replying to elemoine:

Handler/Point.js: * destroyFeature should check if the layer isn't null before doing layer.destroyFeatures(), I have a case where a featureAdded callback (set in a draw feature control) deactivates the draw feature control, and deactivating the draw feature control destroys the sketch layer

Easy enough.

(in reply to: ↑ 6 ) 09/04/08 18:25:45 changed by tschaub

Replying to elemoine:

Handler/Point.js: * why does createFeature now call layer.addFeatures (with a feature whose geometry has no coordinates)? I've seen issues with this and the new renderer code. The new renderer code does if (!feature.geometry.getBounds().intersectsBounds(this.extent)) { which is problematic if the geometry has no coordinates (getBounds() returns null)

I was previously just doing layer.drawFeature(feature) instead of adding the feature to the (temporary) layer. This meant if you set persist to true and zoomed out after drawing a sketch, the sketch would not get redrawn. The proper way to draw features is to have them on the layer.

The renderer changes introduce a regression. Previously, we could add a feature to a layer with null geometry. I thought ahocevar changed things so this would still be allowed. I'll poke around a bit.

* because of the above (I think), the unit tests fail with current trunk

Will figure this out.

* if we use addFeatures we should pass it {silent: true} to avoid featureadded and featuresadded events

This is a temporary layer that only the handler has a reference to. Can't imagine who is registering any listeners for events there. But it is easy enough to call with silent true.

* layerOptions should be a class property

Will do.

(in reply to: ↑ 6 ) 09/04/08 19:10:37 changed by tschaub

Replying to elemoine:

Handler/Point.js: * because of the above (I think), the unit tests fail with current trunk

Ok, there were a couple places where the sketch handlers were still modifying geometries without clearing bounds. Previously, this wasn't a problem because the getBounds was not being called until all point geometries had valid coords.

09/04/08 19:18:54 changed by tschaub

  • attachment sketch.2.patch added.

updates to sketch handlers

09/04/08 19:20:21 changed by tschaub

  • state changed from Needs More Work to Review.

New patch addresses all issues above. Examples work, (relevant) tests pass.

09/05/08 03:36:59 changed by elemoine

  • state changed from Review to Commit.

This is looking good. I tested the patch in my application (with the measure control and persis:true) and it works great. Please commit.

09/05/08 11:06:04 changed by euzuro

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

(In [7964]) Sketch handler updates. Patch by tschaub, review elemoine (Closes #1698)