Add LineString/linestring.

The inhertance of this class might change in the future.
This commit is contained in:
Marc Jansen
2012-06-21 15:57:04 +02:00
parent 745ae25b6b
commit ce49bb8876
4 changed files with 536 additions and 0 deletions

63
src/ol/geom/LineString.js Normal file
View File

@@ -0,0 +1,63 @@
goog.provide('ol.geom.LineString');
goog.require('goog.array');
goog.require('ol.geom.Geometry');
goog.require('ol.geom.Point');
goog.require('ol.Projection');
/**
* Creates ol.geom.LineString objects.
*
* @extends {ol.geom.Geometry}
* @param {Array.<ol.geom.Point>} vertices An array of points building the
* linestrings vertices.
*
* @constructor
*/
ol.geom.LineString = function(vertices) {
/**
* @private
* @type {Array.<ol.geom.Point>}
*/
this.vertices_ = vertices;
};
goog.inherits(ol.geom.LineString, ol.geom.Geometry);
/**
* Sets the LineString's points.
*
* @return {Array.<ol.geom.Point>} An array of points.
*/
ol.geom.LineString.prototype.getVertices = function() {
return this.vertices_;
};
/**
* Gets the LineString's points.
*
* @param {Array.<ol.geom.Point>} vertices An array of points.
*/
ol.geom.LineString.prototype.setVertices = function(vertices) {
this.vertices_ = vertices;
};
/**
* Adds the given vertex to the list of vertices at the specified index.
*
* @param {ol.geom.Point} vertex A point to be added.
* @param {number} index The index where to add.
*/
ol.geom.LineString.prototype.addVertex = function(vertex, index) {
goog.array.insertAt(this.vertices_,vertex,index);
};
/**
* Removes the given vertex from the list of vertices.
*
* @param {ol.geom.Point} vertex A point to be removed.
*/
ol.geom.LineString.prototype.removeVertex = function(vertex) {
goog.array.remove(this.vertices_, vertex);
};