Ticket #3442 (closed bug: fixed)

Opened 22 months ago

Last modified 22 months ago

Fix OpenLayers.Renderer.Canvas.drawFeature method in case if feature's bounds are empty

Reported by: arublev Owned by: crschmidt
Priority: major Milestone: 2.11 Release
Component: Renderer.Canvas Version: 2.11 RC1
Keywords: Cc:
State: Pullup

Attachments

3442.0.patch Download (0.9 KB) - added by fredj 22 months ago.
3442.1.patch Download (1.8 KB) - added by fredj 22 months ago.
adding unit tests

Change History

  Changed 22 months ago by arublev

  • type changed from feature to bug

follow-up: ↓ 4   Changed 22 months ago by fredj

looks good to go: this check is missing for Renderer.Canvas but already done for Renderer (see source:trunk/openlayers/lib/OpenLayers/Renderer.js#L181)

Changed 22 months ago by fredj

  Changed 22 months ago by fredj

  • state set to Review

in reply to: ↑ 2   Changed 22 months ago by erilem

Replying to fredj:

looks good to go: this check is missing for Renderer.Canvas but already done for Renderer (see source:trunk/openlayers/lib/OpenLayers/Renderer.js#L181)

Fredj, could do write a quick test for that before commit? If you have no time, I'll do it. Thanks.

Changed 22 months ago by fredj

adding unit tests

  Changed 22 months ago by fredj

attachment:"3442.1.patch" Download adds units tests (using a Polygon geometry with no coordinates: new OpenLayers.Geometry.Polygon().getBounds() returns null).

I've also updated the test in drawFeature: instead of:

rendered = (style.display !== "none") && bounds && bounds.intersectsBounds(this.extent)

it's now:

rendered = !!(style.display !== "none" && bounds && bounds.intersectsBounds(this.extent))

because if bounds is null, rendered equals null.

A side effect of writing unit tests: finding bugs :-)

follow-up: ↓ 7   Changed 22 months ago by erilem

  • state changed from Review to Commit

For clarity I'd rather do

rendered = (style.display !== "none") && !!bounds && bounds.intersectsBounds(this.extent);

With that we make it explicit what element we need to cast to a boolean.

Please commit with the statement you like most.

in reply to: ↑ 6   Changed 22 months ago by fredj

Replying to erilem:

For clarity I'd rather do {{{ rendered = (style.display !== "none") && !!bounds && bounds.intersectsBounds(this.extent); }}} With that we make it explicit what element we need to cast to a boolean. Please commit with the statement you like most.

your version is is more clear, thanks

  Changed 22 months ago by fredj

  • status changed from new to closed
  • resolution set to fixed

(In [12205]) handle features with null bounds in OpenLayers.Renderer.Canvas.drawFeature. p=arublev,me r=erilem (closes #3442)

  Changed 22 months ago by fredj

  • status changed from closed to reopened
  • state changed from Commit to Pullup
  • resolution fixed deleted

  Changed 22 months ago by ahocevar

  • status changed from reopened to closed
  • resolution set to fixed

in 2.11-rc2

Note: See TracTickets for help on using tickets.