From ac37980999c3e5d3136f8c984bf5e50615bb7712 Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Wed, 6 Nov 2013 20:46:04 +0100 Subject: [PATCH] Add ol.geom.LineString --- src/ol/geom/linestring.js | 64 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 src/ol/geom/linestring.js diff --git a/src/ol/geom/linestring.js b/src/ol/geom/linestring.js new file mode 100644 index 0000000000..af34ea6417 --- /dev/null +++ b/src/ol/geom/linestring.js @@ -0,0 +1,64 @@ +goog.provide('ol.geom.LineString'); + +goog.require('goog.asserts'); +goog.require('ol.extent'); +goog.require('ol.geom.Geometry'); + + + +/** + * @constructor + * @extends {ol.geom.Geometry} + * @param {Array.} coordinates Coordinates. + */ +ol.geom.LineString = function(coordinates) { + + goog.base(this); + + /** + * @private + * @type {Array.>} + */ + this.coordinates_ = coordinates; + +}; +goog.inherits(ol.geom.LineString, ol.geom.Geometry); + + +/** + * @return {Array.>} Coordinates. + */ +ol.geom.LineString.prototype.getCoordinates = function() { + return this.coordinates_; +}; + + +/** + * @inheritDoc + */ +ol.geom.LineString.prototype.getExtent = function(opt_extent) { + if (this.extentRevision != this.revision) { + this.extent = ol.extent.createOrUpdateFromCoordinates( + this.coordinates_, this.extent); + this.extentRevision = this.revision; + } + goog.asserts.assert(goog.isDef(this.extent)); + return ol.extent.returnOrUpdate(this.extent, opt_extent); +}; + + +/** + * @inheritDoc + */ +ol.geom.LineString.prototype.getType = function() { + return ol.geom.GeometryType.LINE_STRING; +}; + + +/** + * @param {Array.} coordinates Coordinates. + */ +ol.geom.LineString.prototype.setCoordinates = function(coordinates) { + this.coordinates_ = coordinates; + this.dispatchChangeEvent(); +};