#912 first and last component of a linear ring refer to the same point
git-svn-id: http://svn.openlayers.org/trunk/openlayers@3956 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -65,22 +65,20 @@ OpenLayers.Geometry.LinearRing = OpenLayers.Class(
|
||||
var added = false;
|
||||
|
||||
//remove last point
|
||||
var lastPoint = this.components[this.components.length-1];
|
||||
OpenLayers.Geometry.Collection.prototype.removeComponent.apply(this,
|
||||
[lastPoint]);
|
||||
var lastPoint = this.components.pop();
|
||||
|
||||
// given an index, add the point
|
||||
// without an index only add non-duplicate points
|
||||
if(index != null || !point.equals(lastPoint)) {
|
||||
added = OpenLayers.Geometry.Collection.prototype.addComponent.apply(this,
|
||||
arguments);
|
||||
arguments);
|
||||
}
|
||||
|
||||
//append copy of first point
|
||||
var firstPoint = this.components[0];
|
||||
OpenLayers.Geometry.Collection.prototype.addComponent.apply(this,
|
||||
[firstPoint.clone()]);
|
||||
|
||||
[firstPoint]);
|
||||
|
||||
return added;
|
||||
},
|
||||
|
||||
@@ -95,9 +93,7 @@ OpenLayers.Geometry.LinearRing = OpenLayers.Class(
|
||||
if (this.components.length > 4) {
|
||||
|
||||
//remove last point
|
||||
var lastPoint = this.components[this.components.length-1];
|
||||
OpenLayers.Geometry.Collection.prototype.removeComponent.apply(this,
|
||||
[lastPoint]);
|
||||
this.components.pop();
|
||||
|
||||
//remove our point
|
||||
OpenLayers.Geometry.Collection.prototype.removeComponent.apply(this,
|
||||
@@ -105,10 +101,57 @@ OpenLayers.Geometry.LinearRing = OpenLayers.Class(
|
||||
//append copy of first point
|
||||
var firstPoint = this.components[0];
|
||||
OpenLayers.Geometry.Collection.prototype.addComponent.apply(this,
|
||||
[firstPoint.clone()]);
|
||||
[firstPoint]);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: move
|
||||
* Moves a collection in place
|
||||
*
|
||||
* Parameters:
|
||||
* x - {Float} The x-displacement (in map units)
|
||||
* y - {Float} The y-displacement (in map units)
|
||||
*/
|
||||
move: function(x, y) {
|
||||
for(var i = 0; i < this.components.length - 1; i++) {
|
||||
this.components[i].move(x, y);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: rotate
|
||||
* Rotate a geometry around some origin
|
||||
*
|
||||
* Parameters:
|
||||
* angle - {Float} Rotation angle in radians (measured counterclockwise
|
||||
* from the positive x-axis)
|
||||
* origin - {<OpenLayers.Geometry.Point>} Center point for the rotation
|
||||
*/
|
||||
rotate: function(angle, origin) {
|
||||
for(var i=0; i<this.components.length - 1; ++i) {
|
||||
this.components[i].rotate(angle, origin);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: resize
|
||||
* Resize a geometry relative to some origin. Use this method to apply
|
||||
* a uniform scaling to a geometry.
|
||||
*
|
||||
* Parameters:
|
||||
* scale - {Float} Factor by which to scale the geometry. A scale of 2
|
||||
* doubles the size of the geometry in each dimension
|
||||
* (lines, for example, will be twice as long, and polygons
|
||||
* will have four times the area).
|
||||
* origin - {<OpenLayers.Geometry.Point>} Point of origin for resizing
|
||||
*/
|
||||
resize: function(scale, origin) {
|
||||
for(var i=0; i<this.components.length - 1; ++i) {
|
||||
this.components[i].resize(scale, origin);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: getArea
|
||||
* Note - The area is positive if the ring is oriented CW, otherwise
|
||||
|
||||
Reference in New Issue
Block a user