Making it so you can remove more points from a linear ring. p=gregers, r=me (closes #2172)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@11819 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -93,7 +93,7 @@ OpenLayers.Geometry.LinearRing = OpenLayers.Class(
|
|||||||
* point - {<OpenLayers.Geometry.Point>}
|
* point - {<OpenLayers.Geometry.Point>}
|
||||||
*/
|
*/
|
||||||
removeComponent: function(point) {
|
removeComponent: function(point) {
|
||||||
if (this.components.length > 4) {
|
if (this.components.length > 3) {
|
||||||
|
|
||||||
//remove last point
|
//remove last point
|
||||||
this.components.pop();
|
this.components.pop();
|
||||||
|
|||||||
@@ -58,7 +58,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function test_LinearRing_removeComponent(t) {
|
function test_LinearRing_removeComponent(t) {
|
||||||
t.plan(11);
|
t.plan(10);
|
||||||
|
|
||||||
var components = [new OpenLayers.Geometry.Point(0,0),
|
var components = [new OpenLayers.Geometry.Point(0,0),
|
||||||
new OpenLayers.Geometry.Point(0,10),
|
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.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[0].equals(components[0]), "point one correct");
|
||||||
t.ok(ring.components[1].equals(components[1]), "point two 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],
|
t.ok(ring.components[0] === ring.components[ring.components.length - 1],
|
||||||
"first and last point are the same");
|
"first and last point are the same");
|
||||||
|
|
||||||
@@ -80,10 +80,10 @@
|
|||||||
t.ok(ringBounds.equals(testBounds), "bounds correctly recalculated");
|
t.ok(ringBounds.equals(testBounds), "bounds correctly recalculated");
|
||||||
|
|
||||||
ring.removeComponent( ring.components[2] );
|
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[0].equals(components[0]), "point one correct");
|
||||||
t.ok(ring.components[1].equals(components[1]), "point two 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],
|
t.ok(ring.components[0] === ring.components[ring.components.length - 1],
|
||||||
"first and last point are the same");
|
"first and last point are the same");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user