diff --git a/src/ol/feature.js b/src/ol/feature.js index 1335ca733e..fdd0e196a8 100644 --- a/src/ol/feature.js +++ b/src/ol/feature.js @@ -41,12 +41,6 @@ ol.Feature = function(opt_geometryOrValues) { */ this.geometryName_ = 'geometry'; - /** - * @private - * @type {number} - */ - this.revision_ = 0; - /** * @private * @type {goog.events.Key} @@ -76,15 +70,6 @@ ol.Feature = function(opt_geometryOrValues) { goog.inherits(ol.Feature, ol.Object); -/** - * FIXME empty description for jsdoc - */ -ol.Feature.prototype.dispatchChangeEvent = function() { - ++this.revision_; - this.dispatchEvent(goog.events.EventType.CHANGE); -}; - - /** * @return {ol.geom.Geometry|undefined} Geometry. */ @@ -114,14 +99,6 @@ ol.Feature.prototype.getGeometryName = function() { }; -/** - * @return {number} Revision. - */ -ol.Feature.prototype.getRevision = function() { - return this.revision_; -}; - - /** * @return {ol.feature.FeatureStyleFunction|undefined} Style function. */ diff --git a/src/ol/geom/circle.js b/src/ol/geom/circle.js index fffb4399c0..b669dee7d6 100644 --- a/src/ol/geom/circle.js +++ b/src/ol/geom/circle.js @@ -88,14 +88,14 @@ ol.geom.Circle.prototype.getCenter = function() { * @inheritDoc */ ol.geom.Circle.prototype.getExtent = function(opt_extent) { - if (this.extentRevision != this.revision) { + if (this.extentRevision != this.getRevision()) { var flatCoordinates = this.flatCoordinates; var radius = flatCoordinates[this.stride] - flatCoordinates[0]; this.extent = ol.extent.createOrUpdate( flatCoordinates[0] - radius, flatCoordinates[1] - radius, flatCoordinates[0] + radius, flatCoordinates[1] + radius, this.extent); - this.extentRevision = this.revision; + this.extentRevision = this.getRevision(); } goog.asserts.assert(goog.isDef(this.extent)); return ol.extent.returnOrUpdate(this.extent, opt_extent); diff --git a/src/ol/geom/geometry.js b/src/ol/geom/geometry.js index 7a41e08503..1907b580bc 100644 --- a/src/ol/geom/geometry.js +++ b/src/ol/geom/geometry.js @@ -2,7 +2,6 @@ goog.provide('ol.geom.Geometry'); goog.provide('ol.geom.GeometryType'); goog.require('goog.asserts'); -goog.require('goog.events.EventType'); goog.require('goog.functions'); goog.require('ol.Observable'); @@ -43,12 +42,6 @@ ol.geom.Geometry = function() { goog.base(this); - /** - * @protected - * @type {number} - */ - this.revision = 0; - /** * @protected * @type {ol.Extent|undefined} @@ -129,15 +122,6 @@ ol.geom.Geometry.prototype.containsCoordinate = function(coordinate) { ol.geom.Geometry.prototype.containsXY = goog.functions.FALSE; -/** - * FIXME empty description for jsdoc - */ -ol.geom.Geometry.prototype.dispatchChangeEvent = function() { - ++this.revision; - this.dispatchEvent(goog.events.EventType.CHANGE); -}; - - /** * @param {ol.Extent=} opt_extent Extent. * @return {ol.Extent} extent Extent. @@ -145,14 +129,6 @@ ol.geom.Geometry.prototype.dispatchChangeEvent = function() { ol.geom.Geometry.prototype.getExtent = goog.abstractMethod; -/** - * @return {number} Revision. - */ -ol.geom.Geometry.prototype.getRevision = function() { - return this.revision; -}; - - /** * @param {number} squaredTolerance Squared tolerance. * @return {ol.geom.Geometry} Simplified geometry. diff --git a/src/ol/geom/geometrycollection.js b/src/ol/geom/geometrycollection.js index e37e0dd04d..1c4f3cbfe2 100644 --- a/src/ol/geom/geometrycollection.js +++ b/src/ol/geom/geometrycollection.js @@ -91,7 +91,7 @@ ol.geom.GeometryCollection.prototype.containsXY = function(x, y) { * @inheritDoc */ ol.geom.GeometryCollection.prototype.getExtent = function(opt_extent) { - if (this.extentRevision != this.revision) { + if (this.extentRevision != this.getRevision()) { var extent = ol.extent.createOrUpdateEmpty(this.extent); var geometries = this.geometries_; var i, ii; @@ -99,7 +99,7 @@ ol.geom.GeometryCollection.prototype.getExtent = function(opt_extent) { ol.extent.extend(extent, geometries[i].getExtent()); } this.extent = extent; - this.extentRevision = this.revision; + this.extentRevision = this.getRevision(); } goog.asserts.assert(goog.isDef(this.extent)); return ol.extent.returnOrUpdate(this.extent, opt_extent); @@ -127,10 +127,10 @@ ol.geom.GeometryCollection.prototype.getGeometriesArray = function() { */ ol.geom.GeometryCollection.prototype.getSimplifiedGeometry = function(squaredTolerance) { - if (this.simplifiedGeometryRevision != this.revision) { + if (this.simplifiedGeometryRevision != this.getRevision()) { goog.object.clear(this.simplifiedGeometryCache); this.simplifiedGeometryMaxMinSquaredTolerance = 0; - this.simplifiedGeometryRevision = this.revision; + this.simplifiedGeometryRevision = this.getRevision(); } if (squaredTolerance < 0 || (this.simplifiedGeometryMaxMinSquaredTolerance !== 0 && diff --git a/src/ol/geom/linearring.js b/src/ol/geom/linearring.js index 1772b5f0ab..c74a20bb59 100644 --- a/src/ol/geom/linearring.js +++ b/src/ol/geom/linearring.js @@ -56,10 +56,10 @@ ol.geom.LinearRing.prototype.closestPointXY = ol.extent.closestSquaredDistanceXY(this.getExtent(), x, y)) { return minSquaredDistance; } - if (this.maxDeltaRevision_ != this.revision) { + if (this.maxDeltaRevision_ != this.getRevision()) { this.maxDelta_ = Math.sqrt(ol.geom.closest.getMaxSquaredDelta( this.flatCoordinates, 0, this.flatCoordinates.length, this.stride, 0)); - this.maxDeltaRevision_ = this.revision; + this.maxDeltaRevision_ = this.getRevision(); } return ol.geom.closest.getClosestPoint( this.flatCoordinates, 0, this.flatCoordinates.length, this.stride, diff --git a/src/ol/geom/linestring.js b/src/ol/geom/linestring.js index acc3ac8053..3f94e05a72 100644 --- a/src/ol/geom/linestring.js +++ b/src/ol/geom/linestring.js @@ -56,10 +56,10 @@ ol.geom.LineString.prototype.closestPointXY = ol.extent.closestSquaredDistanceXY(this.getExtent(), x, y)) { return minSquaredDistance; } - if (this.maxDeltaRevision_ != this.revision) { + if (this.maxDeltaRevision_ != this.getRevision()) { this.maxDelta_ = Math.sqrt(ol.geom.closest.getMaxSquaredDelta( this.flatCoordinates, 0, this.flatCoordinates.length, this.stride, 0)); - this.maxDeltaRevision_ = this.revision; + this.maxDeltaRevision_ = this.getRevision(); } return ol.geom.closest.getClosestPoint( this.flatCoordinates, 0, this.flatCoordinates.length, this.stride, diff --git a/src/ol/geom/multilinestring.js b/src/ol/geom/multilinestring.js index c649e41a52..76256ca336 100644 --- a/src/ol/geom/multilinestring.js +++ b/src/ol/geom/multilinestring.js @@ -66,10 +66,10 @@ ol.geom.MultiLineString.prototype.closestPointXY = ol.extent.closestSquaredDistanceXY(this.getExtent(), x, y)) { return minSquaredDistance; } - if (this.maxDeltaRevision_ != this.revision) { + if (this.maxDeltaRevision_ != this.getRevision()) { this.maxDelta_ = Math.sqrt(ol.geom.closest.getsMaxSquaredDelta( this.flatCoordinates, 0, this.ends_, this.stride, 0)); - this.maxDeltaRevision_ = this.revision; + this.maxDeltaRevision_ = this.getRevision(); } return ol.geom.closest.getsClosestPoint( this.flatCoordinates, 0, this.ends_, this.stride, diff --git a/src/ol/geom/multipolygon.js b/src/ol/geom/multipolygon.js index 27727e70a4..2f3e25966f 100644 --- a/src/ol/geom/multipolygon.js +++ b/src/ol/geom/multipolygon.js @@ -76,10 +76,10 @@ ol.geom.MultiPolygon.prototype.closestPointXY = ol.extent.closestSquaredDistanceXY(this.getExtent(), x, y)) { return minSquaredDistance; } - if (this.maxDeltaRevision_ != this.revision) { + if (this.maxDeltaRevision_ != this.getRevision()) { this.maxDelta_ = Math.sqrt(ol.geom.closest.getssMaxSquaredDelta( this.flatCoordinates, 0, this.endss_, this.stride, 0)); - this.maxDeltaRevision_ = this.revision; + this.maxDeltaRevision_ = this.getRevision(); } return ol.geom.closest.getssClosestPoint( this.flatCoordinates, 0, this.endss_, this.stride, @@ -126,12 +126,12 @@ ol.geom.MultiPolygon.prototype.getEndss = function() { * @return {Array.} Interior points. */ ol.geom.MultiPolygon.prototype.getInteriorPoints = function() { - if (this.interiorPointsRevision_ != this.revision) { + if (this.interiorPointsRevision_ != this.getRevision()) { var ys = ol.geom.flat.linearRingssMidYs( this.flatCoordinates, 0, this.endss_, this.stride); this.interiorPoints_ = ol.geom.flat.linearRingssGetInteriorPoints( this.flatCoordinates, 0, this.endss_, this.stride, ys); - this.interiorPointsRevision_ = this.revision; + this.interiorPointsRevision_ = this.getRevision(); } return this.interiorPoints_; }; diff --git a/src/ol/geom/point.js b/src/ol/geom/point.js index 46c76b5a9a..540048ef07 100644 --- a/src/ol/geom/point.js +++ b/src/ol/geom/point.js @@ -65,10 +65,10 @@ ol.geom.Point.prototype.getCoordinates = function() { * @inheritDoc */ ol.geom.Point.prototype.getExtent = function(opt_extent) { - if (this.extentRevision != this.revision) { + if (this.extentRevision != this.getRevision()) { this.extent = ol.extent.createOrUpdateFromCoordinate( this.flatCoordinates, this.extent); - this.extentRevision = this.revision; + this.extentRevision = this.getRevision(); } goog.asserts.assert(goog.isDef(this.extent)); return ol.extent.returnOrUpdate(this.extent, opt_extent); diff --git a/src/ol/geom/polygon.js b/src/ol/geom/polygon.js index 50b2f276e4..3b1cb59981 100644 --- a/src/ol/geom/polygon.js +++ b/src/ol/geom/polygon.js @@ -76,10 +76,10 @@ ol.geom.Polygon.prototype.closestPointXY = ol.extent.closestSquaredDistanceXY(this.getExtent(), x, y)) { return minSquaredDistance; } - if (this.maxDeltaRevision_ != this.revision) { + if (this.maxDeltaRevision_ != this.getRevision()) { this.maxDelta_ = Math.sqrt(ol.geom.closest.getsMaxSquaredDelta( this.flatCoordinates, 0, this.ends_, this.stride, 0)); - this.maxDeltaRevision_ = this.revision; + this.maxDeltaRevision_ = this.getRevision(); } return ol.geom.closest.getsClosestPoint( this.flatCoordinates, 0, this.ends_, this.stride, @@ -126,12 +126,12 @@ ol.geom.Polygon.prototype.getEnds = function() { * @return {ol.Coordinate} Interior point. */ ol.geom.Polygon.prototype.getInteriorPoint = function() { - if (this.interiorPointRevision_ != this.revision) { + if (this.interiorPointRevision_ != this.getRevision()) { var extent = this.getExtent(); var y = (extent[1] + extent[3]) / 2; this.interiorPoint_ = ol.geom.flat.linearRingsGetInteriorPoint( this.flatCoordinates, 0, this.ends_, this.stride, y); - this.interiorPointRevision_ = this.revision; + this.interiorPointRevision_ = this.getRevision(); } return this.interiorPoint_; }; diff --git a/src/ol/geom/simplegeometry.js b/src/ol/geom/simplegeometry.js index 2f24d9d28f..26420ab3fd 100644 --- a/src/ol/geom/simplegeometry.js +++ b/src/ol/geom/simplegeometry.js @@ -87,10 +87,10 @@ ol.geom.SimpleGeometry.prototype.containsXY = goog.functions.FALSE; * @inheritDoc */ ol.geom.SimpleGeometry.prototype.getExtent = function(opt_extent) { - if (this.extentRevision != this.revision) { + if (this.extentRevision != this.getRevision()) { this.extent = ol.extent.createOrUpdateFromFlatCoordinates( this.flatCoordinates, this.stride, this.extent); - this.extentRevision = this.revision; + this.extentRevision = this.getRevision(); } goog.asserts.assert(goog.isDef(this.extent)); return ol.extent.returnOrUpdate(this.extent, opt_extent); @@ -118,10 +118,10 @@ ol.geom.SimpleGeometry.prototype.getLayout = function() { */ ol.geom.SimpleGeometry.prototype.getSimplifiedGeometry = function(squaredTolerance) { - if (this.simplifiedGeometryRevision != this.revision) { + if (this.simplifiedGeometryRevision != this.getRevision()) { goog.object.clear(this.simplifiedGeometryCache); this.simplifiedGeometryMaxMinSquaredTolerance = 0; - this.simplifiedGeometryRevision = this.revision; + this.simplifiedGeometryRevision = this.getRevision(); } // If squaredTolerance is negative or if we know that simplification will not // have any effect then just return this. diff --git a/src/ol/layer/layerbase.js b/src/ol/layer/layerbase.js index 8ddeeb3c32..46bc1b7d2c 100644 --- a/src/ol/layer/layerbase.js +++ b/src/ol/layer/layerbase.js @@ -3,7 +3,6 @@ goog.provide('ol.layer.LayerProperty'); goog.provide('ol.layer.LayerState'); goog.require('goog.events'); -goog.require('goog.events.EventType'); goog.require('goog.math'); goog.require('goog.object'); goog.require('ol.Object'); @@ -75,14 +74,6 @@ ol.layer.Base = function(options) { goog.inherits(ol.layer.Base, ol.Object); -/** - * @protected - */ -ol.layer.Base.prototype.dispatchChangeEvent = function() { - this.dispatchEvent(goog.events.EventType.CHANGE); -}; - - /** * @return {number|undefined} Brightness. */ diff --git a/src/ol/observable.js b/src/ol/observable.js index c3d51b1d24..f48e3a6599 100644 --- a/src/ol/observable.js +++ b/src/ol/observable.js @@ -2,6 +2,7 @@ goog.provide('ol.Observable'); goog.require('goog.events'); goog.require('goog.events.EventTarget'); +goog.require('goog.events.EventType'); @@ -15,12 +16,36 @@ goog.require('goog.events.EventTarget'); * @todo stability experimental */ ol.Observable = function() { + goog.base(this); + /** + * @private + * @type {number} + */ + this.revision_ = 0; + }; goog.inherits(ol.Observable, goog.events.EventTarget); +/** + * FIXME empty description for jsdoc + */ +ol.Observable.prototype.dispatchChangeEvent = function() { + ++this.revision_; + this.dispatchEvent(goog.events.EventType.CHANGE); +}; + + +/** + * @return {number} Revision. + */ +ol.Observable.prototype.getRevision = function() { + return this.revision_; +}; + + /** * Listen for a certain type of event. * @param {string|Array.} type The event type or array of event types. diff --git a/src/ol/source/source.js b/src/ol/source/source.js index d07f916bdb..03f0fa027e 100644 --- a/src/ol/source/source.js +++ b/src/ol/source/source.js @@ -74,25 +74,10 @@ ol.source.Source = function(options) { this.state_ = goog.isDef(options.state) ? options.state : ol.source.State.READY; - /** - * @private - * @type {number} - */ - this.revision_ = 0; - }; goog.inherits(ol.source.Source, ol.Observable); -/** - * @protected - */ -ol.source.Source.prototype.dispatchChangeEvent = function() { - ++this.revision_; - this.dispatchEvent(goog.events.EventType.CHANGE); -}; - - /** * @param {ol.Extent} extent Extent. * @param {number} resolution Resolution. @@ -144,14 +129,6 @@ ol.source.Source.prototype.getProjection = function() { ol.source.Source.prototype.getResolutions = goog.abstractMethod; -/** - * @return {number} Revision. - */ -ol.source.Source.prototype.getRevision = function() { - return this.revision_; -}; - - /** * @return {ol.source.State} State. */