diff --git a/lib/OpenLayers/Geometry/LinearRing.js b/lib/OpenLayers/Geometry/LinearRing.js index c1a8369f68..3b007d4745 100644 --- a/lib/OpenLayers/Geometry/LinearRing.js +++ b/lib/OpenLayers/Geometry/LinearRing.js @@ -93,7 +93,7 @@ OpenLayers.Geometry.LinearRing = OpenLayers.Class( * point - {} */ removeComponent: function(point) { - if (this.components.length > 4) { + if (this.components.length > 3) { //remove last point this.components.pop(); diff --git a/tests/Geometry/LinearRing.html b/tests/Geometry/LinearRing.html index ea3acca740..5cacd89eb7 100644 --- a/tests/Geometry/LinearRing.html +++ b/tests/Geometry/LinearRing.html @@ -58,7 +58,7 @@ } function test_LinearRing_removeComponent(t) { - t.plan(11); + t.plan(10); var components = [new OpenLayers.Geometry.Point(0,0), new OpenLayers.Geometry.Point(0,10), @@ -71,7 +71,7 @@ t.eq(ring.components.length, 4, "removing from linear ring with 5 points: length ok"); t.ok(ring.components[0].equals(components[0]), "point one correct"); t.ok(ring.components[1].equals(components[1]), "point two correct"); - t.ok(ring.components[2].equals(components[3]), "point one correct"); + t.ok(ring.components[2].equals(components[3]), "point three correct"); t.ok(ring.components[0] === ring.components[ring.components.length - 1], "first and last point are the same"); @@ -80,10 +80,10 @@ t.ok(ringBounds.equals(testBounds), "bounds correctly recalculated"); ring.removeComponent( ring.components[2] ); - t.eq(ring.components.length, 4, "cant remove from linear ring with only 4 points. new length ok (unchanged)"); + ring.removeComponent( ring.components[1] ); + t.eq(ring.components.length, 3, "cant remove from linear ring with only 3 points. new length ok"); t.ok(ring.components[0].equals(components[0]), "point one correct"); t.ok(ring.components[1].equals(components[1]), "point two correct"); - t.ok(ring.components[2].equals(components[3]), "point one correct"); t.ok(ring.components[0] === ring.components[ring.components.length - 1], "first and last point are the same");