From cb75fcad9f39aae42f1d6581a87790272a42b562 Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Wed, 6 Nov 2013 20:45:53 +0100 Subject: [PATCH] Add ol.geom.Point --- src/ol/geom/point.js | 64 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 src/ol/geom/point.js diff --git a/src/ol/geom/point.js b/src/ol/geom/point.js new file mode 100644 index 0000000000..f006a061f9 --- /dev/null +++ b/src/ol/geom/point.js @@ -0,0 +1,64 @@ +goog.provide('ol.geom.Point'); + +goog.require('goog.asserts'); +goog.require('ol.extent'); +goog.require('ol.geom.Geometry'); + + + +/** + * @constructor + * @extends {ol.geom.Geometry} + * @param {ol.Coordinate} coordinate Coordinate. + */ +ol.geom.Point = function(coordinate) { + + goog.base(this); + + /** + * @private + * @type {Array.} + */ + this.coordinate_ = coordinate; + +}; +goog.inherits(ol.geom.Point, ol.geom.Geometry); + + +/** + * @return {ol.Coordinate} Coordinate. + */ +ol.geom.Point.prototype.getCoordinate = function() { + return this.coordinate_; +}; + + +/** + * @inheritDoc + */ +ol.geom.Point.prototype.getExtent = function(opt_extent) { + if (this.extentRevision != this.revision) { + this.extent = ol.extent.createOrUpdateFromCoordinate( + this.coordinate_, this.extent); + this.extentRevision = this.revision; + } + goog.asserts.assert(goog.isDef(this.extent)); + return ol.extent.returnOrUpdate(this.extent, opt_extent); +}; + + +/** + * @inheritDoc + */ +ol.geom.Point.prototype.getType = function() { + return ol.geom.GeometryType.POINT; +}; + + +/** + * @param {ol.Coordinate} coordinate Coordinate. + */ +ol.geom.Point.prototype.setCoordinate = function(coordinate) { + this.coordinate_ = coordinate; + this.dispatchChangeEvent(); +};