Skip to content

Commit

Permalink
handle features with null bounds in OpenLayers.Renderer.Canvas.drawFe…
Browse files Browse the repository at this point in the history
…ature. p=arublev,me r=erilem (closes #3442)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@12205 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
  • Loading branch information
fredj committed Aug 3, 2011
1 parent d1fe8f8 commit 0b8a98d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
5 changes: 3 additions & 2 deletions lib/OpenLayers/Renderer/Canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,9 @@ OpenLayers.Renderer.Canvas = OpenLayers.Class(OpenLayers.Renderer, {
if (feature.geometry) {
style = this.applyDefaultSymbolizer(style || feature.style);
// don't render if display none or feature outside extent
rendered = (style.display !== "none") &&
feature.geometry.getBounds().intersectsBounds(this.extent);
var bounds = feature.geometry.getBounds();
rendered = (style.display !== "none") && !!bounds &&
bounds.intersectsBounds(this.extent);
if (rendered) {
// keep track of what we have rendered for redraw
this.features[feature.id] = [feature, style];
Expand Down
11 changes: 10 additions & 1 deletion tests/Renderer/Canvas.html
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
return;
}

t.plan(8);
t.plan(10);
var layer = new OpenLayers.Layer.Vector(null, {
isBaseLayer: true,
renderers: ["Canvas"]
Expand Down Expand Up @@ -183,6 +183,15 @@
t.eq(count, 1, "d) redraw is called when drawing a feature outside renderer extent");
renderer.clear();

// e) draw a polygon feature without bounds
count = 0;
exp = renderer.drawFeature(
new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Polygon()), {}
);
t.eq(exp, false, "d) drawFeature returns false");
t.eq(count, 1, "d) redraw is called when drawing a feature without bounds");
renderer.clear();

map.destroy();
}

Expand Down

0 comments on commit 0b8a98d

Please sign in to comment.