Adding getVertices method to all geometries. Call with nodesOnly true if you only want endpoints (of lines and multilines). r=crschmidt (closes #1192)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@8842 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Tim Schaub
2009-02-05 22:49:03 +00:00
parent dd70dceef9
commit df920a88d5
9 changed files with 190 additions and 0 deletions

View File

@@ -154,6 +154,30 @@ OpenLayers.Geometry.LineString = OpenLayers.Class(OpenLayers.Geometry.Curve, {
return segments.sort(byX1);
},
/**
* APIMethod: getVertices
* Return a list of all points in this geometry.
*
* Parameters:
* nodesOnly - {Boolean} For lines, only return vertices that are
* endpoints.
*
* Returns:
* {Array} A list of all vertices in the geometry.
*/
getVertices: function(nodesOnly) {
var vertices;
if(nodesOnly) {
vertices = [
this.components[0],
this.components[this.components.length-1]
];
} else {
vertices = this.components;
}
return vertices;
},
/**
* APIMethod: distanceTo
* Calculate the closest distance between two geometries.