From c658460c09cdf11229bc7fc89f91988769e8f088 Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Fri, 8 Nov 2013 03:03:04 +0100 Subject: [PATCH] Add ol.geom.MultiLineString --- src/ol/geom/geometry.js | 4 +- src/ol/geom/multilinestring.js | 67 ++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 src/ol/geom/multilinestring.js diff --git a/src/ol/geom/geometry.js b/src/ol/geom/geometry.js index ad3ef65128..a497ea6680 100644 --- a/src/ol/geom/geometry.js +++ b/src/ol/geom/geometry.js @@ -1,5 +1,4 @@ // FIXME add MultiPoint -// FIXME add MultiLineString // FIXME add MultiPolygon // FIXME add GeometryCollection // FIXME add Z and M support @@ -17,7 +16,8 @@ goog.require('goog.events.EventType'); ol.geom.GeometryType = { POINT: 'Point', LINE_STRING: 'LineString', - POLYGON: 'Polygon' + POLYGON: 'Polygon', + MULTI_LINE_STRING: 'MultiLineString' }; diff --git a/src/ol/geom/multilinestring.js b/src/ol/geom/multilinestring.js new file mode 100644 index 0000000000..85370911bb --- /dev/null +++ b/src/ol/geom/multilinestring.js @@ -0,0 +1,67 @@ +goog.provide('ol.geom.MultiLineString'); + +goog.require('goog.asserts'); +goog.require('ol.extent'); +goog.require('ol.geom.Geometry'); + + + +/** + * @constructor + * @extends {ol.geom.Geometry} + * @param {Array.>} coordinatess Coordinatess. + */ +ol.geom.MultiLineString = function(coordinatess) { + + goog.base(this); + + /** + * @private + * @type {Array.>} + */ + this.coordinatess_ = coordinatess; + +}; +goog.inherits(ol.geom.MultiLineString, ol.geom.Geometry); + + +/** + * @return {Array.>} Coordinatess. + */ +ol.geom.MultiLineString.prototype.getCoordinatess = function() { + return this.coordinatess_; +}; + + +/** + * @inheritDoc + */ +ol.geom.MultiLineString.prototype.getExtent = function(opt_extent) { + if (this.extentRevision != this.revision) { + this.extent = ol.extent.createOrUpdateEmpty(this.extent); + var coordinatess = this.coordinatess_; + var i, ii; + for (i = 0, ii = coordinatess.length; i < ii; ++i) { + this.extent = ol.extent.extendCoordinates(this.extent, coordinatess[i]); + } + this.extentRevision = this.revision; + } + goog.asserts.assert(goog.isDef(this.extent)); + return ol.extent.returnOrUpdate(this.extent, opt_extent); +}; + + +/** + * @inheritDoc + */ +ol.geom.MultiLineString.prototype.getType = function() { + return ol.geom.GeometryType.MULTI_LINE_STRING; +}; + + +/** + * @param {Array.>} coordinatess Coordinatess. + */ +ol.geom.MultiLineString.prototype.setCoordinatess = function(coordinatess) { + this.coordinatess_ = coordinatess; +};