From a613420953a99e678d654c50eb7f930507ebc302 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Tue, 15 Sep 2015 10:01:56 +0200 Subject: [PATCH 01/93] Don't use deprecated ol.Observable#unByKey function --- test/spec/ol/source/bingmapssource.test.js | 3 ++- test/spec/ol/source/tilejsonsource.test.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/test/spec/ol/source/bingmapssource.test.js b/test/spec/ol/source/bingmapssource.test.js index 3abe87976d..a53a9f63a1 100644 --- a/test/spec/ol/source/bingmapssource.test.js +++ b/test/spec/ol/source/bingmapssource.test.js @@ -27,7 +27,7 @@ describe('ol.source.BingMaps', function() { goog.net.Jsonp = googNetJsonp; var key = source.on('change', function() { if (source.getState() === 'ready') { - source.unByKey(key); + ol.Observable.unByKey(key); tileGrid = source.getTileGrid(); done(); } @@ -79,3 +79,4 @@ describe('ol.source.BingMaps', function() { goog.require('goog.net.Jsonp'); goog.require('ol.source.BingMaps'); goog.require('ol.tilecoord'); +goog.require('ol.Observable'); diff --git a/test/spec/ol/source/tilejsonsource.test.js b/test/spec/ol/source/tilejsonsource.test.js index b65b120298..68ee73caa2 100644 --- a/test/spec/ol/source/tilejsonsource.test.js +++ b/test/spec/ol/source/tilejsonsource.test.js @@ -40,7 +40,7 @@ describe('ol.source.TileJSON', function() { goog.net.Jsonp = googNetJsonp; var key = source.on('change', function() { if (source.getState() === 'ready') { - source.unByKey(key); + ol.Observable.unByKey(key); tileGrid = source.getTileGrid(); done(); } @@ -91,3 +91,4 @@ goog.require('goog.events'); goog.require('goog.net.Jsonp'); goog.require('ol.source.State'); goog.require('ol.source.TileJSON'); +goog.require('ol.Observable'); From 139bcca26aac04914e9bee9e7538dd6a5a4a6e91 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Tue, 15 Sep 2015 10:05:57 +0200 Subject: [PATCH 02/93] Use goog.array.forEach to unlisten the array of keys --- src/ol/map.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/ol/map.js b/src/ol/map.js index 13c5efccbf..bcfa364b5b 100644 --- a/src/ol/map.js +++ b/src/ol/map.js @@ -1118,10 +1118,8 @@ ol.Map.prototype.handleLayerGroupPropertyChanged_ = function(event) { */ ol.Map.prototype.handleLayerGroupChanged_ = function() { if (!goog.isNull(this.layerGroupPropertyListenerKeys_)) { - var length = this.layerGroupPropertyListenerKeys_.length; - for (var i = 0; i < length; ++i) { - goog.events.unlistenByKey(this.layerGroupPropertyListenerKeys_[i]); - } + goog.array.forEach(this.layerGroupPropertyListenerKeys_, + goog.events.unlistenByKey); this.layerGroupPropertyListenerKeys_ = null; } var layerGroup = this.getLayerGroup(); From 33dbaccb68996eec125abd438fd5cfeb86981c97 Mon Sep 17 00:00:00 2001 From: Elizabeth-Kate Gulland Date: Sat, 19 Sep 2015 05:04:09 +0200 Subject: [PATCH 03/93] Enhanced documentation for ol.style.Text --- externs/olx.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/externs/olx.js b/externs/olx.js index 041a6633f4..65fd15c5fe 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -6150,7 +6150,7 @@ olx.style.TextOptions; /** - * Font. + * Font family. * @type {string|undefined} * @api */ @@ -6192,7 +6192,8 @@ olx.style.TextOptions.prototype.rotation; /** - * Text. + * Text. Possible values: 'normal', 'hide', 'shorten', 'wrap'. + * Default is 'normal'. Multiline labels are not currently supported. * @type {string|undefined} * @api */ @@ -6200,7 +6201,8 @@ olx.style.TextOptions.prototype.text; /** - * Text alignment. + * Text alignment. Possible values: 'left', 'right', 'center', 'end' or 'start'. + * Default is 'start'. * @type {string|undefined} * @api */ @@ -6208,7 +6210,8 @@ olx.style.TextOptions.prototype.textAlign; /** - * Text base line. + * Text base line. Possible values: 'bottom', 'top', 'middle', 'alphabetic', + * 'hanging', 'ideographic'. Default is 'alphabetic'. * @type {string|undefined} * @api */ From 4f45bbc05d3defd05fb691f7956d702cc4143c34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Mon, 21 Sep 2015 20:44:32 +0200 Subject: [PATCH 04/93] ol.style.Stroke has no "opacity" option --- examples/feature-animation.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/feature-animation.js b/examples/feature-animation.js index 00d97d98fc..8295ec745d 100644 --- a/examples/feature-animation.js +++ b/examples/feature-animation.js @@ -72,8 +72,7 @@ function flash(feature) { snapToPixel: false, stroke: new ol.style.Stroke({ color: 'rgba(255, 0, 0, ' + opacity + ')', - width: 1, - opacity: opacity + width: 1 }) }); From 167480bde6996b58e2e68c5e8cfbe5ad88df9adf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Mon, 21 Sep 2015 20:44:52 +0200 Subject: [PATCH 05/93] context.fillStyle should be a string The value we set context.fillStyle to should always be a string. This commit fixes a bug in circlestyle.js where we did set context.fillStyle to an array instead of a string. --- src/ol/style/circlestyle.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ol/style/circlestyle.js b/src/ol/style/circlestyle.js index 57bb47061a..e9d7a2e9ab 100644 --- a/src/ol/style/circlestyle.js +++ b/src/ol/style/circlestyle.js @@ -405,7 +405,7 @@ ol.style.Circle.prototype.drawHitDetectionCanvas_ = renderOptions.size / 2, renderOptions.size / 2, this.radius_, 0, 2 * Math.PI, true); - context.fillStyle = ol.render.canvas.defaultFillStyle; + context.fillStyle = ol.color.asString(ol.render.canvas.defaultFillStyle); context.fill(); if (!goog.isNull(this.stroke_)) { context.strokeStyle = renderOptions.strokeStyle; From e81b68ce8b2cfc6062918409224c856303bc914f Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Mon, 21 Sep 2015 13:59:01 -0600 Subject: [PATCH 06/93] API method for simplifying geometries --- src/ol/geom/geometry.js | 14 ++++++++++++++ src/ol/geom/simplegeometry.js | 1 + test/spec/ol/geom/linestring.test.js | 23 +++++++++++++++++++++++ 3 files changed, 38 insertions(+) diff --git a/src/ol/geom/geometry.js b/src/ol/geom/geometry.js index 0a15563150..bf252fbb44 100644 --- a/src/ol/geom/geometry.js +++ b/src/ol/geom/geometry.js @@ -169,6 +169,20 @@ ol.geom.Geometry.prototype.getExtent = function(opt_extent) { }; +/** + * Create a simplified version of this geometry using the {@link + * http://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm + * Douglas Peucker} algorithm. + * @function + * @param {number} tolerance The tolerance distance for simplification. + * @return {ol.geom.Geometry} A new, simplified version of the original + * geometry. + */ +ol.geom.Geometry.prototype.simplify = function(tolerance) { + return this.getSimplifiedGeometry(tolerance * tolerance); +}; + + /** * Create a simplified version of this geometry using the Douglas Peucker * algorithm. diff --git a/src/ol/geom/simplegeometry.js b/src/ol/geom/simplegeometry.js index e99e5479b9..fd3f3d62fb 100644 --- a/src/ol/geom/simplegeometry.js +++ b/src/ol/geom/simplegeometry.js @@ -144,6 +144,7 @@ ol.geom.SimpleGeometry.prototype.getLayout = function() { /** * @inheritDoc + * @api */ ol.geom.SimpleGeometry.prototype.getSimplifiedGeometry = function(squaredTolerance) { diff --git a/test/spec/ol/geom/linestring.test.js b/test/spec/ol/geom/linestring.test.js index f4dd6cbd11..023510b090 100644 --- a/test/spec/ol/geom/linestring.test.js +++ b/test/spec/ol/geom/linestring.test.js @@ -263,6 +263,29 @@ describe('ol.geom.LineString', function() { }); + describe('#simplify', function() { + + it('returns a simplified geometry', function() { + var simplified = lineString.simplify(1); + expect(simplified).to.be.an(ol.geom.LineString); + expect(simplified.getCoordinates()).to.eql( + [[0, 0], [3, 3], [5, 1], [7, 5]]); + }); + + it('does not modify the original', function() { + lineString.simplify(1); + expect(lineString.getCoordinates()).to.eql( + [[0, 0], [1.5, 1], [3, 3], [5, 1], [6, 3.5], [7, 5]]); + }); + + it('delegates to the internal method', function() { + var simplified = lineString.simplify(2); + var internal = lineString.getSimplifiedGeometry(4); + expect(simplified.getCoordinates()).to.eql(internal.getCoordinates()); + }); + + }); + describe('#getSimplifiedGeometry', function() { it('returns the expectedResult', function() { From 0d23ab44b3b9ba7f2d5035c03198c1d5d9fcba03 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Tue, 22 Sep 2015 11:25:04 +0200 Subject: [PATCH 07/93] Remove use of goog.array.isEmpty --- src/ol/control/control.js | 2 +- src/ol/format/wktformat.js | 3 +-- src/ol/geom/geometrycollection.js | 3 +-- src/ol/source/tilearcgisrestsource.js | 3 +-- src/ol/source/tilewmssource.js | 3 +-- 5 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/ol/control/control.js b/src/ol/control/control.js index ead9a74b8e..e56830b2e9 100644 --- a/src/ol/control/control.js +++ b/src/ol/control/control.js @@ -108,7 +108,7 @@ ol.control.Control.prototype.setMap = function(map) { if (!goog.isNull(this.map_)) { goog.dom.removeNode(this.element); } - if (!goog.array.isEmpty(this.listenerKeys)) { + if (this.listenerKeys.length > 0) { goog.array.forEach(this.listenerKeys, goog.events.unlistenByKey); this.listenerKeys.length = 0; } diff --git a/src/ol/format/wktformat.js b/src/ol/format/wktformat.js index f6183d72c3..ddd609983b 100644 --- a/src/ol/format/wktformat.js +++ b/src/ol/format/wktformat.js @@ -1,6 +1,5 @@ goog.provide('ol.format.WKT'); -goog.require('goog.array'); goog.require('goog.asserts'); goog.require('ol.Feature'); goog.require('ol.format.Feature'); @@ -59,7 +58,7 @@ ol.format.WKT.EMPTY = 'EMPTY'; */ ol.format.WKT.encodePointGeometry_ = function(geom) { var coordinates = geom.getCoordinates(); - if (goog.array.isEmpty(coordinates)) { + if (coordinates.length === 0) { return ''; } return coordinates[0] + ' ' + coordinates[1]; diff --git a/src/ol/geom/geometrycollection.js b/src/ol/geom/geometrycollection.js index c8a786d47d..7ac3963fde 100644 --- a/src/ol/geom/geometrycollection.js +++ b/src/ol/geom/geometrycollection.js @@ -1,6 +1,5 @@ goog.provide('ol.geom.GeometryCollection'); -goog.require('goog.array'); goog.require('goog.events'); goog.require('goog.events.EventType'); goog.require('goog.object'); @@ -231,7 +230,7 @@ ol.geom.GeometryCollection.prototype.intersectsExtent = function(extent) { * @return {boolean} Is empty. */ ol.geom.GeometryCollection.prototype.isEmpty = function() { - return goog.array.isEmpty(this.geometries_); + return this.geometries_.length === 0; }; diff --git a/src/ol/source/tilearcgisrestsource.js b/src/ol/source/tilearcgisrestsource.js index 5602eedbc5..a337ea01f8 100644 --- a/src/ol/source/tilearcgisrestsource.js +++ b/src/ol/source/tilearcgisrestsource.js @@ -1,6 +1,5 @@ goog.provide('ol.source.TileArcGISRest'); -goog.require('goog.array'); goog.require('goog.asserts'); goog.require('goog.math'); goog.require('goog.object'); @@ -101,7 +100,7 @@ ol.source.TileArcGISRest.prototype.getRequestUrl_ = pixelRatio, projection, params) { var urls = this.urls_; - if (goog.array.isEmpty(urls)) { + if (urls.length === 0) { return undefined; } diff --git a/src/ol/source/tilewmssource.js b/src/ol/source/tilewmssource.js index b2fa897e0a..d90bdaaad6 100644 --- a/src/ol/source/tilewmssource.js +++ b/src/ol/source/tilewmssource.js @@ -4,7 +4,6 @@ goog.provide('ol.source.TileWMS'); -goog.require('goog.array'); goog.require('goog.asserts'); goog.require('goog.math'); goog.require('goog.object'); @@ -222,7 +221,7 @@ ol.source.TileWMS.prototype.getRequestUrl_ = pixelRatio, projection, params) { var urls = this.urls_; - if (goog.array.isEmpty(urls)) { + if (urls.length === 0) { return undefined; } From b128675e60bb965a237da718a5e2dc95a40afa05 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Tue, 22 Sep 2015 12:03:52 +0200 Subject: [PATCH 08/93] Remove use of goog.object.remove --- src/ol/format/esrijsonformat.js | 2 +- src/ol/format/geojsonformat.js | 2 +- src/ol/format/gpxformat.js | 10 +++++----- src/ol/format/kmlformat.js | 4 ++-- src/ol/pointer/mousesource.js | 3 +-- src/ol/pointer/mssource.js | 5 ++--- src/ol/pointer/touchsource.js | 2 +- src/ol/structs/rbush.js | 2 +- 8 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/ol/format/esrijsonformat.js b/src/ol/format/esrijsonformat.js index c081768aa6..aae2124455 100644 --- a/src/ol/format/esrijsonformat.js +++ b/src/ol/format/esrijsonformat.js @@ -656,7 +656,7 @@ ol.format.EsriJSON.prototype.writeFeatureObject = function( ol.format.EsriJSON.writeGeometry_(geometry, opt_options); } var properties = feature.getProperties(); - goog.object.remove(properties, feature.getGeometryName()); + delete properties[feature.getGeometryName()]; if (!goog.object.isEmpty(properties)) { object['attributes'] = properties; } else { diff --git a/src/ol/format/geojsonformat.js b/src/ol/format/geojsonformat.js index 02cd817b25..6926fc5036 100644 --- a/src/ol/format/geojsonformat.js +++ b/src/ol/format/geojsonformat.js @@ -545,7 +545,7 @@ ol.format.GeoJSON.prototype.writeFeatureObject = function( object['geometry'] = null; } var properties = feature.getProperties(); - goog.object.remove(properties, feature.getGeometryName()); + delete properties[feature.getGeometryName()]; if (!goog.object.isEmpty(properties)) { object['properties'] = properties; } else { diff --git a/src/ol/format/gpxformat.js b/src/ol/format/gpxformat.js index 6a613b5dfa..1c3f998a24 100644 --- a/src/ol/format/gpxformat.js +++ b/src/ol/format/gpxformat.js @@ -74,14 +74,14 @@ ol.format.GPX.appendCoordinate_ = function(flatCoordinates, node, values) { if (goog.object.containsKey(values, 'ele')) { flatCoordinates.push( /** @type {number} */ (values['ele'])); - goog.object.remove(values, 'ele'); + delete values['ele']; } else { flatCoordinates.push(0); } if (goog.object.containsKey(values, 'time')) { flatCoordinates.push( /** @type {number} */ (values['time'])); - goog.object.remove(values, 'time'); + delete values['time']; } else { flatCoordinates.push(0); } @@ -200,7 +200,7 @@ ol.format.GPX.readRte_ = function(node, objectStack) { } var flatCoordinates = /** @type {Array.} */ (values['flatCoordinates']); - goog.object.remove(values, 'flatCoordinates'); + delete values['flatCoordinates']; var geometry = new ol.geom.LineString(null); geometry.setFlatCoordinates(ol.geom.GeometryLayout.XYZM, flatCoordinates); ol.format.Feature.transformWithOptions(geometry, false, options); @@ -230,9 +230,9 @@ ol.format.GPX.readTrk_ = function(node, objectStack) { } var flatCoordinates = /** @type {Array.} */ (values['flatCoordinates']); - goog.object.remove(values, 'flatCoordinates'); + delete values['flatCoordinates']; var ends = /** @type {Array.} */ (values['ends']); - goog.object.remove(values, 'ends'); + delete values['ends']; var geometry = new ol.geom.MultiLineString(null); geometry.setFlatCoordinates( ol.geom.GeometryLayout.XYZM, flatCoordinates, ends); diff --git a/src/ol/format/kmlformat.js b/src/ol/format/kmlformat.js index d859efa16c..e718ff199a 100644 --- a/src/ol/format/kmlformat.js +++ b/src/ol/format/kmlformat.js @@ -1686,7 +1686,7 @@ ol.format.KML.prototype.readPlacemark_ = function(node, objectStack) { ol.format.Feature.transformWithOptions(geometry, false, options); } feature.setGeometry(geometry); - goog.object.remove(object, 'geometry'); + delete object['geometry']; if (this.extractStyles_) { var style = object['Style']; @@ -1695,7 +1695,7 @@ ol.format.KML.prototype.readPlacemark_ = function(node, objectStack) { style, styleUrl, this.defaultStyle_, this.sharedStyles_); feature.setStyle(styleFunction); } - goog.object.remove(object, 'Style'); + delete object['Style']; // we do not remove the styleUrl property from the object, so it // gets stored on feature when setProperties is called diff --git a/src/ol/pointer/mousesource.js b/src/ol/pointer/mousesource.js index 3e007cfef0..1e226c8ef9 100644 --- a/src/ol/pointer/mousesource.js +++ b/src/ol/pointer/mousesource.js @@ -248,6 +248,5 @@ ol.pointer.MouseSource.prototype.cancel = function(inEvent) { * Remove the mouse from the list of active pointers. */ ol.pointer.MouseSource.prototype.cleanupMouse = function() { - goog.object.remove(this.pointerMap, - ol.pointer.MouseSource.POINTER_ID.toString()); + delete this.pointerMap[ol.pointer.MouseSource.POINTER_ID.toString()]; }; diff --git a/src/ol/pointer/mssource.js b/src/ol/pointer/mssource.js index bbf17e9713..69a326fb3b 100644 --- a/src/ol/pointer/mssource.js +++ b/src/ol/pointer/mssource.js @@ -30,7 +30,6 @@ goog.provide('ol.pointer.MsSource'); -goog.require('goog.object'); goog.require('ol.pointer.EventSource'); @@ -98,7 +97,7 @@ ol.pointer.MsSource.prototype.prepareEvent_ = function(inEvent) { * @param {number} pointerId */ ol.pointer.MsSource.prototype.cleanup = function(pointerId) { - goog.object.remove(this.pointerMap, pointerId); + delete this.pointerMap[pointerId.toString()]; }; @@ -108,7 +107,7 @@ ol.pointer.MsSource.prototype.cleanup = function(pointerId) { * @param {goog.events.BrowserEvent} inEvent */ ol.pointer.MsSource.prototype.msPointerDown = function(inEvent) { - this.pointerMap[inEvent.getBrowserEvent().pointerId] = inEvent; + this.pointerMap[inEvent.getBrowserEvent().pointerId.toString()] = inEvent; var e = this.prepareEvent_(inEvent); this.dispatcher.down(e, inEvent); }; diff --git a/src/ol/pointer/touchsource.js b/src/ol/pointer/touchsource.js index 17befaeac4..b04076c321 100644 --- a/src/ol/pointer/touchsource.js +++ b/src/ol/pointer/touchsource.js @@ -425,7 +425,7 @@ ol.pointer.TouchSource.prototype.cancelOut_ = * @param {Object} inPointer */ ol.pointer.TouchSource.prototype.cleanUpPointer_ = function(inPointer) { - goog.object.remove(this.pointerMap, inPointer.pointerId); + delete this.pointerMap[inPointer.pointerId]; this.removePrimaryPointer_(inPointer); }; diff --git a/src/ol/structs/rbush.js b/src/ol/structs/rbush.js index 81e0961cd9..9754e159dd 100644 --- a/src/ol/structs/rbush.js +++ b/src/ol/structs/rbush.js @@ -118,7 +118,7 @@ ol.structs.RBush.prototype.remove = function(value) { // get the object in which the value was wrapped when adding to the // internal rbush. then use that object to do the removal. var item = this.items_[uid]; - goog.object.remove(this.items_, uid); + delete this.items_[uid]; return this.rbush_.remove(item) !== null; }; From 3978dd87be8c562b1a295fd5df7e9e8fbc439d73 Mon Sep 17 00:00:00 2001 From: ekargee Date: Tue, 22 Sep 2015 18:57:49 +0800 Subject: [PATCH 09/93] Updated documentation for ol.style.Text - font and text --- externs/olx.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/externs/olx.js b/externs/olx.js index 65fd15c5fe..fffdf4143f 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -6150,7 +6150,9 @@ olx.style.TextOptions; /** - * Font family. + * Font style as CSS 'font' value, see: + * {@link https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/font}. + * Default is '10px sans-serif' * @type {string|undefined} * @api */ @@ -6192,8 +6194,7 @@ olx.style.TextOptions.prototype.rotation; /** - * Text. Possible values: 'normal', 'hide', 'shorten', 'wrap'. - * Default is 'normal'. Multiline labels are not currently supported. + * Text content. * @type {string|undefined} * @api */ From 0bc8858760b73cc94bd61a4b2570d0742446a17c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Tue, 22 Sep 2015 16:56:15 +0200 Subject: [PATCH 10/93] Add a "features" option to ol.interaction.Select --- externs/olx.js | 12 ++++++++++++ src/ol/interaction/selectinteraction.js | 1 + test/spec/ol/interaction/selectinteraction.test.js | 11 +++++++++++ 3 files changed, 24 insertions(+) diff --git a/externs/olx.js b/externs/olx.js index 4e5fcedb2a..006846ed1a 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -2779,6 +2779,7 @@ olx.interaction.PointerOptions.prototype.handleUpEvent; * removeCondition: (ol.events.ConditionType|undefined), * toggleCondition: (ol.events.ConditionType|undefined), * multi: (boolean|undefined), + * features: (ol.Collection.|undefined), * filter: (ol.interaction.SelectFilterFunction|undefined), * wrapX: (boolean|undefined)}} * @api @@ -2869,6 +2870,17 @@ olx.interaction.SelectOptions.prototype.toggleCondition; olx.interaction.SelectOptions.prototype.multi; +/** + * Collection where the interaction will place selected features. Optional. If + * not set the interaction will create a collection. In any case the collection + * used by the interaction is returnd by + * {@link ol.interaction.Select#getFeatures}. + * @type {ol.Collection.} + * @api + */ +olx.interaction.SelectOptions.prototype.features; + + /** * A function that takes an {@link ol.Feature} and an {@link ol.layer.Layer} and * returns `true` if the feature may be selected or `false` otherwise. diff --git a/src/ol/interaction/selectinteraction.js b/src/ol/interaction/selectinteraction.js index 48acc210f9..a2b5d49628 100644 --- a/src/ol/interaction/selectinteraction.js +++ b/src/ol/interaction/selectinteraction.js @@ -180,6 +180,7 @@ ol.interaction.Select = function(opt_options) { this.featureOverlay_ = new ol.layer.Vector({ source: new ol.source.Vector({ useSpatialIndex: false, + features: options.features, wrapX: options.wrapX }), style: goog.isDef(options.style) ? options.style : diff --git a/test/spec/ol/interaction/selectinteraction.test.js b/test/spec/ol/interaction/selectinteraction.test.js index 50a05ac798..af3b98a8da 100644 --- a/test/spec/ol/interaction/selectinteraction.test.js +++ b/test/spec/ol/interaction/selectinteraction.test.js @@ -98,6 +98,16 @@ describe('ol.interaction.Select', function() { expect(select).to.be.a(ol.interaction.Interaction); }); + describe('user-provided collection', function() { + + it('uses the user-provided collection', function() { + var features = new ol.Collection(); + var select = new ol.interaction.Select({features: features}); + expect(select.getFeatures()).to.be(features); + }); + + }); + }); describe('selecting a polygon', function() { @@ -269,6 +279,7 @@ goog.require('goog.dispose'); goog.require('goog.events'); goog.require('goog.events.BrowserEvent'); goog.require('goog.style'); +goog.require('ol.Collection'); goog.require('ol.Feature'); goog.require('ol.Map'); goog.require('ol.MapBrowserEvent.EventType'); From 250e86e5f233175b50c58247e867789a230edd92 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Tue, 22 Sep 2015 09:49:42 -0600 Subject: [PATCH 11/93] Update simplification docs --- src/ol/geom/geometry.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ol/geom/geometry.js b/src/ol/geom/geometry.js index bf252fbb44..c505551935 100644 --- a/src/ol/geom/geometry.js +++ b/src/ol/geom/geometry.js @@ -170,9 +170,11 @@ ol.geom.Geometry.prototype.getExtent = function(opt_extent) { /** - * Create a simplified version of this geometry using the {@link + * Create a simplified version of this geometry. For linestrings, this uses + * the the {@link * http://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm - * Douglas Peucker} algorithm. + * Douglas Peucker} algorithm. For polygons, a quantization-based + * simplification is used to preserve topology. * @function * @param {number} tolerance The tolerance distance for simplification. * @return {ol.geom.Geometry} A new, simplified version of the original From 436561d9dd8fa58813e1e1276c05672224ae59c3 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Tue, 22 Sep 2015 10:34:43 -0600 Subject: [PATCH 12/93] Make geom.simplify() exportable --- src/ol/geom/geometry.js | 1 + src/ol/geom/simplegeometry.js | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ol/geom/geometry.js b/src/ol/geom/geometry.js index c505551935..f74a083a92 100644 --- a/src/ol/geom/geometry.js +++ b/src/ol/geom/geometry.js @@ -179,6 +179,7 @@ ol.geom.Geometry.prototype.getExtent = function(opt_extent) { * @param {number} tolerance The tolerance distance for simplification. * @return {ol.geom.Geometry} A new, simplified version of the original * geometry. + * @api */ ol.geom.Geometry.prototype.simplify = function(tolerance) { return this.getSimplifiedGeometry(tolerance * tolerance); diff --git a/src/ol/geom/simplegeometry.js b/src/ol/geom/simplegeometry.js index fd3f3d62fb..e99e5479b9 100644 --- a/src/ol/geom/simplegeometry.js +++ b/src/ol/geom/simplegeometry.js @@ -144,7 +144,6 @@ ol.geom.SimpleGeometry.prototype.getLayout = function() { /** * @inheritDoc - * @api */ ol.geom.SimpleGeometry.prototype.getSimplifiedGeometry = function(squaredTolerance) { From 483f567d26af48557c27868a32f36b3b6bab89ec Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Tue, 22 Sep 2015 10:39:19 -0600 Subject: [PATCH 13/93] Working Wikipedia links --- src/ol/geom/geometry.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ol/geom/geometry.js b/src/ol/geom/geometry.js index f74a083a92..c75da4f1eb 100644 --- a/src/ol/geom/geometry.js +++ b/src/ol/geom/geometry.js @@ -172,7 +172,7 @@ ol.geom.Geometry.prototype.getExtent = function(opt_extent) { /** * Create a simplified version of this geometry. For linestrings, this uses * the the {@link - * http://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm + * https://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm * Douglas Peucker} algorithm. For polygons, a quantization-based * simplification is used to preserve topology. * @function @@ -189,7 +189,7 @@ ol.geom.Geometry.prototype.simplify = function(tolerance) { /** * Create a simplified version of this geometry using the Douglas Peucker * algorithm. - * @see http://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm + * @see https://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm * @function * @param {number} squaredTolerance Squared tolerance. * @return {ol.geom.Geometry} Simplified geometry. From 880be210a18fa110d111ca9a7ad085a9ec3b2171 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Wed, 23 Sep 2015 09:16:29 +0200 Subject: [PATCH 14/93] Rename drag-features example to custom-interactions --- examples/{drag-features.html => custom-interactions.html} | 4 ++-- examples/{drag-features.js => custom-interactions.js} | 0 2 files changed, 2 insertions(+), 2 deletions(-) rename examples/{drag-features.html => custom-interactions.html} (66%) rename examples/{drag-features.js => custom-interactions.js} (100%) diff --git a/examples/drag-features.html b/examples/custom-interactions.html similarity index 66% rename from examples/drag-features.html rename to examples/custom-interactions.html index 9352f6f92e..b04b929aab 100644 --- a/examples/drag-features.html +++ b/examples/custom-interactions.html @@ -1,9 +1,9 @@ --- template: example.html title: Custom interaction example -shortdesc: Example of a custom drag features interaction. +shortdesc: Example of a custom interaction. docs: > - This example demonstrates using a custom interaction with OpenLayers, by subclassing `ol.interaction.Pointer`. + This example demonstrates creating a custom interaction by subclassing `ol.interaction.Pointer`. Note that the built in interaction `ol.interaction.Translate` might be a better option for moving features. tags: "drag, feature, vector, editing, custom, interaction" --- diff --git a/examples/drag-features.js b/examples/custom-interactions.js similarity index 100% rename from examples/drag-features.js rename to examples/custom-interactions.js From 9894ceda2acb3d0e0de246fa7fb65281d271c58e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Tue, 22 Sep 2015 16:28:21 +0200 Subject: [PATCH 15/93] Remove bogus assertion This commit removes an incorrect assertion from the modify interaction, which currently triggers when adding vertices to a line string. A new condition is added to the `if` statement to prevent a compilation error. In practice, `depth` and `segmentDataMatch.depth` are either both defined or both undefined. --- src/ol/interaction/modifyinteraction.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/ol/interaction/modifyinteraction.js b/src/ol/interaction/modifyinteraction.js index 7914ff6509..d2d17210e5 100644 --- a/src/ol/interaction/modifyinteraction.js +++ b/src/ol/interaction/modifyinteraction.js @@ -973,9 +973,8 @@ ol.interaction.Modify.prototype.setGeometryCoordinates_ = ol.interaction.Modify.prototype.updateSegmentIndices_ = function( geometry, index, depth, delta) { this.rBush_.forEachInExtent(geometry.getExtent(), function(segmentDataMatch) { - goog.asserts.assert(goog.isDef(segmentDataMatch.depth)); if (segmentDataMatch.geometry === geometry && - (!goog.isDef(depth) || + (!goog.isDef(depth) || !goog.isDef(segmentDataMatch.depth) || goog.array.equals(segmentDataMatch.depth, depth)) && segmentDataMatch.index > index) { segmentDataMatch.index += delta; From d0621a194922763cc193f5a8e9340180fe43d1fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Wed, 23 Sep 2015 10:13:49 +0200 Subject: [PATCH 16/93] Fix typo in doc --- externs/olx.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/externs/olx.js b/externs/olx.js index 6ff7d41581..51754f29ae 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -2873,7 +2873,7 @@ olx.interaction.SelectOptions.prototype.multi; /** * Collection where the interaction will place selected features. Optional. If * not set the interaction will create a collection. In any case the collection - * used by the interaction is returnd by + * used by the interaction is returned by * {@link ol.interaction.Select#getFeatures}. * @type {ol.Collection.} * @api From e884a8704d5482967ed942ba468d9a352d6d3784 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Wed, 23 Sep 2015 12:17:02 +0200 Subject: [PATCH 17/93] Remove use of goog.object.containsKey --- src/ol/format/gpxformat.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/ol/format/gpxformat.js b/src/ol/format/gpxformat.js index 1c3f998a24..fd4aa70a42 100644 --- a/src/ol/format/gpxformat.js +++ b/src/ol/format/gpxformat.js @@ -3,7 +3,6 @@ goog.provide('ol.format.GPX'); goog.require('goog.array'); goog.require('goog.asserts'); goog.require('goog.dom.NodeType'); -goog.require('goog.object'); goog.require('ol.Feature'); goog.require('ol.format.Feature'); goog.require('ol.format.XMLFeature'); @@ -71,14 +70,14 @@ ol.format.GPX.appendCoordinate_ = function(flatCoordinates, node, values) { flatCoordinates.push( parseFloat(node.getAttribute('lon')), parseFloat(node.getAttribute('lat'))); - if (goog.object.containsKey(values, 'ele')) { + if ('ele' in values) { flatCoordinates.push( /** @type {number} */ (values['ele'])); delete values['ele']; } else { flatCoordinates.push(0); } - if (goog.object.containsKey(values, 'time')) { + if ('time' in values) { flatCoordinates.push( /** @type {number} */ (values['time'])); delete values['time']; From 901c55bf41c26075d3146de4ecdcef8f2599da27 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Wed, 23 Sep 2015 12:18:50 +0200 Subject: [PATCH 18/93] Remove unnecessary newlines --- src/ol/format/gpxformat.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/ol/format/gpxformat.js b/src/ol/format/gpxformat.js index fd4aa70a42..fabb0f6b72 100644 --- a/src/ol/format/gpxformat.js +++ b/src/ol/format/gpxformat.js @@ -71,15 +71,13 @@ ol.format.GPX.appendCoordinate_ = function(flatCoordinates, node, values) { parseFloat(node.getAttribute('lon')), parseFloat(node.getAttribute('lat'))); if ('ele' in values) { - flatCoordinates.push( - /** @type {number} */ (values['ele'])); + flatCoordinates.push(/** @type {number} */ (values['ele'])); delete values['ele']; } else { flatCoordinates.push(0); } if ('time' in values) { - flatCoordinates.push( - /** @type {number} */ (values['time'])); + flatCoordinates.push(/** @type {number} */ (values['time'])); delete values['time']; } else { flatCoordinates.push(0); From ee4f009d2f2798af300b8355a179249a18bfe9c8 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Wed, 23 Sep 2015 12:24:54 +0200 Subject: [PATCH 19/93] Remove use of goog.object.containsKey --- src/ol/pointer/mousesource.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/ol/pointer/mousesource.js b/src/ol/pointer/mousesource.js index 1e226c8ef9..131d4adbca 100644 --- a/src/ol/pointer/mousesource.js +++ b/src/ol/pointer/mousesource.js @@ -30,7 +30,6 @@ goog.provide('ol.pointer.MouseSource'); -goog.require('goog.object'); goog.require('ol.pointer.EventSource'); @@ -161,11 +160,9 @@ ol.pointer.MouseSource.prepareEvent = function(inEvent, dispatcher) { */ ol.pointer.MouseSource.prototype.mousedown = function(inEvent) { if (!this.isEventSimulatedFromTouch_(inEvent)) { - var p = goog.object.containsKey(this.pointerMap, - ol.pointer.MouseSource.POINTER_ID.toString()); // TODO(dfreedman) workaround for some elements not sending mouseup // http://crbug/149091 - if (p) { + if (ol.pointer.MouseSource.POINTER_ID.toString() in this.pointerMap) { this.cancel(inEvent); } var e = ol.pointer.MouseSource.prepareEvent(inEvent, this.dispatcher); From c37e80cd97c3825eb8e3c8125369f954f577bc3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Thu, 24 Sep 2015 12:00:14 +0200 Subject: [PATCH 20/93] Use version 20150920 of Closure Compiler --- closure-util.json | 2 +- package.json | 2 +- src/ol/ol.js | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/closure-util.json b/closure-util.json index 1568b295dd..4c10a7d569 100644 --- a/closure-util.json +++ b/closure-util.json @@ -1,3 +1,3 @@ { - "library_url": "https://github.com/google/closure-library/archive/a5f9b8a.zip" + "library_url": "https://github.com/google/closure-library/archive/5b25e65.zip" } diff --git a/package.json b/package.json index ec59eec283..19d032e567 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "dependencies": { "async": "0.9.0", "browserify": "9.0.3", - "closure-util": "1.7.0", + "closure-util": "1.8.0", "fs-extra": "0.12.0", "glob": "5.0.3", "graceful-fs": "3.0.2", diff --git a/src/ol/ol.js b/src/ol/ol.js index 48c926e560..ba1c7e6282 100644 --- a/src/ol/ol.js +++ b/src/ol/ol.js @@ -232,8 +232,8 @@ ol.WEBGL_EXTENSIONS; // value is set in `ol.has` * // Other code here. * }; * - * @param {Function} childCtor Child constructor. - * @param {Function} parentCtor Parent constructor. + * @param {!Function} childCtor Child constructor. + * @param {!Function} parentCtor Parent constructor. * @function * @api */ From f30744c0b83c706d5a8d490cac38488a0072b71c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Thu, 24 Sep 2015 13:21:09 +0200 Subject: [PATCH 21/93] Simplify test-rendering.js Now that https://github.com/laurentj/slimerjs/issues/333 is properly fixed (see https://github.com/laurentj/slimerjs/commit/911fcb671a36049bd3ca5e7b8d5824a8d7f01dc7) we can no longer read Slimer's exit code from a file. Instead, we can just use the process exit code, which simplifies the test-rendering.js script. --- tasks/test-rendering.js | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/tasks/test-rendering.js b/tasks/test-rendering.js index fb3e917613..9df2f2bc1b 100644 --- a/tasks/test-rendering.js +++ b/tasks/test-rendering.js @@ -39,26 +39,14 @@ serve.createServer(function(err, server) { url + '/test_rendering/index.html' ]; + // The current version of slimerjs is 0.9.6, but this version does not work + // for us because of https://github.com/laurentj/slimerjs/issues/333. This + // issue is now fixed in master and slimerjs-edge (nightly builds) works for + // us. But we should use slimerjs instead of slimerjs-edge when a new + // release is published. var child = spawn(slimerjs.path, args, {stdio: 'inherit'}); child.on('exit', function(code) { - // FIXME SlimerJS has a problem with returning the correct return - // code when using a custom profile, see - // https://github.com/laurentj/slimerjs/issues/333 - // as a work-around we are currently reading the return code from - // a file created in the profile directory. - // if this issue is fixed we should use the npm package 'slimerjs' - // instead of the nightly build 'slimerjs-edge'. - var exitstatus = path.join(profile, 'exitstatus'); - fs.readFile(exitstatus, {encoding: 'utf-8'}, function(err, data) { - if (err) { - process.stderr.write( - 'Error getting the exit status of SlimerJS' + '\n'); - process.stderr.write(err.stack + '\n'); - process.exit(1); - } else { - process.exit(data); - } - }); + process.exit(code); }); }); From 7252227ac66b79c3e394b7cf262ae1fae9cf652b Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Thu, 24 Sep 2015 13:31:28 +0200 Subject: [PATCH 22/93] Remove externs in externs/closure-compiler.js Fixed upstream: * https://github.com/google/closure-compiler/pull/1139 * https://github.com/google/closure-compiler/pull/1140 --- externs/closure-compiler.js | 32 -------------------------------- 1 file changed, 32 deletions(-) diff --git a/externs/closure-compiler.js b/externs/closure-compiler.js index 9ee9e8ade7..763c409f16 100644 --- a/externs/closure-compiler.js +++ b/externs/closure-compiler.js @@ -7,35 +7,3 @@ * * @externs */ - -/** @type {number} */ -Touch.prototype.force; - - -/** @type {number} */ -Touch.prototype.radiusX; - - -/** @type {number} */ -Touch.prototype.radiusY; - - -/** @type {number} */ -Touch.prototype.webkitForce; - - -/** @type {number} */ -Touch.prototype.webkitRadiusX; - - -/** @type {number} */ -Touch.prototype.webkitRadiusY; - - -// see https://github.com/google/closure-compiler/pull/1139 - -/** - * @type {string} - * @see http://www.w3.org/TR/pointerevents/#the-touch-action-css-property - */ -CSSProperties.prototype.touchAction; From e77d705d52a254248b6c41b91f1cbff00fe819d1 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Thu, 24 Sep 2015 14:47:37 +0200 Subject: [PATCH 23/93] Update externs/jquery-1.9.js From https://github.com/google/closure-compiler/blob/master/contrib/externs/jquery-1.9.js --- externs/jquery-1.9.js | 943 ++++++++++++++---------------------------- 1 file changed, 307 insertions(+), 636 deletions(-) diff --git a/externs/jquery-1.9.js b/externs/jquery-1.9.js index 38d21c0393..49975b1c46 100644 --- a/externs/jquery-1.9.js +++ b/externs/jquery-1.9.js @@ -15,7 +15,11 @@ */ /** - * @fileoverview Externs for jQuery 1.9.1 + * @fileoverview Externs for jQuery 1.9 - 1.11 & 2.0 - 2.1 + * + * The jQuery API is identical for the 1.9.x+ and 2.0+ branches. In addition, + * the API has not changed in releases since that date. These externs are valid + * for all jQuery releases since 1.9 and 2.0. * * Note that some functions use different return types depending on the number * of parameters passed in. In these cases, you may need to annotate the type @@ -28,32 +32,32 @@ */ /** - * @typedef {(Window|Document|Element|Array.|string|jQuery| + * @typedef {(Window|Document|Element|Array|string|jQuery| * NodeList)} */ var jQuerySelector; -/** @typedef {function(...)|Array.} */ +/** @typedef {function(...)|Array} */ var jQueryCallback; /** @typedef { { - accepts: (Object.|undefined), + accepts: (Object|undefined), async: (?boolean|undefined), - beforeSend: (function(jQuery.jqXHR, (jQueryAjaxSettings|Object.))|undefined), + beforeSend: (function(jQuery.jqXHR, (jQueryAjaxSettings|Object))|undefined), cache: (?boolean|undefined), complete: (function(jQuery.jqXHR, string)|undefined), - contents: (Object.|undefined), + contents: (Object|undefined), contentType: (?string|undefined), - context: (Object.|jQueryAjaxSettings|undefined), - converters: (Object.|undefined), + context: (Object|jQueryAjaxSettings|undefined), + converters: (Object|undefined), crossDomain: (?boolean|undefined), - data: (Object.|?string|Array.|undefined), - dataFilter: (function(string, string):Object.|undefined), + data: (Object|?string|Array|undefined), + dataFilter: (function(string, string):?|undefined), dataType: (?string|undefined), error: (function(jQuery.jqXHR, string, string)|undefined), global: (?boolean|undefined), - headers: (Object.|undefined), + headers: (Object|undefined), ifModified: (?boolean|undefined), isLocal: (?boolean|undefined), jsonp: (?string|undefined), @@ -62,7 +66,7 @@ var jQueryCallback; password: (?string|undefined), processData: (?boolean|undefined), scriptCharset: (?string|undefined), - statusCode: (Object.|undefined), + statusCode: (Object|undefined), success: (function(?, string, jQuery.jqXHR)|undefined), timeout: (?number|undefined), traditional: (?boolean|undefined), @@ -70,33 +74,27 @@ var jQueryCallback; url: (?string|undefined), username: (?string|undefined), xhr: (function():(ActiveXObject|XMLHttpRequest)|undefined), - xhrFields: (Object.|undefined) + xhrFields: (Object|undefined) }} */ var jQueryAjaxSettings; /** * @constructor - * @param {(jQuerySelector|Element|Object|Array.|jQuery|string| + * @param {(jQuerySelector|Element|Object|Array|jQuery|string| * function())=} arg1 * @param {(Element|jQuery|Document| - * Object.)=} arg2 + * Object)=} arg2 * @return {!jQuery} */ function jQuery(arg1, arg2) {} /** - * @constructor - * @extends {jQuery} - * @param {(jQuerySelector|Element|Object|Array.|jQuery|string| - * function())=} arg1 - * @param {(Element|jQuery|Document| - * Object.)=} arg2 - * @return {!jQuery} + * @const */ -function $(arg1, arg2) {} +var $ = jQuery; /** - * @param {(jQuerySelector|Array.|string|jQuery)} arg1 + * @param {(jQuerySelector|Array|string|jQuery)} arg1 * @param {Element=} context * @return {!jQuery} * @nosideeffects @@ -104,7 +102,7 @@ function $(arg1, arg2) {} jQuery.prototype.add = function(arg1, context) {}; /** - * @param {(jQuerySelector|Array.|string|jQuery)=} arg1 + * @param {(jQuerySelector|Array|string|jQuery)=} arg1 * @return {!jQuery} * @nosideeffects */ @@ -118,85 +116,57 @@ jQuery.prototype.addClass = function(arg1) {}; /** * @param {(string|Element|jQuery|function(number))} arg1 - * @param {(string|Element|Array.|jQuery)=} content + * @param {(string|Element|Array|jQuery)=} content * @return {!jQuery} */ jQuery.prototype.after = function(arg1, content) {}; /** - * @param {(string|jQueryAjaxSettings|Object.)} arg1 - * @param {(jQueryAjaxSettings|Object.)=} settings - * @return {jQuery.jqXHR} + * @param {(string|jQueryAjaxSettings|Object)} arg1 + * @param {(jQueryAjaxSettings|Object)=} settings + * @return {!jQuery.jqXHR} */ jQuery.ajax = function(arg1, settings) {}; /** - * @param {(string|jQueryAjaxSettings|Object.)} arg1 - * @param {(jQueryAjaxSettings|Object.)=} settings - * @return {jQuery.jqXHR} - */ -$.ajax = function(arg1, settings) {}; - -/** - * @param {function(!jQuery.event,XMLHttpRequest,(jQueryAjaxSettings|Object.))} handler + * @param {function(!jQuery.Event,XMLHttpRequest,(jQueryAjaxSettings|Object))} handler * @return {!jQuery} */ jQuery.prototype.ajaxComplete = function(handler) {}; /** - * @param {function(!jQuery.event,jQuery.jqXHR,(jQueryAjaxSettings|Object.),*)} handler + * @param {function(!jQuery.Event,jQuery.jqXHR,(jQueryAjaxSettings|Object),*)} handler * @return {!jQuery} */ jQuery.prototype.ajaxError = function(handler) {}; /** - * @param {(string|function((jQueryAjaxSettings|Object.),(jQueryAjaxSettings|Object.),jQuery.jqXHR))} dataTypes - * @param {function((jQueryAjaxSettings|Object.),(jQueryAjaxSettings|Object.),jQuery.jqXHR)=} handler + * @param {(string|function((jQueryAjaxSettings|Object),(jQueryAjaxSettings|Object),jQuery.jqXHR))} dataTypes + * @param {function((jQueryAjaxSettings|Object),(jQueryAjaxSettings|Object),jQuery.jqXHR)=} handler */ jQuery.ajaxPrefilter = function(dataTypes, handler) {}; /** - * @param {(string|function((jQueryAjaxSettings|Object.),(jQueryAjaxSettings|Object.),jQuery.jqXHR))} dataTypes - * @param {function((jQueryAjaxSettings|Object.),(jQueryAjaxSettings|Object.),jQuery.jqXHR)=} handler - */ -$.ajaxPrefilter = function(dataTypes, handler) {}; - -/** - * @param {function(!jQuery.event,jQuery.jqXHR,(jQueryAjaxSettings|Object.))} handler + * @param {function(!jQuery.Event,jQuery.jqXHR,(jQueryAjaxSettings|Object))} handler * @return {!jQuery} */ jQuery.prototype.ajaxSend = function(handler) {}; -/** @const {jQueryAjaxSettings|Object.} */ +/** @const {jQueryAjaxSettings|Object} */ jQuery.ajaxSettings; -/** @const {jQueryAjaxSettings|Object.} */ -$.ajaxSettings = {}; - -/** @type {Object.} */ +/** @type {Object} */ jQuery.ajaxSettings.flatOptions = {}; -/** @type {Object.} */ -$.ajaxSettings.flatOptions = {}; - /** @type {boolean} */ jQuery.ajaxSettings.processData; -/** @type {boolean} */ -$.ajaxSettings.processData; - -/** @type {Object.} */ +/** @type {Object} */ jQuery.ajaxSettings.responseFields = {}; -/** @type {Object.} */ -$.ajaxSettings.responseFields = {}; - -/** @param {jQueryAjaxSettings|Object.} options */ +/** @param {jQueryAjaxSettings|Object} options */ jQuery.ajaxSetup = function(options) {}; -/** @param {jQueryAjaxSettings|Object.} options */ -$.ajaxSetup = function(options) {}; - /** * @param {function()} handler * @return {!jQuery} @@ -210,7 +180,7 @@ jQuery.prototype.ajaxStart = function(handler) {}; jQuery.prototype.ajaxStop = function(handler) {}; /** - * @param {function(!jQuery.event,XMLHttpRequest,(jQueryAjaxSettings|Object.), ?)} handler + * @param {function(!jQuery.Event,XMLHttpRequest,(jQueryAjaxSettings|Object), ?)} handler * @return {!jQuery} */ jQuery.prototype.ajaxSuccess = function(handler) {}; @@ -223,8 +193,8 @@ jQuery.prototype.ajaxSuccess = function(handler) {}; jQuery.prototype.andSelf = function() {}; /** - * @param {Object.} properties - * @param {(string|number|function()|Object.)=} arg2 + * @param {Object} properties + * @param {(string|number|function()|Object)=} arg2 * @param {(string|function())=} easing * @param {function()=} complete * @return {!jQuery} @@ -232,8 +202,8 @@ jQuery.prototype.andSelf = function() {}; jQuery.prototype.animate = function(properties, arg2, easing, complete) {}; /** - * @param {(string|Element|Array.|jQuery|function(number,string))} arg1 - * @param {...(string|Element|Array.|jQuery)} content + * @param {(string|Element|Array|jQuery|function(number,string))} arg1 + * @param {...(string|Element|Array|jQuery)} content * @return {!jQuery} */ jQuery.prototype.append = function(arg1, content) {}; @@ -245,7 +215,7 @@ jQuery.prototype.append = function(arg1, content) {}; jQuery.prototype.appendTo = function(target) {}; /** - * @param {(string|Object.)} arg1 + * @param {(string|Object)} arg1 * @param {(string|number|boolean|function(number,string))=} arg2 * @return {(string|!jQuery)} */ @@ -253,22 +223,22 @@ jQuery.prototype.attr = function(arg1, arg2) {}; /** * @param {(string|Element|jQuery|function())} arg1 - * @param {(string|Element|Array.|jQuery)=} content + * @param {(string|Element|Array|jQuery)=} content * @return {!jQuery} */ jQuery.prototype.before = function(arg1, content) {}; /** - * @param {(string|Object.)} arg1 - * @param {(Object.|function(!jQuery.event=)|boolean)=} eventData - * @param {(function(!jQuery.event=)|boolean)=} arg3 + * @param {(string|Object)} arg1 + * @param {(Object|function(!jQuery.Event)|boolean)=} eventData + * @param {(function(!jQuery.Event)|boolean)=} arg3 * @return {!jQuery} */ jQuery.prototype.bind = function(arg1, eventData, arg3) {}; /** - * @param {(function(!jQuery.event=)|Object.)=} arg1 - * @param {function(!jQuery.event=)=} handler + * @param {(function(!jQuery.Event)|Object)=} arg1 + * @param {function(!jQuery.Event)=} handler * @return {!jQuery} */ jQuery.prototype.blur = function(arg1, handler) {}; @@ -281,7 +251,7 @@ jQuery.callbacks = function () {}; /** * @param {string=} flags - * @return {jQuery.callbacks} + * @return {!jQuery.callbacks} */ jQuery.Callbacks = function (flags) {}; @@ -320,8 +290,8 @@ jQuery.callbacks.prototype.locked = function() {}; jQuery.callbacks.prototype.remove = function(callbacks) {}; /** - * @param {(function(!jQuery.event=)|Object.)=} arg1 - * @param {function(!jQuery.event=)=} handler + * @param {(function(!jQuery.Event)|Object)=} arg1 + * @param {function(!jQuery.Event)=} handler * @return {!jQuery} */ jQuery.prototype.change = function(arg1, handler) {}; @@ -340,8 +310,8 @@ jQuery.prototype.children = function(selector) {}; jQuery.prototype.clearQueue = function(queueName) {}; /** - * @param {(function(!jQuery.event=)|Object.)=} arg1 - * @param {function(!jQuery.event=)=} handler + * @param {(function(!jQuery.Event)|Object)=} arg1 + * @param {function(!jQuery.Event)=} handler * @return {!jQuery} */ jQuery.prototype.click = function(arg1, handler) {}; @@ -350,7 +320,7 @@ jQuery.prototype.click = function(arg1, handler) {}; * @param {boolean=} withDataAndEvents * @param {boolean=} deepWithDataAndEvents * @return {!jQuery} - * @suppress {checkTypes} see issue 583 + * @suppress {checkTypes} see https://code.google.com/p/closure-compiler/issues/detail?id=583 */ jQuery.prototype.clone = function(withDataAndEvents, deepWithDataAndEvents) {}; @@ -369,13 +339,6 @@ jQuery.prototype.closest = function(arg1, context) {}; */ jQuery.contains = function(container, contained) {}; -/** - * @param {Element} container - * @param {Element} contained - * @return {boolean} - */ -$.contains = function(container, contained) {}; - /** * @return {!jQuery} * @nosideeffects @@ -386,18 +349,15 @@ jQuery.prototype.contents = function() {}; jQuery.prototype.context; /** - * @param {(string|Object.)} arg1 + * @param {(string|Object)} arg1 * @param {(string|number|function(number,*))=} arg2 * @return {(string|!jQuery)} */ jQuery.prototype.css = function(arg1, arg2) {}; -/** @type {Object.} */ +/** @type {Object} */ jQuery.cssHooks; -/** @type {Object.} */ -$.cssHooks; - /** * @param {Element} elem * @param {string=} key @@ -407,23 +367,15 @@ $.cssHooks; jQuery.data = function(elem, key, value) {}; /** - * @param {(string|Object.)=} arg1 + * @param {(string|Object)=} arg1 * @param {*=} value * @return {*} */ jQuery.prototype.data = function(arg1, value) {}; /** - * @param {Element} elem - * @param {string=} key - * @param {*=} value - * @return {*} - */ -$.data = function(elem, key, value) {}; - -/** - * @param {(function(!jQuery.event=)|Object.)=} arg1 - * @param {function(!jQuery.event=)=} handler + * @param {(function(!jQuery.Event)|Object)=} arg1 + * @param {function(!jQuery.Event)=} handler * @return {!jQuery} */ jQuery.prototype.dblclick = function(arg1, handler) {}; @@ -440,31 +392,15 @@ jQuery.deferred = function(opt_fn) {}; * @constructor * @extends {jQuery.deferred} * @param {function()=} opt_fn - * @return {jQuery.Deferred} + * @return {!jQuery.Deferred} */ jQuery.Deferred = function(opt_fn) {}; -/** - * @constructor - * @extends {jQuery.deferred} - * @param {function()=} opt_fn - * @see http://api.jquery.com/category/deferred-object/ - */ -$.deferred = function(opt_fn) {}; - -/** - * @constructor - * @extends {jQuery.deferred} - * @param {function()=} opt_fn - * @return {jQuery.deferred} - */ -$.Deferred = function(opt_fn) {}; - /** * @override * @param {jQueryCallback} alwaysCallbacks * @param {jQueryCallback=} alwaysCallbacks2 - * @return {jQuery.deferred} + * @return {!jQuery.deferred} */ jQuery.deferred.prototype.always = function(alwaysCallbacks, alwaysCallbacks2) {}; @@ -473,7 +409,7 @@ jQuery.deferred.prototype.always * @override * @param {jQueryCallback} doneCallbacks * @param {jQueryCallback=} doneCallbacks2 - * @return {jQuery.deferred} + * @return {!jQuery.deferred} */ jQuery.deferred.prototype.done = function(doneCallbacks, doneCallbacks2) {}; @@ -481,20 +417,20 @@ jQuery.deferred.prototype.done = function(doneCallbacks, doneCallbacks2) {}; * @override * @param {jQueryCallback} failCallbacks * @param {jQueryCallback=} failCallbacks2 - * @return {jQuery.deferred} + * @return {!jQuery.deferred} */ jQuery.deferred.prototype.fail = function(failCallbacks, failCallbacks2) {}; /** * @param {...*} var_args - * @return {jQuery.deferred} + * @return {!jQuery.deferred} */ jQuery.deferred.prototype.notify = function(var_args) {}; /** * @param {Object} context * @param {...*} var_args - * @return {jQuery.deferred} + * @return {!jQuery.deferred} */ jQuery.deferred.prototype.notifyWith = function(context, var_args) {}; @@ -504,46 +440,46 @@ jQuery.deferred.prototype.notifyWith = function(context, var_args) {}; * @param {function()=} doneFilter * @param {function()=} failFilter * @param {function()=} progressFilter - * @return {jQuery.Promise} + * @return {!jQuery.Promise} */ jQuery.deferred.prototype.pipe = function(doneFilter, failFilter, progressFilter) {}; /** * @param {jQueryCallback} progressCallbacks - * @return {jQuery.deferred} + * @return {!jQuery.deferred} */ jQuery.deferred.prototype.progress = function(progressCallbacks) {}; /** * @param {Object=} target - * @return {jQuery.Promise} + * @return {!jQuery.Promise} */ jQuery.deferred.prototype.promise = function(target) {}; /** * @param {...*} var_args - * @return {jQuery.deferred} + * @return {!jQuery.deferred} */ jQuery.deferred.prototype.reject = function(var_args) {}; /** * @param {Object} context - * @param {Array.<*>=} args - * @return {jQuery.deferred} + * @param {Array<*>=} args + * @return {!jQuery.deferred} */ jQuery.deferred.prototype.rejectWith = function(context, args) {}; /** * @param {...*} var_args - * @return {jQuery.deferred} + * @return {!jQuery.deferred} */ jQuery.deferred.prototype.resolve = function(var_args) {}; /** * @param {Object} context - * @param {Array.<*>=} args - * @return {jQuery.deferred} + * @param {Array<*>=} args + * @return {!jQuery.deferred} */ jQuery.deferred.prototype.resolveWith = function(context, args) {}; @@ -555,7 +491,7 @@ jQuery.deferred.prototype.state = function() {}; * @param {jQueryCallback} doneCallbacks * @param {jQueryCallback=} failCallbacks * @param {jQueryCallback=} progressCallbacks - * @return {jQuery.deferred} + * @return {!jQuery.deferred} */ jQuery.deferred.prototype.then = function(doneCallbacks, failCallbacks, progressCallbacks) {}; @@ -569,9 +505,9 @@ jQuery.prototype.delay = function(duration, queueName) {}; /** * @param {string} selector - * @param {(string|Object.)} arg2 - * @param {(function(!jQuery.event=)|Object.)=} arg3 - * @param {function(!jQuery.event=)=} handler + * @param {(string|Object)} arg2 + * @param {(function(!jQuery.Event)|Object)=} arg3 + * @param {function(!jQuery.Event)=} handler * @return {!jQuery} */ jQuery.prototype.delegate = function(selector, arg2, arg3, handler) {}; @@ -588,12 +524,6 @@ jQuery.dequeue = function(elem, queueName) {}; */ jQuery.prototype.dequeue = function(queueName) {}; -/** - * @param {Element} elem - * @param {string=} queueName - */ -$.dequeue = function(elem, queueName) {}; - /** * @param {jQuerySelector=} selector * @return {!jQuery} @@ -602,7 +532,7 @@ jQuery.prototype.detach = function(selector) {}; /** * @param {Object} collection - * @param {function(number,?)} callback + * @param {function((number|string),?)} callback * @return {Object} */ jQuery.each = function(collection, callback) {}; @@ -613,12 +543,6 @@ jQuery.each = function(collection, callback) {}; */ jQuery.prototype.each = function(fnc) {}; -/** - * @param {Object} collection - * @param {function(number,?)} callback - * @return {Object} - */ -$.each = function(collection, callback) {}; /** @return {!jQuery} */ jQuery.prototype.empty = function() {}; @@ -640,114 +564,151 @@ jQuery.error = function(message) {}; /** * @deprecated Please use .on( "error", handler ) instead. - * @param {(function(!jQuery.event=)|Object.)} arg1 - * @param {function(!jQuery.event=)=} handler + * @param {(function(!jQuery.Event)|Object)} arg1 + * @param {function(!jQuery.Event)=} handler * @return {!jQuery} */ jQuery.prototype.error = function(arg1, handler) {}; -/** @param {string} message */ -$.error = function(message) {}; +/** @const */ +jQuery.event = {}; + +/** @type {Array} */ +jQuery.event.props; + +/** @type {Object} */ +jQuery.event.special; /** * @constructor * @param {string} eventType - */ -jQuery.event = function(eventType) {}; - -/** - * @constructor - * @extends {jQuery.event} - * @param {string} eventType * @param {Object=} properties - * @return {jQuery.Event} + * @return {!jQuery.Event} */ jQuery.Event = function(eventType, properties) {}; -/** - * @constructor - * @extends {jQuery.event} - * @param {string} eventType - */ -$.event = function(eventType) {}; +/** @type {boolean} */ +jQuery.Event.prototype.altKey; -/** - * @constructor - * @extends {jQuery.event} - * @param {string} eventType - * @param {Object=} properties - * @return {$.Event} - */ -$.Event = function(eventType, properties) {}; +/** @type {boolean} */ +jQuery.Event.prototype.bubbles; -/** @type {Element} */ -jQuery.event.prototype.currentTarget; +/** @type {number} */ +jQuery.Event.prototype.button; -/** @type {Object.} */ -jQuery.event.prototype.data; - -/** @type {Element} */ -jQuery.event.prototype.delegateTarget; - -/** - * @return {boolean} - * @nosideeffects - */ -jQuery.event.prototype.isDefaultPrevented = function() {}; - -/** - * @return {boolean} - * @nosideeffects - */ -jQuery.event.prototype.isImmediatePropagationStopped = function() {}; - -/** - * @return {boolean} - * @nosideeffects - */ -jQuery.event.prototype.isPropagationStopped = function() {}; +/** @type {boolean} */ +jQuery.Event.prototype.cancelable; /** @type {string} */ -jQuery.event.prototype.namespace; +jQuery.Event.prototype.charChode; + +/** @type {number} */ +jQuery.Event.prototype.clientX; + +/** @type {number} */ +jQuery.Event.prototype.clientY; + +/** @type {boolean} */ +jQuery.Event.prototype.ctrlKey; + +/** @type {Element} */ +jQuery.Event.prototype.currentTarget; + +/** @type {Object} */ +jQuery.Event.prototype.data; + +/** @type {Element} */ +jQuery.Event.prototype.delegateTarget; + +/** @type {number} */ +jQuery.Event.prototype.detail; + +/** @type {number} */ +jQuery.Event.prototype.eventPhase; + +/** + * @return {boolean} + * @nosideeffects + */ +jQuery.Event.prototype.isDefaultPrevented = function() {}; + +/** + * @return {boolean} + * @nosideeffects + */ +jQuery.Event.prototype.isImmediatePropagationStopped = function() {}; + +/** + * @return {boolean} + * @nosideeffects + */ +jQuery.Event.prototype.isPropagationStopped = function() {}; + +/** @type {boolean} */ +jQuery.Event.prototype.metaKey; + +/** @type {string} */ +jQuery.Event.prototype.namespace; + +/** @type {number} */ +jQuery.Event.prototype.offsetX; + +/** @type {number} */ +jQuery.Event.prototype.offsetY; /** @type {Event} */ -jQuery.event.prototype.originalEvent; - -/** @type {number} */ -jQuery.event.prototype.pageX; - -/** @type {number} */ -jQuery.event.prototype.pageY; - -/** @return {undefined} */ -jQuery.event.prototype.preventDefault = function() {}; - -/** @type {Object.} */ -jQuery.event.prototype.props; +jQuery.Event.prototype.originalEvent; /** @type {Element} */ -jQuery.event.prototype.relatedTarget; +jQuery.Event.prototype.originalTarget; + +/** @type {number} */ +jQuery.Event.prototype.pageX; + +/** @type {number} */ +jQuery.Event.prototype.pageY; + +/** @return {undefined} */ +jQuery.Event.prototype.preventDefault = function() {}; + +/** @type {Object} */ +jQuery.Event.prototype.props; + +/** @type {Element} */ +jQuery.Event.prototype.relatedTarget; /** @type {*} */ -jQuery.event.prototype.result; +jQuery.Event.prototype.result; + +/** @type {number} */ +jQuery.Event.prototype.screenX; + +/** @type {number} */ +jQuery.Event.prototype.screenY; + +/** @type {boolean} */ +jQuery.Event.prototype.shiftKey; /** @return {undefined} */ -jQuery.event.prototype.stopImmediatePropagation = function() {}; +jQuery.Event.prototype.stopImmediatePropagation = function() {}; /** @return {undefined} */ -jQuery.event.prototype.stopPropagation = function() {}; +jQuery.Event.prototype.stopPropagation = function() {}; /** @type {Element} */ -jQuery.event.prototype.target; +jQuery.Event.prototype.target; /** @type {number} */ -jQuery.event.prototype.timeStamp; +jQuery.Event.prototype.timeStamp; /** @type {string} */ -jQuery.event.prototype.type; +jQuery.Event.prototype.type; + +/** @type {Window} */ +jQuery.Event.prototype.view; /** @type {number} */ -jQuery.event.prototype.which; +jQuery.Event.prototype.which; /** * @param {(Object|boolean)} arg1 @@ -763,13 +724,6 @@ jQuery.extend = function(arg1, var_args) {}; */ jQuery.prototype.extend = function(arg1, var_args) {}; -/** - * @param {(Object|boolean)} arg1 - * @param {...*} var_args - * @return {Object} - */ -$.extend = function(arg1, var_args) {}; - /** * @param {(string|number|function())=} duration * @param {(function()|string)=} arg2 @@ -823,26 +777,23 @@ jQuery.prototype.first = function() {}; /** @see http://docs.jquery.com/Plugins/Authoring */ jQuery.fn = jQuery.prototype; -/** @see http://docs.jquery.com/Plugins/Authoring */ -$.fn = $.prototype; - /** - * @param {(function(!jQuery.event=)|Object.)=} arg1 - * @param {function(!jQuery.event=)=} handler + * @param {(function(!jQuery.Event)|Object)=} arg1 + * @param {function(!jQuery.Event)=} handler * @return {!jQuery} */ jQuery.prototype.focus = function(arg1, handler) {}; /** - * @param {(function(!jQuery.event=)|Object.)} arg1 - * @param {function(!jQuery.event=)=} handler + * @param {(function(!jQuery.Event)|Object)} arg1 + * @param {function(!jQuery.Event)=} handler * @return {!jQuery} */ jQuery.prototype.focusin = function(arg1, handler) {}; /** - * @param {(function(!jQuery.event=)|Object.)} arg1 - * @param {function(!jQuery.event=)=} handler + * @param {(function(!jQuery.Event)|Object)} arg1 + * @param {function(!jQuery.Event)=} handler * @return {!jQuery} */ jQuery.prototype.focusout = function(arg1, handler) {}; @@ -850,104 +801,58 @@ jQuery.prototype.focusout = function(arg1, handler) {}; /** @const */ jQuery.fx = {}; -/** @const */ -$.fx = {}; - /** @type {number} */ jQuery.fx.interval; -/** @type {number} */ -$.fx.interval; - /** @type {boolean} */ jQuery.fx.off; -/** @type {boolean} */ -$.fx.off; - /** * @param {string} url - * @param {(Object.|string| + * @param {(Object|string| * function(string,string,jQuery.jqXHR))=} data * @param {(function(string,string,jQuery.jqXHR)|string)=} success * @param {string=} dataType - * @return {jQuery.jqXHR} + * @return {!jQuery.jqXHR} */ jQuery.get = function(url, data, success, dataType) {}; /** * @param {number=} index - * @return {(Element|Array.)} + * @return {(Element|Array)} * @nosideeffects */ jQuery.prototype.get = function(index) {}; /** * @param {string} url - * @param {(Object.|string| - * function(string,string,jQuery.jqXHR))=} data - * @param {(function(string,string,jQuery.jqXHR)|string)=} success - * @param {string=} dataType - * @return {jQuery.jqXHR} - */ -$.get = function(url, data, success, dataType) {}; - -/** - * @param {string} url - * @param {(Object.| - * function(Object.,string,jQuery.jqXHR))=} data - * @param {function(Object.,string,jQuery.jqXHR)=} success - * @return {jQuery.jqXHR} + * @param {(Object| + * function(Object,string,jQuery.jqXHR))=} data + * @param {function(Object,string,jQuery.jqXHR)=} success + * @return {!jQuery.jqXHR} * @see http://api.jquery.com/jquery.getjson/#jQuery-getJSON-url-data-success */ jQuery.getJSON = function(url, data, success) {}; -/** - * @param {string} url - * @param {(Object.| - * function(Object.,string,jQuery.jqXHR))=} data - * @param {function(Object.,string,jQuery.jqXHR)=} success - * @return {jQuery.jqXHR} - * @see http://api.jquery.com/jquery.getjson/#jQuery-getJSON-url-data-success - */ -$.getJSON = function(url, data, success) {}; - /** * @param {string} url * @param {function(Node,string,jQuery.jqXHR)=} success - * @return {jQuery.jqXHR} + * @return {!jQuery.jqXHR} */ jQuery.getScript = function(url, success) {}; -/** - * @param {string} url - * @param {function(Node,string,jQuery.jqXHR)=} success - * @return {jQuery.jqXHR} - */ -$.getScript = function(url, success) {}; - /** @param {string} code */ jQuery.globalEval = function(code) {}; -/** @param {string} code */ -$.globalEval = function(code) {}; - /** - * @param {Array.<*>} arr + * @template T + * @param {!Array} arr * @param {function(*,number)} fnc * @param {boolean=} invert - * @return {Array.<*>} + * @return {!Array} */ jQuery.grep = function(arr, fnc, invert) {}; -/** - * @param {Array.<*>} arr - * @param {function(*,number)} fnc - * @param {boolean=} invert - * @return {Array.<*>} - */ -$.grep = function(arr, fnc, invert) {}; - /** * @param {(string|Element)} arg1 * @return {!jQuery} @@ -963,19 +868,12 @@ jQuery.prototype.has = function(arg1) {}; jQuery.prototype.hasClass = function(className) {}; /** - * @param {Element} elem + * @param {!Element} elem * @return {boolean} * @nosideeffects */ jQuery.hasData = function(elem) {}; -/** - * @param {Element} elem - * @return {boolean} - * @nosideeffects - */ -$.hasData = function(elem) {}; - /** * @param {(string|number|function(number,number))=} arg1 * @return {(number|!jQuery)} @@ -993,12 +891,9 @@ jQuery.prototype.hide = function(duration, arg2, callback) {}; /** @param {boolean} hold */ jQuery.holdReady = function(hold) {}; -/** @param {boolean} hold */ -$.holdReady = function(hold) {}; - /** - * @param {function(!jQuery.event=)} arg1 - * @param {function(!jQuery.event=)=} handlerOut + * @param {function(!jQuery.Event)} arg1 + * @param {function(!jQuery.Event)=} handlerOut * @return {!jQuery} */ jQuery.prototype.hover = function(arg1, handlerOut) {}; @@ -1011,22 +906,13 @@ jQuery.prototype.html = function(arg1) {}; /** * @param {*} value - * @param {Array.<*>} arr + * @param {Array<*>} arr * @param {number=} fromIndex * @return {number} * @nosideeffects */ jQuery.inArray = function(value, arr, fromIndex) {}; -/** - * @param {*} value - * @param {Array.<*>} arr - * @param {number=} fromIndex - * @return {number} - * @nosideeffects - */ -$.inArray = function(value, arr, fromIndex) {}; - /** * @param {(jQuerySelector|Element|jQuery)=} arg1 * @return {number} @@ -1070,13 +956,6 @@ jQuery.prototype.is = function(arg1) {}; */ jQuery.isArray = function(obj) {}; -/** - * @param {*} obj - * @return {boolean} - * @nosideeffects - */ -$.isArray = function(obj) {}; - /** * @param {Object} obj * @return {boolean} @@ -1084,13 +963,6 @@ $.isArray = function(obj) {}; */ jQuery.isEmptyObject = function(obj) {}; -/** - * @param {Object} obj - * @return {boolean} - * @nosideeffects - */ -$.isEmptyObject = function(obj) {}; - /** * @param {*} obj * @return {boolean} @@ -1098,13 +970,6 @@ $.isEmptyObject = function(obj) {}; */ jQuery.isFunction = function(obj) {}; -/** - * @param {*} obj - * @return {boolean} - * @nosideeffects - */ -$.isFunction = function(obj) {}; - /** * @param {*} value * @return {boolean} @@ -1112,13 +977,6 @@ $.isFunction = function(obj) {}; */ jQuery.isNumeric = function(value) {}; -/** - * @param {*} value - * @return {boolean} - * @nosideeffects - */ -$.isNumeric = function(value) {}; - /** * @param {*} obj * @return {boolean} @@ -1126,13 +984,6 @@ $.isNumeric = function(value) {}; */ jQuery.isPlainObject = function(obj) {}; -/** - * @param {*} obj - * @return {boolean} - * @nosideeffects - */ -$.isPlainObject = function(obj) {}; - /** * @param {*} obj * @return {boolean} @@ -1140,13 +991,6 @@ $.isPlainObject = function(obj) {}; */ jQuery.isWindow = function(obj) {}; -/** - * @param {*} obj - * @return {boolean} - * @nosideeffects - */ -$.isWindow = function(obj) {}; - /** * @param {Element} node * @return {boolean} @@ -1154,13 +998,6 @@ $.isWindow = function(obj) {}; */ jQuery.isXMLDoc = function(node) {}; -/** - * @param {Element} node - * @return {boolean} - * @nosideeffects - */ -$.isXMLDoc = function(node) {}; - /** @type {string} */ jQuery.prototype.jquery; @@ -1177,7 +1014,7 @@ jQuery.jqXHR = function () {}; * @override * @param {jQueryCallback} alwaysCallbacks * @param {jQueryCallback=} alwaysCallbacks2 - * @return {jQuery.jqXHR} + * @return {!jQuery.jqXHR} */ jQuery.jqXHR.prototype.always = function(alwaysCallbacks, alwaysCallbacks2) {}; @@ -1185,28 +1022,28 @@ jQuery.jqXHR.prototype.always = /** * @deprecated * @param {function()} callback - * @return {jQuery.jqXHR} + * @return {!jQuery.jqXHR} */ jQuery.jqXHR.prototype.complete = function (callback) {}; /** * @override * @param {jQueryCallback} doneCallbacks - * @return {jQuery.jqXHR} + * @return {!jQuery.jqXHR} */ jQuery.jqXHR.prototype.done = function(doneCallbacks) {}; /** * @deprecated * @param {function()} callback - * @return {jQuery.jqXHR} + * @return {!jQuery.jqXHR} */ jQuery.jqXHR.prototype.error = function (callback) {}; /** * @override * @param {jQueryCallback} failCallbacks - * @return {jQuery.jqXHR} + * @return {!jQuery.jqXHR} */ jQuery.jqXHR.prototype.fail = function(failCallbacks) {}; @@ -1221,7 +1058,7 @@ jQuery.jqXHR.prototype.onreadystatechange = function (callback) {}; * @param {function()=} doneFilter * @param {function()=} failFilter * @param {function()=} progressFilter - * @return {jQuery.jqXHR} + * @return {!jQuery.jqXHR} */ jQuery.jqXHR.prototype.pipe = function(doneFilter, failFilter, progressFilter) {}; @@ -1229,7 +1066,7 @@ jQuery.jqXHR.prototype.pipe = /** * @deprecated * @param {function()} callback - * @return {jQuery.jqXHR} + * @return {!jQuery.jqXHR} */ jQuery.jqXHR.prototype.success = function (callback) {}; @@ -1238,28 +1075,28 @@ jQuery.jqXHR.prototype.success = function (callback) {}; * @param {jQueryCallback} doneCallbacks * @param {jQueryCallback=} failCallbacks * @param {jQueryCallback=} progressCallbacks - * @return {jQuery.jqXHR} + * @return {!jQuery.jqXHR} */ jQuery.jqXHR.prototype.then = function(doneCallbacks, failCallbacks, progressCallbacks) {}; /** - * @param {(function(!jQuery.event=)|Object.)=} arg1 - * @param {function(!jQuery.event=)=} handler + * @param {(function(!jQuery.Event)|Object)=} arg1 + * @param {function(!jQuery.Event)=} handler * @return {!jQuery} */ jQuery.prototype.keydown = function(arg1, handler) {}; /** - * @param {(function(!jQuery.event=)|Object.)=} arg1 - * @param {function(!jQuery.event=)=} handler + * @param {(function(!jQuery.Event)|Object)=} arg1 + * @param {function(!jQuery.Event)=} handler * @return {!jQuery} */ jQuery.prototype.keypress = function(arg1, handler) {}; /** - * @param {(function(!jQuery.event=)|Object.)=} arg1 - * @param {function(!jQuery.event=)=} handler + * @param {(function(!jQuery.Event)|Object)=} arg1 + * @param {function(!jQuery.Event)=} handler * @return {!jQuery} */ jQuery.prototype.keyup = function(arg1, handler) {}; @@ -1274,8 +1111,8 @@ jQuery.prototype.length; * @deprecated Please avoid the document loading Event invocation of * .load() and use .on( "load", handler ) instead. (The AJAX * module invocation signature is OK.) - * @param {(function(!jQuery.event=)|Object.|string)} arg1 - * @param {(function(!jQuery.event=)|Object.|string)=} arg2 + * @param {(function(!jQuery.Event)|Object|string)} arg1 + * @param {(function(!jQuery.Event)|Object|string)=} arg2 * @param {function(string,string,XMLHttpRequest)=} complete * @return {!jQuery} */ @@ -1283,20 +1120,14 @@ jQuery.prototype.load = function(arg1, arg2, complete) {}; /** * @param {*} obj - * @return {Array.<*>} + * @return {Array<*>} */ jQuery.makeArray = function(obj) {}; /** - * @param {*} obj - * @return {Array.<*>} - */ -$.makeArray = function(obj) {}; - -/** - * @param {(Array.<*>|Object.)} arg1 + * @param {(Array<*>|Object)} arg1 * @param {(function(*,number)|function(*,(string|number)))} callback - * @return {Array.<*>} + * @return {Array<*>} */ jQuery.map = function(arg1, callback) {}; @@ -1307,71 +1138,57 @@ jQuery.map = function(arg1, callback) {}; jQuery.prototype.map = function(callback) {}; /** - * @param {(Array.<*>|Object.)} arg1 - * @param {(function(*,number)|function(*,(string|number)))} callback - * @return {Array.<*>} - */ -$.map = function(arg1, callback) {}; - -/** - * @param {Array.<*>} first - * @param {Array.<*>} second - * @return {Array.<*>} + * @param {Array<*>} first + * @param {Array<*>} second + * @return {Array<*>} */ jQuery.merge = function(first, second) {}; /** - * @param {Array.<*>} first - * @param {Array.<*>} second - * @return {Array.<*>} - */ -$.merge = function(first, second) {}; - -/** - * @param {(function(!jQuery.event=)|Object.)=} arg1 - * @param {function(!jQuery.event=)=} handler + * @param {(function(!jQuery.Event)|Object)=} arg1 + * @param {function(!jQuery.Event)=} handler * @return {!jQuery} */ jQuery.prototype.mousedown = function(arg1, handler) {}; /** - * @param {(function(!jQuery.event=)|Object.)=} arg1 - * @param {function(!jQuery.event=)=} handler + * @param {(function(!jQuery.Event)|Object)=} arg1 + * @param {function(!jQuery.Event)=} handler * @return {!jQuery} */ jQuery.prototype.mouseenter = function(arg1, handler) {}; /** - * @param {(function(!jQuery.event=)|Object.)=} arg1 - * @param {function(!jQuery.event=)=} handler + * @param {(function(!jQuery.Event)|Object)=} arg1 + * @param {function(!jQuery.Event)=} handler * @return {!jQuery} */ jQuery.prototype.mouseleave = function(arg1, handler) {}; /** - * @param {(function(!jQuery.event=)|Object.)=} arg1 - * @param {function(!jQuery.event=)=} handler + * @param {(function(!jQuery.Event)|Object)=} arg1 + * @param {function(!jQuery.Event)=} handler * @return {!jQuery} */ jQuery.prototype.mousemove = function(arg1, handler) {}; /** - * @param {(function(!jQuery.event=)|Object.)=} arg1 - * @param {function(!jQuery.event=)=} handler + * @param {(function(!jQuery.Event)|Object)=} arg1 + * @param {function(!jQuery.Event)=} handler * @return {!jQuery} */ jQuery.prototype.mouseout = function(arg1, handler) {}; /** - * @param {(function(!jQuery.event=)|Object.)=} arg1 - * @param {function(!jQuery.event=)=} handler + * @param {(function(!jQuery.Event)|Object)=} arg1 + * @param {function(!jQuery.Event)=} handler * @return {!jQuery} */ jQuery.prototype.mouseover = function(arg1, handler) {}; /** - * @param {(function(!jQuery.event=)|Object.)=} arg1 - * @param {function(!jQuery.event=)=} handler + * @param {(function(!jQuery.Event)|Object)=} arg1 + * @param {function(!jQuery.Event)=} handler * @return {!jQuery} */ jQuery.prototype.mouseup = function(arg1, handler) {}; @@ -1404,12 +1221,6 @@ jQuery.prototype.nextUntil = function(arg1, filter) {}; */ jQuery.noConflict = function(removeAll) {}; -/** - * @param {boolean=} removeAll - * @return {Object} - */ -$.noConflict = function(removeAll) {}; - /** * @return {function()} * @nosideeffects @@ -1417,13 +1228,7 @@ $.noConflict = function(removeAll) {}; jQuery.noop = function() {}; /** - * @return {function()} - * @nosideeffects - */ -$.noop = function() {}; - -/** - * @param {(jQuerySelector|Array.|function(number)|jQuery)} arg1 + * @param {(jQuerySelector|Array|function(number)|jQuery)} arg1 * @return {!jQuery} */ jQuery.prototype.not = function(arg1) {}; @@ -1435,15 +1240,9 @@ jQuery.prototype.not = function(arg1) {}; jQuery.now = function() {}; /** - * @return {number} - * @nosideeffects - */ -$.now = function() {}; - -/** - * @param {(string|Object.)=} arg1 - * @param {(string|function(!jQuery.event=))=} selector - * @param {function(!jQuery.event=)=} handler + * @param {(string|Object)=} arg1 + * @param {(string|function(!jQuery.Event))=} selector + * @param {function(!jQuery.Event)=} handler * @return {!jQuery} */ jQuery.prototype.off = function(arg1, selector, handler) {}; @@ -1462,19 +1261,19 @@ jQuery.prototype.offset = function(arg1) {}; jQuery.prototype.offsetParent = function() {}; /** - * @param {(string|Object.)} arg1 + * @param {(string|Object)} arg1 * @param {*=} selector * @param {*=} data - * @param {function(!jQuery.event=)=} handler + * @param {function(!jQuery.Event)=} handler * @return {!jQuery} */ jQuery.prototype.on = function(arg1, selector, data, handler) {}; /** - * @param {(string|Object.)} arg1 + * @param {(string|Object)} arg1 * @param {*=} arg2 * @param {*=} arg3 - * @param {function(!jQuery.event=)=} handler + * @param {function(!jQuery.Event)=} handler * @return {!jQuery} */ jQuery.prototype.one = function(arg1, arg2, arg3, handler) {}; @@ -1494,19 +1293,12 @@ jQuery.prototype.outerHeight = function(includeMargin) {}; jQuery.prototype.outerWidth = function(includeMargin) {}; /** - * @param {(Object.|Array.>)} obj + * @param {(Object|Array>)} obj * @param {boolean=} traditional * @return {string} */ jQuery.param = function(obj, traditional) {}; -/** - * @param {(Object.|Array.>)} obj - * @param {boolean=} traditional - * @return {string} - */ -$.param = function(obj, traditional) {}; - /** * @param {jQuerySelector=} selector * @return {!jQuery} @@ -1533,42 +1325,22 @@ jQuery.prototype.parentsUntil = function(arg1, filter) {}; * @param {string} data * @param {(Element|boolean)=} context * @param {boolean=} keepScripts - * @return {Array.} + * @return {Array} */ jQuery.parseHTML = function(data, context, keepScripts) {}; -/** - * @param {string} data - * @param {(Element|boolean)=} context - * @param {boolean=} keepScripts - * @return {Array.} - */ -$.parseHTML = function(data, context, keepScripts) {}; - /** * @param {string} json - * @return {Object.} + * @return {string|number|Object|Array|boolean} */ jQuery.parseJSON = function(json) {}; -/** - * @param {string} json - * @return {Object.} - */ -$.parseJSON = function(json) {}; - /** * @param {string} data * @return {Document} */ jQuery.parseXML = function(data) {}; -/** - * @param {string} data - * @return {Document} - */ -$.parseXML = function(data) {}; - /** * @return {{left:number,top:number}} * @nosideeffects @@ -1577,24 +1349,13 @@ jQuery.prototype.position = function() {}; /** * @param {string} url - * @param {(Object.|string| + * @param {(Object|string| * function(string,string,jQuery.jqXHR))=} data - * @param {(function(string,string,jQuery.jqXHR)|string)=} success + * @param {(function(string,string,jQuery.jqXHR)|string|null)=} success * @param {string=} dataType - * @return {jQuery.jqXHR} + * @return {!jQuery.jqXHR} */ jQuery.post = function(url, data, success, dataType) {}; - -/** - * @param {string} url - * @param {(Object.|string| - * function(string,string,jQuery.jqXHR))=} data - * @param {(function(string,string,jQuery.jqXHR)|string)=} success - * @param {string=} dataType - * @return {jQuery.jqXHR} - */ -$.post = function(url, data, success, dataType) {}; - /** * @param {(string|Element|jQuery|function(number,string))} arg1 * @param {(string|Element|jQuery)=} content @@ -1633,7 +1394,7 @@ jQuery.prototype.prevUntil = function(arg1, filter) {}; /** * @param {(string|Object)=} type * @param {Object=} target - * @return {jQuery.Promise} + * @return {!jQuery.Promise} */ jQuery.prototype.promise = function(type, target) {}; @@ -1647,20 +1408,20 @@ jQuery.Promise = function () {}; /** * @param {jQueryCallback} alwaysCallbacks * @param {jQueryCallback=} alwaysCallbacks2 - * @return {jQuery.Promise} + * @return {!jQuery.Promise} */ jQuery.Promise.prototype.always = function(alwaysCallbacks, alwaysCallbacks2) {}; /** * @param {jQueryCallback} doneCallbacks - * @return {jQuery.Promise} + * @return {!jQuery.Promise} */ jQuery.Promise.prototype.done = function(doneCallbacks) {}; /** * @param {jQueryCallback} failCallbacks - * @return {jQuery.Promise} + * @return {!jQuery.Promise} */ jQuery.Promise.prototype.fail = function(failCallbacks) {}; @@ -1668,7 +1429,7 @@ jQuery.Promise.prototype.fail = function(failCallbacks) {}; * @param {function()=} doneFilter * @param {function()=} failFilter * @param {function()=} progressFilter - * @return {jQuery.Promise} + * @return {!jQuery.Promise} */ jQuery.Promise.prototype.pipe = function(doneFilter, failFilter, progressFilter) {}; @@ -1677,13 +1438,13 @@ jQuery.Promise.prototype.pipe = * @param {jQueryCallback} doneCallbacks * @param {jQueryCallback=} failCallbacks * @param {jQueryCallback=} progressCallbacks - * @return {jQuery.Promise} + * @return {!jQuery.Promise} */ jQuery.Promise.prototype.then = function(doneCallbacks, failCallbacks, progressCallbacks) {}; /** - * @param {(string|Object.)} arg1 + * @param {(string|Object)} arg1 * @param {(string|number|boolean|function(number,String))=} arg2 * @return {(string|boolean|!jQuery)} */ @@ -1696,42 +1457,28 @@ jQuery.prototype.prop = function(arg1, arg2) {}; jQuery.proxy = function(var_args) {}; /** - * @param {...*} var_args - * @return {function()} - */ -$.proxy = function(var_args) {}; - -/** - * @param {Array.} elements + * @param {Array} elements * @param {string=} name - * @param {Array.<*>=} args + * @param {Array<*>=} args * @return {!jQuery} */ jQuery.prototype.pushStack = function(elements, name, args) {}; /** - * @param {(string|Array.|function(function()))=} queueName - * @param {(Array.|function(function()))=} arg2 - * @return {(Array.|!jQuery)} + * @param {(string|Array|function(function()))=} queueName + * @param {(Array|function(function()))=} arg2 + * @return {(Array|!jQuery)} */ jQuery.prototype.queue = function(queueName, arg2) {}; /** * @param {Element} elem * @param {string=} queueName - * @param {(Array.|function())=} arg3 - * @return {(Array.|!jQuery)} + * @param {(Array|function())=} arg3 + * @return {(Array|!jQuery)} */ jQuery.queue = function(elem, queueName, arg3) {}; -/** - * @param {Element} elem - * @param {string=} queueName - * @param {(Array.|function())=} arg3 - * @return {(Array.|!jQuery)} - */ -$.queue = function(elem, queueName, arg3) {}; - /** * @param {function()} handler * @return {!jQuery} @@ -1757,7 +1504,7 @@ jQuery.prototype.removeAttr = function(attributeName) {}; jQuery.prototype.removeClass = function(arg1) {}; /** - * @param {(string|Array.)=} arg1 + * @param {(string|Array)=} arg1 * @return {!jQuery} */ jQuery.prototype.removeData = function(arg1) {}; @@ -1769,13 +1516,6 @@ jQuery.prototype.removeData = function(arg1) {}; */ jQuery.removeData = function(elem, name) {}; -/** - * @param {Element} elem - * @param {string=} name - * @return {!jQuery} - */ -$.removeData = function(elem, name) {}; - /** * @param {string} propertyName * @return {!jQuery} @@ -1795,15 +1535,15 @@ jQuery.prototype.replaceAll = function(target) {}; jQuery.prototype.replaceWith = function(arg1) {}; /** - * @param {(function(!jQuery.event=)|Object.)=} arg1 - * @param {function(!jQuery.event=)=} handler + * @param {(function(!jQuery.Event)|Object)=} arg1 + * @param {function(!jQuery.Event)=} handler * @return {!jQuery} */ jQuery.prototype.resize = function(arg1, handler) {}; /** - * @param {(function(!jQuery.event=)|Object.)=} arg1 - * @param {function(!jQuery.event=)=} handler + * @param {(function(!jQuery.Event)|Object)=} arg1 + * @param {function(!jQuery.Event)=} handler * @return {!jQuery} */ jQuery.prototype.scroll = function(arg1, handler) {}; @@ -1821,8 +1561,8 @@ jQuery.prototype.scrollLeft = function(value) {}; jQuery.prototype.scrollTop = function(value) {}; /** - * @param {(function(!jQuery.event=)|Object.)=} arg1 - * @param {function(!jQuery.event=)=} handler + * @param {(function(!jQuery.Event)|Object)=} arg1 + * @param {function(!jQuery.Event)=} handler * @return {!jQuery} */ jQuery.prototype.select = function(arg1, handler) {}; @@ -1834,7 +1574,7 @@ jQuery.prototype.select = function(arg1, handler) {}; jQuery.prototype.serialize = function() {}; /** - * @return {Array.>} + * @return {Array>} * @nosideeffects */ jQuery.prototype.serializeArray = function() {}; @@ -1869,7 +1609,7 @@ jQuery.prototype.size = function() {}; jQuery.prototype.slice = function(start, end) {}; /** - * @param {(Object.|string|number)=} optionsOrDuration + * @param {(Object|string|number)=} optionsOrDuration * @param {(function()|string)=} completeOrEasing * @param {function()=} complete * @return {!jQuery} @@ -1878,7 +1618,7 @@ jQuery.prototype.slideDown = function(optionsOrDuration, completeOrEasing, complete) {}; /** - * @param {(Object.|string|number)=} optionsOrDuration + * @param {(Object|string|number)=} optionsOrDuration * @param {(function()|string)=} completeOrEasing * @param {function()=} complete * @return {!jQuery} @@ -1887,7 +1627,7 @@ jQuery.prototype.slideToggle = function(optionsOrDuration, completeOrEasing, complete) {}; /** - * @param {(Object.|string|number)=} optionsOrDuration + * @param {(Object|string|number)=} optionsOrDuration * @param {(function()|string)=} completeOrEasing * @param {function()=} complete * @return {!jQuery} @@ -1904,104 +1644,64 @@ jQuery.prototype.slideUp = jQuery.prototype.stop = function(arg1, arg2, jumpToEnd) {}; /** - * @param {(function(!jQuery.event=)|Object.)=} arg1 - * @param {function(!jQuery.event=)=} handler + * @param {(function(!jQuery.Event)|Object)=} arg1 + * @param {function(!jQuery.Event)=} handler * @return {!jQuery} */ jQuery.prototype.submit = function(arg1, handler) {}; -/** @type {Object.} */ +/** @type {Object} + * @deprecated Please try to use feature detection instead. + */ jQuery.support; -/** @type {Object.} */ -$.support; - /** * @deprecated Please try to use feature detection instead. * @type {boolean} */ jQuery.support.boxModel; -/** - * @deprecated Please try to use feature detection instead. - * @type {boolean} - */ -$.support.boxModel; - /** @type {boolean} */ jQuery.support.changeBubbles; -/** @type {boolean} */ -$.support.changeBubbles; - /** @type {boolean} */ jQuery.support.cors; -/** @type {boolean} */ -$.support.cors; - /** @type {boolean} */ jQuery.support.cssFloat; -/** @type {boolean} */ -$.support.cssFloat; - /** @type {boolean} */ jQuery.support.hrefNormalized; -/** @type {boolean} */ -$.support.hrefNormalized; - /** @type {boolean} */ jQuery.support.htmlSerialize; -/** @type {boolean} */ -$.support.htmlSerialize; - /** @type {boolean} */ jQuery.support.leadingWhitespace; -/** @type {boolean} */ -$.support.leadingWhitespace; - /** @type {boolean} */ jQuery.support.noCloneEvent; -/** @type {boolean} */ -$.support.noCloneEvent; - /** @type {boolean} */ jQuery.support.opacity; -/** @type {boolean} */ -$.support.opacity; - /** @type {boolean} */ jQuery.support.style; -/** @type {boolean} */ -$.support.style; - /** @type {boolean} */ jQuery.support.submitBubbles; -/** @type {boolean} */ -$.support.submitBubbles; - /** @type {boolean} */ jQuery.support.tbody; -/** @type {boolean} */ -$.support.tbody; - /** - * @param {(string|function(number,string))=} arg1 + * @param {(string|number|boolean|function(number,string))=} arg1 * @return {(string|!jQuery)} */ jQuery.prototype.text = function(arg1) {}; /** - * @return {Array.} + * @return {Array} * @nosideeffects */ jQuery.prototype.toArray = function() {}; @@ -2009,7 +1709,7 @@ jQuery.prototype.toArray = function() {}; /** * Refers to the method from the Effects category. There used to be a toggle * method on the Events category which was removed starting version 1.9. - * @param {(number|string|Object.|boolean)=} arg1 + * @param {(number|string|Object|boolean)=} arg1 * @param {(function()|string)=} arg2 * @param {function()=} arg3 * @return {!jQuery} @@ -2024,15 +1724,15 @@ jQuery.prototype.toggle = function(arg1, arg2, arg3) {}; jQuery.prototype.toggleClass = function(arg1, flag) {}; /** - * @param {(string|jQuery.event)} arg1 + * @param {(string|jQuery.Event)} arg1 * @param {...*} var_args * @return {!jQuery} */ jQuery.prototype.trigger = function(arg1, var_args) {}; /** - * @param {string|jQuery.event} eventType - * @param {Array.<*>=} extraParameters + * @param {string|jQuery.Event} eventType + * @param {Array<*>=} extraParameters * @return {*} */ jQuery.prototype.triggerHandler = function(eventType, extraParameters) {}; @@ -2044,13 +1744,6 @@ jQuery.prototype.triggerHandler = function(eventType, extraParameters) {}; */ jQuery.trim = function(str) {}; -/** - * @param {string} str - * @return {string} - * @nosideeffects - */ -$.trim = function(str) {}; - /** * @param {*} obj * @return {string} @@ -2059,43 +1752,30 @@ $.trim = function(str) {}; jQuery.type = function(obj) {}; /** - * @param {*} obj - * @return {string} - * @nosideeffects - */ -$.type = function(obj) {}; - -/** - * @param {(string|function(!jQuery.event=)|jQuery.event)=} arg1 - * @param {(function(!jQuery.event=)|boolean)=} arg2 + * @param {(string|function(!jQuery.Event)|jQuery.Event)=} arg1 + * @param {(function(!jQuery.Event)|boolean)=} arg2 * @return {!jQuery} */ jQuery.prototype.unbind = function(arg1, arg2) {}; /** * @param {string=} arg1 - * @param {(string|Object.)=} arg2 - * @param {function(!jQuery.event=)=} handler + * @param {(string|Object)=} arg2 + * @param {function(!jQuery.Event)=} handler * @return {!jQuery} */ jQuery.prototype.undelegate = function(arg1, arg2, handler) {}; /** - * @param {Array.} arr - * @return {Array.} + * @param {Array} arr + * @return {Array} */ jQuery.unique = function(arr) {}; -/** - * @param {Array.} arr - * @return {Array.} - */ -$.unique = function(arr) {}; - /** * @deprecated Please use .on( "unload", handler ) instead. - * @param {(function(!jQuery.event=)|Object.)} arg1 - * @param {function(!jQuery.event=)=} handler + * @param {(function(!jQuery.Event)|Object)} arg1 + * @param {function(!jQuery.Event)=} handler * @return {!jQuery} */ jQuery.prototype.unload = function(arg1, handler) {}; @@ -2104,8 +1784,8 @@ jQuery.prototype.unload = function(arg1, handler) {}; jQuery.prototype.unwrap = function() {}; /** - * @param {(string|Array.|function(number,*))=} arg1 - * @return {(string|number|Array.|!jQuery)} + * @param {(string|Array|function(number,*))=} arg1 + * @return {(string|number|Array|!jQuery)} */ jQuery.prototype.val = function(arg1) {}; @@ -2119,18 +1799,10 @@ jQuery.prototype.val = function(arg1) {}; * into a promise. * @param {*} deferred * @param {...*} deferreds - * @return {jQuery.Promise} + * @return {!jQuery.Promise} */ jQuery.when = function(deferred, deferreds) {}; -/** - * Note: See jQuery.when(). - * @param {*} deferred - * @param {...*} deferreds - * @return {jQuery.Promise} - */ -$.when = function(deferred, deferreds) {}; - /** * @param {(string|number|function(number,number))=} arg1 * @return {(number|!jQuery)} @@ -2154,4 +1826,3 @@ jQuery.prototype.wrapAll = function(wrappingElement) {}; * @return {!jQuery} */ jQuery.prototype.wrapInner = function(arg1) {}; - From 0acb2a335d4ed7dd1ebb16bbba50870ff23ff733 Mon Sep 17 00:00:00 2001 From: Warren Date: Thu, 24 Sep 2015 12:18:23 -0400 Subject: [PATCH 24/93] Modified the preload.html example to reflect the correct position of the maps displayed --- examples/preload.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/preload.html b/examples/preload.html index ffda2a7e6d..1318ed6e0e 100644 --- a/examples/preload.html +++ b/examples/preload.html @@ -3,7 +3,7 @@ template: example.html title: Preload example shortdesc: Example of tile preloading. docs: > -

The map on the left preloads low resolution tiles. The map on the right does not use any preloading. Try zooming out and panning to see the difference.

+

The map on the top preloads low resolution tiles. The map on the bottom does not use any preloading. Try zooming out and panning to see the difference.

tags: "preload, bing" ---
From 37d0176642d4673c0008080025936c8ffb4a9a02 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Fri, 18 Sep 2015 14:14:41 +0900 Subject: [PATCH 25/93] Remove goog.isDef from animation.js (-42 B) --- src/ol/animation.js | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/ol/animation.js b/src/ol/animation.js index 2051f01d47..9539d7c27b 100644 --- a/src/ol/animation.js +++ b/src/ol/animation.js @@ -15,9 +15,9 @@ goog.require('ol.easing'); */ ol.animation.bounce = function(options) { var resolution = options.resolution; - var start = goog.isDef(options.start) ? options.start : goog.now(); - var duration = goog.isDef(options.duration) ? options.duration : 1000; - var easing = goog.isDef(options.easing) ? + var start = options.start ? options.start : goog.now(); + var duration = options.duration ? options.duration : 1000; + var easing = options.easing ? options.easing : ol.easing.upAndDown; return ( /** @@ -51,11 +51,11 @@ ol.animation.bounce = function(options) { */ ol.animation.pan = function(options) { var source = options.source; - var start = goog.isDef(options.start) ? options.start : goog.now(); + var start = options.start ? options.start : goog.now(); var sourceX = source[0]; var sourceY = source[1]; - var duration = goog.isDef(options.duration) ? options.duration : 1000; - var easing = goog.isDef(options.easing) ? + var duration = options.duration ? options.duration : 1000; + var easing = options.easing ? options.easing : ol.easing.inAndOut; return ( /** @@ -90,12 +90,12 @@ ol.animation.pan = function(options) { * @api */ ol.animation.rotate = function(options) { - var sourceRotation = goog.isDef(options.rotation) ? options.rotation : 0; - var start = goog.isDef(options.start) ? options.start : goog.now(); - var duration = goog.isDef(options.duration) ? options.duration : 1000; - var easing = goog.isDef(options.easing) ? + var sourceRotation = options.rotation ? options.rotation : 0; + var start = options.start ? options.start : goog.now(); + var duration = options.duration ? options.duration : 1000; + var easing = options.easing ? options.easing : ol.easing.inAndOut; - var anchor = goog.isDef(options.anchor) ? + var anchor = options.anchor ? options.anchor : null; return ( @@ -137,9 +137,9 @@ ol.animation.rotate = function(options) { */ ol.animation.zoom = function(options) { var sourceResolution = options.resolution; - var start = goog.isDef(options.start) ? options.start : goog.now(); - var duration = goog.isDef(options.duration) ? options.duration : 1000; - var easing = goog.isDef(options.easing) ? + var start = options.start ? options.start : goog.now(); + var duration = options.duration ? options.duration : 1000; + var easing = options.easing ? options.easing : ol.easing.inAndOut; return ( /** From c8e9525f3b14e01184b17379c5951529d7a842df Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Fri, 18 Sep 2015 14:51:24 +0900 Subject: [PATCH 26/93] Remove goog.isDef from attribution.js through color.js (-54 B) --- src/ol/attribution.js | 3 +-- src/ol/centerconstraint.js | 2 +- src/ol/collection.js | 2 +- src/ol/color/color.js | 6 +++--- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/ol/attribution.js b/src/ol/attribution.js index 8a449b1a20..11a4188f4c 100644 --- a/src/ol/attribution.js +++ b/src/ol/attribution.js @@ -38,8 +38,7 @@ ol.Attribution = function(options) { * @private * @type {Object.>} */ - this.tileRanges_ = goog.isDef(options.tileRanges) ? - options.tileRanges : null; + this.tileRanges_ = options.tileRanges ? options.tileRanges : null; }; diff --git a/src/ol/centerconstraint.js b/src/ol/centerconstraint.js index 2cc4db9592..e67c91082d 100644 --- a/src/ol/centerconstraint.js +++ b/src/ol/centerconstraint.js @@ -21,7 +21,7 @@ ol.CenterConstraint.createExtent = function(extent) { * @return {ol.Coordinate|undefined} Center. */ function(center) { - if (goog.isDef(center)) { + if (center) { return [ goog.math.clamp(center[0], extent[0], extent[2]), goog.math.clamp(center[1], extent[1], extent[3]) diff --git a/src/ol/collection.js b/src/ol/collection.js index a679dca011..2da288fac9 100644 --- a/src/ol/collection.js +++ b/src/ol/collection.js @@ -91,7 +91,7 @@ ol.Collection = function(opt_array) { * @private * @type {!Array.} */ - this.array_ = goog.isDef(opt_array) ? opt_array : []; + this.array_ = opt_array ? opt_array : []; this.updateLength_(); diff --git a/src/ol/color/color.js b/src/ol/color/color.js index ecb2cbae21..98f8cf6abb 100644 --- a/src/ol/color/color.js +++ b/src/ol/color/color.js @@ -62,7 +62,7 @@ ol.color.rgbaColorRe_ = ol.color.blend = function(dst, src, opt_color) { // http://en.wikipedia.org/wiki/Alpha_compositing // FIXME do we need to scale by 255? - var out = goog.isDef(opt_color) ? opt_color : []; + var out = opt_color ? opt_color : []; var dstA = dst[3]; var srcA = src[3]; if (dstA == 1) { @@ -271,7 +271,7 @@ ol.color.isValid = function(color) { * @return {ol.Color} Clamped color. */ ol.color.normalize = function(color, opt_color) { - var result = goog.isDef(opt_color) ? opt_color : []; + var result = opt_color ? opt_color : []; result[0] = goog.math.clamp((color[0] + 0.5) | 0, 0, 255); result[1] = goog.math.clamp((color[1] + 0.5) | 0, 0, 255); result[2] = goog.math.clamp((color[2] + 0.5) | 0, 0, 255); @@ -309,7 +309,7 @@ ol.color.toString = function(color) { * @return {ol.Color} Transformed color. */ ol.color.transform = function(color, transform, opt_color) { - var result = goog.isDef(opt_color) ? opt_color : []; + var result = opt_color ? opt_color : []; result = goog.vec.Mat4.multVec3(transform, color, result); goog.asserts.assert(goog.isArray(result), 'result should be an array'); result[3] = color[3]; From 4c0d857f416ef55e0e03d204620c03fdb7d89687 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Fri, 18 Sep 2015 15:05:16 +0900 Subject: [PATCH 27/93] Remove goog.isDef from colormatrix.js (-12 B) --- src/ol/color/colormatrix.js | 28 ++++++++++++++++------------ src/ol/ol.js | 10 ++++++++++ 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/src/ol/color/colormatrix.js b/src/ol/color/colormatrix.js index ac947263fc..3652ea692c 100644 --- a/src/ol/color/colormatrix.js +++ b/src/ol/color/colormatrix.js @@ -1,6 +1,7 @@ goog.provide('ol.color.Matrix'); goog.require('goog.vec.Mat4'); +goog.require('ol'); @@ -165,39 +166,42 @@ ol.color.Matrix.makeSaturation = function(matrix, value) { ol.color.Matrix.prototype.getMatrix = function( brightness, contrast, hue, saturation) { var colorMatrixDirty = false; - if (goog.isDef(brightness) && brightness !== this.brightness_) { - ol.color.Matrix.makeBrightness(this.brightnessMatrix_, brightness); + if (ol.isDef(brightness) && brightness !== this.brightness_) { + ol.color.Matrix.makeBrightness(this.brightnessMatrix_, + /** @type {number} */ (brightness)); this.brightness_ = brightness; colorMatrixDirty = true; } - if (goog.isDef(contrast) && contrast !== this.contrast_) { - ol.color.Matrix.makeContrast(this.contrastMatrix_, contrast); + if (ol.isDef(contrast) && contrast !== this.contrast_) { + ol.color.Matrix.makeContrast(this.contrastMatrix_, + /** @type {number} */ (contrast)); this.contrast_ = contrast; colorMatrixDirty = true; } - if (goog.isDef(hue) && hue !== this.hue_) { - ol.color.Matrix.makeHue(this.hueMatrix_, hue); + if (ol.isDef(hue) && hue !== this.hue_) { + ol.color.Matrix.makeHue(this.hueMatrix_, /** @type {number} */ (hue)); this.hue_ = hue; colorMatrixDirty = true; } - if (goog.isDef(saturation) && saturation !== this.saturation_) { - ol.color.Matrix.makeSaturation(this.saturationMatrix_, saturation); + if (ol.isDef(saturation) && saturation !== this.saturation_) { + ol.color.Matrix.makeSaturation(this.saturationMatrix_, + /** @type {number} */ (saturation)); this.saturation_ = saturation; colorMatrixDirty = true; } if (colorMatrixDirty) { var colorMatrix = this.colorMatrix_; goog.vec.Mat4.makeIdentity(colorMatrix); - if (goog.isDef(contrast)) { + if (ol.isDef(contrast)) { goog.vec.Mat4.multMat(colorMatrix, this.contrastMatrix_, colorMatrix); } - if (goog.isDef(brightness)) { + if (ol.isDef(brightness)) { goog.vec.Mat4.multMat(colorMatrix, this.brightnessMatrix_, colorMatrix); } - if (goog.isDef(saturation)) { + if (ol.isDef(saturation)) { goog.vec.Mat4.multMat(colorMatrix, this.saturationMatrix_, colorMatrix); } - if (goog.isDef(hue)) { + if (ol.isDef(hue)) { goog.vec.Mat4.multMat(colorMatrix, this.hueMatrix_, colorMatrix); } } diff --git a/src/ol/ol.js b/src/ol/ol.js index ba1c7e6282..4b7969102a 100644 --- a/src/ol/ol.js +++ b/src/ol/ol.js @@ -240,3 +240,13 @@ ol.WEBGL_EXTENSIONS; // value is set in `ol.has` ol.inherits = goog.inherits; // note that the newline above is necessary to satisfy the linter + + +/** + * Determine if a value is defined. + * @param {?} value The value to test. + * @return {boolean} The value is defined. + */ +ol.isDef = function(value) { + return value !== undefined; +}; From 007194a18f75ce06aa65b7fb7ce6ae0946eb1563 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Fri, 18 Sep 2015 16:24:33 +0900 Subject: [PATCH 28/93] Remove goog.isDef from attributioncontrol.js (-33 B) --- src/ol/control/attributioncontrol.js | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/ol/control/attributioncontrol.js b/src/ol/control/attributioncontrol.js index 3e64e77c10..a5daa3140f 100644 --- a/src/ol/control/attributioncontrol.js +++ b/src/ol/control/attributioncontrol.js @@ -10,6 +10,7 @@ goog.require('goog.events'); goog.require('goog.events.EventType'); goog.require('goog.object'); goog.require('goog.style'); +goog.require('ol'); goog.require('ol.Attribution'); goog.require('ol.control.Control'); goog.require('ol.css'); @@ -31,7 +32,7 @@ goog.require('ol.source.Tile'); */ ol.control.Attribution = function(opt_options) { - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = opt_options ? opt_options : {}; /** * @private @@ -52,27 +53,25 @@ ol.control.Attribution = function(opt_options) { * @private * @type {boolean} */ - this.collapsed_ = goog.isDef(options.collapsed) ? options.collapsed : true; + this.collapsed_ = ol.isDef(options.collapsed) ? + /** @type {boolean} */ (options.collapsed) : true; /** * @private * @type {boolean} */ - this.collapsible_ = goog.isDef(options.collapsible) ? - options.collapsible : true; + this.collapsible_ = ol.isDef(options.collapsible) ? + /** @type {boolean} */ (options.collapsible) : true; if (!this.collapsible_) { this.collapsed_ = false; } - var className = goog.isDef(options.className) ? - options.className : 'ol-attribution'; + var className = options.className ? options.className : 'ol-attribution'; - var tipLabel = goog.isDef(options.tipLabel) ? - options.tipLabel : 'Attributions'; + var tipLabel = options.tipLabel ? options.tipLabel : 'Attributions'; - var collapseLabel = goog.isDef(options.collapseLabel) ? - options.collapseLabel : '\u00BB'; + var collapseLabel = options.collapseLabel ? options.collapseLabel : '\u00BB'; /** * @private @@ -82,7 +81,7 @@ ol.control.Attribution = function(opt_options) { goog.dom.createDom(goog.dom.TagName.SPAN, {}, collapseLabel) : collapseLabel); - var label = goog.isDef(options.label) ? options.label : 'i'; + var label = options.label ? options.label : 'i'; /** * @private @@ -116,8 +115,7 @@ ol.control.Attribution = function(opt_options) { var element = goog.dom.createDom(goog.dom.TagName.DIV, cssClasses, this.ulElement_, button); - var render = goog.isDef(options.render) ? - options.render : ol.control.Attribution.render; + var render = options.render ? options.render : ol.control.Attribution.render; goog.base(this, { element: element, @@ -185,7 +183,7 @@ ol.control.Attribution.prototype.getSourceAttributions = function(frameState) { continue; } tileRanges = frameState.usedTiles[sourceKey]; - if (goog.isDef(tileRanges)) { + if (tileRanges) { goog.asserts.assertInstanceof(source, ol.source.Tile, 'source should be an ol.source.Tile'); var tileGrid = source.getTileGridForProjection(projection); From a096ec5bf72c6c99e4ad063a64fa33732a570669 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Fri, 18 Sep 2015 18:28:47 +0900 Subject: [PATCH 29/93] Remove goog.isDef from controls (-278 B) --- externs/olx.js | 2 +- src/ol/control/control.js | 6 ++-- src/ol/control/controldefaults.js | 9 ++--- src/ol/control/fullscreencontrol.js | 17 +++++---- src/ol/control/mousepositioncontrol.js | 20 +++++------ src/ol/control/overviewmapcontrol.js | 48 ++++++++++++-------------- src/ol/control/rotatecontrol.js | 23 ++++++------ src/ol/control/scalelinecontrol.js | 14 ++++---- src/ol/control/zoomcontrol.js | 20 +++++------ src/ol/control/zoomslidercontrol.js | 14 ++++---- src/ol/control/zoomtoextentcontrol.js | 12 +++---- 11 files changed, 88 insertions(+), 97 deletions(-) diff --git a/externs/olx.js b/externs/olx.js index ff7bb77a72..c7240d7293 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -1291,7 +1291,7 @@ olx.control.ScaleLineOptions.prototype.units; /** * @typedef {{duration: (number|undefined), * className: (string|undefined), - * label: (string|Node|undefined), + * label: (string|Element|undefined), * tipLabel: (string|undefined), * target: (Element|undefined), * render: (function(ol.MapEvent)|undefined), diff --git a/src/ol/control/control.js b/src/ol/control/control.js index e56830b2e9..68c2d55be1 100644 --- a/src/ol/control/control.js +++ b/src/ol/control/control.js @@ -45,7 +45,7 @@ ol.control.Control = function(options) { * @protected * @type {Element} */ - this.element = goog.isDef(options.element) ? options.element : null; + this.element = options.element ? options.element : null; /** * @private @@ -68,9 +68,9 @@ ol.control.Control = function(options) { /** * @type {function(ol.MapEvent)} */ - this.render = goog.isDef(options.render) ? options.render : goog.nullFunction; + this.render = options.render ? options.render : goog.nullFunction; - if (goog.isDef(options.target)) { + if (options.target) { this.setTarget(options.target); } diff --git a/src/ol/control/controldefaults.js b/src/ol/control/controldefaults.js index c9c6170ac9..fca2f43ea6 100644 --- a/src/ol/control/controldefaults.js +++ b/src/ol/control/controldefaults.js @@ -1,5 +1,6 @@ goog.provide('ol.control'); +goog.require('ol'); goog.require('ol.Collection'); goog.require('ol.control.Attribution'); goog.require('ol.control.Rotate'); @@ -20,23 +21,23 @@ goog.require('ol.control.Zoom'); */ ol.control.defaults = function(opt_options) { - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = opt_options ? opt_options : {}; var controls = new ol.Collection(); - var zoomControl = goog.isDef(options.zoom) ? + var zoomControl = ol.isDef(options.zoom) ? options.zoom : true; if (zoomControl) { controls.push(new ol.control.Zoom(options.zoomOptions)); } - var rotateControl = goog.isDef(options.rotate) ? + var rotateControl = ol.isDef(options.rotate) ? options.rotate : true; if (rotateControl) { controls.push(new ol.control.Rotate(options.rotateOptions)); } - var attributionControl = goog.isDef(options.attribution) ? + var attributionControl = ol.isDef(options.attribution) ? options.attribution : true; if (attributionControl) { controls.push(new ol.control.Attribution(options.attributionOptions)); diff --git a/src/ol/control/fullscreencontrol.js b/src/ol/control/fullscreencontrol.js index bbf53f371d..ef69518520 100644 --- a/src/ol/control/fullscreencontrol.js +++ b/src/ol/control/fullscreencontrol.js @@ -8,6 +8,7 @@ goog.require('goog.dom.fullscreen'); goog.require('goog.dom.fullscreen.EventType'); goog.require('goog.events'); goog.require('goog.events.EventType'); +goog.require('ol'); goog.require('ol.control.Control'); goog.require('ol.css'); @@ -28,16 +29,15 @@ goog.require('ol.css'); */ ol.control.FullScreen = function(opt_options) { - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = opt_options ? opt_options : {}; /** * @private * @type {string} */ - this.cssClassName_ = goog.isDef(options.className) ? - options.className : 'ol-full-screen'; + this.cssClassName_ = options.className ? options.className : 'ol-full-screen'; - var label = goog.isDef(options.label) ? options.label : '\u2194'; + var label = options.label ? options.label : '\u2194'; /** * @private @@ -46,8 +46,7 @@ ol.control.FullScreen = function(opt_options) { this.labelNode_ = /** @type {Node} */ (goog.isString(label) ? goog.dom.createTextNode(label) : label); - var labelActive = goog.isDef(options.labelActive) ? - options.labelActive : '\u00d7'; + var labelActive = options.labelActive ? options.labelActive : '\u00d7'; /** * @private @@ -56,8 +55,7 @@ ol.control.FullScreen = function(opt_options) { this.labelActiveNode_ = /** @type {Node} */ (goog.isString(labelActive) ? goog.dom.createTextNode(labelActive) : labelActive); - var tipLabel = goog.isDef(options.tipLabel) ? - options.tipLabel : 'Toggle full-screen'; + var tipLabel = options.tipLabel ? options.tipLabel : 'Toggle full-screen'; var button = goog.dom.createDom(goog.dom.TagName.BUTTON, { 'class': this.cssClassName_ + '-' + goog.dom.fullscreen.isFullScreen(), 'type': 'button', @@ -85,7 +83,8 @@ ol.control.FullScreen = function(opt_options) { * @private * @type {boolean} */ - this.keys_ = goog.isDef(options.keys) ? options.keys : false; + this.keys_ = ol.isDef(options.keys) ? + /** @type {boolean} */ (options.keys) : false; }; goog.inherits(ol.control.FullScreen, ol.control.Control); diff --git a/src/ol/control/mousepositioncontrol.js b/src/ol/control/mousepositioncontrol.js index f6a54d9193..a4fd1e2ff3 100644 --- a/src/ol/control/mousepositioncontrol.js +++ b/src/ol/control/mousepositioncontrol.js @@ -40,14 +40,13 @@ ol.control.MousePositionProperty = { */ ol.control.MousePosition = function(opt_options) { - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = opt_options ? opt_options : {}; - var className = goog.isDef(options.className) ? - options.className : 'ol-mouse-position'; + var className = options.className ? options.className : 'ol-mouse-position'; var element = goog.dom.createDom(goog.dom.TagName.DIV, className); - var render = goog.isDef(options.render) ? + var render = options.render ? options.render : ol.control.MousePosition.render; goog.base(this, { @@ -60,10 +59,10 @@ ol.control.MousePosition = function(opt_options) { ol.Object.getChangeEventType(ol.control.MousePositionProperty.PROJECTION), this.handleProjectionChanged_, false, this); - if (goog.isDef(options.coordinateFormat)) { + if (options.coordinateFormat) { this.setCoordinateFormat(options.coordinateFormat); } - if (goog.isDef(options.projection)) { + if (options.projection) { this.setProjection(ol.proj.get(options.projection)); } @@ -71,8 +70,7 @@ ol.control.MousePosition = function(opt_options) { * @private * @type {string} */ - this.undefinedHTML_ = goog.isDef(options.undefinedHTML) ? - options.undefinedHTML : ''; + this.undefinedHTML_ = options.undefinedHTML ? options.undefinedHTML : ''; /** * @private @@ -229,7 +227,7 @@ ol.control.MousePosition.prototype.updateHTML_ = function(pixel) { if (!goog.isNull(pixel) && !goog.isNull(this.mapProjection_)) { if (goog.isNull(this.transform_)) { var projection = this.getProjection(); - if (goog.isDef(projection)) { + if (projection) { this.transform_ = ol.proj.getTransformFromProjections( this.mapProjection_, projection); } else { @@ -241,14 +239,14 @@ ol.control.MousePosition.prototype.updateHTML_ = function(pixel) { if (!goog.isNull(coordinate)) { this.transform_(coordinate, coordinate); var coordinateFormat = this.getCoordinateFormat(); - if (goog.isDef(coordinateFormat)) { + if (coordinateFormat) { html = coordinateFormat(coordinate); } else { html = coordinate.toString(); } } } - if (!goog.isDef(this.renderedHTML_) || html != this.renderedHTML_) { + if (!this.renderedHTML_ || html != this.renderedHTML_) { this.element.innerHTML = html; this.renderedHTML_ = html; } diff --git a/src/ol/control/overviewmapcontrol.js b/src/ol/control/overviewmapcontrol.js index 15a0624579..2b880e7fe4 100644 --- a/src/ol/control/overviewmapcontrol.js +++ b/src/ol/control/overviewmapcontrol.js @@ -8,6 +8,7 @@ goog.require('goog.events'); goog.require('goog.events.EventType'); goog.require('goog.math.Size'); goog.require('goog.style'); +goog.require('ol'); goog.require('ol.Collection'); goog.require('ol.Map'); goog.require('ol.MapEventType'); @@ -34,33 +35,31 @@ goog.require('ol.extent'); */ ol.control.OverviewMap = function(opt_options) { - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = opt_options ? opt_options : {}; /** * @type {boolean} * @private */ - this.collapsed_ = goog.isDef(options.collapsed) ? options.collapsed : true; + this.collapsed_ = ol.isDef(options.collapsed) ? + /** @type {boolean} */ (options.collapsed) : true; /** * @private * @type {boolean} */ - this.collapsible_ = goog.isDef(options.collapsible) ? - options.collapsible : true; + this.collapsible_ = ol.isDef(options.collapsible) ? + /** @type {boolean} */ (options.collapsible) : true; if (!this.collapsible_) { this.collapsed_ = false; } - var className = goog.isDef(options.className) ? - options.className : 'ol-overviewmap'; + var className = options.className ? options.className : 'ol-overviewmap'; - var tipLabel = goog.isDef(options.tipLabel) ? - options.tipLabel : 'Overview map'; + var tipLabel = options.tipLabel ? options.tipLabel : 'Overview map'; - var collapseLabel = goog.isDef(options.collapseLabel) ? - options.collapseLabel : '\u00AB'; + var collapseLabel = options.collapseLabel ? options.collapseLabel : '\u00AB'; /** * @private @@ -70,7 +69,7 @@ ol.control.OverviewMap = function(opt_options) { goog.dom.createDom(goog.dom.TagName.SPAN, {}, collapseLabel) : collapseLabel); - var label = goog.isDef(options.label) ? options.label : '\u00BB'; + var label = options.label ? options.label : '\u00BB'; /** * @private @@ -103,7 +102,7 @@ ol.control.OverviewMap = function(opt_options) { }); var ovmap = this.ovmap_; - if (goog.isDef(options.layers)) { + if (options.layers) { options.layers.forEach( /** * @param {ol.layer.Layer} layer Layer. @@ -133,8 +132,7 @@ ol.control.OverviewMap = function(opt_options) { var element = goog.dom.createDom(goog.dom.TagName.DIV, cssClasses, ovmapDiv, button); - var render = goog.isDef(options.render) ? - options.render : ol.control.OverviewMap.render; + var render = options.render ? options.render : ol.control.OverviewMap.render; goog.base(this, { element: element, @@ -271,14 +269,14 @@ ol.control.OverviewMap.prototype.validateExtent_ = function() { goog.asserts.assertArray(mapSize, 'mapSize should be an array'); var view = map.getView(); - goog.asserts.assert(goog.isDef(view), 'view should be defined'); + goog.asserts.assert(view, 'view should be defined'); var extent = view.calculateExtent(mapSize); var ovmapSize = ovmap.getSize(); goog.asserts.assertArray(ovmapSize, 'ovmapSize should be an array'); var ovview = ovmap.getView(); - goog.asserts.assert(goog.isDef(ovview), 'ovview should be defined'); + goog.asserts.assert(ovview, 'ovview should be defined'); var ovextent = ovview.calculateExtent(ovmapSize); var topLeftPixel = @@ -320,14 +318,14 @@ ol.control.OverviewMap.prototype.resetExtent_ = function() { goog.asserts.assertArray(mapSize, 'mapSize should be an array'); var view = map.getView(); - goog.asserts.assert(goog.isDef(view), 'view should be defined'); + goog.asserts.assert(view, 'view should be defined'); var extent = view.calculateExtent(mapSize); var ovmapSize = ovmap.getSize(); goog.asserts.assertArray(ovmapSize, 'ovmapSize should be an array'); var ovview = ovmap.getView(); - goog.asserts.assert(goog.isDef(ovview), 'ovview should be defined'); + goog.asserts.assert(ovview, 'ovview should be defined'); // get how many times the current map overview could hold different // box sizes using the min and max ratio, pick the step in the middle used @@ -350,10 +348,10 @@ ol.control.OverviewMap.prototype.recenter_ = function() { var ovmap = this.ovmap_; var view = map.getView(); - goog.asserts.assert(goog.isDef(view), 'view should be defined'); + goog.asserts.assert(view, 'view should be defined'); var ovview = ovmap.getView(); - goog.asserts.assert(goog.isDef(ovview), 'ovview should be defined'); + goog.asserts.assert(ovview, 'ovview should be defined'); ovview.setCenter(view.getCenter()); }; @@ -375,16 +373,16 @@ ol.control.OverviewMap.prototype.updateBox_ = function() { goog.asserts.assertArray(mapSize, 'mapSize should be an array'); var view = map.getView(); - goog.asserts.assert(goog.isDef(view), 'view should be defined'); + goog.asserts.assert(view, 'view should be defined'); var ovview = ovmap.getView(); - goog.asserts.assert(goog.isDef(ovview), 'ovview should be defined'); + goog.asserts.assert(ovview, 'ovview should be defined'); var ovmapSize = ovmap.getSize(); goog.asserts.assertArray(ovmapSize, 'ovmapSize should be an array'); var rotation = view.getRotation(); - goog.asserts.assert(goog.isDef(rotation), 'rotation should be defined'); + goog.asserts.assert(ol.isDef(rotation), 'rotation should be defined'); var overlay = this.boxOverlay_; var box = this.boxOverlay_.getElement(); @@ -419,11 +417,11 @@ ol.control.OverviewMap.prototype.calculateCoordinateRotate_ = function( var map = this.getMap(); var view = map.getView(); - goog.asserts.assert(goog.isDef(view), 'view should be defined'); + goog.asserts.assert(view, 'view should be defined'); var currentCenter = view.getCenter(); - if (goog.isDef(currentCenter)) { + if (currentCenter) { coordinateRotate = [ coordinate[0] - currentCenter[0], coordinate[1] - currentCenter[1] diff --git a/src/ol/control/rotatecontrol.js b/src/ol/control/rotatecontrol.js index 0a0dcd26ca..90977b268e 100644 --- a/src/ol/control/rotatecontrol.js +++ b/src/ol/control/rotatecontrol.js @@ -6,6 +6,7 @@ goog.require('goog.dom.classlist'); goog.require('goog.events'); goog.require('goog.events.EventType'); goog.require('goog.math'); +goog.require('ol'); goog.require('ol.animation'); goog.require('ol.control.Control'); goog.require('ol.css'); @@ -26,16 +27,15 @@ goog.require('ol.easing'); */ ol.control.Rotate = function(opt_options) { - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = opt_options ? opt_options : {}; - var className = goog.isDef(options.className) ? + var className = options.className ? options.className : 'ol-rotate'; - var label = goog.isDef(options.label) ? - options.label : '\u21E7'; + var label = options.label ? options.label : '\u21E7'; /** - * @type {Node} + * @type {Element} * @private */ this.label_ = null; @@ -48,8 +48,7 @@ ol.control.Rotate = function(opt_options) { goog.dom.classlist.add(this.label_, 'ol-compass'); } - var tipLabel = goog.isDef(options.tipLabel) ? - options.tipLabel : 'Reset rotation'; + var tipLabel = options.tipLabel ? options.tipLabel : 'Reset rotation'; var button = goog.dom.createDom(goog.dom.TagName.BUTTON, { 'class': className + '-reset', @@ -64,8 +63,7 @@ ol.control.Rotate = function(opt_options) { ol.css.CLASS_CONTROL; var element = goog.dom.createDom(goog.dom.TagName.DIV, cssClasses, button); - var render = goog.isDef(options.render) ? - options.render : ol.control.Rotate.render; + var render = options.render ? options.render : ol.control.Rotate.render; goog.base(this, { element: element, @@ -77,13 +75,14 @@ ol.control.Rotate = function(opt_options) { * @type {number} * @private */ - this.duration_ = goog.isDef(options.duration) ? options.duration : 250; + this.duration_ = options.duration ? options.duration : 250; /** * @type {boolean} * @private */ - this.autoHide_ = goog.isDef(options.autoHide) ? options.autoHide : true; + this.autoHide_ = ol.isDef(options.autoHide) ? + /** @type {boolean} */ (options.autoHide) : true; /** * @private @@ -127,7 +126,7 @@ ol.control.Rotate.prototype.resetNorth_ = function() { while (currentRotation > Math.PI) { currentRotation -= 2 * Math.PI; } - if (goog.isDef(currentRotation)) { + if (ol.isDef(currentRotation)) { if (this.duration_ > 0) { map.beforeRender(ol.animation.rotate({ rotation: currentRotation, diff --git a/src/ol/control/scalelinecontrol.js b/src/ol/control/scalelinecontrol.js index 66e1ef499a..1c20927444 100644 --- a/src/ol/control/scalelinecontrol.js +++ b/src/ol/control/scalelinecontrol.js @@ -8,6 +8,7 @@ goog.require('goog.dom.TagName'); goog.require('goog.events'); goog.require('goog.math'); goog.require('goog.style'); +goog.require('ol'); goog.require('ol.Object'); goog.require('ol.TransformFunction'); goog.require('ol.control.Control'); @@ -58,10 +59,9 @@ ol.control.ScaleLineUnits = { */ ol.control.ScaleLine = function(opt_options) { - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = opt_options ? opt_options : {}; - var className = goog.isDef(options.className) ? - options.className : 'ol-scale-line'; + var className = options.className ? options.className : 'ol-scale-line'; /** * @private @@ -87,7 +87,8 @@ ol.control.ScaleLine = function(opt_options) { * @private * @type {number} */ - this.minWidth_ = goog.isDef(options.minWidth) ? options.minWidth : 64; + this.minWidth_ = ol.isDef(options.minWidth) ? + /** @type {number} */ (options.minWidth) : 64; /** * @private @@ -113,8 +114,7 @@ ol.control.ScaleLine = function(opt_options) { */ this.toEPSG4326_ = null; - var render = goog.isDef(options.render) ? - options.render : ol.control.ScaleLine.render; + var render = options.render ? options.render : ol.control.ScaleLine.render; goog.base(this, { element: this.element_, @@ -233,7 +233,7 @@ ol.control.ScaleLine.prototype.updateElement_ = function() { } cosLatitude = Math.cos(goog.math.toRadians(this.toEPSG4326_(center)[1])); var radius = ol.sphere.NORMAL.radius; - goog.asserts.assert(goog.isDef(ol.proj.METERS_PER_UNIT[projectionUnits]), + goog.asserts.assert(ol.proj.METERS_PER_UNIT[projectionUnits], 'Meters per unit should be defined for the projection unit'); radius /= ol.proj.METERS_PER_UNIT[projectionUnits]; pointResolution *= 180 / (Math.PI * cosLatitude * radius); diff --git a/src/ol/control/zoomcontrol.js b/src/ol/control/zoomcontrol.js index ff31952d22..3bafb07653 100644 --- a/src/ol/control/zoomcontrol.js +++ b/src/ol/control/zoomcontrol.js @@ -24,20 +24,18 @@ goog.require('ol.easing'); */ ol.control.Zoom = function(opt_options) { - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = opt_options ? opt_options : {}; - var className = goog.isDef(options.className) ? options.className : 'ol-zoom'; + var className = options.className ? options.className : 'ol-zoom'; - var delta = goog.isDef(options.delta) ? options.delta : 1; + var delta = options.delta ? options.delta : 1; - var zoomInLabel = goog.isDef(options.zoomInLabel) ? - options.zoomInLabel : '+'; - var zoomOutLabel = goog.isDef(options.zoomOutLabel) ? - options.zoomOutLabel : '\u2212'; + var zoomInLabel = options.zoomInLabel ? options.zoomInLabel : '+'; + var zoomOutLabel = options.zoomOutLabel ? options.zoomOutLabel : '\u2212'; - var zoomInTipLabel = goog.isDef(options.zoomInTipLabel) ? + var zoomInTipLabel = options.zoomInTipLabel ? options.zoomInTipLabel : 'Zoom in'; - var zoomOutTipLabel = goog.isDef(options.zoomOutTipLabel) ? + var zoomOutTipLabel = options.zoomOutTipLabel ? options.zoomOutTipLabel : 'Zoom out'; var inElement = goog.dom.createDom(goog.dom.TagName.BUTTON, { @@ -81,7 +79,7 @@ ol.control.Zoom = function(opt_options) { * @type {number} * @private */ - this.duration_ = goog.isDef(options.duration) ? options.duration : 250; + this.duration_ = options.duration ? options.duration : 250; }; goog.inherits(ol.control.Zoom, ol.control.Control); @@ -111,7 +109,7 @@ ol.control.Zoom.prototype.zoomByDelta_ = function(delta) { return; } var currentResolution = view.getResolution(); - if (goog.isDef(currentResolution)) { + if (currentResolution) { if (this.duration_ > 0) { map.beforeRender(ol.animation.zoom({ resolution: currentResolution, diff --git a/src/ol/control/zoomslidercontrol.js b/src/ol/control/zoomslidercontrol.js index c39f8c452d..1f42abdb27 100644 --- a/src/ol/control/zoomslidercontrol.js +++ b/src/ol/control/zoomslidercontrol.js @@ -38,7 +38,7 @@ goog.require('ol.easing'); */ ol.control.ZoomSlider = function(opt_options) { - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = opt_options ? opt_options : {}; /** * Will hold the current resolution of the view. @@ -76,10 +76,9 @@ ol.control.ZoomSlider = function(opt_options) { * @private * @type {number} */ - this.duration_ = goog.isDef(options.duration) ? options.duration : 200; + this.duration_ = options.duration ? options.duration : 200; - var className = goog.isDef(options.className) ? - options.className : 'ol-zoomslider'; + var className = options.className ? options.className : 'ol-zoomslider'; var thumbElement = goog.dom.createDom(goog.dom.TagName.DIV, [className + '-thumb', ol.css.CLASS_UNSELECTABLE]); var containerElement = goog.dom.createDom(goog.dom.TagName.DIV, @@ -105,8 +104,7 @@ ol.control.ZoomSlider = function(opt_options) { goog.events.listen(thumbElement, goog.events.EventType.CLICK, goog.events.Event.stopPropagation); - var render = goog.isDef(options.render) ? - options.render : ol.control.ZoomSlider.render; + var render = options.render ? options.render : ol.control.ZoomSlider.render; goog.base(this, { element: containerElement, @@ -205,7 +203,7 @@ ol.control.ZoomSlider.prototype.handleContainerClick_ = function(browserEvent) { var map = this.getMap(); var view = map.getView(); var currentResolution = view.getResolution(); - goog.asserts.assert(goog.isDef(currentResolution), + goog.asserts.assert(currentResolution, 'currentResolution should be defined'); map.beforeRender(ol.animation.zoom({ resolution: currentResolution, @@ -252,7 +250,7 @@ ol.control.ZoomSlider.prototype.handleDraggerEnd_ = function(event) { var map = this.getMap(); var view = map.getView(); view.setHint(ol.ViewHint.INTERACTING, -1); - goog.asserts.assert(goog.isDef(this.currentResolution_), + goog.asserts.assert(this.currentResolution_, 'this.currentResolution_ should be defined'); map.beforeRender(ol.animation.zoom({ resolution: this.currentResolution_, diff --git a/src/ol/control/zoomtoextentcontrol.js b/src/ol/control/zoomtoextentcontrol.js index 88e918ab53..868618d8b8 100644 --- a/src/ol/control/zoomtoextentcontrol.js +++ b/src/ol/control/zoomtoextentcontrol.js @@ -21,19 +21,19 @@ goog.require('ol.css'); * @api stable */ ol.control.ZoomToExtent = function(opt_options) { - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = opt_options ? opt_options : {}; /** * @type {ol.Extent} * @private */ - this.extent_ = goog.isDef(options.extent) ? options.extent : null; + this.extent_ = options.extent ? options.extent : null; - var className = goog.isDef(options.className) ? options.className : + var className = options.className ? options.className : 'ol-zoom-extent'; - var label = goog.isDef(options.label) ? options.label : 'E'; - var tipLabel = goog.isDef(options.tipLabel) ? + var label = options.label ? options.label : 'E'; + var tipLabel = options.tipLabel ? options.tipLabel : 'Fit to extent'; var button = goog.dom.createDom(goog.dom.TagName.BUTTON, { 'type': 'button', @@ -74,6 +74,6 @@ ol.control.ZoomToExtent.prototype.handleZoomToExtent_ = function() { var extent = goog.isNull(this.extent_) ? view.getProjection().getExtent() : this.extent_; var size = map.getSize(); - goog.asserts.assert(goog.isDef(size), 'size should be defined'); + goog.asserts.assert(size, 'size should be defined'); view.fit(extent, size); }; From 390153adc863eb4403d804c2b7a34332b6d57ac5 Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Sat, 19 Sep 2015 04:52:09 +0200 Subject: [PATCH 30/93] Remove goog.isDef from coordinate.js --- src/ol/coordinate.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ol/coordinate.js b/src/ol/coordinate.js index 3a9b2a5c45..3e29571892 100644 --- a/src/ol/coordinate.js +++ b/src/ol/coordinate.js @@ -164,7 +164,7 @@ ol.coordinate.degreesToStringHDMS_ = function(degrees, hemispheres) { * @api stable */ ol.coordinate.format = function(coordinate, template, opt_fractionDigits) { - if (goog.isDef(coordinate)) { + if (coordinate) { return template .replace('{x}', coordinate[0].toFixed(opt_fractionDigits)) .replace('{y}', coordinate[1].toFixed(opt_fractionDigits)); @@ -295,7 +295,7 @@ ol.coordinate.squaredDistanceToSegment = function(coordinate, segment) { * @api stable */ ol.coordinate.toStringHDMS = function(coordinate) { - if (goog.isDef(coordinate)) { + if (coordinate) { return ol.coordinate.degreesToStringHDMS_(coordinate[1], 'NS') + ' ' + ol.coordinate.degreesToStringHDMS_(coordinate[0], 'EW'); } else { From 5350e9ba37b98ab916b55239c993808e2222b10f Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Mon, 21 Sep 2015 05:27:14 +0900 Subject: [PATCH 31/93] Remove goog.isDef from device orientation, dom, extent, and feature --- src/ol/deviceorientation.js | 6 ++++-- src/ol/dom/dom.js | 12 ++++++------ src/ol/extent.js | 15 +++++++-------- src/ol/feature.js | 3 ++- 4 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/ol/deviceorientation.js b/src/ol/deviceorientation.js index 2933d89a83..2b2d95f3fc 100644 --- a/src/ol/deviceorientation.js +++ b/src/ol/deviceorientation.js @@ -3,6 +3,7 @@ goog.provide('ol.DeviceOrientationProperty'); goog.require('goog.events'); goog.require('goog.math'); +goog.require('ol'); goog.require('ol.Object'); goog.require('ol.has'); @@ -79,7 +80,7 @@ ol.DeviceOrientation = function(opt_options) { goog.base(this); - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = opt_options ? opt_options : {}; /** * @private @@ -91,7 +92,8 @@ ol.DeviceOrientation = function(opt_options) { ol.Object.getChangeEventType(ol.DeviceOrientationProperty.TRACKING), this.handleTrackingChanged_, false, this); - this.setTracking(goog.isDef(options.tracking) ? options.tracking : false); + this.setTracking(ol.isDef(options.tracking) ? + /** @type {boolean} */ (options.tracking) : false); }; goog.inherits(ol.DeviceOrientation, ol.Object); diff --git a/src/ol/dom/dom.js b/src/ol/dom/dom.js index d3ede697d7..86eb2b2b04 100644 --- a/src/ol/dom/dom.js +++ b/src/ol/dom/dom.js @@ -19,10 +19,10 @@ goog.require('ol'); */ ol.dom.createCanvasContext2D = function(opt_width, opt_height) { var canvas = goog.dom.createElement(goog.dom.TagName.CANVAS); - if (goog.isDef(opt_width)) { + if (opt_width) { canvas.width = opt_width; } - if (goog.isDef(opt_height)) { + if (opt_height) { canvas.height = opt_height; } return canvas.getContext('2d'); @@ -47,7 +47,7 @@ ol.dom.BrowserFeature = { ol.dom.canUseCssTransform = (function() { var canUseCssTransform; return function() { - if (!goog.isDef(canUseCssTransform)) { + if (!ol.isDef(canUseCssTransform)) { goog.asserts.assert(!goog.isNull(document.body), 'document.body should not be null'); if (!goog.global.getComputedStyle) { @@ -90,7 +90,7 @@ ol.dom.canUseCssTransform = (function() { ol.dom.canUseCssTransform3D = (function() { var canUseCssTransform3D; return function() { - if (!goog.isDef(canUseCssTransform3D)) { + if (!ol.isDef(canUseCssTransform3D)) { goog.asserts.assert(!goog.isNull(document.body), 'document.body should not be null'); if (!goog.global.getComputedStyle) { @@ -224,7 +224,7 @@ ol.dom.transformElement2D = if (ol.dom.canUseCssTransform3D()) { var value3D; - if (goog.isDef(opt_precision)) { + if (ol.isDef(opt_precision)) { /** @type {Array.} */ var strings3D = new Array(16); for (i = 0; i < 16; ++i) { @@ -246,7 +246,7 @@ ol.dom.transformElement2D = goog.vec.Mat4.getElement(transform, 1, 3) ]; var value2D; - if (goog.isDef(opt_precision)) { + if (ol.isDef(opt_precision)) { /** @type {Array.} */ var strings2D = new Array(6); for (i = 0; i < 6; ++i) { diff --git a/src/ol/extent.js b/src/ol/extent.js index 5c13604b5f..086f7e433d 100644 --- a/src/ol/extent.js +++ b/src/ol/extent.js @@ -87,7 +87,7 @@ ol.extent.boundingExtentXYs_ = function(xs, ys, opt_extent) { * @api stable */ ol.extent.buffer = function(extent, value, opt_extent) { - if (goog.isDef(opt_extent)) { + if (opt_extent) { opt_extent[0] = extent[0] - value; opt_extent[1] = extent[1] - value; opt_extent[2] = extent[2] + value; @@ -112,7 +112,7 @@ ol.extent.buffer = function(extent, value, opt_extent) { * @return {ol.Extent} The clone. */ ol.extent.clone = function(extent, opt_extent) { - if (goog.isDef(opt_extent)) { + if (opt_extent) { opt_extent[0] = extent[0]; opt_extent[1] = extent[1]; opt_extent[2] = extent[2]; @@ -247,7 +247,7 @@ ol.extent.createEmpty = function() { * @return {ol.Extent} Extent. */ ol.extent.createOrUpdate = function(minX, minY, maxX, maxY, opt_extent) { - if (goog.isDef(opt_extent)) { + if (opt_extent) { opt_extent[0] = minX; opt_extent[1] = minY; opt_extent[2] = maxX; @@ -545,7 +545,7 @@ ol.extent.getCorner = function(extent, corner) { } else { goog.asserts.fail('Invalid corner: %s', corner); } - goog.asserts.assert(goog.isDef(coordinate), 'coordinate should be defined'); + goog.asserts.assert(coordinate, 'coordinate should be defined'); return coordinate; }; @@ -624,8 +624,7 @@ ol.extent.getIntersectionArea = function(extent1, extent2) { * @api stable */ ol.extent.getIntersection = function(extent1, extent2, opt_extent) { - var intersection = goog.isDef(opt_extent) ? - opt_extent : ol.extent.createEmpty(); + var intersection = opt_extent ? opt_extent : ol.extent.createEmpty(); if (ol.extent.intersects(extent1, extent2)) { if (extent1[0] > extent2[0]) { intersection[0] = extent1[0]; @@ -760,7 +759,7 @@ ol.extent.normalize = function(extent, coordinate) { * @return {ol.Extent} Extent. */ ol.extent.returnOrUpdate = function(extent, opt_extent) { - if (goog.isDef(opt_extent)) { + if (opt_extent) { opt_extent[0] = extent[0]; opt_extent[1] = extent[1]; opt_extent[2] = extent[2]; @@ -886,7 +885,7 @@ ol.extent.applyTransform = function(extent, transformFn, opt_extent) { * @return {ol.Extent} The transformed extent. */ ol.extent.transform2D = function(extent, transform, opt_extent) { - var dest = goog.isDef(opt_extent) ? opt_extent : []; + var dest = opt_extent ? opt_extent : []; var m00 = goog.vec.Mat4.getElement(transform, 0, 0); var m10 = goog.vec.Mat4.getElement(transform, 1, 0); var m01 = goog.vec.Mat4.getElement(transform, 0, 1); diff --git a/src/ol/feature.js b/src/ol/feature.js index 126edf8805..d3ca941779 100644 --- a/src/ol/feature.js +++ b/src/ol/feature.js @@ -5,6 +5,7 @@ goog.require('goog.asserts'); goog.require('goog.events'); goog.require('goog.events.EventType'); goog.require('goog.functions'); +goog.require('ol'); goog.require('ol.Object'); goog.require('ol.geom.Geometry'); goog.require('ol.style.Style'); @@ -96,7 +97,7 @@ ol.Feature = function(opt_geometryOrProperties) { this, ol.Object.getChangeEventType(this.geometryName_), this.handleGeometryChanged_, false, this); - if (goog.isDef(opt_geometryOrProperties)) { + if (ol.isDef(opt_geometryOrProperties)) { if (opt_geometryOrProperties instanceof ol.geom.Geometry || goog.isNull(opt_geometryOrProperties)) { var geometry = /** @type {ol.geom.Geometry} */ (opt_geometryOrProperties); From 1fceb4a70904c46aee415076af878337035fa2b0 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Mon, 21 Sep 2015 05:51:45 +0900 Subject: [PATCH 32/93] Remove goog.isDef from formats --- src/ol/format/esrijsonformat.js | 21 +++--- src/ol/format/geojsonformat.js | 18 ++--- src/ol/format/gml/gml3format.js | 54 +++++++------- src/ol/format/gpxformat.js | 28 +++---- src/ol/format/igcformat.js | 4 +- src/ol/format/jsonfeatureformat.js | 2 +- src/ol/format/kmlformat.js | 115 +++++++++++++++-------------- src/ol/format/osmxmlformat.js | 2 +- src/ol/format/owsformat.js | 8 +- src/ol/format/polylineformat.js | 14 ++-- src/ol/format/topojsonformat.js | 13 ++-- 11 files changed, 138 insertions(+), 141 deletions(-) diff --git a/src/ol/format/esrijsonformat.js b/src/ol/format/esrijsonformat.js index aae2124455..340453c6ea 100644 --- a/src/ol/format/esrijsonformat.js +++ b/src/ol/format/esrijsonformat.js @@ -32,7 +32,7 @@ goog.require('ol.proj'); */ ol.format.EsriJSON = function(opt_options) { - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = opt_options ? opt_options : {}; goog.base(this); @@ -80,9 +80,9 @@ ol.format.EsriJSON.readGeometry_ = function(object, opt_options) { object.rings = rings; } } - goog.asserts.assert(goog.isDef(type), 'geometry type should be defined'); + goog.asserts.assert(type, 'geometry type should be defined'); var geometryReader = ol.format.EsriJSON.GEOMETRY_READERS_[type]; - goog.asserts.assert(goog.isDef(geometryReader), + goog.asserts.assert(geometryReader, 'geometryReader should be defined'); return /** @type {ol.geom.Geometry} */ ( ol.format.Feature.transformWithOptions( @@ -490,19 +490,19 @@ ol.format.EsriJSON.prototype.readFeatureFromObject = function( var geometry = ol.format.EsriJSON.readGeometry_(esriJSONFeature.geometry, opt_options); var feature = new ol.Feature(); - if (goog.isDef(this.geometryName_)) { + if (this.geometryName_) { feature.setGeometryName(this.geometryName_); } feature.setGeometry(geometry); - if (goog.isDef(opt_options) && goog.isDef(opt_options.idField) && - goog.isDef(esriJSONFeature.attributes[opt_options.idField])) { + if (opt_options && opt_options.idField && + esriJSONFeature.attributes[opt_options.idField]) { goog.asserts.assert( goog.isNumber(esriJSONFeature.attributes[opt_options.idField]), 'objectIdFieldName value should be a number'); feature.setId(/** @type {number} */( esriJSONFeature.attributes[opt_options.idField])); } - if (goog.isDef(esriJSONFeature.attributes)) { + if (esriJSONFeature.attributes) { feature.setProperties(esriJSONFeature.attributes); } return feature; @@ -515,7 +515,7 @@ ol.format.EsriJSON.prototype.readFeatureFromObject = function( ol.format.EsriJSON.prototype.readFeaturesFromObject = function( object, opt_options) { var esriJSONObject = /** @type {EsriJSONObject} */ (object); - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = opt_options ? opt_options : {}; if (goog.isDefAndNotNull(esriJSONObject.features)) { var esriJSONFeatureCollection = /** @type {EsriJSONFeatureCollection} */ (object); @@ -591,8 +591,7 @@ ol.format.EsriJSON.prototype.readProjectionFromObject = function(object) { */ ol.format.EsriJSON.writeGeometry_ = function(geometry, opt_options) { var geometryWriter = ol.format.EsriJSON.GEOMETRY_WRITERS_[geometry.getType()]; - goog.asserts.assert(goog.isDef(geometryWriter), - 'geometryWriter should be defined'); + goog.asserts.assert(geometryWriter, 'geometryWriter should be defined'); return geometryWriter(/** @type {ol.geom.Geometry} */ ( ol.format.Feature.transformWithOptions(geometry, true, opt_options)), opt_options); @@ -662,7 +661,7 @@ ol.format.EsriJSON.prototype.writeFeatureObject = function( } else { object['attributes'] = {}; } - if (goog.isDef(opt_options) && goog.isDef(opt_options.featureProjection)) { + if (opt_options && opt_options.featureProjection) { object['spatialReference'] = /** @type {EsriJSONCRS} */({ wkid: ol.proj.get( opt_options.featureProjection).getCode().split(':').pop() diff --git a/src/ol/format/geojsonformat.js b/src/ol/format/geojsonformat.js index 6926fc5036..30925927af 100644 --- a/src/ol/format/geojsonformat.js +++ b/src/ol/format/geojsonformat.js @@ -31,7 +31,7 @@ goog.require('ol.proj'); */ ol.format.GeoJSON = function(opt_options) { - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = opt_options ? opt_options : {}; goog.base(this); @@ -73,8 +73,7 @@ ol.format.GeoJSON.readGeometry_ = function(object, opt_options) { return null; } var geometryReader = ol.format.GeoJSON.GEOMETRY_READERS_[object.type]; - goog.asserts.assert(goog.isDef(geometryReader), - 'geometryReader should be defined'); + goog.asserts.assert(geometryReader, 'geometryReader should be defined'); return /** @type {ol.geom.Geometry} */ ( ol.format.Feature.transformWithOptions( geometryReader(object), false, opt_options)); @@ -183,8 +182,7 @@ ol.format.GeoJSON.readPolygonGeometry_ = function(object) { */ ol.format.GeoJSON.writeGeometry_ = function(geometry, opt_options) { var geometryWriter = ol.format.GeoJSON.GEOMETRY_WRITERS_[geometry.getType()]; - goog.asserts.assert(goog.isDef(geometryWriter), - 'geometryWriter should be defined'); + goog.asserts.assert(geometryWriter, 'geometryWriter should be defined'); return geometryWriter(/** @type {ol.geom.Geometry} */ ( ol.format.Feature.transformWithOptions(geometry, true, opt_options)), opt_options); @@ -284,7 +282,7 @@ ol.format.GeoJSON.writeMultiPolygonGeometry_ = function(geometry, opt_options) { goog.asserts.assertInstanceof(geometry, ol.geom.MultiPolygon, 'geometry should be an ol.geom.MultiPolygon'); var right; - if (goog.isDef(opt_options)) { + if (opt_options) { right = opt_options.rightHanded; } return /** @type {GeoJSONGeometry} */ ({ @@ -320,7 +318,7 @@ ol.format.GeoJSON.writePolygonGeometry_ = function(geometry, opt_options) { goog.asserts.assertInstanceof(geometry, ol.geom.Polygon, 'geometry should be an ol.geom.Polygon'); var right; - if (goog.isDef(opt_options)) { + if (opt_options) { right = opt_options.rightHanded; } return /** @type {GeoJSONGeometry} */ ({ @@ -408,14 +406,14 @@ ol.format.GeoJSON.prototype.readFeatureFromObject = function( var geometry = ol.format.GeoJSON.readGeometry_(geoJSONFeature.geometry, opt_options); var feature = new ol.Feature(); - if (goog.isDef(this.geometryName_)) { + if (this.geometryName_) { feature.setGeometryName(this.geometryName_); } feature.setGeometry(geometry); - if (goog.isDef(geoJSONFeature.id)) { + if (geoJSONFeature.id) { feature.setId(geoJSONFeature.id); } - if (goog.isDef(geoJSONFeature.properties)) { + if (geoJSONFeature.properties) { feature.setProperties(geoJSONFeature.properties); } return feature; diff --git a/src/ol/format/gml/gml3format.js b/src/ol/format/gml/gml3format.js index 6dcff97b7b..b0fd244e62 100644 --- a/src/ol/format/gml/gml3format.js +++ b/src/ol/format/gml/gml3format.js @@ -5,6 +5,7 @@ goog.require('goog.array'); goog.require('goog.asserts'); goog.require('goog.dom.NodeType'); goog.require('goog.object'); +goog.require('ol'); goog.require('ol.Feature'); goog.require('ol.extent'); goog.require('ol.format.Feature'); @@ -37,7 +38,7 @@ goog.require('ol.xml'); */ ol.format.GML3 = function(opt_options) { var options = /** @type {olx.format.GMLOptions} */ - (goog.isDef(opt_options) ? opt_options : {}); + (opt_options ? opt_options : {}); goog.base(this, options); @@ -45,34 +46,34 @@ ol.format.GML3 = function(opt_options) { * @private * @type {boolean} */ - this.surface_ = goog.isDef(options.surface) ? - options.surface : false; + this.surface_ = ol.isDef(options.surface) ? + /** @type {boolean} */ (options.surface) : false; /** * @private * @type {boolean} */ - this.curve_ = goog.isDef(options.curve) ? - options.curve : false; + this.curve_ = ol.isDef(options.curve) ? + /** @type {boolean} */ (options.curve) : false; /** * @private * @type {boolean} */ - this.multiCurve_ = goog.isDef(options.multiCurve) ? - options.multiCurve : true; + this.multiCurve_ = ol.isDef(options.multiCurve) ? + /** @type {boolean} */ (options.multiCurve) : true; /** * @private * @type {boolean} */ - this.multiSurface_ = goog.isDef(options.multiSurface) ? - options.multiSurface : true; + this.multiSurface_ = ol.isDef(options.multiSurface) ? + /** @type {boolean} */ (options.multiSurface) : true; /** * @inheritDoc */ - this.schemaLocation = goog.isDef(options.schemaLocation) ? + this.schemaLocation = options.schemaLocation ? options.schemaLocation : ol.format.GML3.schemaLocation_; }; @@ -103,7 +104,7 @@ ol.format.GML3.prototype.readMultiCurve_ = function(node, objectStack) { var lineStrings = ol.xml.pushParseAndPop( /** @type {Array.} */ ([]), this.MULTICURVE_PARSERS_, node, objectStack, this); - if (goog.isDef(lineStrings)) { + if (lineStrings) { var multiLineString = new ol.geom.MultiLineString(null); multiLineString.setLineStrings(lineStrings); return multiLineString; @@ -127,7 +128,7 @@ ol.format.GML3.prototype.readMultiSurface_ = function(node, objectStack) { var polygons = ol.xml.pushParseAndPop( /** @type {Array.} */ ([]), this.MULTISURFACE_PARSERS_, node, objectStack, this); - if (goog.isDef(polygons)) { + if (polygons) { var multiPolygon = new ol.geom.MultiPolygon(null); multiPolygon.setPolygons(polygons); return multiPolygon; @@ -251,7 +252,7 @@ ol.format.GML3.prototype.interiorParser_ = function(node, objectStack) { var flatLinearRing = ol.xml.pushParseAndPop( /** @type {Array.|undefined} */ (undefined), this.RING_PARSERS, node, objectStack, this); - if (goog.isDef(flatLinearRing)) { + if (flatLinearRing) { var flatLinearRings = /** @type {Array.>} */ (objectStack[objectStack.length - 1]); goog.asserts.assert(goog.isArray(flatLinearRings), @@ -276,7 +277,7 @@ ol.format.GML3.prototype.exteriorParser_ = function(node, objectStack) { var flatLinearRing = ol.xml.pushParseAndPop( /** @type {Array.|undefined} */ (undefined), this.RING_PARSERS, node, objectStack, this); - if (goog.isDef(flatLinearRing)) { + if (flatLinearRing) { var flatLinearRings = /** @type {Array.>} */ (objectStack[objectStack.length - 1]); goog.asserts.assert(goog.isArray(flatLinearRings), @@ -302,8 +303,7 @@ ol.format.GML3.prototype.readSurface_ = function(node, objectStack) { var flatLinearRings = ol.xml.pushParseAndPop( /** @type {Array.>} */ ([null]), this.SURFACE_PARSERS_, node, objectStack, this); - if (goog.isDef(flatLinearRings) && - !goog.isNull(flatLinearRings[0])) { + if (flatLinearRings && !goog.isNull(flatLinearRings[0])) { var polygon = new ol.geom.Polygon(null); var flatCoordinates = flatLinearRings[0]; var ends = [flatCoordinates.length]; @@ -334,7 +334,7 @@ ol.format.GML3.prototype.readCurve_ = function(node, objectStack) { var flatCoordinates = ol.xml.pushParseAndPop( /** @type {Array.} */ ([null]), this.CURVE_PARSERS_, node, objectStack, this); - if (goog.isDef(flatCoordinates)) { + if (flatCoordinates) { var lineString = new ol.geom.LineString(null); lineString.setFlatCoordinates(ol.geom.GeometryLayout.XYZ, flatCoordinates); return lineString; @@ -741,7 +741,7 @@ ol.format.GML3.prototype.writeEnvelope = function(node, extent, objectStack) { var context = objectStack[objectStack.length - 1]; goog.asserts.assert(goog.isObject(context), 'context should be an Object'); var srsName = context['srsName']; - if (goog.isDef(srsName)) { + if (srsName) { node.setAttribute('srsName', srsName); } var keys = ['lowerCorner', 'upperCorner']; @@ -787,11 +787,11 @@ ol.format.GML3.prototype.RING_NODE_FACTORY_ = var parentNode = context.node; goog.asserts.assert(goog.isObject(context), 'context should be an Object'); var exteriorWritten = context['exteriorWritten']; - if (!goog.isDef(exteriorWritten)) { + if (!ol.isDef(exteriorWritten)) { context['exteriorWritten'] = true; } return ol.xml.createElementNS(parentNode.namespaceURI, - goog.isDef(exteriorWritten) ? 'interior' : 'exterior'); + ol.isDef(exteriorWritten) ? 'interior' : 'exterior'); }; @@ -947,7 +947,7 @@ ol.format.GML3.prototype.writeSurfaceOrPolygonMember_ = goog.asserts.assert(goog.isObject(context), 'context should be an Object'); var child = this.GEOMETRY_NODE_FACTORY_( polygon, objectStack); - if (goog.isDef(child)) { + if (child) { node.appendChild(child); this.writeSurfaceOrPolygon_(child, polygon, objectStack); } @@ -979,7 +979,7 @@ ol.format.GML3.prototype.writeLineStringOrCurveMember_ = var context = objectStack[objectStack.length - 1]; goog.asserts.assert(goog.isObject(context), 'context should be an Object'); var child = this.GEOMETRY_NODE_FACTORY_(line, objectStack); - if (goog.isDef(child)) { + if (child) { node.appendChild(child); this.writeCurveOrLineString_(child, line, objectStack); } @@ -1028,7 +1028,7 @@ ol.format.GML3.prototype.writeGeometryElement = item.node = node; var value; if (goog.isArray(geometry)) { - if (goog.isDef(context.dataProjection)) { + if (context.dataProjection) { value = ol.proj.transformExtent( geometry, context.featureProjection, context.dataProjection); } else { @@ -1055,14 +1055,14 @@ ol.format.GML3.prototype.writeGeometryElement = ol.format.GML3.prototype.writeFeatureElement = function(node, feature, objectStack) { var fid = feature.getId(); - if (goog.isDef(fid)) { + if (fid) { node.setAttribute('fid', fid); } var context = objectStack[objectStack.length - 1]; goog.asserts.assert(goog.isObject(context), 'context should be an Object'); var featureNS = context['featureNS']; var geometryName = feature.getGeometryName(); - if (!goog.isDef(context.serializers)) { + if (!context.serializers) { context.serializers = {}; context.serializers[featureNS] = {}; } @@ -1293,7 +1293,7 @@ ol.format.GML3.prototype.writeGeometryNode = function(geometry, opt_options) { var context = {node: geom, srsName: this.srsName, curve: this.curve_, surface: this.surface_, multiSurface: this.multiSurface_, multiCurve: this.multiCurve_}; - if (goog.isDef(opt_options)) { + if (opt_options) { goog.object.extend(context, opt_options); } this.writeGeometryElement(geom, geometry, [context]); @@ -1336,7 +1336,7 @@ ol.format.GML3.prototype.writeFeaturesNode = function(features, opt_options) { featureNS: this.featureNS, featureType: this.featureType }; - if (goog.isDef(opt_options)) { + if (opt_options) { goog.object.extend(context, opt_options); } this.writeFeatureMembers_(node, features, [context]); diff --git a/src/ol/format/gpxformat.js b/src/ol/format/gpxformat.js index fabb0f6b72..2da803bf43 100644 --- a/src/ol/format/gpxformat.js +++ b/src/ol/format/gpxformat.js @@ -27,7 +27,7 @@ goog.require('ol.xml'); */ ol.format.GPX = function(opt_options) { - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = opt_options ? opt_options : {}; goog.base(this); @@ -130,7 +130,7 @@ ol.format.GPX.parseRtePt_ = function(node, objectStack) { goog.asserts.assert(node.localName == 'rtept', 'localName should be rtept'); var values = ol.xml.pushParseAndPop( {}, ol.format.GPX.RTEPT_PARSERS_, node, objectStack); - if (goog.isDef(values)) { + if (values) { var rteValues = /** @type {Object} */ (objectStack[objectStack.length - 1]); var flatCoordinates = /** @type {Array.} */ (rteValues['flatCoordinates']); @@ -150,7 +150,7 @@ ol.format.GPX.parseTrkPt_ = function(node, objectStack) { goog.asserts.assert(node.localName == 'trkpt', 'localName should be trkpt'); var values = ol.xml.pushParseAndPop( {}, ol.format.GPX.TRKPT_PARSERS_, node, objectStack); - if (goog.isDef(values)) { + if (values) { var trkValues = /** @type {Object} */ (objectStack[objectStack.length - 1]); var flatCoordinates = /** @type {Array.} */ (trkValues['flatCoordinates']); @@ -192,7 +192,7 @@ ol.format.GPX.readRte_ = function(node, objectStack) { var values = ol.xml.pushParseAndPop({ 'flatCoordinates': [] }, ol.format.GPX.RTE_PARSERS_, node, objectStack); - if (!goog.isDef(values)) { + if (!values) { return undefined; } var flatCoordinates = /** @type {Array.} */ @@ -222,7 +222,7 @@ ol.format.GPX.readTrk_ = function(node, objectStack) { 'flatCoordinates': [], 'ends': [] }, ol.format.GPX.TRK_PARSERS_, node, objectStack); - if (!goog.isDef(values)) { + if (!values) { return undefined; } var flatCoordinates = /** @type {Array.} */ @@ -253,7 +253,7 @@ ol.format.GPX.readWpt_ = function(node, objectStack) { var options = /** @type {olx.format.ReadOptions} */ (objectStack[0]); var values = ol.xml.pushParseAndPop( {}, ol.format.GPX.WPT_PARSERS_, node, objectStack); - if (!goog.isDef(values)) { + if (!values) { return undefined; } var coordinates = ol.format.GPX.appendCoordinate_([], node, values); @@ -422,7 +422,7 @@ ol.format.GPX.prototype.handleReadExtensions_ = function(features) { } for (var i = 0, ii = features.length; i < ii; ++i) { var feature = features[i]; - if (goog.isDef(this.readExtensions_)) { + if (this.readExtensions_) { var extensionsNode = feature.get('extensionsNode_') || null; this.readExtensions_(feature, extensionsNode); } @@ -453,11 +453,11 @@ ol.format.GPX.prototype.readFeatureFromNode = function(node, opt_options) { return null; } var featureReader = ol.format.GPX.FEATURE_READER_[node.localName]; - if (!goog.isDef(featureReader)) { + if (!featureReader) { return null; } var feature = featureReader(node, [this.getReadOptions(node, opt_options)]); - if (!goog.isDef(feature)) { + if (!feature) { return null; } this.handleReadExtensions_([feature]); @@ -490,7 +490,7 @@ ol.format.GPX.prototype.readFeaturesFromNode = function(node, opt_options) { var features = ol.xml.pushParseAndPop( /** @type {Array.} */ ([]), ol.format.GPX.GPX_PARSERS_, node, [this.getReadOptions(node, opt_options)]); - if (goog.isDef(features)) { + if (features) { this.handleReadExtensions_(features); return features; } else { @@ -588,7 +588,7 @@ ol.format.GPX.writeRte_ = function(node, feature, objectStack) { var properties = feature.getProperties(); var context = {node: node, 'properties': properties}; var geometry = feature.getGeometry(); - if (goog.isDef(geometry)) { + if (geometry) { goog.asserts.assertInstanceof(geometry, ol.geom.LineString, 'geometry should be an ol.geom.LineString'); geometry = /** @type {ol.geom.LineString} */ @@ -616,7 +616,7 @@ ol.format.GPX.writeTrk_ = function(node, feature, objectStack) { var properties = feature.getProperties(); var context = {node: node, 'properties': properties}; var geometry = feature.getGeometry(); - if (goog.isDef(geometry)) { + if (geometry) { goog.asserts.assertInstanceof(geometry, ol.geom.MultiLineString, 'geometry should be an ol.geom.MultiLineString'); geometry = /** @type {ol.geom.MultiLineString} */ @@ -659,7 +659,7 @@ ol.format.GPX.writeWpt_ = function(node, feature, objectStack) { goog.asserts.assert(goog.isObject(context), 'context should be an Object'); context['properties'] = feature.getProperties(); var geometry = feature.getGeometry(); - if (goog.isDef(geometry)) { + if (geometry) { goog.asserts.assertInstanceof(geometry, ol.geom.Point, 'geometry should be an ol.geom.Point'); geometry = /** @type {ol.geom.Point} */ @@ -838,7 +838,7 @@ ol.format.GPX.GPX_NODE_FACTORY_ = function(value, objectStack, opt_nodeName) { goog.asserts.assertInstanceof(value, ol.Feature, 'value should be an ol.Feature'); var geometry = value.getGeometry(); - if (goog.isDef(geometry)) { + if (geometry) { var parentNode = objectStack[objectStack.length - 1].node; goog.asserts.assert(ol.xml.isNode(parentNode), 'parentNode should be an XML node'); diff --git a/src/ol/format/igcformat.js b/src/ol/format/igcformat.js index 08fd284084..8a2f7a0bb4 100644 --- a/src/ol/format/igcformat.js +++ b/src/ol/format/igcformat.js @@ -36,7 +36,7 @@ ol.format.IGCZ = { */ ol.format.IGC = function(opt_options) { - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = opt_options ? opt_options : {}; goog.base(this); @@ -49,7 +49,7 @@ ol.format.IGC = function(opt_options) { * @private * @type {ol.format.IGCZ} */ - this.altitudeMode_ = goog.isDef(options.altitudeMode) ? + this.altitudeMode_ = options.altitudeMode ? options.altitudeMode : ol.format.IGCZ.NONE; }; diff --git a/src/ol/format/jsonfeatureformat.js b/src/ol/format/jsonfeatureformat.js index 0ef66bc725..5016f02d3d 100644 --- a/src/ol/format/jsonfeatureformat.js +++ b/src/ol/format/jsonfeatureformat.js @@ -32,7 +32,7 @@ ol.format.JSONFeature.prototype.getObject_ = function(source) { return source; } else if (goog.isString(source)) { var object = goog.json.parse(source); - return goog.isDef(object) ? object : null; + return object ? object : null; } else { goog.asserts.fail(); return null; diff --git a/src/ol/format/kmlformat.js b/src/ol/format/kmlformat.js index e718ff199a..9371fb20d2 100644 --- a/src/ol/format/kmlformat.js +++ b/src/ol/format/kmlformat.js @@ -13,6 +13,7 @@ goog.require('goog.dom.NodeType'); goog.require('goog.math'); goog.require('goog.object'); goog.require('goog.string'); +goog.require('ol'); goog.require('ol.Feature'); goog.require('ol.FeatureStyleFunction'); goog.require('ol.color'); @@ -68,7 +69,7 @@ ol.format.KMLGxTrackObject_; */ ol.format.KML = function(opt_options) { - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = opt_options ? opt_options : {}; goog.base(this); @@ -81,15 +82,15 @@ ol.format.KML = function(opt_options) { * @private * @type {Array.} */ - this.defaultStyle_ = goog.isDef(options.defaultStyle) ? + this.defaultStyle_ = options.defaultStyle ? options.defaultStyle : ol.format.KML.DEFAULT_STYLE_ARRAY_; /** * @private * @type {boolean} */ - this.extractStyles_ = goog.isDef(options.extractStyles) ? - options.extractStyles : true; + this.extractStyles_ = ol.isDef(options.extractStyles) ? + /** @type {boolean} */ (options.extractStyles) : true; /** * @private @@ -296,10 +297,10 @@ ol.format.KML.createFeatureStyleFunction_ = function( * @this {ol.Feature} */ function(resolution) { - if (goog.isDef(style)) { + if (style) { return style; } - if (goog.isDef(styleUrl)) { + if (styleUrl) { return ol.format.KML.findStyle_(styleUrl, defaultStyle, sharedStyles); } return defaultStyle; @@ -440,7 +441,7 @@ ol.format.KML.readVec2_ = function(node) { */ ol.format.KML.readScale_ = function(node) { var number = ol.format.XSD.readDecimal(node); - if (goog.isDef(number)) { + if (ol.isDef(number)) { return Math.sqrt(number); } else { return undefined; @@ -479,7 +480,7 @@ ol.format.KML.IconStyleParser_ = function(node, objectStack) { // FIXME httpQuery var object = ol.xml.pushParseAndPop( {}, ol.format.KML.ICON_STYLE_PARSERS_, node, objectStack); - if (!goog.isDef(object)) { + if (!object) { return; } var styleObject = /** @type {Object} */ (objectStack[objectStack.length - 1]); @@ -489,7 +490,7 @@ ol.format.KML.IconStyleParser_ = function(node, objectStack) { var src; var href = /** @type {string|undefined} */ (IconObject['href']); - if (goog.isDef(href)) { + if (href) { src = href; } else { src = ol.format.KML.DEFAULT_IMAGE_STYLE_SRC_; @@ -497,7 +498,7 @@ ol.format.KML.IconStyleParser_ = function(node, objectStack) { var anchor, anchorXUnits, anchorYUnits; var hotSpot = /** @type {ol.format.KMLVec2_|undefined} */ (object['hotSpot']); - if (goog.isDef(hotSpot)) { + if (hotSpot) { anchor = [hotSpot.x, hotSpot.y]; anchorXUnits = hotSpot.xunits; anchorYUnits = hotSpot.yunits; @@ -516,7 +517,7 @@ ol.format.KML.IconStyleParser_ = function(node, objectStack) { (IconObject['x']); var y = /** @type {number|undefined} */ (IconObject['y']); - if (goog.isDef(x) && goog.isDef(y)) { + if (ol.isDef(x) && ol.isDef(y)) { offset = [x, y]; } @@ -525,14 +526,14 @@ ol.format.KML.IconStyleParser_ = function(node, objectStack) { (IconObject['w']); var h = /** @type {number|undefined} */ (IconObject['h']); - if (goog.isDef(w) && goog.isDef(h)) { + if (ol.isDef(w) && ol.isDef(h)) { size = [w, h]; } var rotation; - var heading = /** @type {number|undefined} */ + var heading = /** @type {number} */ (object['heading']); - if (goog.isDef(heading)) { + if (ol.isDef(heading)) { rotation = goog.math.toRadians(heading); } @@ -572,7 +573,7 @@ ol.format.KML.LabelStyleParser_ = function(node, objectStack) { // FIXME colorMode var object = ol.xml.pushParseAndPop( {}, ol.format.KML.LABEL_STYLE_PARSERS_, node, objectStack); - if (!goog.isDef(object)) { + if (!object) { return; } var styleObject = objectStack[objectStack.length - 1]; @@ -607,7 +608,7 @@ ol.format.KML.LineStyleParser_ = function(node, objectStack) { // FIXME gx:labelVisibility var object = ol.xml.pushParseAndPop( {}, ol.format.KML.LINE_STYLE_PARSERS_, node, objectStack); - if (!goog.isDef(object)) { + if (!object) { return; } var styleObject = objectStack[objectStack.length - 1]; @@ -635,7 +636,7 @@ ol.format.KML.PolyStyleParser_ = function(node, objectStack) { // FIXME colorMode var object = ol.xml.pushParseAndPop( {}, ol.format.KML.POLY_STYLE_PARSERS_, node, objectStack); - if (!goog.isDef(object)) { + if (!object) { return; } var styleObject = objectStack[objectStack.length - 1]; @@ -647,12 +648,12 @@ ol.format.KML.PolyStyleParser_ = function(node, objectStack) { }); styleObject['fillStyle'] = fillStyle; var fill = /** @type {boolean|undefined} */ (object['fill']); - if (goog.isDef(fill)) { + if (ol.isDef(fill)) { styleObject['fill'] = fill; } var outline = /** @type {boolean|undefined} */ (object['outline']); - if (goog.isDef(outline)) { + if (ol.isDef(outline)) { styleObject['outline'] = outline; } }; @@ -723,7 +724,7 @@ ol.format.KML.readGxMultiTrack_ = function(node, objectStack) { var lineStrings = ol.xml.pushParseAndPop( /** @type {Array.} */ ([]), ol.format.KML.GX_MULTITRACK_GEOMETRY_PARSERS_, node, objectStack); - if (!goog.isDef(lineStrings)) { + if (!lineStrings) { return undefined; } var multiLineString = new ol.geom.MultiLineString(null); @@ -750,7 +751,7 @@ ol.format.KML.readGxTrack_ = function(node, objectStack) { flatCoordinates: [], whens: [] }), ol.format.KML.GX_TRACK_PARSERS_, node, objectStack); - if (!goog.isDef(gxTrackObject)) { + if (!gxTrackObject) { return undefined; } var flatCoordinates = gxTrackObject.flatCoordinates; @@ -781,7 +782,7 @@ ol.format.KML.readIcon_ = function(node, objectStack) { goog.asserts.assert(node.localName == 'Icon', 'localName should be Icon'); var iconObject = ol.xml.pushParseAndPop( {}, ol.format.KML.ICON_PARSERS_, node, objectStack); - if (goog.isDef(iconObject)) { + if (iconObject) { return iconObject; } else { return null; @@ -819,7 +820,7 @@ ol.format.KML.readLineString_ = function(node, objectStack) { objectStack); var flatCoordinates = ol.format.KML.readFlatCoordinatesFromNode_(node, objectStack); - if (goog.isDef(flatCoordinates)) { + if (flatCoordinates) { var lineString = new ol.geom.LineString(null); lineString.setFlatCoordinates(ol.geom.GeometryLayout.XYZ, flatCoordinates); lineString.setProperties(properties); @@ -846,7 +847,7 @@ ol.format.KML.readLinearRing_ = function(node, objectStack) { objectStack); var flatCoordinates = ol.format.KML.readFlatCoordinatesFromNode_(node, objectStack); - if (goog.isDef(flatCoordinates)) { + if (flatCoordinates) { var polygon = new ol.geom.Polygon(null); polygon.setFlatCoordinates(ol.geom.GeometryLayout.XYZ, flatCoordinates, [flatCoordinates.length]); @@ -872,7 +873,7 @@ ol.format.KML.readMultiGeometry_ = function(node, objectStack) { var geometries = ol.xml.pushParseAndPop( /** @type {Array.} */ ([]), ol.format.KML.MULTI_GEOMETRY_PARSERS_, node, objectStack); - if (!goog.isDef(geometries)) { + if (!geometries) { return null; } if (geometries.length === 0) { @@ -1010,14 +1011,14 @@ ol.format.KML.readStyle_ = function(node, objectStack) { goog.asserts.assert(node.localName == 'Style', 'localName should be Style'); var styleObject = ol.xml.pushParseAndPop( {}, ol.format.KML.STYLE_PARSERS_, node, objectStack); - if (!goog.isDef(styleObject)) { + if (!styleObject) { return null; } var fillStyle = /** @type {ol.style.Fill} */ (goog.object.get( styleObject, 'fillStyle', ol.format.KML.DEFAULT_FILL_STYLE_)); var fill = /** @type {boolean|undefined} */ (styleObject['fill']); - if (goog.isDef(fill) && !fill) { + if (ol.isDef(fill) && !fill) { fillStyle = null; } var imageStyle = /** @type {ol.style.Image} */ (goog.object.get( @@ -1028,7 +1029,7 @@ ol.format.KML.readStyle_ = function(node, objectStack) { styleObject, 'strokeStyle', ol.format.KML.DEFAULT_STROKE_STYLE_)); var outline = /** @type {boolean|undefined} */ (styleObject['outline']); - if (goog.isDef(outline) && !outline) { + if (ol.isDef(outline) && !outline) { strokeStyle = null; } return [new ol.style.Style({ @@ -1060,8 +1061,8 @@ ol.format.KML.setCommonGeometryProperties_ = function(multiGeometry, geometry = geometries[i]; extrudes[i] = geometry.get('extrude'); altitudeModes[i] = geometry.get('altitudeMode'); - hasExtrude = hasExtrude || goog.isDef(extrudes[i]); - hasAltitudeMode = hasAltitudeMode || goog.isDef(altitudeModes[i]); + hasExtrude = hasExtrude || ol.isDef(extrudes[i]); + hasAltitudeMode = hasAltitudeMode || altitudeModes[i]; } if (hasExtrude) { multiGeometry.set('extrude', extrudes); @@ -1085,7 +1086,7 @@ ol.format.KML.DataParser_ = function(node, objectStack) { if (!goog.isNull(name)) { var data = ol.xml.pushParseAndPop( undefined, ol.format.KML.DATA_PARSERS_, node, objectStack); - if (goog.isDef(data)) { + if (data) { var featureObject = /** @type {Object} */ (objectStack[objectStack.length - 1]); goog.asserts.assert(goog.isObject(featureObject), @@ -1121,20 +1122,20 @@ ol.format.KML.PairDataParser_ = function(node, objectStack) { goog.asserts.assert(node.localName == 'Pair', 'localName should be Pair'); var pairObject = ol.xml.pushParseAndPop( {}, ol.format.KML.PAIR_PARSERS_, node, objectStack); - if (!goog.isDef(pairObject)) { + if (!pairObject) { return; } var key = /** @type {string|undefined} */ (pairObject['key']); - if (goog.isDef(key) && key == 'normal') { + if (key && key == 'normal') { var styleUrl = /** @type {string|undefined} */ (pairObject['styleUrl']); - if (goog.isDef(styleUrl)) { + if (styleUrl) { objectStack[objectStack.length - 1] = styleUrl; } var Style = /** @type {ol.style.Style} */ (pairObject['Style']); - if (goog.isDef(Style)) { + if (Style) { objectStack[objectStack.length - 1] = Style; } } @@ -1152,7 +1153,7 @@ ol.format.KML.PlacemarkStyleMapParser_ = function(node, objectStack) { goog.asserts.assert(node.localName == 'StyleMap', 'localName should be StyleMap'); var styleMapValue = ol.format.KML.readStyleMapValue_(node, objectStack); - if (!goog.isDef(styleMapValue)) { + if (!styleMapValue) { return; } var placemarkObject = objectStack[objectStack.length - 1]; @@ -1215,7 +1216,7 @@ ol.format.KML.innerBoundaryIsParser_ = function(node, objectStack) { var flatLinearRing = ol.xml.pushParseAndPop( /** @type {Array.|undefined} */ (undefined), ol.format.KML.INNER_BOUNDARY_IS_PARSERS_, node, objectStack); - if (goog.isDef(flatLinearRing)) { + if (flatLinearRing) { var flatLinearRings = /** @type {Array.>} */ (objectStack[objectStack.length - 1]); goog.asserts.assert(goog.isArray(flatLinearRings), @@ -1240,7 +1241,7 @@ ol.format.KML.outerBoundaryIsParser_ = function(node, objectStack) { var flatLinearRing = ol.xml.pushParseAndPop( /** @type {Array.|undefined} */ (undefined), ol.format.KML.OUTER_BOUNDARY_IS_PARSERS_, node, objectStack); - if (goog.isDef(flatLinearRing)) { + if (flatLinearRing) { var flatLinearRings = /** @type {Array.>} */ (objectStack[objectStack.length - 1]); goog.asserts.assert(goog.isArray(flatLinearRings), @@ -1285,16 +1286,16 @@ ol.format.KML.whenParser_ = function(node, objectStack) { var m = re.exec(s); if (m) { var year = parseInt(m[1], 10); - var month = goog.isDef(m[3]) ? parseInt(m[3], 10) - 1 : 0; - var day = goog.isDef(m[5]) ? parseInt(m[5], 10) : 1; - var hour = goog.isDef(m[7]) ? parseInt(m[7], 10) : 0; - var minute = goog.isDef(m[8]) ? parseInt(m[8], 10) : 0; - var second = goog.isDef(m[9]) ? parseInt(m[9], 10) : 0; + var month = m[3] ? parseInt(m[3], 10) - 1 : 0; + var day = m[5] ? parseInt(m[5], 10) : 1; + var hour = m[7] ? parseInt(m[7], 10) : 0; + var minute = m[8] ? parseInt(m[8], 10) : 0; + var second = m[9] ? parseInt(m[9], 10) : 0; var when = Date.UTC(year, month, day, hour, minute, second); - if (goog.isDef(m[10]) && m[10] != 'Z') { + if (m[10] && m[10] != 'Z') { var sign = m[11] == '-' ? -1 : 1; when += sign * 60 * parseInt(m[12], 10); - if (goog.isDef(m[13])) { + if (m[13]) { when += sign * 60 * 60 * parseInt(m[13], 10); } } @@ -1650,7 +1651,7 @@ ol.format.KML.prototype.readDocumentOrFolder_ = function(node, objectStack) { }); var features = ol.xml.pushParseAndPop(/** @type {Array.} */ ([]), parsersNS, node, objectStack, this); - if (goog.isDef(features)) { + if (features) { return features; } else { return undefined; @@ -1671,7 +1672,7 @@ ol.format.KML.prototype.readPlacemark_ = function(node, objectStack) { 'localName should be Placemark'); var object = ol.xml.pushParseAndPop({'geometry': null}, ol.format.KML.PLACEMARK_PARSERS_, node, objectStack); - if (!goog.isDef(object)) { + if (!object) { return undefined; } var feature = new ol.Feature(); @@ -1717,7 +1718,7 @@ ol.format.KML.prototype.readSharedStyle_ = function(node, objectStack) { var id = node.getAttribute('id'); if (!goog.isNull(id)) { var style = ol.format.KML.readStyle_(node, objectStack); - if (goog.isDef(style)) { + if (style) { var styleUri; if (goog.isDefAndNotNull(node.baseURI)) { styleUri = goog.Uri.resolve(node.baseURI, '#' + id).toString(); @@ -1745,7 +1746,7 @@ ol.format.KML.prototype.readSharedStyleMap_ = function(node, objectStack) { return; } var styleMapValue = ol.format.KML.readStyleMapValue_(node, objectStack); - if (!goog.isDef(styleMapValue)) { + if (!styleMapValue) { return; } var styleUri; @@ -1783,7 +1784,7 @@ ol.format.KML.prototype.readFeatureFromNode = function(node, opt_options) { 'localName should be Placemark'); var feature = this.readPlacemark_( node, [this.getReadOptions(node, opt_options)]); - if (goog.isDef(feature)) { + if (feature) { return feature; } else { return null; @@ -1817,7 +1818,7 @@ ol.format.KML.prototype.readFeaturesFromNode = function(node, opt_options) { if (localName == 'Document' || localName == 'Folder') { features = this.readDocumentOrFolder_( node, [this.getReadOptions(node, opt_options)]); - if (goog.isDef(features)) { + if (features) { return features; } else { return []; @@ -1825,7 +1826,7 @@ ol.format.KML.prototype.readFeaturesFromNode = function(node, opt_options) { } else if (localName == 'Placemark') { var feature = this.readPlacemark_( node, [this.getReadOptions(node, opt_options)]); - if (goog.isDef(feature)) { + if (feature) { return [feature]; } else { return []; @@ -1836,7 +1837,7 @@ ol.format.KML.prototype.readFeaturesFromNode = function(node, opt_options) { for (n = node.firstElementChild; !goog.isNull(n); n = n.nextElementSibling) { var fs = this.readFeaturesFromNode(n, opt_options); - if (goog.isDef(fs)) { + if (fs) { goog.array.extend(features, fs); } } @@ -1878,7 +1879,7 @@ ol.format.KML.prototype.readNameFromDocument = function(doc) { for (n = doc.firstChild; !goog.isNull(n); n = n.nextSibling) { if (n.nodeType == goog.dom.NodeType.ELEMENT) { var name = this.readNameFromNode(n); - if (goog.isDef(name)) { + if (name) { return name; } } @@ -1907,7 +1908,7 @@ ol.format.KML.prototype.readNameFromNode = function(node) { localName == 'Placemark' || localName == 'kml')) { var name = this.readNameFromNode(n); - if (goog.isDef(name)) { + if (name) { return name; } } @@ -2165,7 +2166,7 @@ ol.format.KML.writeLabelStyle_ = function(node, style, objectStack) { properties['color'] = fill.getColor(); } var scale = style.getScale(); - if (goog.isDef(scale) && scale !== 1) { + if (scale && scale !== 1) { properties['scale'] = scale; } var parentNode = objectStack[objectStack.length - 1].node; @@ -2272,7 +2273,7 @@ ol.format.KML.writePlacemark_ = function(node, feature, objectStack) { // serialize properties (properties unknown to KML are not serialized) var properties = feature.getProperties(); var styleFunction = feature.getStyleFunction(); - if (goog.isDef(styleFunction)) { + if (styleFunction) { // FIXME the styles returned by the style function are supposed to be // resolution-independent here var styles = styleFunction.call(feature, 0); diff --git a/src/ol/format/osmxmlformat.js b/src/ol/format/osmxmlformat.js index d6cb8733b4..f45ca8211d 100644 --- a/src/ol/format/osmxmlformat.js +++ b/src/ol/format/osmxmlformat.js @@ -223,7 +223,7 @@ ol.format.OSMXML.prototype.readFeaturesFromNode = function(node, opt_options) { nodes: {}, features: [] }, ol.format.OSMXML.PARSERS_, node, [options]); - if (goog.isDef(state.features)) { + if (state.features) { return state.features; } } diff --git a/src/ol/format/owsformat.js b/src/ol/format/owsformat.js index 30090069a9..1ebd2df650 100644 --- a/src/ol/format/owsformat.js +++ b/src/ol/format/owsformat.js @@ -44,7 +44,7 @@ ol.format.OWS.prototype.readFromNode = function(node) { 'node.nodeType should be ELEMENT'); var owsObject = ol.xml.pushParseAndPop({}, ol.format.OWS.PARSERS_, node, []); - return goog.isDef(owsObject) ? owsObject : null; + return owsObject ? owsObject : null; }; @@ -92,7 +92,7 @@ ol.format.OWS.readConstraint_ = function(node, objectStack) { goog.asserts.assert(node.localName == 'Constraint', 'localName should be Constraint'); var name = node.getAttribute('name'); - if (!goog.isDef(name)) { + if (!name) { return undefined; } return ol.xml.pushParseAndPop({'name': name}, @@ -143,7 +143,7 @@ ol.format.OWS.readGet_ = function(node, objectStack) { 'node.nodeType should be ELEMENT'); goog.asserts.assert(node.localName == 'Get', 'localName should be Get'); var href = ol.format.XLink.readHref(node); - if (!goog.isDef(href)) { + if (!href) { return undefined; } return ol.xml.pushParseAndPop({'href': href}, @@ -180,7 +180,7 @@ ol.format.OWS.readOperation_ = function(node, objectStack) { var name = node.getAttribute('name'); var value = ol.xml.pushParseAndPop({}, ol.format.OWS.OPERATION_PARSERS_, node, objectStack); - if (!goog.isDef(value)) { + if (!value) { return undefined; } var object = /** @type {Object} */ diff --git a/src/ol/format/polylineformat.js b/src/ol/format/polylineformat.js index a8d369d1f6..8bba501ee9 100644 --- a/src/ol/format/polylineformat.js +++ b/src/ol/format/polylineformat.js @@ -26,7 +26,7 @@ goog.require('ol.proj'); */ ol.format.Polyline = function(opt_options) { - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = opt_options ? opt_options : {}; goog.base(this); @@ -39,13 +39,13 @@ ol.format.Polyline = function(opt_options) { * @private * @type {number} */ - this.factor_ = goog.isDef(options.factor) ? options.factor : 1e5; + this.factor_ = options.factor ? options.factor : 1e5; /** * @private * @type {ol.geom.GeometryLayout} */ - this.geometryLayout_ = goog.isDef(options.geometryLayout) ? + this.geometryLayout_ = options.geometryLayout ? options.geometryLayout : ol.geom.GeometryLayout.XY; }; goog.inherits(ol.format.Polyline, ol.format.TextFeature); @@ -65,7 +65,7 @@ goog.inherits(ol.format.Polyline, ol.format.TextFeature); * @api */ ol.format.Polyline.encodeDeltas = function(numbers, stride, opt_factor) { - var factor = goog.isDef(opt_factor) ? opt_factor : 1e5; + var factor = opt_factor ? opt_factor : 1e5; var d; var lastNumbers = new Array(stride); @@ -100,7 +100,7 @@ ol.format.Polyline.encodeDeltas = function(numbers, stride, opt_factor) { * @api */ ol.format.Polyline.decodeDeltas = function(encoded, stride, opt_factor) { - var factor = goog.isDef(opt_factor) ? opt_factor : 1e5; + var factor = opt_factor ? opt_factor : 1e5; var d; /** @type {Array.} */ @@ -137,7 +137,7 @@ ol.format.Polyline.decodeDeltas = function(encoded, stride, opt_factor) { * @api */ ol.format.Polyline.encodeFloats = function(numbers, opt_factor) { - var factor = goog.isDef(opt_factor) ? opt_factor : 1e5; + var factor = opt_factor ? opt_factor : 1e5; var i, ii; for (i = 0, ii = numbers.length; i < ii; ++i) { numbers[i] = Math.round(numbers[i] * factor); @@ -157,7 +157,7 @@ ol.format.Polyline.encodeFloats = function(numbers, opt_factor) { * @api */ ol.format.Polyline.decodeFloats = function(encoded, opt_factor) { - var factor = goog.isDef(opt_factor) ? opt_factor : 1e5; + var factor = opt_factor ? opt_factor : 1e5; var numbers = ol.format.Polyline.decodeSignedIntegers(encoded); var i, ii; for (i = 0, ii = numbers.length; i < ii; ++i) { diff --git a/src/ol/format/topojsonformat.js b/src/ol/format/topojsonformat.js index cf85306a49..d8a30b34e5 100644 --- a/src/ol/format/topojsonformat.js +++ b/src/ol/format/topojsonformat.js @@ -26,7 +26,7 @@ goog.require('ol.proj'); */ ol.format.TopoJSON = function(opt_options) { - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = opt_options ? opt_options : {}; goog.base(this); @@ -251,8 +251,7 @@ ol.format.TopoJSON.readFeatureFromGeometry_ = function(object, arcs, var geometry; var type = object.type; var geometryReader = ol.format.TopoJSON.GEOMETRY_READERS_[type]; - goog.asserts.assert(goog.isDef(geometryReader), - 'geometryReader should be defined'); + goog.asserts.assert(geometryReader, 'geometryReader should be defined'); if ((type === 'Point') || (type === 'MultiPoint')) { geometry = geometryReader(object, scale, translate); } else { @@ -261,10 +260,10 @@ ol.format.TopoJSON.readFeatureFromGeometry_ = function(object, arcs, var feature = new ol.Feature(); feature.setGeometry(/** @type {ol.geom.Geometry} */ ( ol.format.Feature.transformWithOptions(geometry, false, opt_options))); - if (goog.isDef(object.id)) { + if (object.id) { feature.setId(object.id); } - if (goog.isDef(object.properties)) { + if (object.properties) { feature.setProperties(object.properties); } return feature; @@ -290,13 +289,13 @@ ol.format.TopoJSON.prototype.readFeaturesFromObject = function( if (object.type == 'Topology') { var topoJSONTopology = /** @type {TopoJSONTopology} */ (object); var transform, scale = null, translate = null; - if (goog.isDef(topoJSONTopology.transform)) { + if (topoJSONTopology.transform) { transform = topoJSONTopology.transform; scale = transform.scale; translate = transform.translate; } var arcs = topoJSONTopology.arcs; - if (goog.isDef(transform)) { + if (transform) { ol.format.TopoJSON.transformArcs_(arcs, scale, translate); } /** @type {Array.} */ From b0fe36e609f24ad3ae9ef38c9788edb38be24c3d Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Mon, 21 Sep 2015 05:59:47 +0900 Subject: [PATCH 33/93] Remove goog.isDef for geometries --- src/ol/geom/circle.js | 2 +- src/ol/geom/flat/closestflatgeom.js | 6 +++--- src/ol/geom/flat/deflateflatgeom.js | 4 ++-- src/ol/geom/flat/interiorpointflatgeom.js | 2 +- src/ol/geom/flat/orientflatgeom.js | 5 +++-- src/ol/geom/flat/transformflatgeom.js | 8 ++++---- src/ol/geom/geometry.js | 3 +-- src/ol/geom/geometrycollection.js | 2 +- src/ol/geom/multilinestring.js | 7 +++++-- src/ol/geom/multipolygon.js | 3 ++- src/ol/geom/polygon.js | 9 +++++---- src/ol/geom/simplegeometry.js | 2 +- 12 files changed, 29 insertions(+), 24 deletions(-) diff --git a/src/ol/geom/circle.js b/src/ol/geom/circle.js index 9a882b32ed..66eeb43c45 100644 --- a/src/ol/geom/circle.js +++ b/src/ol/geom/circle.js @@ -23,7 +23,7 @@ goog.require('ol.proj'); */ ol.geom.Circle = function(center, opt_radius, opt_layout) { goog.base(this); - var radius = goog.isDef(opt_radius) ? opt_radius : 0; + var radius = opt_radius ? opt_radius : 0; this.setCenterAndRadius(center, radius, opt_layout); }; goog.inherits(ol.geom.Circle, ol.geom.SimpleGeometry); diff --git a/src/ol/geom/flat/closestflatgeom.js b/src/ol/geom/flat/closestflatgeom.js index 132753aa72..efe7470629 100644 --- a/src/ol/geom/flat/closestflatgeom.js +++ b/src/ol/geom/flat/closestflatgeom.js @@ -154,7 +154,7 @@ ol.geom.flat.closest.getClosestPoint = function(flatCoordinates, offset, end, } } goog.asserts.assert(maxDelta > 0, 'maxDelta should be larger than 0'); - var tmpPoint = goog.isDef(opt_tmpPoint) ? opt_tmpPoint : [NaN, NaN]; + var tmpPoint = opt_tmpPoint ? opt_tmpPoint : [NaN, NaN]; var index = offset + stride; while (index < end) { ol.geom.flat.closest.point( @@ -217,7 +217,7 @@ ol.geom.flat.closest.getClosestPoint = function(flatCoordinates, offset, end, ol.geom.flat.closest.getsClosestPoint = function(flatCoordinates, offset, ends, stride, maxDelta, isRing, x, y, closestPoint, minSquaredDistance, opt_tmpPoint) { - var tmpPoint = goog.isDef(opt_tmpPoint) ? opt_tmpPoint : [NaN, NaN]; + var tmpPoint = opt_tmpPoint ? opt_tmpPoint : [NaN, NaN]; var i, ii; for (i = 0, ii = ends.length; i < ii; ++i) { var end = ends[i]; @@ -247,7 +247,7 @@ ol.geom.flat.closest.getsClosestPoint = function(flatCoordinates, offset, ends, ol.geom.flat.closest.getssClosestPoint = function(flatCoordinates, offset, endss, stride, maxDelta, isRing, x, y, closestPoint, minSquaredDistance, opt_tmpPoint) { - var tmpPoint = goog.isDef(opt_tmpPoint) ? opt_tmpPoint : [NaN, NaN]; + var tmpPoint = opt_tmpPoint ? opt_tmpPoint : [NaN, NaN]; var i, ii; for (i = 0, ii = endss.length; i < ii; ++i) { var ends = endss[i]; diff --git a/src/ol/geom/flat/deflateflatgeom.js b/src/ol/geom/flat/deflateflatgeom.js index 069467e3fe..08c7fe7b02 100644 --- a/src/ol/geom/flat/deflateflatgeom.js +++ b/src/ol/geom/flat/deflateflatgeom.js @@ -55,7 +55,7 @@ ol.geom.flat.deflate.coordinates = */ ol.geom.flat.deflate.coordinatess = function(flatCoordinates, offset, coordinatess, stride, opt_ends) { - var ends = goog.isDef(opt_ends) ? opt_ends : []; + var ends = opt_ends ? opt_ends : []; var i = 0; var j, jj; for (j = 0, jj = coordinatess.length; j < jj; ++j) { @@ -79,7 +79,7 @@ ol.geom.flat.deflate.coordinatess = */ ol.geom.flat.deflate.coordinatesss = function(flatCoordinates, offset, coordinatesss, stride, opt_endss) { - var endss = goog.isDef(opt_endss) ? opt_endss : []; + var endss = opt_endss ? opt_endss : []; var i = 0; var j, jj; for (j = 0, jj = coordinatesss.length; j < jj; ++j) { diff --git a/src/ol/geom/flat/interiorpointflatgeom.js b/src/ol/geom/flat/interiorpointflatgeom.js index 883f9cffa0..59e69242b2 100644 --- a/src/ol/geom/flat/interiorpointflatgeom.js +++ b/src/ol/geom/flat/interiorpointflatgeom.js @@ -60,7 +60,7 @@ ol.geom.flat.interiorpoint.linearRings = function(flatCoordinates, offset, // ring. Use the center of the the linear ring's extent. pointX = flatCenters[flatCentersOffset]; } - if (goog.isDef(opt_dest)) { + if (opt_dest) { opt_dest.push(pointX, y); return opt_dest; } else { diff --git a/src/ol/geom/flat/orientflatgeom.js b/src/ol/geom/flat/orientflatgeom.js index 688b6a3f97..5b80341ce8 100644 --- a/src/ol/geom/flat/orientflatgeom.js +++ b/src/ol/geom/flat/orientflatgeom.js @@ -1,5 +1,6 @@ goog.provide('ol.geom.flat.orient'); +goog.require('ol'); goog.require('ol.geom.flat.reverse'); @@ -43,7 +44,7 @@ ol.geom.flat.orient.linearRingIsClockwise = */ ol.geom.flat.orient.linearRingsAreOriented = function(flatCoordinates, offset, ends, stride, opt_right) { - var right = goog.isDef(opt_right) ? opt_right : false; + var right = ol.isDef(opt_right) ? opt_right : false; var i, ii; for (i = 0, ii = ends.length; i < ii; ++i) { var end = ends[i]; @@ -105,7 +106,7 @@ ol.geom.flat.orient.linearRingssAreOriented = */ ol.geom.flat.orient.orientLinearRings = function(flatCoordinates, offset, ends, stride, opt_right) { - var right = goog.isDef(opt_right) ? opt_right : false; + var right = ol.isDef(opt_right) ? opt_right : false; var i, ii; for (i = 0, ii = ends.length; i < ii; ++i) { var end = ends[i]; diff --git a/src/ol/geom/flat/transformflatgeom.js b/src/ol/geom/flat/transformflatgeom.js index 7bb08e8a83..81ecf4a53c 100644 --- a/src/ol/geom/flat/transformflatgeom.js +++ b/src/ol/geom/flat/transformflatgeom.js @@ -20,7 +20,7 @@ ol.geom.flat.transform.transform2D = var m11 = goog.vec.Mat4.getElement(transform, 1, 1); var m03 = goog.vec.Mat4.getElement(transform, 0, 3); var m13 = goog.vec.Mat4.getElement(transform, 1, 3); - var dest = goog.isDef(opt_dest) ? opt_dest : []; + var dest = opt_dest ? opt_dest : []; var i = 0; var j; for (j = offset; j < end; j += stride) { @@ -29,7 +29,7 @@ ol.geom.flat.transform.transform2D = dest[i++] = m00 * x + m01 * y + m03; dest[i++] = m10 * x + m11 * y + m13; } - if (goog.isDef(opt_dest) && dest.length != i) { + if (opt_dest && dest.length != i) { dest.length = i; } return dest; @@ -48,7 +48,7 @@ ol.geom.flat.transform.transform2D = */ ol.geom.flat.transform.translate = function(flatCoordinates, offset, end, stride, deltaX, deltaY, opt_dest) { - var dest = goog.isDef(opt_dest) ? opt_dest : []; + var dest = opt_dest ? opt_dest : []; var i = 0; var j, k; for (j = offset; j < end; j += stride) { @@ -58,7 +58,7 @@ ol.geom.flat.transform.translate = dest[i++] = flatCoordinates[k]; } } - if (goog.isDef(opt_dest) && dest.length != i) { + if (opt_dest && dest.length != i) { dest.length = i; } return dest; diff --git a/src/ol/geom/geometry.js b/src/ol/geom/geometry.js index c75da4f1eb..70fac46257 100644 --- a/src/ol/geom/geometry.js +++ b/src/ol/geom/geometry.js @@ -122,8 +122,7 @@ ol.geom.Geometry.prototype.closestPointXY = goog.abstractMethod; * @api stable */ ol.geom.Geometry.prototype.getClosestPoint = function(point, opt_closestPoint) { - var closestPoint = goog.isDef(opt_closestPoint) ? - opt_closestPoint : [NaN, NaN]; + var closestPoint = opt_closestPoint ? opt_closestPoint : [NaN, NaN]; this.closestPointXY(point[0], point[1], closestPoint, Infinity); return closestPoint; }; diff --git a/src/ol/geom/geometrycollection.js b/src/ol/geom/geometrycollection.js index 7ac3963fde..548f389736 100644 --- a/src/ol/geom/geometrycollection.js +++ b/src/ol/geom/geometrycollection.js @@ -26,7 +26,7 @@ ol.geom.GeometryCollection = function(opt_geometries) { * @private * @type {Array.} */ - this.geometries_ = goog.isDef(opt_geometries) ? opt_geometries : null; + this.geometries_ = opt_geometries ? opt_geometries : null; this.listenGeometriesChange_(); }; diff --git a/src/ol/geom/multilinestring.js b/src/ol/geom/multilinestring.js index fb3d94af48..30b3b5afdd 100644 --- a/src/ol/geom/multilinestring.js +++ b/src/ol/geom/multilinestring.js @@ -2,6 +2,7 @@ goog.provide('ol.geom.MultiLineString'); goog.require('goog.array'); goog.require('goog.asserts'); +goog.require('ol'); goog.require('ol.extent'); goog.require('ol.geom.GeometryLayout'); goog.require('ol.geom.GeometryType'); @@ -135,8 +136,10 @@ ol.geom.MultiLineString.prototype.getCoordinateAtM = this.flatCoordinates.length === 0) { return null; } - var extrapolate = goog.isDef(opt_extrapolate) ? opt_extrapolate : false; - var interpolate = goog.isDef(opt_interpolate) ? opt_interpolate : false; + var extrapolate = ol.isDef(opt_extrapolate) ? + /** @type {boolean} */ (opt_extrapolate) : false; + var interpolate = ol.isDef(opt_interpolate) ? + /** @type {boolean} */ (opt_interpolate) : false; return ol.geom.flat.lineStringsCoordinateAtM(this.flatCoordinates, 0, this.ends_, this.stride, m, extrapolate, interpolate); }; diff --git a/src/ol/geom/multipolygon.js b/src/ol/geom/multipolygon.js index d74c7b781d..41b56f8d16 100644 --- a/src/ol/geom/multipolygon.js +++ b/src/ol/geom/multipolygon.js @@ -3,6 +3,7 @@ goog.provide('ol.geom.MultiPolygon'); goog.require('goog.array'); goog.require('goog.asserts'); goog.require('goog.object'); +goog.require('ol'); goog.require('ol.extent'); goog.require('ol.geom.GeometryLayout'); goog.require('ol.geom.GeometryType'); @@ -182,7 +183,7 @@ ol.geom.MultiPolygon.prototype.getArea = function() { */ ol.geom.MultiPolygon.prototype.getCoordinates = function(opt_right) { var flatCoordinates; - if (goog.isDef(opt_right)) { + if (ol.isDef(opt_right)) { flatCoordinates = this.getOrientedFlatCoordinates().slice(); ol.geom.flat.orient.orientLinearRingss( flatCoordinates, 0, this.endss_, this.stride, opt_right); diff --git a/src/ol/geom/polygon.js b/src/ol/geom/polygon.js index b16263c2ac..a93ded2d54 100644 --- a/src/ol/geom/polygon.js +++ b/src/ol/geom/polygon.js @@ -3,6 +3,7 @@ goog.provide('ol.geom.Polygon'); goog.require('goog.array'); goog.require('goog.asserts'); goog.require('goog.math'); +goog.require('ol'); goog.require('ol.extent'); goog.require('ol.geom.GeometryLayout'); goog.require('ol.geom.GeometryType'); @@ -169,7 +170,7 @@ ol.geom.Polygon.prototype.getArea = function() { */ ol.geom.Polygon.prototype.getCoordinates = function(opt_right) { var flatCoordinates; - if (goog.isDef(opt_right)) { + if (ol.isDef(opt_right)) { flatCoordinates = this.getOrientedFlatCoordinates().slice(); ol.geom.flat.orient.orientLinearRings( flatCoordinates, 0, this.ends_, this.stride, opt_right); @@ -388,7 +389,7 @@ ol.geom.Polygon.prototype.setFlatCoordinates = * @api stable */ ol.geom.Polygon.circular = function(sphere, center, radius, opt_n) { - var n = goog.isDef(opt_n) ? opt_n : 32; + var n = opt_n ? opt_n : 32; /** @type {Array.} */ var flatCoordinates = []; var i; @@ -434,7 +435,7 @@ ol.geom.Polygon.fromExtent = function(extent) { * @api */ ol.geom.Polygon.fromCircle = function(circle, opt_sides, opt_angle) { - var sides = goog.isDef(opt_sides) ? opt_sides : 32; + var sides = opt_sides ? opt_sides : 32; var stride = circle.getStride(); var layout = circle.getLayout(); var polygon = new ol.geom.Polygon(null, layout); @@ -462,7 +463,7 @@ ol.geom.Polygon.makeRegular = function(polygon, center, radius, opt_angle) { var ends = polygon.getEnds(); goog.asserts.assert(ends.length === 1, 'only 1 ring is supported'); var sides = flatCoordinates.length / stride - 1; - var startAngle = goog.isDef(opt_angle) ? opt_angle : 0; + var startAngle = opt_angle ? opt_angle : 0; var angle, coord, offset; for (var i = 0; i <= sides; ++i) { offset = i * stride; diff --git a/src/ol/geom/simplegeometry.js b/src/ol/geom/simplegeometry.js index e99e5479b9..4da4b706ad 100644 --- a/src/ol/geom/simplegeometry.js +++ b/src/ol/geom/simplegeometry.js @@ -232,7 +232,7 @@ ol.geom.SimpleGeometry.prototype.setLayout = function(layout, coordinates, nesting) { /** @type {number} */ var stride; - if (goog.isDef(layout)) { + if (layout) { stride = ol.geom.SimpleGeometry.getStrideForLayout(layout); } else { var i; From d7ca176362add03500d89c1454885195ff9782e4 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Mon, 21 Sep 2015 06:32:20 +0900 Subject: [PATCH 34/93] Remove goog.isDef from more formats --- externs/olx.js | 2 + src/ol/format/featureformat.js | 10 ++-- src/ol/format/gml/gml2format.js | 8 +-- src/ol/format/gml/gmlbaseformat.js | 26 +++++----- src/ol/format/wfsformat.js | 63 ++++++++++++------------ src/ol/format/wktformat.js | 20 ++++---- src/ol/format/wmscapabilitiesformat.js | 43 ++++++++-------- src/ol/format/wmsgetfeatureinfoformat.js | 6 +-- src/ol/format/wmtscapabilitiesformat.js | 14 +++--- src/ol/format/xsdformat.js | 5 +- 10 files changed, 99 insertions(+), 98 deletions(-) diff --git a/externs/olx.js b/externs/olx.js index c7240d7293..f2ae250a9a 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -1914,6 +1914,8 @@ olx.format.WFSOptions.prototype.schemaLocation; * maxFeatures: (number|undefined), * geometryName: (string|undefined), * propertyNames: (Array.|undefined), + * startIndex: (number|undefined), + * count: (number|undefined), * bbox: (ol.Extent|undefined)}} * @api */ diff --git a/src/ol/format/featureformat.js b/src/ol/format/featureformat.js index d480625e80..bb3425e209 100644 --- a/src/ol/format/featureformat.js +++ b/src/ol/format/featureformat.js @@ -42,9 +42,9 @@ ol.format.Feature.prototype.getExtensions = goog.abstractMethod; */ ol.format.Feature.prototype.getReadOptions = function(source, opt_options) { var options; - if (goog.isDef(opt_options)) { + if (opt_options) { options = { - dataProjection: goog.isDef(opt_options.dataProjection) ? + dataProjection: opt_options.dataProjection ? opt_options.dataProjection : this.readProjection(source), featureProjection: opt_options.featureProjection }; @@ -64,7 +64,7 @@ ol.format.Feature.prototype.getReadOptions = function(source, opt_options) { */ ol.format.Feature.prototype.adaptOptions = function(options) { var updatedOptions; - if (goog.isDef(options)) { + if (options) { updatedOptions = { featureProjection: options.featureProjection, dataProjection: goog.isDefAndNotNull(options.dataProjection) ? @@ -161,9 +161,9 @@ ol.format.Feature.prototype.writeGeometry = goog.abstractMethod; */ ol.format.Feature.transformWithOptions = function( geometry, write, opt_options) { - var featureProjection = goog.isDef(opt_options) ? + var featureProjection = opt_options ? ol.proj.get(opt_options.featureProjection) : null; - var dataProjection = goog.isDef(opt_options) ? + var dataProjection = opt_options ? ol.proj.get(opt_options.dataProjection) : null; if (!goog.isNull(featureProjection) && !goog.isNull(dataProjection) && !ol.proj.equivalent(featureProjection, dataProjection)) { diff --git a/src/ol/format/gml/gml2format.js b/src/ol/format/gml/gml2format.js index 73ec528e1a..88ff8a5671 100644 --- a/src/ol/format/gml/gml2format.js +++ b/src/ol/format/gml/gml2format.js @@ -22,7 +22,7 @@ goog.require('ol.xml'); */ ol.format.GML2 = function(opt_options) { var options = /** @type {olx.format.GMLOptions} */ - (goog.isDef(opt_options) ? opt_options : {}); + (opt_options ? opt_options : {}); goog.base(this, options); @@ -33,7 +33,7 @@ ol.format.GML2 = function(opt_options) { /** * @inheritDoc */ - this.schemaLocation = goog.isDef(options.schemaLocation) ? + this.schemaLocation = options.schemaLocation ? options.schemaLocation : ol.format.GML2.schemaLocation_; }; @@ -127,7 +127,7 @@ ol.format.GML2.prototype.innerBoundaryIsParser_ = var flatLinearRing = ol.xml.pushParseAndPop( /** @type {Array.|undefined} */ (undefined), this.RING_PARSERS, node, objectStack, this); - if (goog.isDef(flatLinearRing)) { + if (flatLinearRing) { var flatLinearRings = /** @type {Array.>} */ (objectStack[objectStack.length - 1]); goog.asserts.assert(goog.isArray(flatLinearRings), @@ -153,7 +153,7 @@ ol.format.GML2.prototype.outerBoundaryIsParser_ = var flatLinearRing = ol.xml.pushParseAndPop( /** @type {Array.|undefined} */ (undefined), this.RING_PARSERS, node, objectStack, this); - if (goog.isDef(flatLinearRing)) { + if (flatLinearRing) { var flatLinearRings = /** @type {Array.>} */ (objectStack[objectStack.length - 1]); goog.asserts.assert(goog.isArray(flatLinearRings), diff --git a/src/ol/format/gml/gmlbaseformat.js b/src/ol/format/gml/gmlbaseformat.js index a65717cff8..6f0dab84d8 100644 --- a/src/ol/format/gml/gmlbaseformat.js +++ b/src/ol/format/gml/gmlbaseformat.js @@ -41,7 +41,7 @@ goog.require('ol.xml'); */ ol.format.GMLBase = function(opt_options) { var options = /** @type {olx.format.GMLOptions} */ - (goog.isDef(opt_options) ? opt_options : {}); + (opt_options ? opt_options : {}); /** * @protected @@ -116,7 +116,7 @@ ol.format.GMLBase.prototype.readFeaturesInternal = function(node, objectStack) { var featureType = context['featureType']; var featureNS = context['featureNS']; var i, ii, prefix = 'p', defaultPrefix = 'p0'; - if (!goog.isDef(featureType) && goog.isDefAndNotNull(node.childNodes)) { + if (!featureType && goog.isDefAndNotNull(node.childNodes)) { featureType = [], featureNS = {}; for (i = 0, ii = node.childNodes.length; i < ii; ++i) { var child = node.childNodes[i]; @@ -162,7 +162,7 @@ ol.format.GMLBase.prototype.readFeaturesInternal = function(node, objectStack) { } features = ol.xml.pushParseAndPop([], parsersNS, node, objectStack); } - if (!goog.isDef(features)) { + if (!features) { features = []; } return features; @@ -222,7 +222,7 @@ ol.format.GMLBase.prototype.readFeatureElement = function(node, objectStack) { } } var feature = new ol.Feature(values); - if (goog.isDef(geometryName)) { + if (geometryName) { feature.setGeometryName(geometryName); } if (fid) { @@ -266,7 +266,7 @@ ol.format.GMLBase.prototype.readMultiPoint = function(node, objectStack) { var coordinates = ol.xml.pushParseAndPop( /** @type {Array.>} */ ([]), this.MULTIPOINT_PARSERS_, node, objectStack, this); - if (goog.isDef(coordinates)) { + if (coordinates) { return new ol.geom.MultiPoint(coordinates); } else { return undefined; @@ -287,7 +287,7 @@ ol.format.GMLBase.prototype.readMultiLineString = function(node, objectStack) { var lineStrings = ol.xml.pushParseAndPop( /** @type {Array.} */ ([]), this.MULTILINESTRING_PARSERS_, node, objectStack, this); - if (goog.isDef(lineStrings)) { + if (lineStrings) { var multiLineString = new ol.geom.MultiLineString(null); multiLineString.setLineStrings(lineStrings); return multiLineString; @@ -310,7 +310,7 @@ ol.format.GMLBase.prototype.readMultiPolygon = function(node, objectStack) { var polygons = ol.xml.pushParseAndPop( /** @type {Array.} */ ([]), this.MULTIPOLYGON_PARSERS_, node, objectStack, this); - if (goog.isDef(polygons)) { + if (polygons) { var multiPolygon = new ol.geom.MultiPolygon(null); multiPolygon.setPolygons(polygons); return multiPolygon; @@ -426,7 +426,7 @@ ol.format.GMLBase.prototype.readLinearRing = function(node, objectStack) { 'localName should be LinearRing'); var flatCoordinates = this.readFlatCoordinatesFromNode_(node, objectStack); - if (goog.isDef(flatCoordinates)) { + if (flatCoordinates) { var ring = new ol.geom.LinearRing(null); ring.setFlatCoordinates(ol.geom.GeometryLayout.XYZ, flatCoordinates); return ring; @@ -449,7 +449,7 @@ ol.format.GMLBase.prototype.readPolygon = function(node, objectStack) { var flatLinearRings = ol.xml.pushParseAndPop( /** @type {Array.>} */ ([null]), this.FLAT_LINEAR_RINGS_PARSERS_, node, objectStack, this); - if (goog.isDef(flatLinearRings) && + if (flatLinearRings && !goog.isNull(flatLinearRings[0])) { var polygon = new ol.geom.Polygon(null); var flatCoordinates = flatLinearRings[0]; @@ -588,8 +588,8 @@ ol.format.GMLBase.prototype.RING_PARSERS = Object({ ol.format.GMLBase.prototype.readGeometryFromNode = function(node, opt_options) { var geometry = this.readGeometryElement(node, - [this.getReadOptions(node, goog.isDef(opt_options) ? opt_options : {})]); - return goog.isDef(geometry) ? geometry : null; + [this.getReadOptions(node, opt_options ? opt_options : {})]); + return geometry ? geometry : null; }; @@ -614,7 +614,7 @@ ol.format.GMLBase.prototype.readFeaturesFromNode = featureType: this.featureType, featureNS: this.featureNS }; - if (goog.isDef(opt_options)) { + if (opt_options) { goog.object.extend(options, this.getReadOptions(node, opt_options)); } return this.readFeaturesInternal(node, [options]); @@ -625,6 +625,6 @@ ol.format.GMLBase.prototype.readFeaturesFromNode = * @inheritDoc */ ol.format.GMLBase.prototype.readProjectionFromNode = function(node) { - return ol.proj.get(goog.isDef(this.srsName_) ? this.srsName_ : + return ol.proj.get(this.srsName_ ? this.srsName_ : node.firstElementChild.getAttribute('srsName')); }; diff --git a/src/ol/format/wfsformat.js b/src/ol/format/wfsformat.js index e78e179b12..295ae8c68f 100644 --- a/src/ol/format/wfsformat.js +++ b/src/ol/format/wfsformat.js @@ -3,6 +3,7 @@ goog.provide('ol.format.WFS'); goog.require('goog.asserts'); goog.require('goog.dom.NodeType'); goog.require('goog.object'); +goog.require('ol'); goog.require('ol.format.GML3'); goog.require('ol.format.GMLBase'); goog.require('ol.format.XMLFeature'); @@ -27,7 +28,7 @@ goog.require('ol.xml'); * @api stable */ ol.format.WFS = function(opt_options) { - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = opt_options ? opt_options : {}; /** * @private @@ -45,14 +46,14 @@ ol.format.WFS = function(opt_options) { * @private * @type {ol.format.GMLBase} */ - this.gmlFormat_ = goog.isDef(options.gmlFormat) ? + this.gmlFormat_ = options.gmlFormat ? options.gmlFormat : new ol.format.GML3(); /** * @private * @type {string} */ - this.schemaLocation_ = goog.isDef(options.schemaLocation) ? + this.schemaLocation_ = options.schemaLocation ? options.schemaLocation : ol.format.WFS.SCHEMA_LOCATION; goog.base(this); @@ -123,7 +124,7 @@ ol.format.WFS.prototype.readFeaturesFromNode = function(node, opt_options) { 'featureNS': this.featureNS_ }; goog.object.extend(context, this.getReadOptions(node, - goog.isDef(opt_options) ? opt_options : {})); + opt_options ? opt_options : {})); var objectStack = [context]; this.gmlFormat_.FEATURE_COLLECTION_PARSERS[ol.format.GMLBase.GMLNS][ 'featureMember'] = @@ -131,7 +132,7 @@ ol.format.WFS.prototype.readFeaturesFromNode = function(node, opt_options) { var features = ol.xml.pushParseAndPop([], this.gmlFormat_.FEATURE_COLLECTION_PARSERS, node, objectStack, this.gmlFormat_); - if (!goog.isDef(features)) { + if (!features) { features = []; } return features; @@ -414,14 +415,14 @@ ol.format.WFS.writeDelete_ = function(node, feature, objectStack) { goog.asserts.assert(goog.isObject(context), 'context should be an Object'); var featureType = context['featureType']; var featurePrefix = context['featurePrefix']; - featurePrefix = goog.isDef(featurePrefix) ? featurePrefix : + featurePrefix = featurePrefix ? featurePrefix : ol.format.WFS.FEATURE_PREFIX; var featureNS = context['featureNS']; node.setAttribute('typeName', featurePrefix + ':' + featureType); ol.xml.setAttributeNS(node, ol.format.WFS.XMLNS, 'xmlns:' + featurePrefix, featureNS); var fid = feature.getId(); - if (goog.isDef(fid)) { + if (fid) { ol.format.WFS.writeOgcFidFilter_(node, fid, objectStack); } }; @@ -438,19 +439,19 @@ ol.format.WFS.writeUpdate_ = function(node, feature, objectStack) { goog.asserts.assert(goog.isObject(context), 'context should be an Object'); var featureType = context['featureType']; var featurePrefix = context['featurePrefix']; - featurePrefix = goog.isDef(featurePrefix) ? featurePrefix : + featurePrefix = featurePrefix ? featurePrefix : ol.format.WFS.FEATURE_PREFIX; var featureNS = context['featureNS']; node.setAttribute('typeName', featurePrefix + ':' + featureType); ol.xml.setAttributeNS(node, ol.format.WFS.XMLNS, 'xmlns:' + featurePrefix, featureNS); var fid = feature.getId(); - if (goog.isDef(fid)) { + if (fid) { var keys = feature.getKeys(); var values = []; for (var i = 0, ii = keys.length; i < ii; i++) { var value = feature.get(keys[i]); - if (goog.isDef(value)) { + if (ol.isDef(value)) { values.push({name: keys[i], value: value}); } } @@ -495,13 +496,13 @@ ol.format.WFS.writeProperty_ = function(node, pair, objectStack) { * @private */ ol.format.WFS.writeNative_ = function(node, nativeElement, objectStack) { - if (goog.isDef(nativeElement.vendorId)) { + if (nativeElement.vendorId) { node.setAttribute('vendorId', nativeElement.vendorId); } - if (goog.isDef(nativeElement.safeToIgnore)) { + if (ol.isDef(nativeElement.safeToIgnore)) { node.setAttribute('safeToIgnore', nativeElement.safeToIgnore); } - if (goog.isDef(nativeElement.value)) { + if (ol.isDef(nativeElement.value)) { ol.format.XSD.writeStringTextNode(node, nativeElement.value); } }; @@ -535,12 +536,12 @@ ol.format.WFS.writeQuery_ = function(node, featureType, objectStack) { var featureNS = context['featureNS']; var propertyNames = context['propertyNames']; var srsName = context['srsName']; - var prefix = goog.isDef(featurePrefix) ? featurePrefix + ':' : ''; + var prefix = featurePrefix ? featurePrefix + ':' : ''; node.setAttribute('typeName', prefix + featureType); - if (goog.isDef(srsName)) { + if (srsName) { node.setAttribute('srsName', srsName); } - if (goog.isDef(featureNS)) { + if (featureNS) { ol.xml.setAttributeNS(node, ol.format.WFS.XMLNS, 'xmlns:' + featurePrefix, featureNS); } @@ -551,7 +552,7 @@ ol.format.WFS.writeQuery_ = function(node, featureType, objectStack) { ol.xml.makeSimpleNodeFactory('PropertyName'), propertyNames, objectStack); var bbox = context['bbox']; - if (goog.isDef(bbox)) { + if (bbox) { var child = ol.xml.createElementNS('http://www.opengis.net/ogc', 'Filter'); ol.format.WFS.writeOgcBBOX_(child, bbox, objectStack); node.appendChild(child); @@ -632,23 +633,23 @@ ol.format.WFS.prototype.writeGetFeature = function(options) { 'GetFeature'); node.setAttribute('service', 'WFS'); node.setAttribute('version', '1.1.0'); - if (goog.isDef(options)) { - if (goog.isDef(options.handle)) { + if (options) { + if (options.handle) { node.setAttribute('handle', options.handle); } - if (goog.isDef(options.outputFormat)) { + if (options.outputFormat) { node.setAttribute('outputFormat', options.outputFormat); } - if (goog.isDef(options.maxFeatures)) { + if (ol.isDef(options.maxFeatures)) { node.setAttribute('maxFeatures', options.maxFeatures); } - if (goog.isDef(options.resultType)) { + if (options.resultType) { node.setAttribute('resultType', options.resultType); } - if (goog.isDef(options.startIndex)) { + if (ol.isDef(options.startIndex)) { node.setAttribute('startIndex', options.startIndex); } - if (goog.isDef(options.count)) { + if (ol.isDef(options.count)) { node.setAttribute('count', options.count); } } @@ -657,13 +658,11 @@ ol.format.WFS.prototype.writeGetFeature = function(options) { var context = { node: node, srsName: options.srsName, - featureNS: goog.isDef(options.featureNS) ? - options.featureNS : this.featureNS_, + featureNS: options.featureNS ? options.featureNS : this.featureNS_, featurePrefix: options.featurePrefix, geometryName: options.geometryName, bbox: options.bbox, - propertyNames: goog.isDef(options.propertyNames) ? - options.propertyNames : [] + propertyNames: options.propertyNames ? options.propertyNames : [] }; goog.asserts.assert(goog.isArray(options.featureTypes), 'options.featureTypes should be an array'); @@ -690,9 +689,9 @@ ol.format.WFS.prototype.writeTransaction = function(inserts, updates, deletes, node.setAttribute('service', 'WFS'); node.setAttribute('version', '1.1.0'); var baseObj, obj; - if (goog.isDef(options)) { - baseObj = goog.isDef(options.gmlOptions) ? options.gmlOptions : {}; - if (goog.isDef(options.handle)) { + if (options) { + baseObj = options.gmlOptions ? options.gmlOptions : {}; + if (options.handle) { node.setAttribute('handle', options.handle); } } @@ -723,7 +722,7 @@ ol.format.WFS.prototype.writeTransaction = function(inserts, updates, deletes, ol.xml.makeSimpleNodeFactory('Delete'), deletes, objectStack); } - if (goog.isDef(options.nativeElements)) { + if (options.nativeElements) { ol.xml.pushSerializeAndPop({node: node, featureNS: options.featureNS, featureType: options.featureType, featurePrefix: options.featurePrefix}, ol.format.WFS.TRANSACTION_SERIALIZERS_, diff --git a/src/ol/format/wktformat.js b/src/ol/format/wktformat.js index ddd609983b..f7d1ad6cd8 100644 --- a/src/ol/format/wktformat.js +++ b/src/ol/format/wktformat.js @@ -1,6 +1,7 @@ goog.provide('ol.format.WKT'); goog.require('goog.asserts'); +goog.require('ol'); goog.require('ol.Feature'); goog.require('ol.format.Feature'); goog.require('ol.format.TextFeature'); @@ -28,7 +29,7 @@ goog.require('ol.geom.Polygon'); */ ol.format.WKT = function(opt_options) { - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = opt_options ? opt_options : {}; goog.base(this); @@ -37,8 +38,8 @@ ol.format.WKT = function(opt_options) { * @type {boolean} * @private */ - this.splitCollection_ = goog.isDef(options.splitCollection) ? - options.splitCollection : false; + this.splitCollection_ = ol.isDef(options.splitCollection) ? + /** @type {boolean} */ (options.splitCollection) : false; }; goog.inherits(ol.format.WKT, ol.format.TextFeature); @@ -167,8 +168,7 @@ ol.format.WKT.encodeMultiPolygonGeometry_ = function(geom) { ol.format.WKT.encode_ = function(geom) { var type = geom.getType(); var geometryEncoder = ol.format.WKT.GeometryEncoder_[type]; - goog.asserts.assert(goog.isDef(geometryEncoder), - 'geometryEncoder should be defined'); + goog.asserts.assert(geometryEncoder, 'geometryEncoder should be defined'); var enc = geometryEncoder(geom); type = type.toUpperCase(); if (enc.length === 0) { @@ -225,7 +225,7 @@ ol.format.WKT.prototype.readFeature; */ ol.format.WKT.prototype.readFeatureFromText = function(text, opt_options) { var geom = this.readGeometryFromText(text, opt_options); - if (goog.isDef(geom)) { + if (geom) { var feature = new ol.Feature(); feature.setGeometry(geom); return feature; @@ -286,7 +286,7 @@ ol.format.WKT.prototype.readGeometry; */ ol.format.WKT.prototype.readGeometryFromText = function(text, opt_options) { var geometry = this.parse_(text); - if (goog.isDef(geometry)) { + if (geometry) { return /** @type {ol.geom.Geometry} */ ( ol.format.Feature.transformWithOptions(geometry, false, opt_options)); } else { @@ -312,7 +312,7 @@ ol.format.WKT.prototype.writeFeature; */ ol.format.WKT.prototype.writeFeatureText = function(feature, opt_options) { var geometry = feature.getGeometry(); - if (goog.isDef(geometry)) { + if (geometry) { return this.writeGeometryText(geometry, opt_options); } return ''; @@ -427,7 +427,7 @@ ol.format.WKT.Lexer.prototype.isAlpha_ = function(c) { * @private */ ol.format.WKT.Lexer.prototype.isNumeric_ = function(c, opt_decimal) { - var decimal = goog.isDef(opt_decimal) ? opt_decimal : false; + var decimal = ol.isDef(opt_decimal) ? opt_decimal : false; return c >= '0' && c <= '9' || c == '.' && !decimal; }; @@ -603,7 +603,7 @@ ol.format.WKT.Parser.prototype.parseGeometry_ = function() { } else { var parser = ol.format.WKT.Parser.GeometryParser_[geomType]; var ctor = ol.format.WKT.Parser.GeometryConstructor_[geomType]; - if (!goog.isDef(parser) || !goog.isDef(ctor)) { + if (!parser || !ctor) { throw new Error('Invalid geometry type: ' + geomType); } var coordinates = parser.call(this); diff --git a/src/ol/format/wmscapabilitiesformat.js b/src/ol/format/wmscapabilitiesformat.js index 52108caa0d..21e83c4617 100644 --- a/src/ol/format/wmscapabilitiesformat.js +++ b/src/ol/format/wmscapabilitiesformat.js @@ -5,6 +5,7 @@ goog.require('goog.asserts'); goog.require('goog.dom.NodeType'); goog.require('goog.object'); goog.require('goog.string'); +goog.require('ol'); goog.require('ol.format.XLink'); goog.require('ol.format.XML'); goog.require('ol.format.XSD'); @@ -74,7 +75,7 @@ ol.format.WMSCapabilities.prototype.readFromNode = function(node) { var wmsCapabilityObject = ol.xml.pushParseAndPop({ 'version': this.version }, ol.format.WMSCapabilities.PARSERS_, node, []); - return goog.isDef(wmsCapabilityObject) ? wmsCapabilityObject : null; + return wmsCapabilityObject ? wmsCapabilityObject : null; }; @@ -142,7 +143,7 @@ ol.format.WMSCapabilities.readEXGeographicBoundingBox_ = {}, ol.format.WMSCapabilities.EX_GEOGRAPHIC_BOUNDING_BOX_PARSERS_, node, objectStack); - if (!goog.isDef(geographicBoundingBox)) { + if (!geographicBoundingBox) { return undefined; } var westBoundLongitude = /** @type {number|undefined} */ @@ -153,8 +154,8 @@ ol.format.WMSCapabilities.readEXGeographicBoundingBox_ = (geographicBoundingBox['eastBoundLongitude']); var northBoundLatitude = /** @type {number|undefined} */ (geographicBoundingBox['northBoundLatitude']); - if (!goog.isDef(westBoundLongitude) || !goog.isDef(southBoundLatitude) || - !goog.isDef(eastBoundLongitude) || !goog.isDef(northBoundLatitude)) { + if (!ol.isDef(westBoundLongitude) || !ol.isDef(southBoundLatitude) || + !ol.isDef(eastBoundLongitude) || !ol.isDef(northBoundLatitude)) { return undefined; } return /** @type {ol.Extent} */ ([ @@ -297,46 +298,46 @@ ol.format.WMSCapabilities.readLayer_ = function(node, objectStack) { var layerObject = /** @type {Object.} */ (ol.xml.pushParseAndPop( {}, ol.format.WMSCapabilities.LAYER_PARSERS_, node, objectStack)); - if (!goog.isDef(layerObject)) { + if (!layerObject) { return undefined; } var queryable = ol.format.XSD.readBooleanString(node.getAttribute('queryable')); - if (!goog.isDef(queryable)) { + if (!ol.isDef(queryable)) { queryable = parentLayerObject['queryable']; } - layerObject['queryable'] = goog.isDef(queryable) ? queryable : false; + layerObject['queryable'] = ol.isDef(queryable) ? queryable : false; var cascaded = ol.format.XSD.readNonNegativeIntegerString( node.getAttribute('cascaded')); - if (!goog.isDef(cascaded)) { + if (!ol.isDef(cascaded)) { cascaded = parentLayerObject['cascaded']; } layerObject['cascaded'] = cascaded; var opaque = ol.format.XSD.readBooleanString(node.getAttribute('opaque')); - if (!goog.isDef(opaque)) { + if (!ol.isDef(opaque)) { opaque = parentLayerObject['opaque']; } - layerObject['opaque'] = goog.isDef(opaque) ? opaque : false; + layerObject['opaque'] = ol.isDef(opaque) ? opaque : false; var noSubsets = ol.format.XSD.readBooleanString(node.getAttribute('noSubsets')); - if (!goog.isDef(noSubsets)) { + if (!ol.isDef(noSubsets)) { noSubsets = parentLayerObject['noSubsets']; } - layerObject['noSubsets'] = goog.isDef(noSubsets) ? noSubsets : false; + layerObject['noSubsets'] = ol.isDef(noSubsets) ? noSubsets : false; var fixedWidth = ol.format.XSD.readDecimalString(node.getAttribute('fixedWidth')); - if (!goog.isDef(fixedWidth)) { + if (!fixedWidth) { fixedWidth = parentLayerObject['fixedWidth']; } layerObject['fixedWidth'] = fixedWidth; var fixedHeight = ol.format.XSD.readDecimalString(node.getAttribute('fixedHeight')); - if (!goog.isDef(fixedHeight)) { + if (!fixedHeight) { fixedHeight = parentLayerObject['fixedHeight']; } layerObject['fixedHeight'] = fixedHeight; @@ -344,10 +345,9 @@ ol.format.WMSCapabilities.readLayer_ = function(node, objectStack) { // See 7.2.4.8 var addKeys = ['Style', 'CRS', 'AuthorityURL']; goog.array.forEach(addKeys, function(key) { - var parentValue = parentLayerObject[key]; - if (goog.isDef(parentValue)) { + if (key in parentLayerObject) { var childValue = goog.object.setIfUndefined(layerObject, key, []); - childValue = childValue.concat(parentValue); + childValue = childValue.concat(parentLayerObject[key]); layerObject[key] = childValue; } }); @@ -355,8 +355,7 @@ ol.format.WMSCapabilities.readLayer_ = function(node, objectStack) { var replaceKeys = ['EX_GeographicBoundingBox', 'BoundingBox', 'Dimension', 'Attribution', 'MinScaleDenominator', 'MaxScaleDenominator']; goog.array.forEach(replaceKeys, function(key) { - var childValue = layerObject[key]; - if (!goog.isDef(childValue)) { + if (!(key in layerObject)) { var parentValue = parentLayerObject[key]; layerObject[key] = parentValue; } @@ -482,7 +481,7 @@ ol.format.WMSCapabilities.readSizedFormatOnlineresource_ = 'node.nodeType should be ELEMENT'); var formatOnlineresource = ol.format.WMSCapabilities.readFormatOnlineresource_(node, objectStack); - if (goog.isDef(formatOnlineresource)) { + if (formatOnlineresource) { var size = [ ol.format.XSD.readNonNegativeIntegerString(node.getAttribute('width')), ol.format.XSD.readNonNegativeIntegerString(node.getAttribute('height')) @@ -507,7 +506,7 @@ ol.format.WMSCapabilities.readAuthorityURL_ = function(node, objectStack) { 'localName should be AuthorityURL'); var authorityObject = ol.format.WMSCapabilities.readFormatOnlineresource_(node, objectStack); - if (goog.isDef(authorityObject)) { + if (authorityObject) { authorityObject['name'] = node.getAttribute('name'); return authorityObject; } @@ -528,7 +527,7 @@ ol.format.WMSCapabilities.readMetadataURL_ = function(node, objectStack) { 'localName should be MetadataURL'); var metadataObject = ol.format.WMSCapabilities.readFormatOnlineresource_(node, objectStack); - if (goog.isDef(metadataObject)) { + if (metadataObject) { metadataObject['type'] = node.getAttribute('type'); return metadataObject; } diff --git a/src/ol/format/wmsgetfeatureinfoformat.js b/src/ol/format/wmsgetfeatureinfoformat.js index 33397a0b29..6b439459dd 100644 --- a/src/ol/format/wmsgetfeatureinfoformat.js +++ b/src/ol/format/wmsgetfeatureinfoformat.js @@ -102,7 +102,7 @@ ol.format.WMSGetFeatureInfo.prototype.readFeatures_ = layer.namespaceURI = this.featureNS_; var layerFeatures = ol.xml.pushParseAndPop( [], parsersNS, layer, objectStack, this.gmlFormat_); - if (goog.isDef(layerFeatures)) { + if (layerFeatures) { goog.array.extend(features, layerFeatures); } }, this); @@ -111,7 +111,7 @@ ol.format.WMSGetFeatureInfo.prototype.readFeatures_ = var gmlFeatures = ol.xml.pushParseAndPop([], this.gmlFormat_.FEATURE_COLLECTION_PARSERS, node, [{}], this.gmlFormat_); - if (goog.isDef(gmlFeatures)) { + if (gmlFeatures) { features = gmlFeatures; } } @@ -140,7 +140,7 @@ ol.format.WMSGetFeatureInfo.prototype.readFeaturesFromNode = 'featureType': this.featureType, 'featureNS': this.featureNS }; - if (goog.isDef(opt_options)) { + if (opt_options) { goog.object.extend(options, this.getReadOptions(node, opt_options)); } return this.readFeatures_(node, [options]); diff --git a/src/ol/format/wmtscapabilitiesformat.js b/src/ol/format/wmtscapabilitiesformat.js index aabfff519c..11cc05ec4d 100644 --- a/src/ol/format/wmtscapabilitiesformat.js +++ b/src/ol/format/wmtscapabilitiesformat.js @@ -71,13 +71,13 @@ ol.format.WMTSCapabilities.prototype.readFromNode = function(node) { this.version = goog.string.trim(node.getAttribute('version')); goog.asserts.assertString(this.version, 'this.version should be a string'); var WMTSCapabilityObject = this.owsParser_.readFromNode(node); - if (!goog.isDef(WMTSCapabilityObject)) { + if (!WMTSCapabilityObject) { return null; } WMTSCapabilityObject['version'] = this.version; WMTSCapabilityObject = ol.xml.pushParseAndPop(WMTSCapabilityObject, ol.format.WMTSCapabilities.PARSERS_, node, []); - return goog.isDef(WMTSCapabilityObject) ? WMTSCapabilityObject : null; + return WMTSCapabilityObject ? WMTSCapabilityObject : null; }; @@ -134,7 +134,7 @@ ol.format.WMTSCapabilities.readTileMatrixSet_ = function(node, objectStack) { ol.format.WMTSCapabilities.readStyle_ = function(node, objectStack) { var style = ol.xml.pushParseAndPop({}, ol.format.WMTSCapabilities.STYLE_PARSERS_, node, objectStack); - if (!goog.isDef(style)) { + if (!style) { return undefined; } var isDefault = node.getAttribute('isDefault') === 'true'; @@ -168,13 +168,13 @@ ol.format.WMTSCapabilities.readResourceUrl_ = function(node, objectStack) { var template = node.getAttribute('template'); var resourceType = node.getAttribute('resourceType'); var resource = {}; - if (goog.isDef(format)) { + if (format) { resource['format'] = format; } - if (goog.isDef(template)) { + if (template) { resource['template'] = template; } - if (goog.isDef(resourceType)) { + if (resourceType) { resource['resourceType'] = resourceType; } return resource; @@ -219,7 +219,7 @@ ol.format.WMTSCapabilities.readLegendUrl_ = function(node, objectStack) { */ ol.format.WMTSCapabilities.readCoordinates_ = function(node, objectStack) { var coordinates = ol.format.XSD.readString(node).split(' '); - if (!goog.isDef(coordinates) || coordinates.length != 2) { + if (!coordinates || coordinates.length != 2) { return undefined; } var x = +coordinates[0]; diff --git a/src/ol/format/xsdformat.js b/src/ol/format/xsdformat.js index 200751ce9a..c220a64d96 100644 --- a/src/ol/format/xsdformat.js +++ b/src/ol/format/xsdformat.js @@ -2,6 +2,7 @@ goog.provide('ol.format.XSD'); goog.require('goog.asserts'); goog.require('goog.string'); +goog.require('ol'); goog.require('ol.xml'); @@ -29,7 +30,7 @@ ol.format.XSD.readBoolean = function(node) { ol.format.XSD.readBooleanString = function(string) { var m = /^\s*(true|1)|(false|0)\s*$/.exec(string); if (m) { - return goog.isDef(m[1]) || false; + return ol.isDef(m[1]) || false; } else { return undefined; } @@ -56,7 +57,7 @@ ol.format.XSD.readDateTime = function(node) { if (m[7] != 'Z') { var sign = m[8] == '-' ? -1 : 1; dateTime += sign * 60 * parseInt(m[9], 10); - if (goog.isDef(m[10])) { + if (ol.isDef(m[10])) { dateTime += sign * 60 * 60 * parseInt(m[10], 10); } } From ceb39b0d07acf534772eda00162016093a51fff1 Mon Sep 17 00:00:00 2001 From: Bart van den Eijnden Date: Mon, 21 Sep 2015 09:57:34 +0200 Subject: [PATCH 35/93] Add docs for count and startIndex (WFS paging) --- externs/olx.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/externs/olx.js b/externs/olx.js index f2ae250a9a..a430044773 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -1995,6 +1995,25 @@ olx.format.WFSWriteGetFeatureOptions.prototype.geometryName; olx.format.WFSWriteGetFeatureOptions.prototype.propertyNames; +/** + * Start index to use for WFS paging. This is a WFS 2.0 feature backported to + * WFS 1.1.0 by some Web Feature Services. + * @type {number|undefined} + * @api + */ +olx.format.WFSWriteGetFeatureOptions.prototype.startIndex; + + +/** + * Number of features to retrieve when paging. This is a WFS 2.0 feature + * backported to WFS 1.1.0 by some Web Feature Services. Please note that some + * Web Feature Services have repurposed `maxfeatures` instead. + * @type {number|undefined} + * @api + */ +olx.format.WFSWriteGetFeatureOptions.prototype.count; + + /** * Extent to use for the BBOX filter. * @type {ol.Extent|undefined} From eeba5f4d108c39900c3ecd49739ee97762289f4d Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Tue, 22 Sep 2015 09:14:14 +0200 Subject: [PATCH 36/93] Remove goog.isDef from drawinteraction --- src/ol/interaction/drawinteraction.js | 40 +++++++++++++-------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/src/ol/interaction/drawinteraction.js b/src/ol/interaction/drawinteraction.js index 4b025dec09..a1cadd6e08 100644 --- a/src/ol/interaction/drawinteraction.js +++ b/src/ol/interaction/drawinteraction.js @@ -112,22 +112,21 @@ ol.interaction.Draw = function(options) { * @type {ol.source.Vector} * @private */ - this.source_ = goog.isDef(options.source) ? options.source : null; + this.source_ = options.source ? options.source : null; /** * Target collection for drawn features. * @type {ol.Collection.} * @private */ - this.features_ = goog.isDef(options.features) ? options.features : null; + this.features_ = options.features ? options.features : null; /** * Pixel distance for snapping. * @type {number} * @private */ - this.snapTolerance_ = goog.isDef(options.snapTolerance) ? - options.snapTolerance : 12; + this.snapTolerance_ = options.snapTolerance ? options.snapTolerance : 12; /** * Geometry type. @@ -150,7 +149,7 @@ ol.interaction.Draw = function(options) { * @type {number} * @private */ - this.minPoints_ = goog.isDef(options.minPoints) ? + this.minPoints_ = options.minPoints ? options.minPoints : (this.mode_ === ol.interaction.DrawMode.POLYGON ? 3 : 2); @@ -160,11 +159,10 @@ ol.interaction.Draw = function(options) { * @type {number} * @private */ - this.maxPoints_ = goog.isDef(options.maxPoints) ? - options.maxPoints : Infinity; + this.maxPoints_ = options.maxPoints ? options.maxPoints : Infinity; var geometryFunction = options.geometryFunction; - if (!goog.isDef(geometryFunction)) { + if (!geometryFunction) { if (this.type_ === ol.geom.GeometryType.CIRCLE) { /** * @param {ol.Coordinate|Array.|Array.>} coordinates @@ -172,7 +170,7 @@ ol.interaction.Draw = function(options) { * @return {ol.geom.SimpleGeometry} */ geometryFunction = function(coordinates, opt_geometry) { - var circle = goog.isDef(opt_geometry) ? opt_geometry : + var circle = opt_geometry ? opt_geometry : new ol.geom.Circle([NaN, NaN]); goog.asserts.assertInstanceof(circle, ol.geom.Circle, 'geometry must be an ol.geom.Circle'); @@ -198,7 +196,7 @@ ol.interaction.Draw = function(options) { */ geometryFunction = function(coordinates, opt_geometry) { var geometry = opt_geometry; - if (goog.isDef(geometry)) { + if (geometry) { geometry.setCoordinates(coordinates); } else { geometry = new Constructor(coordinates); @@ -264,7 +262,7 @@ ol.interaction.Draw = function(options) { * @type {number} * @private */ - this.squaredClickTolerance_ = goog.isDef(options.clickTolerance) ? + this.squaredClickTolerance_ = options.clickTolerance ? options.clickTolerance * options.clickTolerance : 36; /** @@ -275,10 +273,10 @@ ol.interaction.Draw = function(options) { this.overlay_ = new ol.layer.Vector({ source: new ol.source.Vector({ useSpatialIndex: false, - wrapX: goog.isDef(options.wrapX) ? options.wrapX : false + wrapX: options.wrapX ? options.wrapX : false }), - style: goog.isDef(options.style) ? - options.style : ol.interaction.Draw.getDefaultStyleFunction() + style: options.style ? options.style : + ol.interaction.Draw.getDefaultStyleFunction() }); /** @@ -292,14 +290,14 @@ ol.interaction.Draw = function(options) { * @private * @type {ol.events.ConditionType} */ - this.condition_ = goog.isDef(options.condition) ? + this.condition_ = options.condition ? options.condition : ol.events.condition.noModifierKeys; /** * @private * @type {ol.events.ConditionType} */ - this.freehandCondition_ = goog.isDef(options.freehandCondition) ? + this.freehandCondition_ = options.freehandCondition ? options.freehandCondition : ol.events.condition.shiftKeyOnly; goog.events.listen(this, @@ -512,9 +510,9 @@ ol.interaction.Draw.prototype.startDrawing_ = function(event) { new ol.geom.LineString(this.sketchLineCoords_)); } var geometry = this.geometryFunction_(this.sketchCoords_); - goog.asserts.assert(goog.isDef(geometry), 'geometry should be defined'); + goog.asserts.assert(geometry !== undefined, 'geometry should be defined'); this.sketchFeature_ = new ol.Feature(); - if (goog.isDef(this.geometryName_)) { + if (this.geometryName_) { this.sketchFeature_.setGeometryName(this.geometryName_); } this.sketchFeature_.setGeometry(geometry); @@ -806,11 +804,11 @@ ol.interaction.Draw.createRegularPolygon = function(opt_sides, opt_angle) { var end = coordinates[1]; var radius = Math.sqrt( ol.coordinate.squaredDistance(center, end)); - var geometry = goog.isDef(opt_geometry) ? opt_geometry : + var geometry = opt_geometry ? opt_geometry : ol.geom.Polygon.fromCircle(new ol.geom.Circle(center), opt_sides); goog.asserts.assertInstanceof(geometry, ol.geom.Polygon, 'geometry must be a polygon'); - var angle = goog.isDef(opt_angle) ? opt_angle : + var angle = opt_angle ? opt_angle : Math.atan((end[1] - center[1]) / (end[0] - center[0])); ol.geom.Polygon.makeRegular(geometry, center, radius, angle); return geometry; @@ -840,7 +838,7 @@ ol.interaction.Draw.getMode_ = function(type) { } else if (type === ol.geom.GeometryType.CIRCLE) { mode = ol.interaction.DrawMode.CIRCLE; } - goog.asserts.assert(goog.isDef(mode), 'mode should be defined'); + goog.asserts.assert(mode !== undefined, 'mode should be defined'); return mode; }; From 2b77e1601ad671b1d5b98e6fc9c26ccc97515e84 Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Tue, 22 Sep 2015 09:18:16 +0200 Subject: [PATCH 37/93] Remove goog.isDef from doubleclickzoominteraction --- src/ol/interaction/doubleclickzoominteraction.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ol/interaction/doubleclickzoominteraction.js b/src/ol/interaction/doubleclickzoominteraction.js index a9cf643b87..a874369363 100644 --- a/src/ol/interaction/doubleclickzoominteraction.js +++ b/src/ol/interaction/doubleclickzoominteraction.js @@ -18,13 +18,13 @@ goog.require('ol.interaction.Interaction'); */ ol.interaction.DoubleClickZoom = function(opt_options) { - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = opt_options ? opt_options : {}; /** * @private * @type {number} */ - this.delta_ = goog.isDef(options.delta) ? options.delta : 1; + this.delta_ = options.delta ? options.delta : 1; goog.base(this, { handleEvent: ol.interaction.DoubleClickZoom.handleEvent @@ -34,7 +34,7 @@ ol.interaction.DoubleClickZoom = function(opt_options) { * @private * @type {number} */ - this.duration_ = goog.isDef(options.duration) ? options.duration : 250; + this.duration_ = options.duration ? options.duration : 250; }; goog.inherits(ol.interaction.DoubleClickZoom, ol.interaction.Interaction); From 27fb1b6fde94816f8633f29d4a83a08a1ed98aa8 Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Tue, 22 Sep 2015 09:21:37 +0200 Subject: [PATCH 38/93] Remove goog.isDef from geom/linestring --- src/ol/geom/linestring.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ol/geom/linestring.js b/src/ol/geom/linestring.js index f89bc1a46a..7305604068 100644 --- a/src/ol/geom/linestring.js +++ b/src/ol/geom/linestring.js @@ -148,7 +148,7 @@ ol.geom.LineString.prototype.getCoordinateAtM = function(m, opt_extrapolate) { this.layout != ol.geom.GeometryLayout.XYZM) { return null; } - var extrapolate = goog.isDef(opt_extrapolate) ? opt_extrapolate : false; + var extrapolate = opt_extrapolate ? opt_extrapolate : false; return ol.geom.flat.lineStringCoordinateAtM(this.flatCoordinates, 0, this.flatCoordinates.length, this.stride, m, extrapolate); }; From 631b92412e9dc2a06f3c50c0462a2f93a2569ded Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Tue, 22 Sep 2015 09:33:05 +0200 Subject: [PATCH 39/93] Remove goog.isDef from draganddropinteraction --- src/ol/interaction/draganddropinteraction.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/ol/interaction/draganddropinteraction.js b/src/ol/interaction/draganddropinteraction.js index 2297e2316d..e1edc684ff 100644 --- a/src/ol/interaction/draganddropinteraction.js +++ b/src/ol/interaction/draganddropinteraction.js @@ -27,7 +27,7 @@ goog.require('ol.proj'); */ ol.interaction.DragAndDrop = function(opt_options) { - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = opt_options ? opt_options : {}; goog.base(this, { handleEvent: ol.interaction.DragAndDrop.handleEvent @@ -37,14 +37,14 @@ ol.interaction.DragAndDrop = function(opt_options) { * @private * @type {Array.} */ - this.formatConstructors_ = goog.isDef(options.formatConstructors) ? + this.formatConstructors_ = options.formatConstructors ? options.formatConstructors : []; /** * @private * @type {ol.proj.Projection} */ - this.projection_ = goog.isDef(options.projection) ? + this.projection_ = options.projection ? ol.proj.get(options.projection) : null; /** @@ -67,7 +67,7 @@ goog.inherits(ol.interaction.DragAndDrop, ol.interaction.Interaction); * @inheritDoc */ ol.interaction.DragAndDrop.prototype.disposeInternal = function() { - if (goog.isDef(this.dropListenKey_)) { + if (this.dropListenKey_) { goog.events.unlistenByKey(this.dropListenKey_); } goog.base(this, 'disposeInternal'); @@ -104,7 +104,7 @@ ol.interaction.DragAndDrop.prototype.handleResult_ = function(file, result) { var view = map.getView(); goog.asserts.assert(!goog.isNull(view), 'view should not be null'); projection = view.getProjection(); - goog.asserts.assert(goog.isDef(projection), + goog.asserts.assert(projection !== undefined, 'projection should be defined'); } var formatConstructors = this.formatConstructors_; @@ -150,7 +150,7 @@ ol.interaction.DragAndDrop.handleEvent = goog.functions.TRUE; * @inheritDoc */ ol.interaction.DragAndDrop.prototype.setMap = function(map) { - if (goog.isDef(this.dropListenKey_)) { + if (this.dropListenKey_) { goog.events.unlistenByKey(this.dropListenKey_); this.dropListenKey_ = undefined; } @@ -158,7 +158,7 @@ ol.interaction.DragAndDrop.prototype.setMap = function(map) { goog.dispose(this.fileDropHandler_); this.fileDropHandler_ = null; } - goog.asserts.assert(!goog.isDef(this.dropListenKey_), + goog.asserts.assert(this.dropListenKey_ === undefined, 'this.dropListenKey_ should be undefined'); goog.base(this, 'setMap', map); if (!goog.isNull(map)) { From a42e4d4f4e657013763175128f6f509e819b93c8 Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Tue, 22 Sep 2015 10:19:06 +0200 Subject: [PATCH 40/93] Remove goog.isDef from dragboxinteraction --- src/ol/interaction/dragboxinteraction.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ol/interaction/dragboxinteraction.js b/src/ol/interaction/dragboxinteraction.js index 9438dca7dc..afc0b4e6b3 100644 --- a/src/ol/interaction/dragboxinteraction.js +++ b/src/ol/interaction/dragboxinteraction.js @@ -91,13 +91,13 @@ ol.interaction.DragBox = function(opt_options) { handleUpEvent: ol.interaction.DragBox.handleUpEvent_ }); - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = opt_options ? opt_options : {}; /** * @private * @type {ol.style.Style} */ - var style = goog.isDef(options.style) ? options.style : null; + var style = options.style ? options.style : null; /** * @type {ol.render.Box} @@ -115,7 +115,7 @@ ol.interaction.DragBox = function(opt_options) { * @private * @type {ol.events.ConditionType} */ - this.condition_ = goog.isDef(options.condition) ? + this.condition_ = options.condition ? options.condition : ol.events.condition.always; }; From 3e49fc6081bd9689aaccc9063bcde545813b9994 Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Tue, 22 Sep 2015 10:19:17 +0200 Subject: [PATCH 41/93] Remove goog.isDef from dragpaninteraction --- src/ol/interaction/dragpaninteraction.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ol/interaction/dragpaninteraction.js b/src/ol/interaction/dragpaninteraction.js index 66f0a5d1e1..ae78fc37ad 100644 --- a/src/ol/interaction/dragpaninteraction.js +++ b/src/ol/interaction/dragpaninteraction.js @@ -28,7 +28,7 @@ ol.interaction.DragPan = function(opt_options) { handleUpEvent: ol.interaction.DragPan.handleUpEvent_ }); - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = opt_options ? opt_options : {}; /** * @private @@ -51,7 +51,7 @@ ol.interaction.DragPan = function(opt_options) { * @private * @type {ol.events.ConditionType} */ - this.condition_ = goog.isDef(options.condition) ? + this.condition_ = options.condition ? options.condition : ol.events.condition.noModifierKeys; /** @@ -109,7 +109,7 @@ ol.interaction.DragPan.handleUpEvent_ = function(mapBrowserEvent) { var distance = this.kinetic_.getDistance(); var angle = this.kinetic_.getAngle(); var center = view.getCenter(); - goog.asserts.assert(goog.isDef(center), 'center should be defined'); + goog.asserts.assert(center !== undefined, 'center should be defined'); this.kineticPreRenderFn_ = this.kinetic_.pan(center); map.beforeRender(this.kineticPreRenderFn_); var centerpx = map.getPixelFromCoordinate(center); From 35dfa6c811aedf23b277d7a009ed68013cfcfc31 Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Tue, 22 Sep 2015 10:19:41 +0200 Subject: [PATCH 42/93] Remove goog.isDef from dragrotateandzoominteraction --- src/ol/interaction/dragrotateandzoominteraction.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ol/interaction/dragrotateandzoominteraction.js b/src/ol/interaction/dragrotateandzoominteraction.js index fef67b9f9c..f764286ce3 100644 --- a/src/ol/interaction/dragrotateandzoominteraction.js +++ b/src/ol/interaction/dragrotateandzoominteraction.js @@ -26,7 +26,7 @@ goog.require('ol.interaction.Pointer'); */ ol.interaction.DragRotateAndZoom = function(opt_options) { - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = opt_options ? opt_options : {}; goog.base(this, { handleDownEvent: ol.interaction.DragRotateAndZoom.handleDownEvent_, @@ -38,7 +38,7 @@ ol.interaction.DragRotateAndZoom = function(opt_options) { * @private * @type {ol.events.ConditionType} */ - this.condition_ = goog.isDef(options.condition) ? + this.condition_ = options.condition ? options.condition : ol.events.condition.shiftKeyOnly; /** @@ -63,7 +63,7 @@ ol.interaction.DragRotateAndZoom = function(opt_options) { * @private * @type {number} */ - this.duration_ = goog.isDef(options.duration) ? options.duration : 400; + this.duration_ = options.duration ? options.duration : 400; }; goog.inherits(ol.interaction.DragRotateAndZoom, ol.interaction.Pointer); @@ -89,17 +89,17 @@ ol.interaction.DragRotateAndZoom.handleDragEvent_ = function(mapBrowserEvent) { var magnitude = delta.magnitude(); var view = map.getView(); map.render(); - if (goog.isDef(this.lastAngle_)) { + if (this.lastAngle_ !== undefined) { var angleDelta = theta - this.lastAngle_; ol.interaction.Interaction.rotateWithoutConstraints( map, view, view.getRotation() - angleDelta); } this.lastAngle_ = theta; - if (goog.isDef(this.lastMagnitude_)) { + if (this.lastMagnitude_ !== undefined) { var resolution = this.lastMagnitude_ * (view.getResolution() / magnitude); ol.interaction.Interaction.zoomWithoutConstraints(map, view, resolution); } - if (goog.isDef(this.lastMagnitude_)) { + if (this.lastMagnitude_ !== undefined) { this.lastScaleDelta_ = this.lastMagnitude_ / magnitude; } this.lastMagnitude_ = magnitude; From 08699e2b0408d94a5a68bead9d6ebeaf4cfc0953 Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Tue, 22 Sep 2015 10:19:58 +0200 Subject: [PATCH 43/93] Remove goog.isDef from dragrotateinteraction --- src/ol/interaction/dragrotateinteraction.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ol/interaction/dragrotateinteraction.js b/src/ol/interaction/dragrotateinteraction.js index 476cf1778f..d5815a08c8 100644 --- a/src/ol/interaction/dragrotateinteraction.js +++ b/src/ol/interaction/dragrotateinteraction.js @@ -23,7 +23,7 @@ goog.require('ol.interaction.Pointer'); */ ol.interaction.DragRotate = function(opt_options) { - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = opt_options ? opt_options : {}; goog.base(this, { handleDownEvent: ol.interaction.DragRotate.handleDownEvent_, @@ -35,7 +35,7 @@ ol.interaction.DragRotate = function(opt_options) { * @private * @type {ol.events.ConditionType} */ - this.condition_ = goog.isDef(options.condition) ? + this.condition_ = options.condition ? options.condition : ol.events.condition.altShiftKeysOnly; /** @@ -48,7 +48,7 @@ ol.interaction.DragRotate = function(opt_options) { * @private * @type {number} */ - this.duration_ = goog.isDef(options.duration) ? options.duration : 250; + this.duration_ = options.duration ? options.duration : 250; }; goog.inherits(ol.interaction.DragRotate, ol.interaction.Pointer); @@ -68,7 +68,7 @@ ol.interaction.DragRotate.handleDragEvent_ = function(mapBrowserEvent) { var offset = mapBrowserEvent.pixel; var theta = Math.atan2(size[1] / 2 - offset[1], offset[0] - size[0] / 2); - if (goog.isDef(this.lastAngle_)) { + if (this.lastAngle_ !== undefined) { var delta = theta - this.lastAngle_; var view = map.getView(); var rotation = view.getRotation(); From c56ee197634afea305eafc9d043b254950d770b7 Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Tue, 22 Sep 2015 10:20:20 +0200 Subject: [PATCH 44/93] Remove goog.isDef from dragzoominteraction --- src/ol/interaction/dragzoominteraction.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/ol/interaction/dragzoominteraction.js b/src/ol/interaction/dragzoominteraction.js index 83e82cafdf..82eefa25ff 100644 --- a/src/ol/interaction/dragzoominteraction.js +++ b/src/ol/interaction/dragzoominteraction.js @@ -23,22 +23,22 @@ goog.require('ol.style.Style'); * @api stable */ ol.interaction.DragZoom = function(opt_options) { - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = opt_options ? opt_options : {}; - var condition = goog.isDef(options.condition) ? + var condition = options.condition ? options.condition : ol.events.condition.shiftKeyOnly; /** * @private * @type {number} */ - this.duration_ = goog.isDef(options.duration) ? options.duration : 200; + this.duration_ = options.duration ? options.duration : 200; /** * @private * @type {ol.style.Style} */ - var style = goog.isDef(options.style) ? + var style = options.style ? options.style : new ol.style.Style({ stroke: new ol.style.Stroke({ color: [0, 0, 255, 1] @@ -64,7 +64,7 @@ ol.interaction.DragZoom.prototype.onBoxEnd = function() { goog.asserts.assert(!goog.isNull(view), 'view should not be null'); var size = map.getSize(); - goog.asserts.assert(goog.isDef(size), 'size should be defined'); + goog.asserts.assert(size !== undefined, 'size should be defined'); var extent = this.getGeometry().getExtent(); @@ -72,10 +72,10 @@ ol.interaction.DragZoom.prototype.onBoxEnd = function() { view.getResolutionForExtent(extent, size)); var currentResolution = view.getResolution(); - goog.asserts.assert(goog.isDef(currentResolution), 'res should be defined'); + goog.asserts.assert(currentResolution !== undefined, 'res should be defined'); var currentCenter = view.getCenter(); - goog.asserts.assert(goog.isDef(currentCenter), 'center should be defined'); + goog.asserts.assert(currentCenter !== undefined, 'center should be defined'); map.beforeRender(ol.animation.zoom({ resolution: currentResolution, From 293c65088d31a566c914f0ef90c9edd1c9bac95c Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Tue, 22 Sep 2015 10:20:38 +0200 Subject: [PATCH 45/93] Remove goog.isDef from interaction --- src/ol/interaction/interaction.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/ol/interaction/interaction.js b/src/ol/interaction/interaction.js index 2e45101983..a4e15be650 100644 --- a/src/ol/interaction/interaction.js +++ b/src/ol/interaction/interaction.js @@ -107,8 +107,8 @@ ol.interaction.Interaction.prototype.setMap = function(map) { */ ol.interaction.Interaction.pan = function(map, view, delta, opt_duration) { var currentCenter = view.getCenter(); - if (goog.isDef(currentCenter)) { - if (goog.isDef(opt_duration) && opt_duration > 0) { + if (currentCenter) { + if (opt_duration && opt_duration > 0) { map.beforeRender(ol.animation.pan({ source: currentCenter, duration: opt_duration, @@ -149,14 +149,14 @@ ol.interaction.Interaction.rotateWithoutConstraints = if (goog.isDefAndNotNull(rotation)) { var currentRotation = view.getRotation(); var currentCenter = view.getCenter(); - if (goog.isDef(currentRotation) && goog.isDef(currentCenter) && - goog.isDef(opt_duration) && opt_duration > 0) { + if (currentRotation !== undefined && currentCenter && + opt_duration && opt_duration > 0) { map.beforeRender(ol.animation.rotate({ rotation: currentRotation, duration: opt_duration, easing: ol.easing.easeOut })); - if (goog.isDef(opt_anchor)) { + if (opt_anchor) { map.beforeRender(ol.animation.pan({ source: currentCenter, duration: opt_duration, @@ -220,14 +220,14 @@ ol.interaction.Interaction.zoomWithoutConstraints = if (goog.isDefAndNotNull(resolution)) { var currentResolution = view.getResolution(); var currentCenter = view.getCenter(); - if (goog.isDef(currentResolution) && goog.isDef(currentCenter) && - goog.isDef(opt_duration) && opt_duration > 0) { + if (currentResolution !== undefined && currentCenter && + opt_duration && opt_duration > 0) { map.beforeRender(ol.animation.zoom({ resolution: currentResolution, duration: opt_duration, easing: ol.easing.easeOut })); - if (goog.isDef(opt_anchor)) { + if (opt_anchor) { map.beforeRender(ol.animation.pan({ source: currentCenter, duration: opt_duration, From 241047795f448d9da3ca8519770ed92d8b3b531a Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Tue, 22 Sep 2015 10:20:54 +0200 Subject: [PATCH 46/93] Remove goog.isDef from interactiondefaults --- src/ol/interaction/interactiondefaults.js | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/ol/interaction/interactiondefaults.js b/src/ol/interaction/interactiondefaults.js index 4b0815a9ad..081e22927c 100644 --- a/src/ol/interaction/interactiondefaults.js +++ b/src/ol/interaction/interactiondefaults.js @@ -41,19 +41,19 @@ goog.require('ol.interaction.PinchZoom'); */ ol.interaction.defaults = function(opt_options) { - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = opt_options ? opt_options : {}; var interactions = new ol.Collection(); var kinetic = new ol.Kinetic(-0.005, 0.05, 100); - var altShiftDragRotate = goog.isDef(options.altShiftDragRotate) ? + var altShiftDragRotate = options.altShiftDragRotate !== undefined ? options.altShiftDragRotate : true; if (altShiftDragRotate) { interactions.push(new ol.interaction.DragRotate()); } - var doubleClickZoom = goog.isDef(options.doubleClickZoom) ? + var doubleClickZoom = options.doubleClickZoom !== undefined ? options.doubleClickZoom : true; if (doubleClickZoom) { interactions.push(new ol.interaction.DoubleClickZoom({ @@ -62,30 +62,27 @@ ol.interaction.defaults = function(opt_options) { })); } - var dragPan = goog.isDef(options.dragPan) ? - options.dragPan : true; + var dragPan = options.dragPan !== undefined ? options.dragPan : true; if (dragPan) { interactions.push(new ol.interaction.DragPan({ kinetic: kinetic })); } - var pinchRotate = goog.isDef(options.pinchRotate) ? - options.pinchRotate : true; + var pinchRotate = options.pinchRotate !== undefined ? options.pinchRotate : + true; if (pinchRotate) { interactions.push(new ol.interaction.PinchRotate()); } - var pinchZoom = goog.isDef(options.pinchZoom) ? - options.pinchZoom : true; + var pinchZoom = options.pinchZoom !== undefined ? options.pinchZoom : true; if (pinchZoom) { interactions.push(new ol.interaction.PinchZoom({ duration: options.zoomDuration })); } - var keyboard = goog.isDef(options.keyboard) ? - options.keyboard : true; + var keyboard = options.keyboard !== undefined ? options.keyboard : true; if (keyboard) { interactions.push(new ol.interaction.KeyboardPan()); interactions.push(new ol.interaction.KeyboardZoom({ @@ -94,7 +91,7 @@ ol.interaction.defaults = function(opt_options) { })); } - var mouseWheelZoom = goog.isDef(options.mouseWheelZoom) ? + var mouseWheelZoom = options.mouseWheelZoom !== undefined ? options.mouseWheelZoom : true; if (mouseWheelZoom) { interactions.push(new ol.interaction.MouseWheelZoom({ @@ -102,7 +99,7 @@ ol.interaction.defaults = function(opt_options) { })); } - var shiftDragZoom = goog.isDef(options.shiftDragZoom) ? + var shiftDragZoom = options.shiftDragZoom !== undefined ? options.shiftDragZoom : true; if (shiftDragZoom) { interactions.push(new ol.interaction.DragZoom()); From bd7ff165379f72c05bda87e8d691ea8b92d6dfd5 Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Tue, 22 Sep 2015 10:21:09 +0200 Subject: [PATCH 47/93] Remove goog.isDef from keyboardzoominteraction --- src/ol/interaction/keyboardzoominteraction.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ol/interaction/keyboardzoominteraction.js b/src/ol/interaction/keyboardzoominteraction.js index 7965fd0aa2..9245d07191 100644 --- a/src/ol/interaction/keyboardzoominteraction.js +++ b/src/ol/interaction/keyboardzoominteraction.js @@ -31,26 +31,26 @@ ol.interaction.KeyboardZoom = function(opt_options) { handleEvent: ol.interaction.KeyboardZoom.handleEvent }); - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = opt_options ? opt_options : {}; /** * @private * @type {ol.events.ConditionType} */ - this.condition_ = goog.isDef(options.condition) ? options.condition : + this.condition_ = options.condition ? options.condition : ol.events.condition.targetNotEditable; /** * @private * @type {number} */ - this.delta_ = goog.isDef(options.delta) ? options.delta : 1; + this.delta_ = options.delta ? options.delta : 1; /** * @private * @type {number} */ - this.duration_ = goog.isDef(options.duration) ? options.duration : 100; + this.duration_ = options.duration ? options.duration : 100; }; goog.inherits(ol.interaction.KeyboardZoom, ol.interaction.Interaction); From 0e4c73072f02ccc136b42569c9f8d1833b3dc4d5 Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Tue, 22 Sep 2015 10:21:29 +0200 Subject: [PATCH 48/93] Remove goog.isDef from modifyinteraction --- src/ol/interaction/modifyinteraction.js | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/ol/interaction/modifyinteraction.js b/src/ol/interaction/modifyinteraction.js index d2d17210e5..cb8989cd07 100644 --- a/src/ol/interaction/modifyinteraction.js +++ b/src/ol/interaction/modifyinteraction.js @@ -116,7 +116,7 @@ ol.interaction.Modify = function(options) { * @type {ol.events.ConditionType} * @private */ - this.deleteCondition_ = goog.isDef(options.deleteCondition) ? + this.deleteCondition_ = options.deleteCondition ? options.deleteCondition : /** @type {ol.events.ConditionType} */ (goog.functions.and( ol.events.condition.noModifierKeys, @@ -161,8 +161,7 @@ ol.interaction.Modify = function(options) { * @type {number} * @private */ - this.pixelTolerance_ = goog.isDef(options.pixelTolerance) ? - options.pixelTolerance : 10; + this.pixelTolerance_ = options.pixelTolerance ? options.pixelTolerance : 10; /** * @type {boolean} @@ -192,9 +191,9 @@ ol.interaction.Modify = function(options) { this.overlay_ = new ol.layer.Vector({ source: new ol.source.Vector({ useSpatialIndex: false, - wrapX: goog.isDef(options.wrapX) ? options.wrapX : false + wrapX: options.wrapX ? options.wrapX : false }), - style: goog.isDef(options.style) ? options.style : + style: options.style ? options.style : ol.interaction.Modify.getDefaultStyleFunction(), updateWhileAnimating: true, updateWhileInteracting: true @@ -238,7 +237,7 @@ goog.inherits(ol.interaction.Modify, ol.interaction.Pointer); */ ol.interaction.Modify.prototype.addFeature_ = function(feature) { var geometry = feature.getGeometry(); - if (goog.isDef(this.SEGMENT_WRITERS_[geometry.getType()])) { + if (this.SEGMENT_WRITERS_[geometry.getType()]) { this.SEGMENT_WRITERS_[geometry.getType()].call(this, feature, geometry); } var map = this.getMap(); @@ -822,9 +821,9 @@ ol.interaction.Modify.prototype.insertVertex_ = function(segmentData, vertex) { this.setGeometryCoordinates_(geometry, coordinates); var rTree = this.rBush_; - goog.asserts.assert(goog.isDef(segment), 'segment should be defined'); + goog.asserts.assert(segment !== undefined, 'segment should be defined'); rTree.remove(segmentData); - goog.asserts.assert(goog.isDef(index), 'index should be defined'); + goog.asserts.assert(index !== undefined, 'index should be defined'); this.updateSegmentIndices_(geometry, index, depth, 1); var newSegmentData = /** @type {ol.interaction.SegmentDataType} */ ({ segment: [segment[0], vertex], @@ -883,13 +882,13 @@ ol.interaction.Modify.prototype.removeVertex_ = function() { segmentsByFeature[uid] = [left, right, index]; } newSegment = segmentsByFeature[uid]; - if (goog.isDef(left)) { + if (left !== undefined) { newSegment[0] = left; } - if (goog.isDef(right)) { + if (right !== undefined) { newSegment[1] = right; } - if (goog.isDef(newSegment[0]) && goog.isDef(newSegment[1])) { + if (newSegment[0] !== undefined && newSegment[1] !== undefined) { component = coordinates; deleted = false; newIndex = index - 1; @@ -974,7 +973,7 @@ ol.interaction.Modify.prototype.updateSegmentIndices_ = function( geometry, index, depth, delta) { this.rBush_.forEachInExtent(geometry.getExtent(), function(segmentDataMatch) { if (segmentDataMatch.geometry === geometry && - (!goog.isDef(depth) || !goog.isDef(segmentDataMatch.depth) || + (depth === undefined || segmentDataMatch.depth === undefined || goog.array.equals(segmentDataMatch.depth, depth)) && segmentDataMatch.index > index) { segmentDataMatch.index += delta; From 68442578bacd5b07b657fa06ae4f823ce964edf7 Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Tue, 22 Sep 2015 10:55:46 +0200 Subject: [PATCH 49/93] Use ol.isDef when checking booleans --- src/ol/geom/linestring.js | 4 +++- .../interaction/dragrotateandzoominteraction.js | 7 ++++--- src/ol/interaction/dragrotateinteraction.js | 3 ++- src/ol/interaction/interaction.js | 7 ++++--- src/ol/interaction/interactiondefaults.js | 17 +++++++++-------- src/ol/interaction/modifyinteraction.js | 7 ++++--- 6 files changed, 26 insertions(+), 19 deletions(-) diff --git a/src/ol/geom/linestring.js b/src/ol/geom/linestring.js index 7305604068..3aeb2980ff 100644 --- a/src/ol/geom/linestring.js +++ b/src/ol/geom/linestring.js @@ -2,6 +2,7 @@ goog.provide('ol.geom.LineString'); goog.require('goog.array'); goog.require('goog.asserts'); +goog.require('ol'); goog.require('ol.extent'); goog.require('ol.geom.GeometryLayout'); goog.require('ol.geom.GeometryType'); @@ -148,7 +149,8 @@ ol.geom.LineString.prototype.getCoordinateAtM = function(m, opt_extrapolate) { this.layout != ol.geom.GeometryLayout.XYZM) { return null; } - var extrapolate = opt_extrapolate ? opt_extrapolate : false; + var extrapolate = ol.isDef(opt_extrapolate) ? + /** @type {boolean} */ (opt_extrapolate) : false; return ol.geom.flat.lineStringCoordinateAtM(this.flatCoordinates, 0, this.flatCoordinates.length, this.stride, m, extrapolate); }; diff --git a/src/ol/interaction/dragrotateandzoominteraction.js b/src/ol/interaction/dragrotateandzoominteraction.js index f764286ce3..c0c8f6df8d 100644 --- a/src/ol/interaction/dragrotateandzoominteraction.js +++ b/src/ol/interaction/dragrotateandzoominteraction.js @@ -1,6 +1,7 @@ goog.provide('ol.interaction.DragRotateAndZoom'); goog.require('goog.math.Vec2'); +goog.require('ol'); goog.require('ol.ViewHint'); goog.require('ol.events.ConditionType'); goog.require('ol.events.condition'); @@ -89,17 +90,17 @@ ol.interaction.DragRotateAndZoom.handleDragEvent_ = function(mapBrowserEvent) { var magnitude = delta.magnitude(); var view = map.getView(); map.render(); - if (this.lastAngle_ !== undefined) { + if (ol.isDef(this.lastAngle_)) { var angleDelta = theta - this.lastAngle_; ol.interaction.Interaction.rotateWithoutConstraints( map, view, view.getRotation() - angleDelta); } this.lastAngle_ = theta; - if (this.lastMagnitude_ !== undefined) { + if (ol.isDef(this.lastMagnitude_)) { var resolution = this.lastMagnitude_ * (view.getResolution() / magnitude); ol.interaction.Interaction.zoomWithoutConstraints(map, view, resolution); } - if (this.lastMagnitude_ !== undefined) { + if (ol.isDef(this.lastMagnitude_)) { this.lastScaleDelta_ = this.lastMagnitude_ / magnitude; } this.lastMagnitude_ = magnitude; diff --git a/src/ol/interaction/dragrotateinteraction.js b/src/ol/interaction/dragrotateinteraction.js index d5815a08c8..c7a97d752b 100644 --- a/src/ol/interaction/dragrotateinteraction.js +++ b/src/ol/interaction/dragrotateinteraction.js @@ -1,5 +1,6 @@ goog.provide('ol.interaction.DragRotate'); +goog.require('ol'); goog.require('ol.ViewHint'); goog.require('ol.events.ConditionType'); goog.require('ol.events.condition'); @@ -68,7 +69,7 @@ ol.interaction.DragRotate.handleDragEvent_ = function(mapBrowserEvent) { var offset = mapBrowserEvent.pixel; var theta = Math.atan2(size[1] / 2 - offset[1], offset[0] - size[0] / 2); - if (this.lastAngle_ !== undefined) { + if (ol.isDef(this.lastAngle_)) { var delta = theta - this.lastAngle_; var view = map.getView(); var rotation = view.getRotation(); diff --git a/src/ol/interaction/interaction.js b/src/ol/interaction/interaction.js index a4e15be650..fc592ec716 100644 --- a/src/ol/interaction/interaction.js +++ b/src/ol/interaction/interaction.js @@ -3,6 +3,7 @@ goog.provide('ol.interaction.Interaction'); goog.provide('ol.interaction.InteractionProperty'); +goog.require('ol'); goog.require('ol.MapBrowserEvent'); goog.require('ol.Object'); goog.require('ol.animation'); @@ -149,7 +150,7 @@ ol.interaction.Interaction.rotateWithoutConstraints = if (goog.isDefAndNotNull(rotation)) { var currentRotation = view.getRotation(); var currentCenter = view.getCenter(); - if (currentRotation !== undefined && currentCenter && + if (ol.isDef(currentRotation) && currentCenter && opt_duration && opt_duration > 0) { map.beforeRender(ol.animation.rotate({ rotation: currentRotation, @@ -220,10 +221,10 @@ ol.interaction.Interaction.zoomWithoutConstraints = if (goog.isDefAndNotNull(resolution)) { var currentResolution = view.getResolution(); var currentCenter = view.getCenter(); - if (currentResolution !== undefined && currentCenter && + if (ol.isDef(currentResolution) && currentCenter && opt_duration && opt_duration > 0) { map.beforeRender(ol.animation.zoom({ - resolution: currentResolution, + resolution: /** @type {number} */ (currentResolution), duration: opt_duration, easing: ol.easing.easeOut })); diff --git a/src/ol/interaction/interactiondefaults.js b/src/ol/interaction/interactiondefaults.js index 081e22927c..2d40d36d26 100644 --- a/src/ol/interaction/interactiondefaults.js +++ b/src/ol/interaction/interactiondefaults.js @@ -1,5 +1,6 @@ goog.provide('ol.interaction'); +goog.require('ol'); goog.require('ol.Collection'); goog.require('ol.Kinetic'); goog.require('ol.interaction.DoubleClickZoom'); @@ -47,13 +48,13 @@ ol.interaction.defaults = function(opt_options) { var kinetic = new ol.Kinetic(-0.005, 0.05, 100); - var altShiftDragRotate = options.altShiftDragRotate !== undefined ? + var altShiftDragRotate = ol.isDef(options.altShiftDragRotate) ? options.altShiftDragRotate : true; if (altShiftDragRotate) { interactions.push(new ol.interaction.DragRotate()); } - var doubleClickZoom = options.doubleClickZoom !== undefined ? + var doubleClickZoom = ol.isDef(options.doubleClickZoom) ? options.doubleClickZoom : true; if (doubleClickZoom) { interactions.push(new ol.interaction.DoubleClickZoom({ @@ -62,27 +63,27 @@ ol.interaction.defaults = function(opt_options) { })); } - var dragPan = options.dragPan !== undefined ? options.dragPan : true; + var dragPan = ol.isDef(options.dragPan) ? options.dragPan : true; if (dragPan) { interactions.push(new ol.interaction.DragPan({ kinetic: kinetic })); } - var pinchRotate = options.pinchRotate !== undefined ? options.pinchRotate : + var pinchRotate = ol.isDef(options.pinchRotate) ? options.pinchRotate : true; if (pinchRotate) { interactions.push(new ol.interaction.PinchRotate()); } - var pinchZoom = options.pinchZoom !== undefined ? options.pinchZoom : true; + var pinchZoom = ol.isDef(options.pinchZoom) ? options.pinchZoom : true; if (pinchZoom) { interactions.push(new ol.interaction.PinchZoom({ duration: options.zoomDuration })); } - var keyboard = options.keyboard !== undefined ? options.keyboard : true; + var keyboard = ol.isDef(options.keyboard) ? options.keyboard : true; if (keyboard) { interactions.push(new ol.interaction.KeyboardPan()); interactions.push(new ol.interaction.KeyboardZoom({ @@ -91,7 +92,7 @@ ol.interaction.defaults = function(opt_options) { })); } - var mouseWheelZoom = options.mouseWheelZoom !== undefined ? + var mouseWheelZoom = ol.isDef(options.mouseWheelZoom) ? options.mouseWheelZoom : true; if (mouseWheelZoom) { interactions.push(new ol.interaction.MouseWheelZoom({ @@ -99,7 +100,7 @@ ol.interaction.defaults = function(opt_options) { })); } - var shiftDragZoom = options.shiftDragZoom !== undefined ? + var shiftDragZoom = ol.isDef(options.shiftDragZoom) ? options.shiftDragZoom : true; if (shiftDragZoom) { interactions.push(new ol.interaction.DragZoom()); diff --git a/src/ol/interaction/modifyinteraction.js b/src/ol/interaction/modifyinteraction.js index cb8989cd07..fa2a5040ff 100644 --- a/src/ol/interaction/modifyinteraction.js +++ b/src/ol/interaction/modifyinteraction.js @@ -7,6 +7,7 @@ goog.require('goog.events'); goog.require('goog.events.Event'); goog.require('goog.events.EventType'); goog.require('goog.functions'); +goog.require('ol'); goog.require('ol.Collection'); goog.require('ol.CollectionEventType'); goog.require('ol.Feature'); @@ -882,13 +883,13 @@ ol.interaction.Modify.prototype.removeVertex_ = function() { segmentsByFeature[uid] = [left, right, index]; } newSegment = segmentsByFeature[uid]; - if (left !== undefined) { + if (ol.isDef(left)) { newSegment[0] = left; } - if (right !== undefined) { + if (ol.isDef(right)) { newSegment[1] = right; } - if (newSegment[0] !== undefined && newSegment[1] !== undefined) { + if (ol.isDef(newSegment[0]) && ol.isDef(newSegment[1])) { component = coordinates; deleted = false; newIndex = index - 1; From 05da0ceaab92bc3d477c8cecbcf6161ecd38890a Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Wed, 23 Sep 2015 13:18:03 +0200 Subject: [PATCH 50/93] Use ol.isDef when testing options.duration --- src/ol/animation.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/ol/animation.js b/src/ol/animation.js index 9539d7c27b..c0f4986afd 100644 --- a/src/ol/animation.js +++ b/src/ol/animation.js @@ -1,5 +1,6 @@ goog.provide('ol.animation'); +goog.require('ol'); goog.require('ol.PreRenderFunction'); goog.require('ol.ViewHint'); goog.require('ol.coordinate'); @@ -16,7 +17,7 @@ goog.require('ol.easing'); ol.animation.bounce = function(options) { var resolution = options.resolution; var start = options.start ? options.start : goog.now(); - var duration = options.duration ? options.duration : 1000; + var duration = ol.isDef(options.duration) ? options.duration : 1000; var easing = options.easing ? options.easing : ol.easing.upAndDown; return ( @@ -54,7 +55,7 @@ ol.animation.pan = function(options) { var start = options.start ? options.start : goog.now(); var sourceX = source[0]; var sourceY = source[1]; - var duration = options.duration ? options.duration : 1000; + var duration = ol.isDef(options.duration) ? options.duration : 1000; var easing = options.easing ? options.easing : ol.easing.inAndOut; return ( @@ -92,7 +93,7 @@ ol.animation.pan = function(options) { ol.animation.rotate = function(options) { var sourceRotation = options.rotation ? options.rotation : 0; var start = options.start ? options.start : goog.now(); - var duration = options.duration ? options.duration : 1000; + var duration = ol.isDef(options.duration) ? options.duration : 1000; var easing = options.easing ? options.easing : ol.easing.inAndOut; var anchor = options.anchor ? @@ -138,7 +139,7 @@ ol.animation.rotate = function(options) { ol.animation.zoom = function(options) { var sourceResolution = options.resolution; var start = options.start ? options.start : goog.now(); - var duration = options.duration ? options.duration : 1000; + var duration = ol.isDef(options.duration) ? options.duration : 1000; var easing = options.easing ? options.easing : ol.easing.inAndOut; return ( From 13273fb632b3148e1d075b6a044c6befd8a2d433 Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Wed, 23 Sep 2015 20:06:54 +0200 Subject: [PATCH 51/93] Add explicit type casts for options.duration --- src/ol/animation.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/ol/animation.js b/src/ol/animation.js index c0f4986afd..430eb6fa79 100644 --- a/src/ol/animation.js +++ b/src/ol/animation.js @@ -17,7 +17,8 @@ goog.require('ol.easing'); ol.animation.bounce = function(options) { var resolution = options.resolution; var start = options.start ? options.start : goog.now(); - var duration = ol.isDef(options.duration) ? options.duration : 1000; + var duration = ol.isDef(options.duration) ? + /** @type {number} */ (options.duration) : 1000; var easing = options.easing ? options.easing : ol.easing.upAndDown; return ( @@ -55,7 +56,8 @@ ol.animation.pan = function(options) { var start = options.start ? options.start : goog.now(); var sourceX = source[0]; var sourceY = source[1]; - var duration = ol.isDef(options.duration) ? options.duration : 1000; + var duration = ol.isDef(options.duration) ? + /** @type {number} */ (options.duration) : 1000; var easing = options.easing ? options.easing : ol.easing.inAndOut; return ( @@ -93,7 +95,8 @@ ol.animation.pan = function(options) { ol.animation.rotate = function(options) { var sourceRotation = options.rotation ? options.rotation : 0; var start = options.start ? options.start : goog.now(); - var duration = ol.isDef(options.duration) ? options.duration : 1000; + var duration = ol.isDef(options.duration) ? + /** @type {number} */ (options.duration) : 1000; var easing = options.easing ? options.easing : ol.easing.inAndOut; var anchor = options.anchor ? @@ -139,7 +142,8 @@ ol.animation.rotate = function(options) { ol.animation.zoom = function(options) { var sourceResolution = options.resolution; var start = options.start ? options.start : goog.now(); - var duration = ol.isDef(options.duration) ? options.duration : 1000; + var duration = ol.isDef(options.duration) ? + /** @type {number} */ (options.duration) : 1000; var easing = options.easing ? options.easing : ol.easing.inAndOut; return ( From 20b694b8c19cfd5a8e482fd6a14f243df6970fe3 Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Wed, 23 Sep 2015 20:13:08 +0200 Subject: [PATCH 52/93] Remove goog.isDef from keyboardpaninteraction --- src/ol/interaction/keyboardpaninteraction.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/ol/interaction/keyboardpaninteraction.js b/src/ol/interaction/keyboardpaninteraction.js index a8c8335331..5f9c87340b 100644 --- a/src/ol/interaction/keyboardpaninteraction.js +++ b/src/ol/interaction/keyboardpaninteraction.js @@ -4,6 +4,7 @@ goog.require('goog.asserts'); goog.require('goog.events.KeyCodes'); goog.require('goog.events.KeyHandler.EventType'); goog.require('goog.functions'); +goog.require('ol'); goog.require('ol.coordinate'); goog.require('ol.events.ConditionType'); goog.require('ol.events.condition'); @@ -34,13 +35,14 @@ ol.interaction.KeyboardPan = function(opt_options) { handleEvent: ol.interaction.KeyboardPan.handleEvent }); - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = ol.isDef(opt_options) ? opt_options : {}; /** * @private * @type {ol.events.ConditionType} */ - this.condition_ = goog.isDef(options.condition) ? options.condition : + this.condition_ = ol.isDef(options.condition) ? + /** @type {ol.events.ConditionType} */ (options.condition) : goog.functions.and(ol.events.condition.noModifierKeys, ol.events.condition.targetNotEditable); @@ -48,13 +50,15 @@ ol.interaction.KeyboardPan = function(opt_options) { * @private * @type {number} */ - this.duration_ = goog.isDef(options.duration) ? options.duration : 100; + this.duration_ = ol.isDef(options.duration) ? + /** @type {number} */ (options.duration) : 100; /** * @private * @type {number} */ - this.pixelDelta_ = goog.isDef(options.pixelDelta) ? options.pixelDelta : 128; + this.pixelDelta_ = ol.isDef(options.pixelDelta) ? + /** @type {number} */ (options.pixelDelta) : 128; }; goog.inherits(ol.interaction.KeyboardPan, ol.interaction.Interaction); From 10d4aeb1c6b9a0b4c7c67d6c284f5abb7a7802cf Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Wed, 23 Sep 2015 20:13:25 +0200 Subject: [PATCH 53/93] Remove goog.isDef from mousewheelzoominteraction --- src/ol/interaction/mousewheelzoominteraction.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/ol/interaction/mousewheelzoominteraction.js b/src/ol/interaction/mousewheelzoominteraction.js index c9d1d6bb74..6b7d75d651 100644 --- a/src/ol/interaction/mousewheelzoominteraction.js +++ b/src/ol/interaction/mousewheelzoominteraction.js @@ -25,7 +25,7 @@ ol.interaction.MouseWheelZoom = function(opt_options) { handleEvent: ol.interaction.MouseWheelZoom.handleEvent }); - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = ol.isDef(opt_options) ? opt_options : {}; /** * @private @@ -37,14 +37,15 @@ ol.interaction.MouseWheelZoom = function(opt_options) { * @private * @type {number} */ - this.duration_ = goog.isDef(options.duration) ? options.duration : 250; + this.duration_ = ol.isDef(options.duration) ? + /** @type {number} */ (options.duration) : 250; /** * @private * @type {boolean} */ - this.useAnchor_ = goog.isDef(options.useAnchor) ? - options.useAnchor : true; + this.useAnchor_ = ol.isDef(options.useAnchor) ? + /** @type {boolean} */ (options.useAnchor) : true; /** * @private @@ -91,7 +92,7 @@ ol.interaction.MouseWheelZoom.handleEvent = function(mapBrowserEvent) { this.delta_ += mouseWheelEvent.deltaY; - if (!goog.isDef(this.startTime_)) { + if (!ol.isDef(this.startTime_)) { this.startTime_ = goog.now(); } From c7a98f19b7e0e121d75ca8ff20b97b77c82db865 Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Wed, 23 Sep 2015 20:13:40 +0200 Subject: [PATCH 54/93] Remove goog.isDef from pinchrotateinteraction --- src/ol/interaction/pinchrotateinteraction.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/ol/interaction/pinchrotateinteraction.js b/src/ol/interaction/pinchrotateinteraction.js index 7cae131e17..462fe5ad18 100644 --- a/src/ol/interaction/pinchrotateinteraction.js +++ b/src/ol/interaction/pinchrotateinteraction.js @@ -3,6 +3,7 @@ goog.provide('ol.interaction.PinchRotate'); goog.require('goog.asserts'); goog.require('goog.functions'); goog.require('goog.style'); +goog.require('ol'); goog.require('ol.Coordinate'); goog.require('ol.ViewHint'); goog.require('ol.interaction.Interaction'); @@ -28,7 +29,7 @@ ol.interaction.PinchRotate = function(opt_options) { handleUpEvent: ol.interaction.PinchRotate.handleUpEvent_ }); - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = ol.isDef(opt_options) ? opt_options : {}; /** * @private @@ -58,13 +59,15 @@ ol.interaction.PinchRotate = function(opt_options) { * @private * @type {number} */ - this.threshold_ = goog.isDef(options.threshold) ? options.threshold : 0.3; + this.threshold_ = ol.isDef(options.threshold) ? + /** @type {number} */ (options.threshold) : 0.3; /** * @private * @type {number} */ - this.duration_ = goog.isDef(options.duration) ? options.duration : 250; + this.duration_ = ol.isDef(options.duration) ? + /** @type {number} */ (options.duration) : 250; }; goog.inherits(ol.interaction.PinchRotate, ol.interaction.Pointer); @@ -88,7 +91,7 @@ ol.interaction.PinchRotate.handleDragEvent_ = function(mapBrowserEvent) { touch1.clientY - touch0.clientY, touch1.clientX - touch0.clientX); - if (goog.isDef(this.lastAngle_)) { + if (ol.isDef(this.lastAngle_)) { var delta = angle - this.lastAngle_; this.rotationDelta_ += delta; if (!this.rotating_ && From 779811b52d23aa803227eb80fd52814580524fc6 Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Wed, 23 Sep 2015 20:13:56 +0200 Subject: [PATCH 55/93] Remove goog.isDef from pinchzoominteraction --- src/ol/interaction/pinchzoominteraction.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/ol/interaction/pinchzoominteraction.js b/src/ol/interaction/pinchzoominteraction.js index b4195ef6b4..7ff5b8f0c2 100644 --- a/src/ol/interaction/pinchzoominteraction.js +++ b/src/ol/interaction/pinchzoominteraction.js @@ -3,6 +3,7 @@ goog.provide('ol.interaction.PinchZoom'); goog.require('goog.asserts'); goog.require('goog.functions'); goog.require('goog.style'); +goog.require('ol'); goog.require('ol.Coordinate'); goog.require('ol.ViewHint'); goog.require('ol.interaction.Interaction'); @@ -28,7 +29,7 @@ ol.interaction.PinchZoom = function(opt_options) { handleUpEvent: ol.interaction.PinchZoom.handleUpEvent_ }); - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = opt_options ? opt_options : {}; /** * @private @@ -40,7 +41,8 @@ ol.interaction.PinchZoom = function(opt_options) { * @private * @type {number} */ - this.duration_ = goog.isDef(options.duration) ? options.duration : 400; + this.duration_ = ol.isDef(options.duration) ? + /** @type {number} */ (options.duration) : 400; /** * @private @@ -76,7 +78,7 @@ ol.interaction.PinchZoom.handleDragEvent_ = function(mapBrowserEvent) { // distance between touches var distance = Math.sqrt(dx * dx + dy * dy); - if (goog.isDef(this.lastDistance_)) { + if (ol.isDef(this.lastDistance_)) { scaleDelta = this.lastDistance_ / distance; } this.lastDistance_ = distance; From 6c581b8eafff42ebd4ea32f89d2a67b482090eb5 Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Wed, 23 Sep 2015 20:14:12 +0200 Subject: [PATCH 56/93] Remove goog.isDef from pointerinteraction --- src/ol/interaction/pointerinteraction.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ol/interaction/pointerinteraction.js b/src/ol/interaction/pointerinteraction.js index 059d1aa4d9..18cff5509d 100644 --- a/src/ol/interaction/pointerinteraction.js +++ b/src/ol/interaction/pointerinteraction.js @@ -26,9 +26,9 @@ goog.require('ol.interaction.Interaction'); */ ol.interaction.Pointer = function(opt_options) { - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = opt_options ? opt_options : {}; - var handleEvent = goog.isDef(options.handleEvent) ? + var handleEvent = options.handleEvent ? options.handleEvent : ol.interaction.Pointer.handleEvent; goog.base(this, { @@ -39,28 +39,28 @@ ol.interaction.Pointer = function(opt_options) { * @type {function(ol.MapBrowserPointerEvent):boolean} * @private */ - this.handleDownEvent_ = goog.isDef(options.handleDownEvent) ? + this.handleDownEvent_ = options.handleDownEvent ? options.handleDownEvent : ol.interaction.Pointer.handleDownEvent; /** * @type {function(ol.MapBrowserPointerEvent)} * @private */ - this.handleDragEvent_ = goog.isDef(options.handleDragEvent) ? + this.handleDragEvent_ = options.handleDragEvent ? options.handleDragEvent : ol.interaction.Pointer.handleDragEvent; /** * @type {function(ol.MapBrowserPointerEvent)} * @private */ - this.handleMoveEvent_ = goog.isDef(options.handleMoveEvent) ? + this.handleMoveEvent_ = options.handleMoveEvent ? options.handleMoveEvent : ol.interaction.Pointer.handleMoveEvent; /** * @type {function(ol.MapBrowserPointerEvent):boolean} * @private */ - this.handleUpEvent_ = goog.isDef(options.handleUpEvent) ? + this.handleUpEvent_ = options.handleUpEvent ? options.handleUpEvent : ol.interaction.Pointer.handleUpEvent; /** From 4b993727c886af7734069a1f0fbe1ab22c724390 Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Wed, 23 Sep 2015 20:14:27 +0200 Subject: [PATCH 57/93] Remove goog.isDef from selectinteraction --- src/ol/interaction/selectinteraction.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/ol/interaction/selectinteraction.js b/src/ol/interaction/selectinteraction.js index a2b5d49628..57a0d506ae 100644 --- a/src/ol/interaction/selectinteraction.js +++ b/src/ol/interaction/selectinteraction.js @@ -105,51 +105,51 @@ ol.interaction.Select = function(opt_options) { handleEvent: ol.interaction.Select.handleEvent }); - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = opt_options ? opt_options : {}; /** * @private * @type {ol.events.ConditionType} */ - this.condition_ = goog.isDef(options.condition) ? + this.condition_ = options.condition ? options.condition : ol.events.condition.singleClick; /** * @private * @type {ol.events.ConditionType} */ - this.addCondition_ = goog.isDef(options.addCondition) ? + this.addCondition_ = options.addCondition ? options.addCondition : ol.events.condition.never; /** * @private * @type {ol.events.ConditionType} */ - this.removeCondition_ = goog.isDef(options.removeCondition) ? + this.removeCondition_ = options.removeCondition ? options.removeCondition : ol.events.condition.never; /** * @private * @type {ol.events.ConditionType} */ - this.toggleCondition_ = goog.isDef(options.toggleCondition) ? + this.toggleCondition_ = options.toggleCondition ? options.toggleCondition : ol.events.condition.shiftKeyOnly; /** * @private * @type {boolean} */ - this.multi_ = goog.isDef(options.multi) ? options.multi : false; + this.multi_ = options.multi ? options.multi : false; /** * @private * @type {ol.interaction.SelectFilterFunction} */ - this.filter_ = goog.isDef(options.filter) ? options.filter : + this.filter_ = options.filter ? options.filter : goog.functions.TRUE; var layerFilter; - if (goog.isDef(options.layers)) { + if (options.layers) { if (goog.isFunction(options.layers)) { layerFilter = options.layers; } else { @@ -183,7 +183,7 @@ ol.interaction.Select = function(opt_options) { features: options.features, wrapX: options.wrapX }), - style: goog.isDef(options.style) ? options.style : + style: options.style ? options.style : ol.interaction.Select.getDefaultStyleFunction(), updateWhileAnimating: true, updateWhileInteracting: true From c1c07e2f3c43e9f043774225417e9c3bce37c8e4 Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Wed, 23 Sep 2015 20:14:41 +0200 Subject: [PATCH 58/93] Remove goog.isDef from snapinteraction --- src/ol/interaction/snapinteraction.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/ol/interaction/snapinteraction.js b/src/ol/interaction/snapinteraction.js index fceed0af19..30f8b2bbaa 100644 --- a/src/ol/interaction/snapinteraction.js +++ b/src/ol/interaction/snapinteraction.js @@ -6,6 +6,7 @@ goog.require('goog.asserts'); goog.require('goog.events'); goog.require('goog.events.EventType'); goog.require('goog.object'); +goog.require('ol'); goog.require('ol.Collection'); goog.require('ol.CollectionEvent'); goog.require('ol.CollectionEventType'); @@ -54,19 +55,19 @@ ol.interaction.Snap = function(opt_options) { handleUpEvent: ol.interaction.Snap.handleUpEvent_ }); - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = opt_options ? opt_options : {}; /** * @type {ol.source.Vector} * @private */ - this.source_ = goog.isDef(options.source) ? options.source : null; + this.source_ = options.source ? options.source : null; /** * @type {ol.Collection.} * @private */ - this.features_ = goog.isDef(options.features) ? options.features : null; + this.features_ = options.features ? options.features : null; /** * @type {Array.} @@ -114,8 +115,8 @@ ol.interaction.Snap = function(opt_options) { * @type {number} * @private */ - this.pixelTolerance_ = goog.isDef(options.pixelTolerance) ? - options.pixelTolerance : 10; + this.pixelTolerance_ = ol.isDef(options.pixelTolerance) ? + /** @type {number} */ (options.pixelTolerance) : 10; /** * @type {function(ol.interaction.Snap.SegmentDataType, ol.interaction.Snap.SegmentDataType): number} @@ -159,10 +160,11 @@ goog.inherits(ol.interaction.Snap, ol.interaction.Pointer); * @api */ ol.interaction.Snap.prototype.addFeature = function(feature, opt_listen) { - var listen = goog.isDef(opt_listen) ? opt_listen : true; + var listen = ol.isDef(opt_listen) ? + /** @type {boolean} */ (opt_listen) : true; var geometry = feature.getGeometry(); var segmentWriter = this.SEGMENT_WRITERS_[geometry.getType()]; - if (goog.isDef(segmentWriter)) { + if (segmentWriter) { var feature_uid = goog.getUid(feature); this.indexedFeaturesExtents_[feature_uid] = geometry.getExtent( ol.extent.createEmpty()); @@ -210,7 +212,7 @@ ol.interaction.Snap.prototype.getFeatures_ = function() { } else if (!goog.isNull(this.source_)) { features = this.source_.getFeatures(); } - goog.asserts.assert(goog.isDef(features), 'features should be defined'); + goog.asserts.assert(features !== undefined, 'features should be defined'); return features; }; @@ -286,7 +288,8 @@ ol.interaction.Snap.prototype.handleGeometryModify_ = function(feature, evt) { * @api */ ol.interaction.Snap.prototype.removeFeature = function(feature, opt_unlisten) { - var unlisten = goog.isDef(opt_unlisten) ? opt_unlisten : true; + var unlisten = ol.isDef(opt_unlisten) ? + /** @type {boolean} */ (opt_unlisten) : true; var feature_uid = goog.getUid(feature); var extent = this.indexedFeaturesExtents_[feature_uid]; if (extent) { From b5ecc6e43c90413314a9df853a16959e4b55bb12 Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Wed, 23 Sep 2015 20:59:50 +0200 Subject: [PATCH 59/93] Remove goog.isDef from heatmaplayer --- src/ol/layer/heatmaplayer.js | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/ol/layer/heatmaplayer.js b/src/ol/layer/heatmaplayer.js index 58f3ccae7e..a299ec5ec3 100644 --- a/src/ol/layer/heatmaplayer.js +++ b/src/ol/layer/heatmaplayer.js @@ -4,6 +4,7 @@ goog.require('goog.asserts'); goog.require('goog.events'); goog.require('goog.math'); goog.require('goog.object'); +goog.require('ol'); goog.require('ol.Object'); goog.require('ol.dom'); goog.require('ol.layer.Vector'); @@ -37,7 +38,7 @@ ol.layer.HeatmapLayerProperty = { * @api */ ol.layer.Heatmap = function(opt_options) { - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = opt_options ? opt_options : {}; var baseOptions = goog.object.clone(options); @@ -58,7 +59,8 @@ ol.layer.Heatmap = function(opt_options) { * @private * @type {number} */ - this.shadow_ = goog.isDef(options.shadow) ? options.shadow : 250; + this.shadow_ = ol.isDef(options.shadow) ? + /** @type {number} */ (options.shadow) : 250; /** * @private @@ -76,12 +78,14 @@ ol.layer.Heatmap = function(opt_options) { ol.Object.getChangeEventType(ol.layer.HeatmapLayerProperty.GRADIENT), this.handleGradientChanged_, false, this); - this.setGradient(goog.isDef(options.gradient) ? + this.setGradient(options.gradient ? options.gradient : ol.layer.Heatmap.DEFAULT_GRADIENT); - this.setBlur(goog.isDef(options.blur) ? options.blur : 15); + this.setBlur(ol.isDef(options.blur) ? + /** @type {number} */ (options.blur) : 15); - this.setRadius(goog.isDef(options.radius) ? options.radius : 8); + this.setRadius(ol.isDef(options.radius) ? + /** @type {number} */ (options.radius) : 8); goog.events.listen(this, [ ol.Object.getChangeEventType(ol.layer.HeatmapLayerProperty.BLUR), @@ -90,7 +94,7 @@ ol.layer.Heatmap = function(opt_options) { this.handleStyleChanged_(); - var weight = goog.isDef(options.weight) ? options.weight : 'weight'; + var weight = options.weight ? options.weight : 'weight'; var weightFunction; if (goog.isString(weight)) { weightFunction = function(feature) { @@ -105,14 +109,15 @@ ol.layer.Heatmap = function(opt_options) { this.setStyle(goog.bind(function(feature, resolution) { goog.asserts.assert(!goog.isNull(this.styleCache_), 'this.styleCache_ should not be null'); - goog.asserts.assert(goog.isDef(this.circleImage_), + goog.asserts.assert(this.circleImage_ !== undefined, 'this.circleImage_ should be defined'); var weight = weightFunction(feature); - var opacity = goog.isDef(weight) ? goog.math.clamp(weight, 0, 1) : 1; + var opacity = ol.isDef(weight) ? + goog.math.clamp(/** @type {number} */ (weight), 0, 1) : 1; // cast to 8 bits var index = (255 * opacity) | 0; var style = this.styleCache_[index]; - if (!goog.isDef(style)) { + if (!style) { style = [ new ol.style.Style({ image: new ol.style.Icon({ @@ -174,7 +179,7 @@ ol.layer.Heatmap.createGradient_ = function(colors) { ol.layer.Heatmap.prototype.createCircle_ = function() { var radius = this.getRadius(); var blur = this.getBlur(); - goog.asserts.assert(goog.isDef(radius) && goog.isDef(blur), + goog.asserts.assert(radius !== undefined && blur !== undefined, 'radius and blur should be defined'); var halfSize = radius + blur + 1; var size = 2 * halfSize; From 66ad8364e05bb7f4ae0d5f8caf8dad5ab9a12c8e Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Wed, 23 Sep 2015 21:00:02 +0200 Subject: [PATCH 60/93] Remove goog.isDef from imagelayer --- src/ol/layer/imagelayer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ol/layer/imagelayer.js b/src/ol/layer/imagelayer.js index 36f96b4c13..6e41c8b733 100644 --- a/src/ol/layer/imagelayer.js +++ b/src/ol/layer/imagelayer.js @@ -19,7 +19,7 @@ goog.require('ol.layer.Layer'); * @api stable */ ol.layer.Image = function(opt_options) { - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = opt_options ? opt_options : {}; goog.base(this, /** @type {olx.layer.LayerOptions} */ (options)); }; goog.inherits(ol.layer.Image, ol.layer.Layer); From cbb72c1ce4c360a66f1bb4f34d4a8d3463cf5c00 Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Wed, 23 Sep 2015 21:00:14 +0200 Subject: [PATCH 61/93] Remove goog.isDef from layer --- src/ol/layer/layer.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/ol/layer/layer.js b/src/ol/layer/layer.js index 9d646e4e23..c85f845d68 100644 --- a/src/ol/layer/layer.js +++ b/src/ol/layer/layer.js @@ -3,6 +3,7 @@ goog.provide('ol.layer.Layer'); goog.require('goog.events'); goog.require('goog.events.EventType'); goog.require('goog.object'); +goog.require('ol'); goog.require('ol.Object'); goog.require('ol.layer.Base'); goog.require('ol.layer.LayerProperty'); @@ -52,7 +53,7 @@ ol.layer.Layer = function(options) { */ this.sourceChangeKey_ = null; - if (goog.isDef(options.map)) { + if (options.map) { this.setMap(options.map); } @@ -60,7 +61,7 @@ ol.layer.Layer = function(options) { ol.Object.getChangeEventType(ol.layer.LayerProperty.SOURCE), this.handleSourcePropertyChange_, false, this); - var source = goog.isDef(options.source) ? options.source : null; + var source = options.source ? options.source : null; this.setSource(source); }; goog.inherits(ol.layer.Layer, ol.layer.Base); @@ -84,7 +85,7 @@ ol.layer.Layer.visibleAtResolution = function(layerState, resolution) { * @inheritDoc */ ol.layer.Layer.prototype.getLayersArray = function(opt_array) { - var array = goog.isDef(opt_array) ? opt_array : []; + var array = opt_array ? opt_array : []; array.push(this); return array; }; @@ -94,7 +95,7 @@ ol.layer.Layer.prototype.getLayersArray = function(opt_array) { * @inheritDoc */ ol.layer.Layer.prototype.getLayerStatesArray = function(opt_states) { - var states = goog.isDef(opt_states) ? opt_states : []; + var states = opt_states ? opt_states : []; states.push(this.getLayerState()); return states; }; @@ -108,7 +109,7 @@ ol.layer.Layer.prototype.getLayerStatesArray = function(opt_states) { */ ol.layer.Layer.prototype.getSource = function() { var source = this.get(ol.layer.LayerProperty.SOURCE); - return goog.isDef(source) ? + return ol.isDef(source) ? /** @type {ol.source.Source} */ (source) : null; }; From 0f55d173b8052b153d8775332f01f5e5b522bd15 Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Wed, 23 Sep 2015 21:00:29 +0200 Subject: [PATCH 62/93] Remove goog.isDef from layerbase --- src/ol/layer/layerbase.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/ol/layer/layerbase.js b/src/ol/layer/layerbase.js index 4f5faff1aa..dee4b441af 100644 --- a/src/ol/layer/layerbase.js +++ b/src/ol/layer/layerbase.js @@ -4,6 +4,7 @@ goog.provide('ol.layer.LayerState'); goog.require('goog.math'); goog.require('goog.object'); +goog.require('ol'); goog.require('ol.Object'); goog.require('ol.source.State'); @@ -67,23 +68,23 @@ ol.layer.Base = function(options) { */ var properties = goog.object.clone(options); properties[ol.layer.LayerProperty.BRIGHTNESS] = - goog.isDef(options.brightness) ? options.brightness : 0; + ol.isDef(options.brightness) ? options.brightness : 0; properties[ol.layer.LayerProperty.CONTRAST] = - goog.isDef(options.contrast) ? options.contrast : 1; + ol.isDef(options.contrast) ? options.contrast : 1; properties[ol.layer.LayerProperty.HUE] = - goog.isDef(options.hue) ? options.hue : 0; + ol.isDef(options.hue) ? options.hue : 0; properties[ol.layer.LayerProperty.OPACITY] = - goog.isDef(options.opacity) ? options.opacity : 1; + ol.isDef(options.opacity) ? options.opacity : 1; properties[ol.layer.LayerProperty.SATURATION] = - goog.isDef(options.saturation) ? options.saturation : 1; + ol.isDef(options.saturation) ? options.saturation : 1; properties[ol.layer.LayerProperty.VISIBLE] = - goog.isDef(options.visible) ? options.visible : true; + ol.isDef(options.visible) ? options.visible : true; properties[ol.layer.LayerProperty.Z_INDEX] = - goog.isDef(options.zIndex) ? options.zIndex : 0; + ol.isDef(options.zIndex) ? options.zIndex : 0; properties[ol.layer.LayerProperty.MAX_RESOLUTION] = - goog.isDef(options.maxResolution) ? options.maxResolution : Infinity; + ol.isDef(options.maxResolution) ? options.maxResolution : Infinity; properties[ol.layer.LayerProperty.MIN_RESOLUTION] = - goog.isDef(options.minResolution) ? options.minResolution : 0; + ol.isDef(options.minResolution) ? options.minResolution : 0; this.setProperties(properties); }; From 2b53d43faa198815eb8e426e5d6db692b3ce7966 Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Wed, 23 Sep 2015 21:00:42 +0200 Subject: [PATCH 63/93] Remove goog.isDef from tilelayer --- src/ol/layer/tilelayer.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/ol/layer/tilelayer.js b/src/ol/layer/tilelayer.js index 54c5262050..3d59d3427a 100644 --- a/src/ol/layer/tilelayer.js +++ b/src/ol/layer/tilelayer.js @@ -1,6 +1,7 @@ goog.provide('ol.layer.Tile'); goog.require('goog.object'); +goog.require('ol'); goog.require('ol.layer.Layer'); @@ -29,7 +30,7 @@ ol.layer.TileProperty = { * @api stable */ ol.layer.Tile = function(opt_options) { - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = opt_options ? opt_options : {}; var baseOptions = goog.object.clone(options); @@ -37,9 +38,10 @@ ol.layer.Tile = function(opt_options) { delete baseOptions.useInterimTilesOnError; goog.base(this, /** @type {olx.layer.LayerOptions} */ (baseOptions)); - this.setPreload(goog.isDef(options.preload) ? options.preload : 0); - this.setUseInterimTilesOnError(goog.isDef(options.useInterimTilesOnError) ? - options.useInterimTilesOnError : true); + this.setPreload(ol.isDef(options.preload) ? + /** @type {number} */ (options.preload) : 0); + this.setUseInterimTilesOnError(ol.isDef(options.useInterimTilesOnError) ? + /** @type {boolean} */ (options.useInterimTilesOnError) : true); }; goog.inherits(ol.layer.Tile, ol.layer.Layer); From 4fa590965c6bd317085de154b24c793989c33658 Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Wed, 23 Sep 2015 21:00:53 +0200 Subject: [PATCH 64/93] Remove goog.isDef from vectorlayer --- src/ol/layer/vectorlayer.js | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/ol/layer/vectorlayer.js b/src/ol/layer/vectorlayer.js index 52a1cd328f..c5c6cf5b13 100644 --- a/src/ol/layer/vectorlayer.js +++ b/src/ol/layer/vectorlayer.js @@ -2,6 +2,7 @@ goog.provide('ol.layer.Vector'); goog.require('goog.asserts'); goog.require('goog.object'); +goog.require('ol'); goog.require('ol.layer.Layer'); goog.require('ol.style.Style'); @@ -30,11 +31,11 @@ ol.layer.VectorProperty = { */ ol.layer.Vector = function(opt_options) { - var options = goog.isDef(opt_options) ? + var options = opt_options ? opt_options : /** @type {olx.layer.VectorOptions} */ ({}); goog.asserts.assert( - !goog.isDef(options.renderOrder) || goog.isNull(options.renderOrder) || + options.renderOrder === undefined || goog.isNull(options.renderOrder) || goog.isFunction(options.renderOrder), 'renderOrder must be a comparator function'); @@ -50,8 +51,8 @@ ol.layer.Vector = function(opt_options) { * @type {number} * @private */ - this.renderBuffer_ = goog.isDef(options.renderBuffer) ? - options.renderBuffer : 100; + this.renderBuffer_ = ol.isDef(options.renderBuffer) ? + /** @type {number} */ (options.renderBuffer) : 100; /** * User provided style. @@ -73,15 +74,15 @@ ol.layer.Vector = function(opt_options) { * @type {boolean} * @private */ - this.updateWhileAnimating_ = goog.isDef(options.updateWhileAnimating) ? - options.updateWhileAnimating : false; + this.updateWhileAnimating_ = ol.isDef(options.updateWhileAnimating) ? + /** @type {boolean} */ (options.updateWhileAnimating) : false; /** * @type {boolean} * @private */ - this.updateWhileInteracting_ = goog.isDef(options.updateWhileInteracting) ? - options.updateWhileInteracting : false; + this.updateWhileInteracting_ = ol.isDef(options.updateWhileInteracting) ? + /** @type {boolean} */ (options.updateWhileInteracting) : false; }; goog.inherits(ol.layer.Vector, ol.layer.Layer); @@ -160,7 +161,7 @@ ol.layer.Vector.prototype.getUpdateWhileInteracting = function() { */ ol.layer.Vector.prototype.setRenderOrder = function(renderOrder) { goog.asserts.assert( - !goog.isDef(renderOrder) || goog.isNull(renderOrder) || + renderOrder === undefined || goog.isNull(renderOrder) || goog.isFunction(renderOrder), 'renderOrder must be a comparator function'); this.set(ol.layer.VectorProperty.RENDER_ORDER, renderOrder); @@ -174,12 +175,16 @@ ol.layer.Vector.prototype.setRenderOrder = function(renderOrder) { * it is `null` the layer has no style (a `null` style), so only features * that have their own styles will be rendered in the layer. See * {@link ol.style} for information on the default style. - * @param {ol.style.Style|Array.|ol.style.StyleFunction|undefined} + * @param {ol.style.Style|Array.|ol.style.StyleFunction|null|undefined} * style Layer style. * @api stable */ ol.layer.Vector.prototype.setStyle = function(style) { - this.style_ = goog.isDef(style) ? style : ol.style.defaultStyleFunction; + this.style_ = ol.isDef(style) ? + /** + * @type {ol.style.Style|Array.|ol.style.StyleFunction|null} + */ + (style) : ol.style.defaultStyleFunction; this.styleFunction_ = goog.isNull(style) ? undefined : ol.style.createStyleFunction(this.style_); this.changed(); From 3de0aad52ade0e98a1642c36b98f3663a026a3f3 Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Wed, 23 Sep 2015 21:07:49 +0200 Subject: [PATCH 65/93] Remove goog.isDef from pointerevent --- src/ol/pointer/pointerevent.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ol/pointer/pointerevent.js b/src/ol/pointer/pointerevent.js index d17c1ba612..74e92f359f 100644 --- a/src/ol/pointer/pointerevent.js +++ b/src/ol/pointer/pointerevent.js @@ -59,7 +59,7 @@ ol.pointer.PointerEvent = function(type, browserEvent, opt_eventDict) { */ this.browserEvent = browserEvent; - var eventDict = goog.isDef(opt_eventDict) ? opt_eventDict : {}; + var eventDict = opt_eventDict ? opt_eventDict : {}; /** * @type {number} From 06b34055d1701608eaf02e0579b2ecf236bc7788 Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Wed, 23 Sep 2015 21:08:00 +0200 Subject: [PATCH 66/93] Remove goog.isDef from touchsource --- src/ol/pointer/touchsource.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ol/pointer/touchsource.js b/src/ol/pointer/touchsource.js index b04076c321..7d0a7c6590 100644 --- a/src/ol/pointer/touchsource.js +++ b/src/ol/pointer/touchsource.js @@ -32,6 +32,7 @@ goog.provide('ol.pointer.TouchSource'); goog.require('goog.array'); goog.require('goog.object'); +goog.require('ol'); goog.require('ol.pointer.EventSource'); goog.require('ol.pointer.MouseSource'); @@ -168,7 +169,7 @@ ol.pointer.TouchSource.prototype.resetClickCountHandler_ = function() { * @private */ ol.pointer.TouchSource.prototype.cancelResetClickCount_ = function() { - if (goog.isDef(this.resetId_)) { + if (ol.isDef(this.resetId_)) { goog.global.clearTimeout(this.resetId_); } }; From 710353784b7d79a8a91fc62f58849750bd452ad4 Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Wed, 23 Sep 2015 21:08:22 +0200 Subject: [PATCH 67/93] Remove goog.isDef from render/vector --- src/ol/render/vector.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ol/render/vector.js b/src/ol/render/vector.js index c055f87ebe..16c5c878e1 100644 --- a/src/ol/render/vector.js +++ b/src/ol/render/vector.js @@ -127,7 +127,7 @@ ol.renderer.vector.renderFeature_ = function( var simplifiedGeometry = geometry.getSimplifiedGeometry(squaredTolerance); var geometryRenderer = ol.renderer.vector.GEOMETRY_RENDERERS_[simplifiedGeometry.getType()]; - goog.asserts.assert(goog.isDef(geometryRenderer), + goog.asserts.assert(geometryRenderer !== undefined, 'geometryRenderer should be defined'); geometryRenderer(replayGroup, simplifiedGeometry, style, feature); }; @@ -149,7 +149,7 @@ ol.renderer.vector.renderGeometryCollectionGeometry_ = for (i = 0, ii = geometries.length; i < ii; ++i) { var geometryRenderer = ol.renderer.vector.GEOMETRY_RENDERERS_[geometries[i].getType()]; - goog.asserts.assert(goog.isDef(geometryRenderer), + goog.asserts.assert(geometryRenderer !== undefined, 'geometryRenderer should be defined'); geometryRenderer(replayGroup, geometries[i], style, feature); } From 8eea8273430536078fa37861a69332fbbeee9c8e Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Wed, 23 Sep 2015 21:08:33 +0200 Subject: [PATCH 68/93] Remove goog.isDef from maprenderer --- src/ol/renderer/maprenderer.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ol/renderer/maprenderer.js b/src/ol/renderer/maprenderer.js index 4966aba9b6..c588a70080 100644 --- a/src/ol/renderer/maprenderer.js +++ b/src/ol/renderer/maprenderer.js @@ -9,6 +9,7 @@ goog.require('goog.events.EventType'); goog.require('goog.functions'); goog.require('goog.object'); goog.require('goog.vec.Mat4'); +goog.require('ol'); goog.require('ol.extent'); goog.require('ol.layer.Layer'); goog.require('ol.renderer.Layer'); @@ -139,7 +140,7 @@ ol.renderer.Map.prototype.forEachFeatureAtCoordinate = * @return {?} Callback result. */ function forEachFeatureAtCoordinate(feature) { - goog.asserts.assert(goog.isDef(feature), 'received a feature'); + goog.asserts.assert(feature !== undefined, 'received a feature'); var key = goog.getUid(feature).toString(); if (!(key in features)) { features[key] = true; @@ -241,7 +242,7 @@ ol.renderer.Map.prototype.hasFeatureAtCoordinate = var hasFeature = this.forEachFeatureAtCoordinate( coordinate, frameState, goog.functions.TRUE, this, layerFilter, thisArg); - return goog.isDef(hasFeature); + return ol.isDef(hasFeature); }; From 7352ddeb89641e19cd42d85b8dc2163c6717be9a Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Fri, 25 Sep 2015 10:41:09 +0200 Subject: [PATCH 69/93] Use ol.isDef in assertion This addresses comment https://github.com/openlayers/ol3/commit/e558b5db639065fa0a7e41012cb9fa2fde7c41d5#commitcomment-13406867 by @elemoine. --- src/ol/renderer/maprenderer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ol/renderer/maprenderer.js b/src/ol/renderer/maprenderer.js index c588a70080..9b686d9eed 100644 --- a/src/ol/renderer/maprenderer.js +++ b/src/ol/renderer/maprenderer.js @@ -140,7 +140,7 @@ ol.renderer.Map.prototype.forEachFeatureAtCoordinate = * @return {?} Callback result. */ function forEachFeatureAtCoordinate(feature) { - goog.asserts.assert(feature !== undefined, 'received a feature'); + goog.asserts.assert(ol.isDef(feature), 'received a feature'); var key = goog.getUid(feature).toString(); if (!(key in features)) { features[key] = true; From d610b206f7ce51545b185f6f92055dcd9701067f Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Fri, 25 Sep 2015 10:56:52 +0200 Subject: [PATCH 70/93] Adjust checks against undefined as suggested This commit changes the various checks against undefined as suggested by @elemoine, see e.g. his comments on 38636513bfc3792125de2e711a24bd3c898875ac. --- src/ol/interaction/modifyinteraction.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/ol/interaction/modifyinteraction.js b/src/ol/interaction/modifyinteraction.js index fa2a5040ff..ce20fd8489 100644 --- a/src/ol/interaction/modifyinteraction.js +++ b/src/ol/interaction/modifyinteraction.js @@ -162,7 +162,8 @@ ol.interaction.Modify = function(options) { * @type {number} * @private */ - this.pixelTolerance_ = options.pixelTolerance ? options.pixelTolerance : 10; + this.pixelTolerance_ = ol.isDef(options.pixelTolerance) ? + /** @type {number} */ (options.pixelTolerance) : 10; /** * @type {boolean} @@ -192,7 +193,7 @@ ol.interaction.Modify = function(options) { this.overlay_ = new ol.layer.Vector({ source: new ol.source.Vector({ useSpatialIndex: false, - wrapX: options.wrapX ? options.wrapX : false + wrapX: !!options.wrapX }), style: options.style ? options.style : ol.interaction.Modify.getDefaultStyleFunction(), @@ -238,7 +239,7 @@ goog.inherits(ol.interaction.Modify, ol.interaction.Pointer); */ ol.interaction.Modify.prototype.addFeature_ = function(feature) { var geometry = feature.getGeometry(); - if (this.SEGMENT_WRITERS_[geometry.getType()]) { + if (geometry.getType() in this.SEGMENT_WRITERS_) { this.SEGMENT_WRITERS_[geometry.getType()].call(this, feature, geometry); } var map = this.getMap(); @@ -822,10 +823,10 @@ ol.interaction.Modify.prototype.insertVertex_ = function(segmentData, vertex) { this.setGeometryCoordinates_(geometry, coordinates); var rTree = this.rBush_; - goog.asserts.assert(segment !== undefined, 'segment should be defined'); + goog.asserts.assert(ol.isDef(segment), 'segment should be defined'); rTree.remove(segmentData); - goog.asserts.assert(index !== undefined, 'index should be defined'); - this.updateSegmentIndices_(geometry, index, depth, 1); + goog.asserts.assert(ol.isDef(index), 'index should be defined'); + this.updateSegmentIndices_(geometry, /** @type {number} */ (index), depth, 1); var newSegmentData = /** @type {ol.interaction.SegmentDataType} */ ({ segment: [segment[0], vertex], feature: feature, @@ -975,7 +976,9 @@ ol.interaction.Modify.prototype.updateSegmentIndices_ = function( this.rBush_.forEachInExtent(geometry.getExtent(), function(segmentDataMatch) { if (segmentDataMatch.geometry === geometry && (depth === undefined || segmentDataMatch.depth === undefined || - goog.array.equals(segmentDataMatch.depth, depth)) && + goog.array.equals( + /** @type {null|{length: number}} */ (segmentDataMatch.depth), + depth)) && segmentDataMatch.index > index) { segmentDataMatch.index += delta; } From 0927c55b3cf7ea8763540b3513e33fa8aeddac65 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Fri, 25 Sep 2015 12:16:42 -0600 Subject: [PATCH 71/93] Toward natural JavaScript syntax --- src/ol/animation.js | 12 ++++------ src/ol/color/colormatrix.js | 16 +++++++------- src/ol/control/attributioncontrol.js | 7 +++--- src/ol/control/controldefaults.js | 8 +++---- src/ol/control/fullscreencontrol.js | 3 +-- src/ol/control/overviewmapcontrol.js | 9 ++++---- src/ol/control/rotatecontrol.js | 5 ++--- src/ol/control/scalelinecontrol.js | 3 +-- src/ol/deviceorientation.js | 3 +-- src/ol/dom/dom.js | 8 +++---- src/ol/feature.js | 2 +- src/ol/format/gml/gml3format.js | 16 ++++++-------- src/ol/format/kmlformat.js | 22 +++++++++---------- src/ol/format/wfsformat.js | 12 +++++----- src/ol/format/wktformat.js | 6 ++--- src/ol/format/wmscapabilitiesformat.js | 18 +++++++-------- src/ol/format/xsdformat.js | 4 ++-- src/ol/geom/flat/orientflatgeom.js | 4 ++-- src/ol/geom/linestring.js | 3 +-- src/ol/geom/multilinestring.js | 6 ++--- src/ol/geom/multipolygon.js | 2 +- src/ol/geom/polygon.js | 2 +- .../dragrotateandzoominteraction.js | 6 ++--- src/ol/interaction/dragrotateinteraction.js | 2 +- src/ol/interaction/interaction.js | 4 ++-- src/ol/interaction/interactiondefaults.js | 16 +++++++------- src/ol/interaction/keyboardpaninteraction.js | 13 +++++------ src/ol/interaction/modifyinteraction.js | 14 ++++++------ .../interaction/mousewheelzoominteraction.js | 10 ++++----- src/ol/interaction/pinchrotateinteraction.js | 10 ++++----- src/ol/interaction/pinchzoominteraction.js | 5 ++--- src/ol/interaction/snapinteraction.js | 10 ++++----- src/ol/layer/heatmaplayer.js | 11 +++++----- src/ol/layer/layer.js | 3 +-- src/ol/layer/layerbase.js | 18 +++++++-------- src/ol/layer/tilelayer.js | 7 +++--- src/ol/layer/vectorlayer.js | 18 ++++++--------- src/ol/ol.js | 10 --------- src/ol/pointer/touchsource.js | 2 +- src/ol/renderer/maprenderer.js | 4 ++-- 40 files changed, 146 insertions(+), 188 deletions(-) diff --git a/src/ol/animation.js b/src/ol/animation.js index 430eb6fa79..6358452621 100644 --- a/src/ol/animation.js +++ b/src/ol/animation.js @@ -17,8 +17,7 @@ goog.require('ol.easing'); ol.animation.bounce = function(options) { var resolution = options.resolution; var start = options.start ? options.start : goog.now(); - var duration = ol.isDef(options.duration) ? - /** @type {number} */ (options.duration) : 1000; + var duration = options.duration !== undefined ? options.duration : 1000; var easing = options.easing ? options.easing : ol.easing.upAndDown; return ( @@ -56,8 +55,7 @@ ol.animation.pan = function(options) { var start = options.start ? options.start : goog.now(); var sourceX = source[0]; var sourceY = source[1]; - var duration = ol.isDef(options.duration) ? - /** @type {number} */ (options.duration) : 1000; + var duration = options.duration !== undefined ? options.duration : 1000; var easing = options.easing ? options.easing : ol.easing.inAndOut; return ( @@ -95,8 +93,7 @@ ol.animation.pan = function(options) { ol.animation.rotate = function(options) { var sourceRotation = options.rotation ? options.rotation : 0; var start = options.start ? options.start : goog.now(); - var duration = ol.isDef(options.duration) ? - /** @type {number} */ (options.duration) : 1000; + var duration = options.duration !== undefined ? options.duration : 1000; var easing = options.easing ? options.easing : ol.easing.inAndOut; var anchor = options.anchor ? @@ -142,8 +139,7 @@ ol.animation.rotate = function(options) { ol.animation.zoom = function(options) { var sourceResolution = options.resolution; var start = options.start ? options.start : goog.now(); - var duration = ol.isDef(options.duration) ? - /** @type {number} */ (options.duration) : 1000; + var duration = options.duration !== undefined ? options.duration : 1000; var easing = options.easing ? options.easing : ol.easing.inAndOut; return ( diff --git a/src/ol/color/colormatrix.js b/src/ol/color/colormatrix.js index 3652ea692c..31ae21d1aa 100644 --- a/src/ol/color/colormatrix.js +++ b/src/ol/color/colormatrix.js @@ -166,24 +166,24 @@ ol.color.Matrix.makeSaturation = function(matrix, value) { ol.color.Matrix.prototype.getMatrix = function( brightness, contrast, hue, saturation) { var colorMatrixDirty = false; - if (ol.isDef(brightness) && brightness !== this.brightness_) { + if (brightness !== undefined && brightness !== this.brightness_) { ol.color.Matrix.makeBrightness(this.brightnessMatrix_, /** @type {number} */ (brightness)); this.brightness_ = brightness; colorMatrixDirty = true; } - if (ol.isDef(contrast) && contrast !== this.contrast_) { + if (contrast !== undefined && contrast !== this.contrast_) { ol.color.Matrix.makeContrast(this.contrastMatrix_, /** @type {number} */ (contrast)); this.contrast_ = contrast; colorMatrixDirty = true; } - if (ol.isDef(hue) && hue !== this.hue_) { + if (hue !== undefined && hue !== this.hue_) { ol.color.Matrix.makeHue(this.hueMatrix_, /** @type {number} */ (hue)); this.hue_ = hue; colorMatrixDirty = true; } - if (ol.isDef(saturation) && saturation !== this.saturation_) { + if (saturation !== undefined && saturation !== this.saturation_) { ol.color.Matrix.makeSaturation(this.saturationMatrix_, /** @type {number} */ (saturation)); this.saturation_ = saturation; @@ -192,16 +192,16 @@ ol.color.Matrix.prototype.getMatrix = function( if (colorMatrixDirty) { var colorMatrix = this.colorMatrix_; goog.vec.Mat4.makeIdentity(colorMatrix); - if (ol.isDef(contrast)) { + if (contrast !== undefined) { goog.vec.Mat4.multMat(colorMatrix, this.contrastMatrix_, colorMatrix); } - if (ol.isDef(brightness)) { + if (brightness !== undefined) { goog.vec.Mat4.multMat(colorMatrix, this.brightnessMatrix_, colorMatrix); } - if (ol.isDef(saturation)) { + if (saturation !== undefined) { goog.vec.Mat4.multMat(colorMatrix, this.saturationMatrix_, colorMatrix); } - if (ol.isDef(hue)) { + if (hue !== undefined) { goog.vec.Mat4.multMat(colorMatrix, this.hueMatrix_, colorMatrix); } } diff --git a/src/ol/control/attributioncontrol.js b/src/ol/control/attributioncontrol.js index a5daa3140f..fd87d72162 100644 --- a/src/ol/control/attributioncontrol.js +++ b/src/ol/control/attributioncontrol.js @@ -53,15 +53,14 @@ ol.control.Attribution = function(opt_options) { * @private * @type {boolean} */ - this.collapsed_ = ol.isDef(options.collapsed) ? - /** @type {boolean} */ (options.collapsed) : true; + this.collapsed_ = options.collapsed !== undefined ? options.collapsed : true; /** * @private * @type {boolean} */ - this.collapsible_ = ol.isDef(options.collapsible) ? - /** @type {boolean} */ (options.collapsible) : true; + this.collapsible_ = options.collapsible !== undefined ? + options.collapsible : true; if (!this.collapsible_) { this.collapsed_ = false; diff --git a/src/ol/control/controldefaults.js b/src/ol/control/controldefaults.js index fca2f43ea6..c2512af30e 100644 --- a/src/ol/control/controldefaults.js +++ b/src/ol/control/controldefaults.js @@ -25,19 +25,17 @@ ol.control.defaults = function(opt_options) { var controls = new ol.Collection(); - var zoomControl = ol.isDef(options.zoom) ? - options.zoom : true; + var zoomControl = options.zoom !== undefined ? options.zoom : true; if (zoomControl) { controls.push(new ol.control.Zoom(options.zoomOptions)); } - var rotateControl = ol.isDef(options.rotate) ? - options.rotate : true; + var rotateControl = options.rotate !== undefined ? options.rotate : true; if (rotateControl) { controls.push(new ol.control.Rotate(options.rotateOptions)); } - var attributionControl = ol.isDef(options.attribution) ? + var attributionControl = options.attribution !== undefined ? options.attribution : true; if (attributionControl) { controls.push(new ol.control.Attribution(options.attributionOptions)); diff --git a/src/ol/control/fullscreencontrol.js b/src/ol/control/fullscreencontrol.js index ef69518520..fbd8b7fa61 100644 --- a/src/ol/control/fullscreencontrol.js +++ b/src/ol/control/fullscreencontrol.js @@ -83,8 +83,7 @@ ol.control.FullScreen = function(opt_options) { * @private * @type {boolean} */ - this.keys_ = ol.isDef(options.keys) ? - /** @type {boolean} */ (options.keys) : false; + this.keys_ = options.keys !== undefined ? options.keys : false; }; goog.inherits(ol.control.FullScreen, ol.control.Control); diff --git a/src/ol/control/overviewmapcontrol.js b/src/ol/control/overviewmapcontrol.js index 2b880e7fe4..a6325e2eca 100644 --- a/src/ol/control/overviewmapcontrol.js +++ b/src/ol/control/overviewmapcontrol.js @@ -41,15 +41,14 @@ ol.control.OverviewMap = function(opt_options) { * @type {boolean} * @private */ - this.collapsed_ = ol.isDef(options.collapsed) ? - /** @type {boolean} */ (options.collapsed) : true; + this.collapsed_ = options.collapsed !== undefined ? options.collapsed : true; /** * @private * @type {boolean} */ - this.collapsible_ = ol.isDef(options.collapsible) ? - /** @type {boolean} */ (options.collapsible) : true; + this.collapsible_ = options.collapsible !== undefined ? + options.collapsible : true; if (!this.collapsible_) { this.collapsed_ = false; @@ -382,7 +381,7 @@ ol.control.OverviewMap.prototype.updateBox_ = function() { goog.asserts.assertArray(ovmapSize, 'ovmapSize should be an array'); var rotation = view.getRotation(); - goog.asserts.assert(ol.isDef(rotation), 'rotation should be defined'); + goog.asserts.assert(rotation !== undefined, 'rotation should be defined'); var overlay = this.boxOverlay_; var box = this.boxOverlay_.getElement(); diff --git a/src/ol/control/rotatecontrol.js b/src/ol/control/rotatecontrol.js index 90977b268e..849c895396 100644 --- a/src/ol/control/rotatecontrol.js +++ b/src/ol/control/rotatecontrol.js @@ -81,8 +81,7 @@ ol.control.Rotate = function(opt_options) { * @type {boolean} * @private */ - this.autoHide_ = ol.isDef(options.autoHide) ? - /** @type {boolean} */ (options.autoHide) : true; + this.autoHide_ = options.autoHide !== undefined ? options.autoHide : true; /** * @private @@ -126,7 +125,7 @@ ol.control.Rotate.prototype.resetNorth_ = function() { while (currentRotation > Math.PI) { currentRotation -= 2 * Math.PI; } - if (ol.isDef(currentRotation)) { + if (currentRotation !== undefined) { if (this.duration_ > 0) { map.beforeRender(ol.animation.rotate({ rotation: currentRotation, diff --git a/src/ol/control/scalelinecontrol.js b/src/ol/control/scalelinecontrol.js index 1c20927444..477cfad3a7 100644 --- a/src/ol/control/scalelinecontrol.js +++ b/src/ol/control/scalelinecontrol.js @@ -87,8 +87,7 @@ ol.control.ScaleLine = function(opt_options) { * @private * @type {number} */ - this.minWidth_ = ol.isDef(options.minWidth) ? - /** @type {number} */ (options.minWidth) : 64; + this.minWidth_ = options.minWidth !== undefined ? options.minWidth : 64; /** * @private diff --git a/src/ol/deviceorientation.js b/src/ol/deviceorientation.js index 2b2d95f3fc..8707fb2073 100644 --- a/src/ol/deviceorientation.js +++ b/src/ol/deviceorientation.js @@ -92,8 +92,7 @@ ol.DeviceOrientation = function(opt_options) { ol.Object.getChangeEventType(ol.DeviceOrientationProperty.TRACKING), this.handleTrackingChanged_, false, this); - this.setTracking(ol.isDef(options.tracking) ? - /** @type {boolean} */ (options.tracking) : false); + this.setTracking(options.tracking !== undefined ? options.tracking : false); }; goog.inherits(ol.DeviceOrientation, ol.Object); diff --git a/src/ol/dom/dom.js b/src/ol/dom/dom.js index 86eb2b2b04..72bfd45696 100644 --- a/src/ol/dom/dom.js +++ b/src/ol/dom/dom.js @@ -47,7 +47,7 @@ ol.dom.BrowserFeature = { ol.dom.canUseCssTransform = (function() { var canUseCssTransform; return function() { - if (!ol.isDef(canUseCssTransform)) { + if (canUseCssTransform === undefined) { goog.asserts.assert(!goog.isNull(document.body), 'document.body should not be null'); if (!goog.global.getComputedStyle) { @@ -90,7 +90,7 @@ ol.dom.canUseCssTransform = (function() { ol.dom.canUseCssTransform3D = (function() { var canUseCssTransform3D; return function() { - if (!ol.isDef(canUseCssTransform3D)) { + if (canUseCssTransform3D === undefined) { goog.asserts.assert(!goog.isNull(document.body), 'document.body should not be null'); if (!goog.global.getComputedStyle) { @@ -224,7 +224,7 @@ ol.dom.transformElement2D = if (ol.dom.canUseCssTransform3D()) { var value3D; - if (ol.isDef(opt_precision)) { + if (opt_precision !== undefined) { /** @type {Array.} */ var strings3D = new Array(16); for (i = 0; i < 16; ++i) { @@ -246,7 +246,7 @@ ol.dom.transformElement2D = goog.vec.Mat4.getElement(transform, 1, 3) ]; var value2D; - if (ol.isDef(opt_precision)) { + if (opt_precision !== undefined) { /** @type {Array.} */ var strings2D = new Array(6); for (i = 0; i < 6; ++i) { diff --git a/src/ol/feature.js b/src/ol/feature.js index d3ca941779..de33035b9f 100644 --- a/src/ol/feature.js +++ b/src/ol/feature.js @@ -97,7 +97,7 @@ ol.Feature = function(opt_geometryOrProperties) { this, ol.Object.getChangeEventType(this.geometryName_), this.handleGeometryChanged_, false, this); - if (ol.isDef(opt_geometryOrProperties)) { + if (opt_geometryOrProperties !== undefined) { if (opt_geometryOrProperties instanceof ol.geom.Geometry || goog.isNull(opt_geometryOrProperties)) { var geometry = /** @type {ol.geom.Geometry} */ (opt_geometryOrProperties); diff --git a/src/ol/format/gml/gml3format.js b/src/ol/format/gml/gml3format.js index b0fd244e62..ac54f41137 100644 --- a/src/ol/format/gml/gml3format.js +++ b/src/ol/format/gml/gml3format.js @@ -46,28 +46,26 @@ ol.format.GML3 = function(opt_options) { * @private * @type {boolean} */ - this.surface_ = ol.isDef(options.surface) ? - /** @type {boolean} */ (options.surface) : false; + this.surface_ = options.surface !== undefined ? options.surface : false; /** * @private * @type {boolean} */ - this.curve_ = ol.isDef(options.curve) ? - /** @type {boolean} */ (options.curve) : false; + this.curve_ = options.curve !== undefined ? options.curve : false; /** * @private * @type {boolean} */ - this.multiCurve_ = ol.isDef(options.multiCurve) ? - /** @type {boolean} */ (options.multiCurve) : true; + this.multiCurve_ = options.multiCurve !== undefined ? + options.multiCurve : true; /** * @private * @type {boolean} */ - this.multiSurface_ = ol.isDef(options.multiSurface) ? + this.multiSurface_ = options.multiSurface !== undefined ? /** @type {boolean} */ (options.multiSurface) : true; /** @@ -787,11 +785,11 @@ ol.format.GML3.prototype.RING_NODE_FACTORY_ = var parentNode = context.node; goog.asserts.assert(goog.isObject(context), 'context should be an Object'); var exteriorWritten = context['exteriorWritten']; - if (!ol.isDef(exteriorWritten)) { + if (exteriorWritten === undefined) { context['exteriorWritten'] = true; } return ol.xml.createElementNS(parentNode.namespaceURI, - ol.isDef(exteriorWritten) ? 'interior' : 'exterior'); + exteriorWritten !== undefined ? 'interior' : 'exterior'); }; diff --git a/src/ol/format/kmlformat.js b/src/ol/format/kmlformat.js index 9371fb20d2..51d3427b7a 100644 --- a/src/ol/format/kmlformat.js +++ b/src/ol/format/kmlformat.js @@ -89,8 +89,8 @@ ol.format.KML = function(opt_options) { * @private * @type {boolean} */ - this.extractStyles_ = ol.isDef(options.extractStyles) ? - /** @type {boolean} */ (options.extractStyles) : true; + this.extractStyles_ = options.extractStyles !== undefined ? + options.extractStyles : true; /** * @private @@ -441,7 +441,7 @@ ol.format.KML.readVec2_ = function(node) { */ ol.format.KML.readScale_ = function(node) { var number = ol.format.XSD.readDecimal(node); - if (ol.isDef(number)) { + if (number !== undefined) { return Math.sqrt(number); } else { return undefined; @@ -517,7 +517,7 @@ ol.format.KML.IconStyleParser_ = function(node, objectStack) { (IconObject['x']); var y = /** @type {number|undefined} */ (IconObject['y']); - if (ol.isDef(x) && ol.isDef(y)) { + if (x !== undefined && y !== undefined) { offset = [x, y]; } @@ -526,14 +526,14 @@ ol.format.KML.IconStyleParser_ = function(node, objectStack) { (IconObject['w']); var h = /** @type {number|undefined} */ (IconObject['h']); - if (ol.isDef(w) && ol.isDef(h)) { + if (w !== undefined && h !== undefined) { size = [w, h]; } var rotation; var heading = /** @type {number} */ (object['heading']); - if (ol.isDef(heading)) { + if (heading !== undefined) { rotation = goog.math.toRadians(heading); } @@ -648,12 +648,12 @@ ol.format.KML.PolyStyleParser_ = function(node, objectStack) { }); styleObject['fillStyle'] = fillStyle; var fill = /** @type {boolean|undefined} */ (object['fill']); - if (ol.isDef(fill)) { + if (fill !== undefined) { styleObject['fill'] = fill; } var outline = /** @type {boolean|undefined} */ (object['outline']); - if (ol.isDef(outline)) { + if (outline !== undefined) { styleObject['outline'] = outline; } }; @@ -1018,7 +1018,7 @@ ol.format.KML.readStyle_ = function(node, objectStack) { styleObject, 'fillStyle', ol.format.KML.DEFAULT_FILL_STYLE_)); var fill = /** @type {boolean|undefined} */ (styleObject['fill']); - if (ol.isDef(fill) && !fill) { + if (fill !== undefined && !fill) { fillStyle = null; } var imageStyle = /** @type {ol.style.Image} */ (goog.object.get( @@ -1029,7 +1029,7 @@ ol.format.KML.readStyle_ = function(node, objectStack) { styleObject, 'strokeStyle', ol.format.KML.DEFAULT_STROKE_STYLE_)); var outline = /** @type {boolean|undefined} */ (styleObject['outline']); - if (ol.isDef(outline) && !outline) { + if (outline !== undefined && !outline) { strokeStyle = null; } return [new ol.style.Style({ @@ -1061,7 +1061,7 @@ ol.format.KML.setCommonGeometryProperties_ = function(multiGeometry, geometry = geometries[i]; extrudes[i] = geometry.get('extrude'); altitudeModes[i] = geometry.get('altitudeMode'); - hasExtrude = hasExtrude || ol.isDef(extrudes[i]); + hasExtrude = hasExtrude || extrudes[i] !== undefined; hasAltitudeMode = hasAltitudeMode || altitudeModes[i]; } if (hasExtrude) { diff --git a/src/ol/format/wfsformat.js b/src/ol/format/wfsformat.js index 295ae8c68f..3e965205f1 100644 --- a/src/ol/format/wfsformat.js +++ b/src/ol/format/wfsformat.js @@ -451,7 +451,7 @@ ol.format.WFS.writeUpdate_ = function(node, feature, objectStack) { var values = []; for (var i = 0, ii = keys.length; i < ii; i++) { var value = feature.get(keys[i]); - if (ol.isDef(value)) { + if (value !== undefined) { values.push({name: keys[i], value: value}); } } @@ -499,10 +499,10 @@ ol.format.WFS.writeNative_ = function(node, nativeElement, objectStack) { if (nativeElement.vendorId) { node.setAttribute('vendorId', nativeElement.vendorId); } - if (ol.isDef(nativeElement.safeToIgnore)) { + if (nativeElement.safeToIgnore !== undefined) { node.setAttribute('safeToIgnore', nativeElement.safeToIgnore); } - if (ol.isDef(nativeElement.value)) { + if (nativeElement.value !== undefined) { ol.format.XSD.writeStringTextNode(node, nativeElement.value); } }; @@ -640,16 +640,16 @@ ol.format.WFS.prototype.writeGetFeature = function(options) { if (options.outputFormat) { node.setAttribute('outputFormat', options.outputFormat); } - if (ol.isDef(options.maxFeatures)) { + if (options.maxFeatures !== undefined) { node.setAttribute('maxFeatures', options.maxFeatures); } if (options.resultType) { node.setAttribute('resultType', options.resultType); } - if (ol.isDef(options.startIndex)) { + if (options.startIndex !== undefined) { node.setAttribute('startIndex', options.startIndex); } - if (ol.isDef(options.count)) { + if (options.count !== undefined) { node.setAttribute('count', options.count); } } diff --git a/src/ol/format/wktformat.js b/src/ol/format/wktformat.js index f7d1ad6cd8..843c64ea40 100644 --- a/src/ol/format/wktformat.js +++ b/src/ol/format/wktformat.js @@ -38,8 +38,8 @@ ol.format.WKT = function(opt_options) { * @type {boolean} * @private */ - this.splitCollection_ = ol.isDef(options.splitCollection) ? - /** @type {boolean} */ (options.splitCollection) : false; + this.splitCollection_ = options.splitCollection !== undefined ? + options.splitCollection : false; }; goog.inherits(ol.format.WKT, ol.format.TextFeature); @@ -427,7 +427,7 @@ ol.format.WKT.Lexer.prototype.isAlpha_ = function(c) { * @private */ ol.format.WKT.Lexer.prototype.isNumeric_ = function(c, opt_decimal) { - var decimal = ol.isDef(opt_decimal) ? opt_decimal : false; + var decimal = opt_decimal !== undefined ? opt_decimal : false; return c >= '0' && c <= '9' || c == '.' && !decimal; }; diff --git a/src/ol/format/wmscapabilitiesformat.js b/src/ol/format/wmscapabilitiesformat.js index 21e83c4617..2283cd4487 100644 --- a/src/ol/format/wmscapabilitiesformat.js +++ b/src/ol/format/wmscapabilitiesformat.js @@ -154,8 +154,8 @@ ol.format.WMSCapabilities.readEXGeographicBoundingBox_ = (geographicBoundingBox['eastBoundLongitude']); var northBoundLatitude = /** @type {number|undefined} */ (geographicBoundingBox['northBoundLatitude']); - if (!ol.isDef(westBoundLongitude) || !ol.isDef(southBoundLatitude) || - !ol.isDef(eastBoundLongitude) || !ol.isDef(northBoundLatitude)) { + if (westBoundLongitude === undefined || southBoundLatitude === undefined || + eastBoundLongitude === undefined || northBoundLatitude === undefined) { return undefined; } return /** @type {ol.Extent} */ ([ @@ -303,30 +303,30 @@ ol.format.WMSCapabilities.readLayer_ = function(node, objectStack) { } var queryable = ol.format.XSD.readBooleanString(node.getAttribute('queryable')); - if (!ol.isDef(queryable)) { + if (queryable === undefined) { queryable = parentLayerObject['queryable']; } - layerObject['queryable'] = ol.isDef(queryable) ? queryable : false; + layerObject['queryable'] = queryable !== undefined ? queryable : false; var cascaded = ol.format.XSD.readNonNegativeIntegerString( node.getAttribute('cascaded')); - if (!ol.isDef(cascaded)) { + if (cascaded === undefined) { cascaded = parentLayerObject['cascaded']; } layerObject['cascaded'] = cascaded; var opaque = ol.format.XSD.readBooleanString(node.getAttribute('opaque')); - if (!ol.isDef(opaque)) { + if (opaque === undefined) { opaque = parentLayerObject['opaque']; } - layerObject['opaque'] = ol.isDef(opaque) ? opaque : false; + layerObject['opaque'] = opaque !== undefined ? opaque : false; var noSubsets = ol.format.XSD.readBooleanString(node.getAttribute('noSubsets')); - if (!ol.isDef(noSubsets)) { + if (noSubsets === undefined) { noSubsets = parentLayerObject['noSubsets']; } - layerObject['noSubsets'] = ol.isDef(noSubsets) ? noSubsets : false; + layerObject['noSubsets'] = noSubsets !== undefined ? noSubsets : false; var fixedWidth = ol.format.XSD.readDecimalString(node.getAttribute('fixedWidth')); diff --git a/src/ol/format/xsdformat.js b/src/ol/format/xsdformat.js index c220a64d96..075a625e83 100644 --- a/src/ol/format/xsdformat.js +++ b/src/ol/format/xsdformat.js @@ -30,7 +30,7 @@ ol.format.XSD.readBoolean = function(node) { ol.format.XSD.readBooleanString = function(string) { var m = /^\s*(true|1)|(false|0)\s*$/.exec(string); if (m) { - return ol.isDef(m[1]) || false; + return m[1] !== undefined || false; } else { return undefined; } @@ -57,7 +57,7 @@ ol.format.XSD.readDateTime = function(node) { if (m[7] != 'Z') { var sign = m[8] == '-' ? -1 : 1; dateTime += sign * 60 * parseInt(m[9], 10); - if (ol.isDef(m[10])) { + if (m[10] !== undefined) { dateTime += sign * 60 * 60 * parseInt(m[10], 10); } } diff --git a/src/ol/geom/flat/orientflatgeom.js b/src/ol/geom/flat/orientflatgeom.js index 5b80341ce8..0e177e990d 100644 --- a/src/ol/geom/flat/orientflatgeom.js +++ b/src/ol/geom/flat/orientflatgeom.js @@ -44,7 +44,7 @@ ol.geom.flat.orient.linearRingIsClockwise = */ ol.geom.flat.orient.linearRingsAreOriented = function(flatCoordinates, offset, ends, stride, opt_right) { - var right = ol.isDef(opt_right) ? opt_right : false; + var right = opt_right !== undefined ? opt_right : false; var i, ii; for (i = 0, ii = ends.length; i < ii; ++i) { var end = ends[i]; @@ -106,7 +106,7 @@ ol.geom.flat.orient.linearRingssAreOriented = */ ol.geom.flat.orient.orientLinearRings = function(flatCoordinates, offset, ends, stride, opt_right) { - var right = ol.isDef(opt_right) ? opt_right : false; + var right = opt_right !== undefined ? opt_right : false; var i, ii; for (i = 0, ii = ends.length; i < ii; ++i) { var end = ends[i]; diff --git a/src/ol/geom/linestring.js b/src/ol/geom/linestring.js index 3aeb2980ff..68e596e5c2 100644 --- a/src/ol/geom/linestring.js +++ b/src/ol/geom/linestring.js @@ -149,8 +149,7 @@ ol.geom.LineString.prototype.getCoordinateAtM = function(m, opt_extrapolate) { this.layout != ol.geom.GeometryLayout.XYZM) { return null; } - var extrapolate = ol.isDef(opt_extrapolate) ? - /** @type {boolean} */ (opt_extrapolate) : false; + var extrapolate = opt_extrapolate !== undefined ? opt_extrapolate : false; return ol.geom.flat.lineStringCoordinateAtM(this.flatCoordinates, 0, this.flatCoordinates.length, this.stride, m, extrapolate); }; diff --git a/src/ol/geom/multilinestring.js b/src/ol/geom/multilinestring.js index 30b3b5afdd..7b4e12d559 100644 --- a/src/ol/geom/multilinestring.js +++ b/src/ol/geom/multilinestring.js @@ -136,10 +136,8 @@ ol.geom.MultiLineString.prototype.getCoordinateAtM = this.flatCoordinates.length === 0) { return null; } - var extrapolate = ol.isDef(opt_extrapolate) ? - /** @type {boolean} */ (opt_extrapolate) : false; - var interpolate = ol.isDef(opt_interpolate) ? - /** @type {boolean} */ (opt_interpolate) : false; + var extrapolate = opt_extrapolate !== undefined ? opt_extrapolate : false; + var interpolate = opt_interpolate !== undefined ? opt_interpolate : false; return ol.geom.flat.lineStringsCoordinateAtM(this.flatCoordinates, 0, this.ends_, this.stride, m, extrapolate, interpolate); }; diff --git a/src/ol/geom/multipolygon.js b/src/ol/geom/multipolygon.js index 41b56f8d16..1e0c75806a 100644 --- a/src/ol/geom/multipolygon.js +++ b/src/ol/geom/multipolygon.js @@ -183,7 +183,7 @@ ol.geom.MultiPolygon.prototype.getArea = function() { */ ol.geom.MultiPolygon.prototype.getCoordinates = function(opt_right) { var flatCoordinates; - if (ol.isDef(opt_right)) { + if (opt_right !== undefined) { flatCoordinates = this.getOrientedFlatCoordinates().slice(); ol.geom.flat.orient.orientLinearRingss( flatCoordinates, 0, this.endss_, this.stride, opt_right); diff --git a/src/ol/geom/polygon.js b/src/ol/geom/polygon.js index a93ded2d54..bf23f93966 100644 --- a/src/ol/geom/polygon.js +++ b/src/ol/geom/polygon.js @@ -170,7 +170,7 @@ ol.geom.Polygon.prototype.getArea = function() { */ ol.geom.Polygon.prototype.getCoordinates = function(opt_right) { var flatCoordinates; - if (ol.isDef(opt_right)) { + if (opt_right !== undefined) { flatCoordinates = this.getOrientedFlatCoordinates().slice(); ol.geom.flat.orient.orientLinearRings( flatCoordinates, 0, this.ends_, this.stride, opt_right); diff --git a/src/ol/interaction/dragrotateandzoominteraction.js b/src/ol/interaction/dragrotateandzoominteraction.js index c0c8f6df8d..66f60baa0a 100644 --- a/src/ol/interaction/dragrotateandzoominteraction.js +++ b/src/ol/interaction/dragrotateandzoominteraction.js @@ -90,17 +90,17 @@ ol.interaction.DragRotateAndZoom.handleDragEvent_ = function(mapBrowserEvent) { var magnitude = delta.magnitude(); var view = map.getView(); map.render(); - if (ol.isDef(this.lastAngle_)) { + if (this.lastAngle_ !== undefined) { var angleDelta = theta - this.lastAngle_; ol.interaction.Interaction.rotateWithoutConstraints( map, view, view.getRotation() - angleDelta); } this.lastAngle_ = theta; - if (ol.isDef(this.lastMagnitude_)) { + if (this.lastMagnitude_ !== undefined) { var resolution = this.lastMagnitude_ * (view.getResolution() / magnitude); ol.interaction.Interaction.zoomWithoutConstraints(map, view, resolution); } - if (ol.isDef(this.lastMagnitude_)) { + if (this.lastMagnitude_ !== undefined) { this.lastScaleDelta_ = this.lastMagnitude_ / magnitude; } this.lastMagnitude_ = magnitude; diff --git a/src/ol/interaction/dragrotateinteraction.js b/src/ol/interaction/dragrotateinteraction.js index c7a97d752b..d073ad34a4 100644 --- a/src/ol/interaction/dragrotateinteraction.js +++ b/src/ol/interaction/dragrotateinteraction.js @@ -69,7 +69,7 @@ ol.interaction.DragRotate.handleDragEvent_ = function(mapBrowserEvent) { var offset = mapBrowserEvent.pixel; var theta = Math.atan2(size[1] / 2 - offset[1], offset[0] - size[0] / 2); - if (ol.isDef(this.lastAngle_)) { + if (this.lastAngle_ !== undefined) { var delta = theta - this.lastAngle_; var view = map.getView(); var rotation = view.getRotation(); diff --git a/src/ol/interaction/interaction.js b/src/ol/interaction/interaction.js index fc592ec716..07cbff4518 100644 --- a/src/ol/interaction/interaction.js +++ b/src/ol/interaction/interaction.js @@ -150,7 +150,7 @@ ol.interaction.Interaction.rotateWithoutConstraints = if (goog.isDefAndNotNull(rotation)) { var currentRotation = view.getRotation(); var currentCenter = view.getCenter(); - if (ol.isDef(currentRotation) && currentCenter && + if (currentRotation !== undefined && currentCenter && opt_duration && opt_duration > 0) { map.beforeRender(ol.animation.rotate({ rotation: currentRotation, @@ -221,7 +221,7 @@ ol.interaction.Interaction.zoomWithoutConstraints = if (goog.isDefAndNotNull(resolution)) { var currentResolution = view.getResolution(); var currentCenter = view.getCenter(); - if (ol.isDef(currentResolution) && currentCenter && + if (currentResolution !== undefined && currentCenter && opt_duration && opt_duration > 0) { map.beforeRender(ol.animation.zoom({ resolution: /** @type {number} */ (currentResolution), diff --git a/src/ol/interaction/interactiondefaults.js b/src/ol/interaction/interactiondefaults.js index 2d40d36d26..f6ad1b188a 100644 --- a/src/ol/interaction/interactiondefaults.js +++ b/src/ol/interaction/interactiondefaults.js @@ -48,13 +48,13 @@ ol.interaction.defaults = function(opt_options) { var kinetic = new ol.Kinetic(-0.005, 0.05, 100); - var altShiftDragRotate = ol.isDef(options.altShiftDragRotate) ? + var altShiftDragRotate = options.altShiftDragRotate !== undefined ? options.altShiftDragRotate : true; if (altShiftDragRotate) { interactions.push(new ol.interaction.DragRotate()); } - var doubleClickZoom = ol.isDef(options.doubleClickZoom) ? + var doubleClickZoom = options.doubleClickZoom !== undefined ? options.doubleClickZoom : true; if (doubleClickZoom) { interactions.push(new ol.interaction.DoubleClickZoom({ @@ -63,27 +63,27 @@ ol.interaction.defaults = function(opt_options) { })); } - var dragPan = ol.isDef(options.dragPan) ? options.dragPan : true; + var dragPan = options.dragPan !== undefined ? options.dragPan : true; if (dragPan) { interactions.push(new ol.interaction.DragPan({ kinetic: kinetic })); } - var pinchRotate = ol.isDef(options.pinchRotate) ? options.pinchRotate : + var pinchRotate = options.pinchRotate !== undefined ? options.pinchRotate : true; if (pinchRotate) { interactions.push(new ol.interaction.PinchRotate()); } - var pinchZoom = ol.isDef(options.pinchZoom) ? options.pinchZoom : true; + var pinchZoom = options.pinchZoom !== undefined ? options.pinchZoom : true; if (pinchZoom) { interactions.push(new ol.interaction.PinchZoom({ duration: options.zoomDuration })); } - var keyboard = ol.isDef(options.keyboard) ? options.keyboard : true; + var keyboard = options.keyboard !== undefined ? options.keyboard : true; if (keyboard) { interactions.push(new ol.interaction.KeyboardPan()); interactions.push(new ol.interaction.KeyboardZoom({ @@ -92,7 +92,7 @@ ol.interaction.defaults = function(opt_options) { })); } - var mouseWheelZoom = ol.isDef(options.mouseWheelZoom) ? + var mouseWheelZoom = options.mouseWheelZoom !== undefined ? options.mouseWheelZoom : true; if (mouseWheelZoom) { interactions.push(new ol.interaction.MouseWheelZoom({ @@ -100,7 +100,7 @@ ol.interaction.defaults = function(opt_options) { })); } - var shiftDragZoom = ol.isDef(options.shiftDragZoom) ? + var shiftDragZoom = options.shiftDragZoom !== undefined ? options.shiftDragZoom : true; if (shiftDragZoom) { interactions.push(new ol.interaction.DragZoom()); diff --git a/src/ol/interaction/keyboardpaninteraction.js b/src/ol/interaction/keyboardpaninteraction.js index 5f9c87340b..a9154fbf0d 100644 --- a/src/ol/interaction/keyboardpaninteraction.js +++ b/src/ol/interaction/keyboardpaninteraction.js @@ -35,14 +35,14 @@ ol.interaction.KeyboardPan = function(opt_options) { handleEvent: ol.interaction.KeyboardPan.handleEvent }); - var options = ol.isDef(opt_options) ? opt_options : {}; + var options = opt_options || {}; /** * @private * @type {ol.events.ConditionType} */ - this.condition_ = ol.isDef(options.condition) ? - /** @type {ol.events.ConditionType} */ (options.condition) : + this.condition_ = options.condition !== undefined ? + options.condition : goog.functions.and(ol.events.condition.noModifierKeys, ol.events.condition.targetNotEditable); @@ -50,15 +50,14 @@ ol.interaction.KeyboardPan = function(opt_options) { * @private * @type {number} */ - this.duration_ = ol.isDef(options.duration) ? - /** @type {number} */ (options.duration) : 100; + this.duration_ = options.duration !== undefined ? options.duration : 100; /** * @private * @type {number} */ - this.pixelDelta_ = ol.isDef(options.pixelDelta) ? - /** @type {number} */ (options.pixelDelta) : 128; + this.pixelDelta_ = options.pixelDelta !== undefined ? + options.pixelDelta : 128; }; goog.inherits(ol.interaction.KeyboardPan, ol.interaction.Interaction); diff --git a/src/ol/interaction/modifyinteraction.js b/src/ol/interaction/modifyinteraction.js index ce20fd8489..30fe563394 100644 --- a/src/ol/interaction/modifyinteraction.js +++ b/src/ol/interaction/modifyinteraction.js @@ -162,8 +162,8 @@ ol.interaction.Modify = function(options) { * @type {number} * @private */ - this.pixelTolerance_ = ol.isDef(options.pixelTolerance) ? - /** @type {number} */ (options.pixelTolerance) : 10; + this.pixelTolerance_ = options.pixelTolerance !== undefined ? + options.pixelTolerance : 10; /** * @type {boolean} @@ -823,9 +823,9 @@ ol.interaction.Modify.prototype.insertVertex_ = function(segmentData, vertex) { this.setGeometryCoordinates_(geometry, coordinates); var rTree = this.rBush_; - goog.asserts.assert(ol.isDef(segment), 'segment should be defined'); + goog.asserts.assert(segment !== undefined, 'segment should be defined'); rTree.remove(segmentData); - goog.asserts.assert(ol.isDef(index), 'index should be defined'); + goog.asserts.assert(index !== undefined, 'index should be defined'); this.updateSegmentIndices_(geometry, /** @type {number} */ (index), depth, 1); var newSegmentData = /** @type {ol.interaction.SegmentDataType} */ ({ segment: [segment[0], vertex], @@ -884,13 +884,13 @@ ol.interaction.Modify.prototype.removeVertex_ = function() { segmentsByFeature[uid] = [left, right, index]; } newSegment = segmentsByFeature[uid]; - if (ol.isDef(left)) { + if (left !== undefined) { newSegment[0] = left; } - if (ol.isDef(right)) { + if (right !== undefined) { newSegment[1] = right; } - if (ol.isDef(newSegment[0]) && ol.isDef(newSegment[1])) { + if (newSegment[0] !== undefined && newSegment[1] !== undefined) { component = coordinates; deleted = false; newIndex = index - 1; diff --git a/src/ol/interaction/mousewheelzoominteraction.js b/src/ol/interaction/mousewheelzoominteraction.js index 6b7d75d651..5bbfa95577 100644 --- a/src/ol/interaction/mousewheelzoominteraction.js +++ b/src/ol/interaction/mousewheelzoominteraction.js @@ -25,7 +25,7 @@ ol.interaction.MouseWheelZoom = function(opt_options) { handleEvent: ol.interaction.MouseWheelZoom.handleEvent }); - var options = ol.isDef(opt_options) ? opt_options : {}; + var options = opt_options || {}; /** * @private @@ -37,15 +37,13 @@ ol.interaction.MouseWheelZoom = function(opt_options) { * @private * @type {number} */ - this.duration_ = ol.isDef(options.duration) ? - /** @type {number} */ (options.duration) : 250; + this.duration_ = options.duration !== undefined ? options.duration : 250; /** * @private * @type {boolean} */ - this.useAnchor_ = ol.isDef(options.useAnchor) ? - /** @type {boolean} */ (options.useAnchor) : true; + this.useAnchor_ = options.useAnchor !== undefined ? options.useAnchor : true; /** * @private @@ -92,7 +90,7 @@ ol.interaction.MouseWheelZoom.handleEvent = function(mapBrowserEvent) { this.delta_ += mouseWheelEvent.deltaY; - if (!ol.isDef(this.startTime_)) { + if (this.startTime_ === undefined) { this.startTime_ = goog.now(); } diff --git a/src/ol/interaction/pinchrotateinteraction.js b/src/ol/interaction/pinchrotateinteraction.js index 462fe5ad18..c401b7e53d 100644 --- a/src/ol/interaction/pinchrotateinteraction.js +++ b/src/ol/interaction/pinchrotateinteraction.js @@ -29,7 +29,7 @@ ol.interaction.PinchRotate = function(opt_options) { handleUpEvent: ol.interaction.PinchRotate.handleUpEvent_ }); - var options = ol.isDef(opt_options) ? opt_options : {}; + var options = opt_options || {}; /** * @private @@ -59,15 +59,13 @@ ol.interaction.PinchRotate = function(opt_options) { * @private * @type {number} */ - this.threshold_ = ol.isDef(options.threshold) ? - /** @type {number} */ (options.threshold) : 0.3; + this.threshold_ = options.threshold !== undefined ? options.threshold : 0.3; /** * @private * @type {number} */ - this.duration_ = ol.isDef(options.duration) ? - /** @type {number} */ (options.duration) : 250; + this.duration_ = options.duration !== undefined ? options.duration : 250; }; goog.inherits(ol.interaction.PinchRotate, ol.interaction.Pointer); @@ -91,7 +89,7 @@ ol.interaction.PinchRotate.handleDragEvent_ = function(mapBrowserEvent) { touch1.clientY - touch0.clientY, touch1.clientX - touch0.clientX); - if (ol.isDef(this.lastAngle_)) { + if (this.lastAngle_ !== undefined) { var delta = angle - this.lastAngle_; this.rotationDelta_ += delta; if (!this.rotating_ && diff --git a/src/ol/interaction/pinchzoominteraction.js b/src/ol/interaction/pinchzoominteraction.js index 7ff5b8f0c2..e930230233 100644 --- a/src/ol/interaction/pinchzoominteraction.js +++ b/src/ol/interaction/pinchzoominteraction.js @@ -41,8 +41,7 @@ ol.interaction.PinchZoom = function(opt_options) { * @private * @type {number} */ - this.duration_ = ol.isDef(options.duration) ? - /** @type {number} */ (options.duration) : 400; + this.duration_ = options.duration !== undefined ? options.duration : 400; /** * @private @@ -78,7 +77,7 @@ ol.interaction.PinchZoom.handleDragEvent_ = function(mapBrowserEvent) { // distance between touches var distance = Math.sqrt(dx * dx + dy * dy); - if (ol.isDef(this.lastDistance_)) { + if (this.lastDistance_ !== undefined) { scaleDelta = this.lastDistance_ / distance; } this.lastDistance_ = distance; diff --git a/src/ol/interaction/snapinteraction.js b/src/ol/interaction/snapinteraction.js index 30f8b2bbaa..c2079dc82c 100644 --- a/src/ol/interaction/snapinteraction.js +++ b/src/ol/interaction/snapinteraction.js @@ -115,8 +115,8 @@ ol.interaction.Snap = function(opt_options) { * @type {number} * @private */ - this.pixelTolerance_ = ol.isDef(options.pixelTolerance) ? - /** @type {number} */ (options.pixelTolerance) : 10; + this.pixelTolerance_ = options.pixelTolerance !== undefined ? + options.pixelTolerance : 10; /** * @type {function(ol.interaction.Snap.SegmentDataType, ol.interaction.Snap.SegmentDataType): number} @@ -160,8 +160,7 @@ goog.inherits(ol.interaction.Snap, ol.interaction.Pointer); * @api */ ol.interaction.Snap.prototype.addFeature = function(feature, opt_listen) { - var listen = ol.isDef(opt_listen) ? - /** @type {boolean} */ (opt_listen) : true; + var listen = opt_listen !== undefined ? opt_listen : true; var geometry = feature.getGeometry(); var segmentWriter = this.SEGMENT_WRITERS_[geometry.getType()]; if (segmentWriter) { @@ -288,8 +287,7 @@ ol.interaction.Snap.prototype.handleGeometryModify_ = function(feature, evt) { * @api */ ol.interaction.Snap.prototype.removeFeature = function(feature, opt_unlisten) { - var unlisten = ol.isDef(opt_unlisten) ? - /** @type {boolean} */ (opt_unlisten) : true; + var unlisten = opt_unlisten !== undefined ? opt_unlisten : true; var feature_uid = goog.getUid(feature); var extent = this.indexedFeaturesExtents_[feature_uid]; if (extent) { diff --git a/src/ol/layer/heatmaplayer.js b/src/ol/layer/heatmaplayer.js index a299ec5ec3..8e9779aa8a 100644 --- a/src/ol/layer/heatmaplayer.js +++ b/src/ol/layer/heatmaplayer.js @@ -59,8 +59,7 @@ ol.layer.Heatmap = function(opt_options) { * @private * @type {number} */ - this.shadow_ = ol.isDef(options.shadow) ? - /** @type {number} */ (options.shadow) : 250; + this.shadow_ = options.shadow !== undefined ? options.shadow : 250; /** * @private @@ -81,10 +80,10 @@ ol.layer.Heatmap = function(opt_options) { this.setGradient(options.gradient ? options.gradient : ol.layer.Heatmap.DEFAULT_GRADIENT); - this.setBlur(ol.isDef(options.blur) ? + this.setBlur(options.blur !== undefined ? /** @type {number} */ (options.blur) : 15); - this.setRadius(ol.isDef(options.radius) ? + this.setRadius(options.radius !== undefined ? /** @type {number} */ (options.radius) : 8); goog.events.listen(this, [ @@ -112,8 +111,8 @@ ol.layer.Heatmap = function(opt_options) { goog.asserts.assert(this.circleImage_ !== undefined, 'this.circleImage_ should be defined'); var weight = weightFunction(feature); - var opacity = ol.isDef(weight) ? - goog.math.clamp(/** @type {number} */ (weight), 0, 1) : 1; + var opacity = weight !== undefined ? + goog.math.clamp(weight, 0, 1) : 1; // cast to 8 bits var index = (255 * opacity) | 0; var style = this.styleCache_[index]; diff --git a/src/ol/layer/layer.js b/src/ol/layer/layer.js index c85f845d68..6ea5b97fe2 100644 --- a/src/ol/layer/layer.js +++ b/src/ol/layer/layer.js @@ -109,8 +109,7 @@ ol.layer.Layer.prototype.getLayerStatesArray = function(opt_states) { */ ol.layer.Layer.prototype.getSource = function() { var source = this.get(ol.layer.LayerProperty.SOURCE); - return ol.isDef(source) ? - /** @type {ol.source.Source} */ (source) : null; + return /** @type {ol.source.Source} */ (source) || null; }; diff --git a/src/ol/layer/layerbase.js b/src/ol/layer/layerbase.js index dee4b441af..7417c982b4 100644 --- a/src/ol/layer/layerbase.js +++ b/src/ol/layer/layerbase.js @@ -68,23 +68,23 @@ ol.layer.Base = function(options) { */ var properties = goog.object.clone(options); properties[ol.layer.LayerProperty.BRIGHTNESS] = - ol.isDef(options.brightness) ? options.brightness : 0; + options.brightness !== undefined ? options.brightness : 0; properties[ol.layer.LayerProperty.CONTRAST] = - ol.isDef(options.contrast) ? options.contrast : 1; + options.contrast !== undefined ? options.contrast : 1; properties[ol.layer.LayerProperty.HUE] = - ol.isDef(options.hue) ? options.hue : 0; + options.hue !== undefined ? options.hue : 0; properties[ol.layer.LayerProperty.OPACITY] = - ol.isDef(options.opacity) ? options.opacity : 1; + options.opacity !== undefined ? options.opacity : 1; properties[ol.layer.LayerProperty.SATURATION] = - ol.isDef(options.saturation) ? options.saturation : 1; + options.saturation !== undefined ? options.saturation : 1; properties[ol.layer.LayerProperty.VISIBLE] = - ol.isDef(options.visible) ? options.visible : true; + options.visible !== undefined ? options.visible : true; properties[ol.layer.LayerProperty.Z_INDEX] = - ol.isDef(options.zIndex) ? options.zIndex : 0; + options.zIndex !== undefined ? options.zIndex : 0; properties[ol.layer.LayerProperty.MAX_RESOLUTION] = - ol.isDef(options.maxResolution) ? options.maxResolution : Infinity; + options.maxResolution !== undefined ? options.maxResolution : Infinity; properties[ol.layer.LayerProperty.MIN_RESOLUTION] = - ol.isDef(options.minResolution) ? options.minResolution : 0; + options.minResolution !== undefined ? options.minResolution : 0; this.setProperties(properties); }; diff --git a/src/ol/layer/tilelayer.js b/src/ol/layer/tilelayer.js index 3d59d3427a..e1e0894423 100644 --- a/src/ol/layer/tilelayer.js +++ b/src/ol/layer/tilelayer.js @@ -38,10 +38,9 @@ ol.layer.Tile = function(opt_options) { delete baseOptions.useInterimTilesOnError; goog.base(this, /** @type {olx.layer.LayerOptions} */ (baseOptions)); - this.setPreload(ol.isDef(options.preload) ? - /** @type {number} */ (options.preload) : 0); - this.setUseInterimTilesOnError(ol.isDef(options.useInterimTilesOnError) ? - /** @type {boolean} */ (options.useInterimTilesOnError) : true); + this.setPreload(options.preload !== undefined ? options.preload : 0); + this.setUseInterimTilesOnError(options.useInterimTilesOnError !== undefined ? + options.useInterimTilesOnError : true); }; goog.inherits(ol.layer.Tile, ol.layer.Layer); diff --git a/src/ol/layer/vectorlayer.js b/src/ol/layer/vectorlayer.js index c5c6cf5b13..2f50e901b3 100644 --- a/src/ol/layer/vectorlayer.js +++ b/src/ol/layer/vectorlayer.js @@ -51,8 +51,8 @@ ol.layer.Vector = function(opt_options) { * @type {number} * @private */ - this.renderBuffer_ = ol.isDef(options.renderBuffer) ? - /** @type {number} */ (options.renderBuffer) : 100; + this.renderBuffer_ = options.renderBuffer !== undefined ? + options.renderBuffer : 100; /** * User provided style. @@ -74,15 +74,15 @@ ol.layer.Vector = function(opt_options) { * @type {boolean} * @private */ - this.updateWhileAnimating_ = ol.isDef(options.updateWhileAnimating) ? - /** @type {boolean} */ (options.updateWhileAnimating) : false; + this.updateWhileAnimating_ = options.updateWhileAnimating !== undefined ? + options.updateWhileAnimating : false; /** * @type {boolean} * @private */ - this.updateWhileInteracting_ = ol.isDef(options.updateWhileInteracting) ? - /** @type {boolean} */ (options.updateWhileInteracting) : false; + this.updateWhileInteracting_ = options.updateWhileInteracting !== undefined ? + options.updateWhileInteracting : false; }; goog.inherits(ol.layer.Vector, ol.layer.Layer); @@ -180,11 +180,7 @@ ol.layer.Vector.prototype.setRenderOrder = function(renderOrder) { * @api stable */ ol.layer.Vector.prototype.setStyle = function(style) { - this.style_ = ol.isDef(style) ? - /** - * @type {ol.style.Style|Array.|ol.style.StyleFunction|null} - */ - (style) : ol.style.defaultStyleFunction; + this.style_ = style !== undefined ? style : ol.style.defaultStyleFunction; this.styleFunction_ = goog.isNull(style) ? undefined : ol.style.createStyleFunction(this.style_); this.changed(); diff --git a/src/ol/ol.js b/src/ol/ol.js index 4b7969102a..ba1c7e6282 100644 --- a/src/ol/ol.js +++ b/src/ol/ol.js @@ -240,13 +240,3 @@ ol.WEBGL_EXTENSIONS; // value is set in `ol.has` ol.inherits = goog.inherits; // note that the newline above is necessary to satisfy the linter - - -/** - * Determine if a value is defined. - * @param {?} value The value to test. - * @return {boolean} The value is defined. - */ -ol.isDef = function(value) { - return value !== undefined; -}; diff --git a/src/ol/pointer/touchsource.js b/src/ol/pointer/touchsource.js index 7d0a7c6590..032ebaef85 100644 --- a/src/ol/pointer/touchsource.js +++ b/src/ol/pointer/touchsource.js @@ -169,7 +169,7 @@ ol.pointer.TouchSource.prototype.resetClickCountHandler_ = function() { * @private */ ol.pointer.TouchSource.prototype.cancelResetClickCount_ = function() { - if (ol.isDef(this.resetId_)) { + if (this.resetId_ !== undefined) { goog.global.clearTimeout(this.resetId_); } }; diff --git a/src/ol/renderer/maprenderer.js b/src/ol/renderer/maprenderer.js index 9b686d9eed..4fb7150b6e 100644 --- a/src/ol/renderer/maprenderer.js +++ b/src/ol/renderer/maprenderer.js @@ -140,7 +140,7 @@ ol.renderer.Map.prototype.forEachFeatureAtCoordinate = * @return {?} Callback result. */ function forEachFeatureAtCoordinate(feature) { - goog.asserts.assert(ol.isDef(feature), 'received a feature'); + goog.asserts.assert(feature !== undefined, 'received a feature'); var key = goog.getUid(feature).toString(); if (!(key in features)) { features[key] = true; @@ -242,7 +242,7 @@ ol.renderer.Map.prototype.hasFeatureAtCoordinate = var hasFeature = this.forEachFeatureAtCoordinate( coordinate, frameState, goog.functions.TRUE, this, layerFilter, thisArg); - return ol.isDef(hasFeature); + return hasFeature !== undefined; }; From cf5eadebaa0e64d324aeec07a417f6ffa8612eb6 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Sun, 27 Sep 2015 10:11:30 -0600 Subject: [PATCH 72/93] Define options --- src/ol/geolocation.js | 2 +- src/ol/graticule.js | 2 +- src/ol/layer/layergroup.js | 2 +- src/ol/source/imagewmssource.js | 2 +- src/ol/source/mapquestsource.js | 2 +- src/ol/source/osmsource.js | 2 +- src/ol/source/tilearcgisrestsource.js | 2 +- src/ol/source/tilewmssource.js | 2 +- src/ol/source/vectorsource.js | 2 +- src/ol/source/zoomifysource.js | 2 +- src/ol/style/atlasmanager.js | 2 +- src/ol/style/circlestyle.js | 2 +- src/ol/style/fillstyle.js | 2 +- src/ol/style/iconstyle.js | 2 +- src/ol/style/strokestyle.js | 2 +- src/ol/style/style.js | 2 +- src/ol/style/textstyle.js | 2 +- src/ol/view.js | 4 ++-- 18 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/ol/geolocation.js b/src/ol/geolocation.js index 4386784b42..01b29e4d0a 100644 --- a/src/ol/geolocation.js +++ b/src/ol/geolocation.js @@ -62,7 +62,7 @@ ol.Geolocation = function(opt_options) { goog.base(this); - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = opt_options || {}; /** * The unprojected (EPSG:4326) device position. diff --git a/src/ol/graticule.js b/src/ol/graticule.js index a005774177..ab3b84dc98 100644 --- a/src/ol/graticule.js +++ b/src/ol/graticule.js @@ -20,7 +20,7 @@ goog.require('ol.style.Stroke'); */ ol.Graticule = function(opt_options) { - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = opt_options || {}; /** * @type {ol.Map} diff --git a/src/ol/layer/layergroup.js b/src/ol/layer/layergroup.js index ece8ffa558..f3456efe2b 100644 --- a/src/ol/layer/layergroup.js +++ b/src/ol/layer/layergroup.js @@ -38,7 +38,7 @@ ol.layer.GroupProperty = { */ ol.layer.Group = function(opt_options) { - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = opt_options || {}; var baseOptions = /** @type {olx.layer.GroupOptions} */ (goog.object.clone(options)); delete baseOptions.layers; diff --git a/src/ol/source/imagewmssource.js b/src/ol/source/imagewmssource.js index e098af2960..ec126ecbd6 100644 --- a/src/ol/source/imagewmssource.js +++ b/src/ol/source/imagewmssource.js @@ -31,7 +31,7 @@ goog.require('ol.source.wms.ServerType'); */ ol.source.ImageWMS = function(opt_options) { - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = opt_options || {}; goog.base(this, { attributions: options.attributions, diff --git a/src/ol/source/mapquestsource.js b/src/ol/source/mapquestsource.js index 1fbf63a26a..f073c13f00 100644 --- a/src/ol/source/mapquestsource.js +++ b/src/ol/source/mapquestsource.js @@ -18,7 +18,7 @@ goog.require('ol.source.XYZ'); */ ol.source.MapQuest = function(opt_options) { - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = opt_options || {}; goog.asserts.assert(options.layer in ol.source.MapQuestConfig, 'known layer configured'); diff --git a/src/ol/source/osmsource.js b/src/ol/source/osmsource.js index 84a8532ca0..10d9c90b85 100644 --- a/src/ol/source/osmsource.js +++ b/src/ol/source/osmsource.js @@ -16,7 +16,7 @@ goog.require('ol.source.XYZ'); */ ol.source.OSM = function(opt_options) { - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = opt_options || {}; var attributions; if (goog.isDef(options.attributions)) { diff --git a/src/ol/source/tilearcgisrestsource.js b/src/ol/source/tilearcgisrestsource.js index a337ea01f8..8ec3c9e74c 100644 --- a/src/ol/source/tilearcgisrestsource.js +++ b/src/ol/source/tilearcgisrestsource.js @@ -32,7 +32,7 @@ goog.require('ol.tilecoord'); */ ol.source.TileArcGISRest = function(opt_options) { - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = opt_options || {}; var params = goog.isDef(options.params) ? options.params : {}; diff --git a/src/ol/source/tilewmssource.js b/src/ol/source/tilewmssource.js index d90bdaaad6..8a17db97da 100644 --- a/src/ol/source/tilewmssource.js +++ b/src/ol/source/tilewmssource.js @@ -33,7 +33,7 @@ goog.require('ol.tilecoord'); */ ol.source.TileWMS = function(opt_options) { - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = opt_options || {}; var params = goog.isDef(options.params) ? options.params : {}; diff --git a/src/ol/source/vectorsource.js b/src/ol/source/vectorsource.js index f03b9517b2..7c54380b7b 100644 --- a/src/ol/source/vectorsource.js +++ b/src/ol/source/vectorsource.js @@ -75,7 +75,7 @@ ol.source.VectorEventType = { */ ol.source.Vector = function(opt_options) { - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = opt_options || {}; goog.base(this, { attributions: options.attributions, diff --git a/src/ol/source/zoomifysource.js b/src/ol/source/zoomifysource.js index 4a40b00731..bad8153fbc 100644 --- a/src/ol/source/zoomifysource.js +++ b/src/ol/source/zoomifysource.js @@ -33,7 +33,7 @@ ol.source.ZoomifyTierSizeCalculation = { */ ol.source.Zoomify = function(opt_options) { - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = opt_options || {}; var size = options.size; var tierSizeCalculation = goog.isDef(options.tierSizeCalculation) ? diff --git a/src/ol/style/atlasmanager.js b/src/ol/style/atlasmanager.js index f49a41cc67..2c64a703f4 100644 --- a/src/ol/style/atlasmanager.js +++ b/src/ol/style/atlasmanager.js @@ -40,7 +40,7 @@ ol.style.AtlasManagerInfo; */ ol.style.AtlasManager = function(opt_options) { - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = opt_options || {}; /** * The size in pixels of the latest atlas image. diff --git a/src/ol/style/circlestyle.js b/src/ol/style/circlestyle.js index e9d7a2e9ab..aeb23d8933 100644 --- a/src/ol/style/circlestyle.js +++ b/src/ol/style/circlestyle.js @@ -26,7 +26,7 @@ goog.require('ol.style.Stroke'); */ ol.style.Circle = function(opt_options) { - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = opt_options || {}; /** * @private diff --git a/src/ol/style/fillstyle.js b/src/ol/style/fillstyle.js index c6bf1f0273..74f5162b62 100644 --- a/src/ol/style/fillstyle.js +++ b/src/ol/style/fillstyle.js @@ -16,7 +16,7 @@ goog.require('ol.structs.IHasChecksum'); */ ol.style.Fill = function(opt_options) { - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = opt_options || {}; /** * @private diff --git a/src/ol/style/iconstyle.js b/src/ol/style/iconstyle.js index 92e72face4..87d13574a2 100644 --- a/src/ol/style/iconstyle.js +++ b/src/ol/style/iconstyle.js @@ -49,7 +49,7 @@ ol.style.IconOrigin = { */ ol.style.Icon = function(opt_options) { - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = opt_options || {}; /** * @private diff --git a/src/ol/style/strokestyle.js b/src/ol/style/strokestyle.js index 2707017d03..e5599ab044 100644 --- a/src/ol/style/strokestyle.js +++ b/src/ol/style/strokestyle.js @@ -21,7 +21,7 @@ goog.require('ol.structs.IHasChecksum'); */ ol.style.Stroke = function(opt_options) { - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = opt_options || {}; /** * @private diff --git a/src/ol/style/style.js b/src/ol/style/style.js index a099d11d60..68897feb2d 100644 --- a/src/ol/style/style.js +++ b/src/ol/style/style.js @@ -26,7 +26,7 @@ goog.require('ol.style.Stroke'); */ ol.style.Style = function(opt_options) { - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = opt_options || {}; /** * @private diff --git a/src/ol/style/textstyle.js b/src/ol/style/textstyle.js index 6c7ad87222..a8e127047b 100644 --- a/src/ol/style/textstyle.js +++ b/src/ol/style/textstyle.js @@ -15,7 +15,7 @@ goog.require('ol.style.Fill'); */ ol.style.Text = function(opt_options) { - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = opt_options || {}; /** * @private diff --git a/src/ol/view.js b/src/ol/view.js index 12f79b01e5..48c0aa9161 100644 --- a/src/ol/view.js +++ b/src/ol/view.js @@ -100,7 +100,7 @@ ol.ViewHint = { */ ol.View = function(opt_options) { goog.base(this); - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = opt_options || {}; /** * @private @@ -456,7 +456,7 @@ ol.View.prototype.fit = function(geometry, size, opt_options) { geometry = ol.geom.Polygon.fromExtent(geometry); } - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = opt_options || {}; var padding = goog.isDef(options.padding) ? options.padding : [0, 0, 0, 0]; var constrainResolution = goog.isDef(options.constrainResolution) ? From 7659e47e0799b04f4718d347eed29f334de55ef4 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Sun, 27 Sep 2015 10:18:44 -0600 Subject: [PATCH 73/93] Inline simple goog.isDef() checks --- src/ol/geom/flat/flipflatgeom.js | 2 +- src/ol/image.js | 2 +- src/ol/imagetile.js | 2 +- src/ol/object.js | 2 +- src/ol/proj/proj.js | 8 ++++---- src/ol/render/canvas/canvasimmediate.js | 2 +- src/ol/render/canvas/canvasreplay.js | 14 +++++++------- src/ol/render/webgl/webglimmediate.js | 2 +- src/ol/render/webgl/webglreplay.js | 4 ++-- src/ol/renderer/layerrenderer.js | 4 ++-- src/ol/resolutionconstraint.js | 6 +++--- src/ol/rotationconstraint.js | 8 ++++---- src/ol/source/imagemapguidesource.js | 2 +- src/ol/source/tilevectorsource.js | 6 +++--- src/ol/source/vectorsource.js | 10 +++++----- src/ol/source/wmtssource.js | 4 ++-- src/ol/style/style.js | 2 +- src/ol/tilecoord.js | 2 +- src/ol/tilerange.js | 2 +- src/ol/view.js | 8 ++++---- src/ol/webgl/context.js | 4 ++-- src/ol/xml.js | 22 +++++++++++----------- 22 files changed, 59 insertions(+), 59 deletions(-) diff --git a/src/ol/geom/flat/flipflatgeom.js b/src/ol/geom/flat/flipflatgeom.js index b40e51e63d..fbf6bd7c72 100644 --- a/src/ol/geom/flat/flipflatgeom.js +++ b/src/ol/geom/flat/flipflatgeom.js @@ -15,7 +15,7 @@ goog.require('goog.asserts'); ol.geom.flat.flip.flipXY = function(flatCoordinates, offset, end, stride, opt_dest, opt_destOffset) { var dest, destOffset; - if (goog.isDef(opt_dest)) { + if (opt_dest !== undefined) { dest = opt_dest; destOffset = goog.isDef(opt_destOffset) ? opt_destOffset : 0; } else { diff --git a/src/ol/image.js b/src/ol/image.js index cc2f71fd41..d98229bc43 100644 --- a/src/ol/image.js +++ b/src/ol/image.js @@ -78,7 +78,7 @@ goog.inherits(ol.Image, ol.ImageBase); * @api */ ol.Image.prototype.getImage = function(opt_context) { - if (goog.isDef(opt_context)) { + if (opt_context !== undefined) { var image; var key = goog.getUid(opt_context); if (key in this.imageByContext_) { diff --git a/src/ol/imagetile.js b/src/ol/imagetile.js index 4750d17970..60e7730387 100644 --- a/src/ol/imagetile.js +++ b/src/ol/imagetile.js @@ -81,7 +81,7 @@ ol.ImageTile.prototype.disposeInternal = function() { * @api */ ol.ImageTile.prototype.getImage = function(opt_context) { - if (goog.isDef(opt_context)) { + if (opt_context !== undefined) { var image; var key = goog.getUid(opt_context); if (key in this.imageByContext_) { diff --git a/src/ol/object.js b/src/ol/object.js index 9eaf670b2a..ece1321182 100644 --- a/src/ol/object.js +++ b/src/ol/object.js @@ -116,7 +116,7 @@ ol.Object = function(opt_values) { */ this.values_ = {}; - if (goog.isDef(opt_values)) { + if (opt_values !== undefined) { this.setProperties(opt_values); } }; diff --git a/src/ol/proj/proj.js b/src/ol/proj/proj.js index 081578af4d..b0d8a10fd1 100644 --- a/src/ol/proj/proj.js +++ b/src/ol/proj/proj.js @@ -148,7 +148,7 @@ ol.proj.Projection = function(options) { if (ol.ENABLE_PROJ4JS && typeof proj4 == 'function' && !goog.isDef(projections[code])) { var def = proj4.defs(code); - if (goog.isDef(def)) { + if (def !== undefined) { if (goog.isDef(def.axis) && !goog.isDef(options.axisOrientation)) { this.axisOrientation_ = def.axis; } @@ -165,7 +165,7 @@ ol.proj.Projection = function(options) { var currentCode, currentDef, currentProj, proj4Transform; for (currentCode in projections) { currentDef = proj4.defs(currentCode); - if (goog.isDef(currentDef)) { + if (currentDef !== undefined) { currentProj = ol.proj.get(currentCode); if (currentDef === def) { ol.proj.addEquivalentProjections([currentProj, this]); @@ -361,7 +361,7 @@ ol.proj.Projection.prototype.getPointResolution_ = function(resolution, point) { vertices.slice(4, 6), vertices.slice(6, 8)); var pointResolution = (width + height) / 2; var metersPerUnit = this.getMetersPerUnit(); - if (goog.isDef(metersPerUnit)) { + if (metersPerUnit !== undefined) { pointResolution /= metersPerUnit; } return pointResolution; @@ -761,7 +761,7 @@ ol.proj.identityTransform = function(input, opt_output, opt_dimension) { */ ol.proj.cloneTransform = function(input, opt_output, opt_dimension) { var output; - if (goog.isDef(opt_output)) { + if (opt_output !== undefined) { for (var i = 0, ii = input.length; i < ii; ++i) { opt_output[i] = input[i]; } diff --git a/src/ol/render/canvas/canvasimmediate.js b/src/ol/render/canvas/canvasimmediate.js index ce0ed0e96e..65ffc8c08c 100644 --- a/src/ol/render/canvas/canvasimmediate.js +++ b/src/ol/render/canvas/canvasimmediate.js @@ -417,7 +417,7 @@ ol.render.canvas.Immediate.prototype.drawRings_ = ol.render.canvas.Immediate.prototype.drawAsync = function(zIndex, callback) { var zIndexKey = zIndex.toString(); var callbacks = this.callbacksByZIndex_[zIndexKey]; - if (goog.isDef(callbacks)) { + if (callbacks !== undefined) { callbacks.push(callback); } else { this.callbacksByZIndex_[zIndexKey] = [callback]; diff --git a/src/ol/render/canvas/canvasreplay.js b/src/ol/render/canvas/canvasreplay.js index 00e130f1ac..cd9c90e0f1 100644 --- a/src/ol/render/canvas/canvasreplay.js +++ b/src/ol/render/canvas/canvasreplay.js @@ -406,7 +406,7 @@ ol.render.canvas.Replay.prototype.replay_ = function( ++i; break; case ol.render.canvas.Instruction.END_GEOMETRY: - if (goog.isDef(featureCallback)) { + if (featureCallback !== undefined) { feature = /** @type {ol.Feature} */ (instruction[1]); var result = featureCallback(feature); if (result) { @@ -1220,7 +1220,7 @@ ol.render.canvas.PolygonReplay.prototype.drawCircleGeometry = if (!goog.isDef(fillStyle) && !goog.isDef(strokeStyle)) { return; } - if (goog.isDef(strokeStyle)) { + if (strokeStyle !== undefined) { goog.asserts.assert(goog.isDef(state.lineWidth), 'state.lineWidth should be defined'); } @@ -1273,7 +1273,7 @@ ol.render.canvas.PolygonReplay.prototype.drawPolygonGeometry = if (!goog.isDef(fillStyle) && !goog.isDef(strokeStyle)) { return; } - if (goog.isDef(strokeStyle)) { + if (strokeStyle !== undefined) { goog.asserts.assert(goog.isDef(state.lineWidth), 'state.lineWidth should be defined'); } @@ -1309,7 +1309,7 @@ ol.render.canvas.PolygonReplay.prototype.drawMultiPolygonGeometry = if (!goog.isDef(fillStyle) && !goog.isDef(strokeStyle)) { return; } - if (goog.isDef(strokeStyle)) { + if (strokeStyle !== undefined) { goog.asserts.assert(goog.isDef(state.lineWidth), 'state.lineWidth should be defined'); } @@ -1446,7 +1446,7 @@ ol.render.canvas.PolygonReplay.prototype.setFillStrokeStyles_ = function() { [ol.render.canvas.Instruction.SET_FILL_STYLE, fillStyle]); state.currentFillStyle = state.fillStyle; } - if (goog.isDef(strokeStyle)) { + if (strokeStyle !== undefined) { goog.asserts.assert(goog.isDef(lineCap), 'lineCap should be defined'); goog.asserts.assert(!goog.isNull(lineDash), 'lineDash should not be null'); goog.asserts.assert(goog.isDef(lineJoin), 'lineJoin should be defined'); @@ -1984,7 +1984,7 @@ ol.render.canvas.ReplayGroup.prototype.replay = function( replays = this.replaysByZIndex_[zs[i].toString()]; for (j = 0, jj = ol.render.REPLAY_ORDER.length; j < jj; ++j) { replay = replays[ol.render.REPLAY_ORDER[j]]; - if (goog.isDef(replay)) { + if (replay !== undefined) { replay.replay(context, pixelRatio, transform, viewRotation, skippedFeaturesHash); } @@ -2020,7 +2020,7 @@ ol.render.canvas.ReplayGroup.prototype.replayHitDetection_ = function( replays = this.replaysByZIndex_[zs[i].toString()]; for (j = ol.render.REPLAY_ORDER.length - 1; j >= 0; --j) { replay = replays[ol.render.REPLAY_ORDER[j]]; - if (goog.isDef(replay)) { + if (replay !== undefined) { result = replay.replayHitDetection(context, transform, viewRotation, skippedFeaturesHash, featureCallback, opt_hitExtent); if (result) { diff --git a/src/ol/render/webgl/webglimmediate.js b/src/ol/render/webgl/webglimmediate.js index 8e7fb7ad81..007d1d2bd0 100644 --- a/src/ol/render/webgl/webglimmediate.js +++ b/src/ol/render/webgl/webglimmediate.js @@ -103,7 +103,7 @@ ol.render.webgl.Immediate.prototype.flush = function() { ol.render.webgl.Immediate.prototype.drawAsync = function(zIndex, callback) { var zIndexKey = zIndex.toString(); var callbacks = this.callbacksByZIndex_[zIndexKey]; - if (goog.isDef(callbacks)) { + if (callbacks !== undefined) { callbacks.push(callback); } else { this.callbacksByZIndex_[zIndexKey] = [callback]; diff --git a/src/ol/render/webgl/webglreplay.js b/src/ol/render/webgl/webglreplay.js index 158d6cffa4..0d3b450b1f 100644 --- a/src/ol/render/webgl/webglreplay.js +++ b/src/ol/render/webgl/webglreplay.js @@ -1078,7 +1078,7 @@ ol.render.webgl.ReplayGroup.prototype.replay = function(context, var i, ii, replay, result; for (i = 0, ii = ol.render.REPLAY_ORDER.length; i < ii; ++i) { replay = this.replays_[ol.render.REPLAY_ORDER[i]]; - if (goog.isDef(replay)) { + if (replay !== undefined) { replay.replay(context, center, resolution, rotation, size, pixelRatio, opacity, brightness, contrast, hue, saturation, skippedFeaturesHash, @@ -1117,7 +1117,7 @@ ol.render.webgl.ReplayGroup.prototype.replayHitDetection_ = function(context, var i, replay, result; for (i = ol.render.REPLAY_ORDER.length - 1; i >= 0; --i) { replay = this.replays_[ol.render.REPLAY_ORDER[i]]; - if (goog.isDef(replay)) { + if (replay !== undefined) { result = replay.replay(context, center, resolution, rotation, size, pixelRatio, opacity, brightness, contrast, hue, saturation, diff --git a/src/ol/renderer/layerrenderer.js b/src/ol/renderer/layerrenderer.js index 070dedb620..81fd1fb375 100644 --- a/src/ol/renderer/layerrenderer.js +++ b/src/ol/renderer/layerrenderer.js @@ -221,7 +221,7 @@ ol.renderer.Layer.prototype.updateAttributions = */ ol.renderer.Layer.prototype.updateLogos = function(frameState, source) { var logo = source.getLogo(); - if (goog.isDef(logo)) { + if (logo !== undefined) { if (goog.isString(logo)) { frameState.logos[logo] = ''; } else if (goog.isObject(logo)) { @@ -319,7 +319,7 @@ ol.renderer.Layer.prototype.manageTilePyramid = function( tileGrid.getTileCoordCenter(tile.tileCoord), tileResolution]); } } - if (goog.isDef(opt_tileCallback)) { + if (opt_tileCallback !== undefined) { opt_tileCallback.call(opt_this, tile); } } else { diff --git a/src/ol/resolutionconstraint.js b/src/ol/resolutionconstraint.js index a90162d6b5..be38b6d2aa 100644 --- a/src/ol/resolutionconstraint.js +++ b/src/ol/resolutionconstraint.js @@ -25,7 +25,7 @@ ol.ResolutionConstraint.createSnapToResolutions = * @return {number|undefined} Resolution. */ function(resolution, delta, direction) { - if (goog.isDef(resolution)) { + if (resolution !== undefined) { var z = ol.array.linearFindNearest(resolutions, resolution, direction); z = goog.math.clamp(z + delta, 0, resolutions.length - 1); @@ -53,7 +53,7 @@ ol.ResolutionConstraint.createSnapToPower = * @return {number|undefined} Resolution. */ function(resolution, delta, direction) { - if (goog.isDef(resolution)) { + if (resolution !== undefined) { var offset; if (direction > 0) { offset = 0; @@ -65,7 +65,7 @@ ol.ResolutionConstraint.createSnapToPower = var oldLevel = Math.floor( Math.log(maxResolution / resolution) / Math.log(power) + offset); var newLevel = Math.max(oldLevel + delta, 0); - if (goog.isDef(opt_maxLevel)) { + if (opt_maxLevel !== undefined) { newLevel = Math.min(newLevel, opt_maxLevel); } return maxResolution / Math.pow(power, newLevel); diff --git a/src/ol/rotationconstraint.js b/src/ol/rotationconstraint.js index fc73600f4e..69996cfaf4 100644 --- a/src/ol/rotationconstraint.js +++ b/src/ol/rotationconstraint.js @@ -16,7 +16,7 @@ ol.RotationConstraintType; * @return {number|undefined} Rotation. */ ol.RotationConstraint.disable = function(rotation, delta) { - if (goog.isDef(rotation)) { + if (rotation !== undefined) { return 0; } else { return undefined; @@ -30,7 +30,7 @@ ol.RotationConstraint.disable = function(rotation, delta) { * @return {number|undefined} Rotation. */ ol.RotationConstraint.none = function(rotation, delta) { - if (goog.isDef(rotation)) { + if (rotation !== undefined) { return rotation + delta; } else { return undefined; @@ -51,7 +51,7 @@ ol.RotationConstraint.createSnapToN = function(n) { * @return {number|undefined} Rotation. */ function(rotation, delta) { - if (goog.isDef(rotation)) { + if (rotation !== undefined) { rotation = Math.floor((rotation + delta) / theta + 0.5) * theta; return rotation; } else { @@ -74,7 +74,7 @@ ol.RotationConstraint.createSnapToZero = function(opt_tolerance) { * @return {number|undefined} Rotation. */ function(rotation, delta) { - if (goog.isDef(rotation)) { + if (rotation !== undefined) { if (Math.abs(rotation + delta) <= tolerance) { return 0; } else { diff --git a/src/ol/source/imagemapguidesource.js b/src/ol/source/imagemapguidesource.js index 88c94f7dff..ac89d59b48 100644 --- a/src/ol/source/imagemapguidesource.js +++ b/src/ol/source/imagemapguidesource.js @@ -149,7 +149,7 @@ ol.source.ImageMapGuide.prototype.getImage = var size = [width * pixelRatio, height * pixelRatio]; var imageUrl = this.imageUrlFunction_(extent, size, projection); - if (goog.isDef(imageUrl)) { + if (imageUrl !== undefined) { image = new ol.Image(extent, resolution, pixelRatio, this.getAttributions(), imageUrl, this.crossOrigin_, this.imageLoadFunction_); diff --git a/src/ol/source/tilevectorsource.js b/src/ol/source/tilevectorsource.js index 4d274e5e87..e1d9b04233 100644 --- a/src/ol/source/tilevectorsource.js +++ b/src/ol/source/tilevectorsource.js @@ -129,7 +129,7 @@ ol.source.TileVector.prototype.forEachFeatureAtCoordinateAndResolution = var tileKey = this.getTileKeyZXY_(tileCoord[0], tileCoord[1], tileCoord[2]); var features = tiles[tileKey]; - if (goog.isDef(features)) { + if (features !== undefined) { var i, ii; for (i = 0, ii = features.length; i < ii; ++i) { var feature = features[i]; @@ -168,7 +168,7 @@ ol.source.TileVector.prototype.forEachFeatureInExtentAtResolution = for (y = tileRange.minY; y <= tileRange.maxY; ++y) { var tileKey = this.getTileKeyZXY_(z, x, y); var features = tiles[tileKey]; - if (goog.isDef(features)) { + if (features !== undefined) { var i, ii; for (i = 0, ii = features.length; i < ii; ++i) { var result = f.call(opt_this, features[i]); @@ -305,7 +305,7 @@ ol.source.TileVector.prototype.loadFeatures = tileCoord, projection); var url = goog.isNull(urlTileCoord) ? undefined : tileUrlFunction(urlTileCoord, 1, projection); - if (goog.isDef(url)) { + if (url !== undefined) { tiles[tileKey] = []; var tileSuccess = goog.partial(success, tileKey); if (!goog.isNull(this.tileLoadFunction_)) { diff --git a/src/ol/source/vectorsource.js b/src/ol/source/vectorsource.js index 7c54380b7b..29aea30397 100644 --- a/src/ol/source/vectorsource.js +++ b/src/ol/source/vectorsource.js @@ -164,10 +164,10 @@ ol.source.Vector = function(opt_options) { if (!useSpatialIndex && !goog.isDef(collection)) { collection = new ol.Collection(features); } - if (goog.isDef(features)) { + if (features !== undefined) { this.addFeaturesInternal(features); } - if (goog.isDef(collection)) { + if (collection !== undefined) { this.bindFeaturesCollection_(collection); } @@ -246,7 +246,7 @@ ol.source.Vector.prototype.setupChangeEvents_ = function(featureKey, feature) { ol.source.Vector.prototype.addToIndex_ = function(featureKey, feature) { var valid = true; var id = feature.getId(); - if (goog.isDef(id)) { + if (id !== undefined) { if (!(id.toString() in this.idIndex_)) { this.idIndex_[id.toString()] = feature; } else { @@ -726,7 +726,7 @@ ol.source.Vector.prototype.handleFeatureChange_ = function(event) { } var id = feature.getId(); var removed; - if (goog.isDef(id)) { + if (id !== undefined) { var sid = id.toString(); if (featureKey in this.undefIdIndex_) { delete this.undefIdIndex_[featureKey]; @@ -827,7 +827,7 @@ ol.source.Vector.prototype.removeFeatureInternal = function(feature) { goog.events.unlistenByKey); delete this.featureChangeKeys_[featureKey]; var id = feature.getId(); - if (goog.isDef(id)) { + if (id !== undefined) { delete this.idIndex_[id.toString()]; } else { delete this.undefIdIndex_[featureKey]; diff --git a/src/ol/source/wmtssource.js b/src/ol/source/wmtssource.js index 08ddff7e4c..616c82d843 100644 --- a/src/ol/source/wmtssource.js +++ b/src/ol/source/wmtssource.js @@ -404,7 +404,7 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) { goog.array.forEach(l['Dimension'], function(elt, index, array) { var key = elt['Identifier']; var value = elt['default']; - if (goog.isDef(value)) { + if (value !== undefined) { goog.asserts.assert(goog.array.contains(elt['values'], value), 'default value contained in values'); } else { @@ -432,7 +432,7 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) { var wgs84BoundingBox = l['WGS84BoundingBox']; var extent, wrapX; - if (goog.isDef(wgs84BoundingBox)) { + if (wgs84BoundingBox !== undefined) { var wgs84ProjectionExtent = ol.proj.get('EPSG:4326').getExtent(); wrapX = (wgs84BoundingBox[0] == wgs84ProjectionExtent[0] && wgs84BoundingBox[2] == wgs84ProjectionExtent[2]); diff --git a/src/ol/style/style.js b/src/ol/style/style.js index 68897feb2d..0a8ab7a6be 100644 --- a/src/ol/style/style.js +++ b/src/ol/style/style.js @@ -172,7 +172,7 @@ ol.style.Style.prototype.setGeometry = function(geometry) { }; } else if (goog.isNull(geometry)) { this.geometryFunction_ = ol.style.defaultGeometryFunction; - } else if (goog.isDef(geometry)) { + } else if (geometry !== undefined) { goog.asserts.assertInstanceof(geometry, ol.geom.Geometry, 'geometry must be an ol.geom.Geometry instance'); this.geometryFunction_ = function() { diff --git a/src/ol/tilecoord.js b/src/ol/tilecoord.js index 190f83ac11..99481d48fc 100644 --- a/src/ol/tilecoord.js +++ b/src/ol/tilecoord.js @@ -50,7 +50,7 @@ ol.tilecoord.createFromString = function(str) { * @return {ol.TileCoord} Tile coordinate. */ ol.tilecoord.createOrUpdate = function(z, x, y, opt_tileCoord) { - if (goog.isDef(opt_tileCoord)) { + if (opt_tileCoord !== undefined) { opt_tileCoord[0] = z; opt_tileCoord[1] = x; opt_tileCoord[2] = y; diff --git a/src/ol/tilerange.js b/src/ol/tilerange.js index 47ecd29103..1052149c91 100644 --- a/src/ol/tilerange.js +++ b/src/ol/tilerange.js @@ -79,7 +79,7 @@ ol.TileRange.boundingTileRange = function(var_args) { * @return {ol.TileRange} Tile range. */ ol.TileRange.createOrUpdate = function(minX, maxX, minY, maxY, tileRange) { - if (goog.isDef(tileRange)) { + if (tileRange !== undefined) { tileRange.minX = minX; tileRange.maxX = maxX; tileRange.minY = minY; diff --git a/src/ol/view.js b/src/ol/view.js index 48c0aa9161..7f584d9566 100644 --- a/src/ol/view.js +++ b/src/ol/view.js @@ -175,7 +175,7 @@ goog.inherits(ol.View, ol.Object); ol.View.prototype.calculateCenterRotate = function(rotation, anchor) { var center; var currentCenter = this.getCenter(); - if (goog.isDef(currentCenter)) { + if (currentCenter !== undefined) { center = [currentCenter[0] - anchor[0], currentCenter[1] - anchor[1]]; ol.coordinate.rotate(center, rotation - this.getRotation()); ol.coordinate.add(center, anchor); @@ -421,7 +421,7 @@ ol.View.prototype.getZoom = function() { var offset; var resolution = this.getResolution(); - if (goog.isDef(resolution)) { + if (resolution !== undefined) { var res, z = 0; do { res = this.constrainResolution(this.maxResolution_, z); @@ -564,7 +564,7 @@ ol.View.prototype.isDef = function() { * @api stable */ ol.View.prototype.rotate = function(rotation, opt_anchor) { - if (goog.isDef(opt_anchor)) { + if (opt_anchor !== undefined) { var center = this.calculateCenterRotate(rotation, opt_anchor); this.setCenter(center); } @@ -695,7 +695,7 @@ ol.View.createResolutionConstraint_ = function(options) { // user provided maxResolution takes precedence maxResolution = options.maxResolution; - if (goog.isDef(maxResolution)) { + if (maxResolution !== undefined) { minZoom = 0; } else { maxResolution = defaultMaxResolution / Math.pow(zoomFactor, minZoom); diff --git a/src/ol/webgl/context.js b/src/ol/webgl/context.js index 943fae8113..2357e7884f 100644 --- a/src/ol/webgl/context.js +++ b/src/ol/webgl/context.js @@ -367,11 +367,11 @@ ol.webgl.Context.createTexture_ = function(gl, opt_wrapS, opt_wrapT) { gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); - if (goog.isDef(opt_wrapS)) { + if (opt_wrapS !== undefined) { gl.texParameteri( goog.webgl.TEXTURE_2D, goog.webgl.TEXTURE_WRAP_S, opt_wrapS); } - if (goog.isDef(opt_wrapT)) { + if (opt_wrapT !== undefined) { gl.texParameteri( goog.webgl.TEXTURE_2D, goog.webgl.TEXTURE_WRAP_T, opt_wrapT); } diff --git a/src/ol/xml.js b/src/ol/xml.js index ec5dc30935..68bf281e62 100644 --- a/src/ol/xml.js +++ b/src/ol/xml.js @@ -132,7 +132,7 @@ ol.xml.getLocalName_ = function(node) { */ ol.xml.getLocalNameIE_ = function(node) { var localName = node.localName; - if (goog.isDef(localName)) { + if (localName !== undefined) { return localName; } var baseName = node.baseName; @@ -227,7 +227,7 @@ ol.xml.getAttributeNS_ = function(node, namespaceURI, name) { ol.xml.getAttributeNSActiveX_ = function(node, namespaceURI, name) { var attributeValue = ''; var attributeNode = ol.xml.getAttributeNodeNS(node, namespaceURI, name); - if (goog.isDef(attributeNode)) { + if (attributeNode !== undefined) { attributeValue = attributeNode.nodeValue; } return attributeValue; @@ -363,7 +363,7 @@ ol.xml.makeArrayExtender = function(valueReader, opt_this) { */ function(node, objectStack) { var value = valueReader.call(opt_this, node, objectStack); - if (goog.isDef(value)) { + if (value !== undefined) { goog.asserts.assert(goog.isArray(value), 'valueReader function is expected to return an array of values'); var array = /** @type {Array.<*>} */ @@ -393,7 +393,7 @@ ol.xml.makeArrayPusher = function(valueReader, opt_this) { function(node, objectStack) { var value = valueReader.call(goog.isDef(opt_this) ? opt_this : this, node, objectStack); - if (goog.isDef(value)) { + if (value !== undefined) { var array = objectStack[objectStack.length - 1]; goog.asserts.assert(goog.isArray(array), 'objectStack is supposed to be an array of arrays'); @@ -420,7 +420,7 @@ ol.xml.makeReplacer = function(valueReader, opt_this) { function(node, objectStack) { var value = valueReader.call(goog.isDef(opt_this) ? opt_this : this, node, objectStack); - if (goog.isDef(value)) { + if (value !== undefined) { objectStack[objectStack.length - 1] = value; } }); @@ -448,7 +448,7 @@ ol.xml.makeObjectPropertyPusher = function(node, objectStack) { var value = valueReader.call(goog.isDef(opt_this) ? opt_this : this, node, objectStack); - if (goog.isDef(value)) { + if (value !== undefined) { var object = /** @type {Object} */ (objectStack[objectStack.length - 1]); var property = goog.isDef(opt_property) ? @@ -482,7 +482,7 @@ ol.xml.makeObjectPropertySetter = function(node, objectStack) { var value = valueReader.call(goog.isDef(opt_this) ? opt_this : this, node, objectStack); - if (goog.isDef(value)) { + if (value !== undefined) { var object = /** @type {Object} */ (objectStack[objectStack.length - 1]); var property = goog.isDef(opt_property) ? @@ -658,9 +658,9 @@ ol.xml.parseNode = function(parsersNS, node, objectStack, opt_this) { var n; for (n = node.firstElementChild; !goog.isNull(n); n = n.nextElementSibling) { var parsers = parsersNS[n.namespaceURI]; - if (goog.isDef(parsers)) { + if (parsers !== undefined) { var parser = parsers[n.localName]; - if (goog.isDef(parser)) { + if (parser !== undefined) { parser.call(opt_this, n, objectStack); } } @@ -715,10 +715,10 @@ ol.xml.serialize = function( var value, node; for (var i = 0; i < length; ++i) { value = values[i]; - if (goog.isDef(value)) { + if (value !== undefined) { node = nodeFactory.call(opt_this, value, objectStack, goog.isDef(opt_keys) ? opt_keys[i] : undefined); - if (goog.isDef(node)) { + if (node !== undefined) { serializersNS[node.namespaceURI][node.localName] .call(opt_this, node, value, objectStack); } From b36d697585dc217b0150c1c881adaa1d36827a90 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Sun, 27 Sep 2015 10:21:50 -0600 Subject: [PATCH 74/93] Inline goog.isDef() property checks --- src/ol/geolocation.js | 4 ++-- src/ol/has.js | 2 +- src/ol/layer/layergroup.js | 4 ++-- src/ol/map.js | 10 +++++----- src/ol/overlay.js | 4 ++-- src/ol/proj/proj.js | 2 +- src/ol/render/canvas/canvasreplay.js | 16 ++++++++-------- src/ol/render/webgl/webglreplay.js | 2 +- .../renderer/canvas/canvasimagelayerrenderer.js | 2 +- .../renderer/canvas/canvastilelayerrenderer.js | 2 +- src/ol/renderer/dom/domimagelayerrenderer.js | 2 +- src/ol/renderer/dom/domtilelayerrenderer.js | 2 +- src/ol/renderer/webgl/webglimagelayerrenderer.js | 2 +- src/ol/renderer/webgl/webgltilelayerrenderer.js | 2 +- src/ol/source/imagemapguidesource.js | 2 +- src/ol/source/imagestaticsource.js | 2 +- src/ol/source/imagevectorsource.js | 2 +- src/ol/source/osmsource.js | 2 +- src/ol/source/rastersource.js | 2 +- src/ol/source/tilejsonsource.js | 4 ++-- src/ol/source/tileutfgridsource.js | 6 +++--- src/ol/source/tilevectorsource.js | 6 +++--- src/ol/source/vectorsource.js | 4 ++-- src/ol/source/xyzsource.js | 6 +++--- src/ol/style/style.js | 2 +- src/ol/tilegrid/tilegrid.js | 6 +++--- src/ol/view.js | 16 ++++++++-------- 27 files changed, 58 insertions(+), 58 deletions(-) diff --git a/src/ol/geolocation.js b/src/ol/geolocation.js index 01b29e4d0a..c218792596 100644 --- a/src/ol/geolocation.js +++ b/src/ol/geolocation.js @@ -90,10 +90,10 @@ ol.Geolocation = function(opt_options) { this, ol.Object.getChangeEventType(ol.GeolocationProperty.TRACKING), this.handleTrackingChanged_, false, this); - if (goog.isDef(options.projection)) { + if (options.projection !== undefined) { this.setProjection(ol.proj.get(options.projection)); } - if (goog.isDef(options.trackingOptions)) { + if (options.trackingOptions !== undefined) { this.setTrackingOptions(options.trackingOptions); } diff --git a/src/ol/has.js b/src/ol/has.js index 8be8bd5950..fb3b699928 100644 --- a/src/ol/has.js +++ b/src/ol/has.js @@ -44,7 +44,7 @@ ol.has.CANVAS = ol.ENABLE_CANVAS && ( if (goog.isNull(context)) { return false; } else { - if (goog.isDef(context.setLineDash)) { + if (context.setLineDash !== undefined) { ol.has.CANVAS_LINE_DASH = true; } return true; diff --git a/src/ol/layer/layergroup.js b/src/ol/layer/layergroup.js index f3456efe2b..0e2c6e84d9 100644 --- a/src/ol/layer/layergroup.js +++ b/src/ol/layer/layergroup.js @@ -226,8 +226,8 @@ ol.layer.Group.prototype.getLayerStatesArray = function(opt_states) { layerState.maxResolution, ownLayerState.maxResolution); layerState.minResolution = Math.max( layerState.minResolution, ownLayerState.minResolution); - if (goog.isDef(ownLayerState.extent)) { - if (goog.isDef(layerState.extent)) { + if (ownLayerState.extent !== undefined) { + if (layerState.extent !== undefined) { layerState.extent = ol.extent.getIntersection( layerState.extent, ownLayerState.extent); } else { diff --git a/src/ol/map.js b/src/ol/map.js index bcfa364b5b..c9eb514a7d 100644 --- a/src/ol/map.js +++ b/src/ol/map.js @@ -1452,7 +1452,7 @@ ol.Map.createOptionsInternal = function(options) { * @type {Element|Document} */ var keyboardEventTarget = null; - if (goog.isDef(options.keyboardEventTarget)) { + if (options.keyboardEventTarget !== undefined) { // cannot use goog.dom.getElement because its argument cannot be // of type Document keyboardEventTarget = goog.isString(options.keyboardEventTarget) ? @@ -1498,7 +1498,7 @@ ol.Map.createOptionsInternal = function(options) { * @type {Array.} */ var rendererTypes; - if (goog.isDef(options.renderer)) { + if (options.renderer !== undefined) { if (goog.isArray(options.renderer)) { rendererTypes = options.renderer; } else if (goog.isString(options.renderer)) { @@ -1533,7 +1533,7 @@ ol.Map.createOptionsInternal = function(options) { } var controls; - if (goog.isDef(options.controls)) { + if (options.controls !== undefined) { if (goog.isArray(options.controls)) { controls = new ol.Collection(options.controls.slice()); } else { @@ -1546,7 +1546,7 @@ ol.Map.createOptionsInternal = function(options) { } var interactions; - if (goog.isDef(options.interactions)) { + if (options.interactions !== undefined) { if (goog.isArray(options.interactions)) { interactions = new ol.Collection(options.interactions.slice()); } else { @@ -1559,7 +1559,7 @@ ol.Map.createOptionsInternal = function(options) { } var overlays; - if (goog.isDef(options.overlays)) { + if (options.overlays !== undefined) { if (goog.isArray(options.overlays)) { overlays = new ol.Collection(options.overlays.slice()); } else { diff --git a/src/ol/overlay.js b/src/ol/overlay.js index 7a1982d6fb..c9bda6cb0b 100644 --- a/src/ol/overlay.js +++ b/src/ol/overlay.js @@ -158,7 +158,7 @@ ol.Overlay = function(options) { this, ol.Object.getChangeEventType(ol.OverlayProperty.POSITIONING), this.handlePositioningChanged, false, this); - if (goog.isDef(options.element)) { + if (options.element !== undefined) { this.setElement(options.element); } @@ -168,7 +168,7 @@ ol.Overlay = function(options) { /** @type {ol.OverlayPositioning} */ (options.positioning) : ol.OverlayPositioning.TOP_LEFT); - if (goog.isDef(options.position)) { + if (options.position !== undefined) { this.setPosition(options.position); } diff --git a/src/ol/proj/proj.js b/src/ol/proj/proj.js index b0d8a10fd1..f0d5db5c7f 100644 --- a/src/ol/proj/proj.js +++ b/src/ol/proj/proj.js @@ -155,7 +155,7 @@ ol.proj.Projection = function(options) { if (!goog.isDef(options.units)) { var units = def.units; if (!goog.isDef(units)) { - if (goog.isDef(def.to_meter)) { + if (def.to_meter !== undefined) { units = def.to_meter.toString(); ol.proj.METERS_PER_UNIT[units] = def.to_meter; } diff --git a/src/ol/render/canvas/canvasreplay.js b/src/ol/render/canvas/canvasreplay.js index cd9c90e0f1..980fa998e1 100644 --- a/src/ol/render/canvas/canvasreplay.js +++ b/src/ol/render/canvas/canvasreplay.js @@ -1194,10 +1194,10 @@ ol.render.canvas.PolygonReplay.prototype.drawFlatCoordinatess_ = // FIXME or all polygons together? var fillInstruction = [ol.render.canvas.Instruction.FILL]; this.hitDetectionInstructions.push(fillInstruction); - if (goog.isDef(state.fillStyle)) { + if (state.fillStyle !== undefined) { this.instructions.push(fillInstruction); } - if (goog.isDef(state.strokeStyle)) { + if (state.strokeStyle !== undefined) { goog.asserts.assert(goog.isDef(state.lineWidth), 'state.lineWidth should be defined'); var strokeInstruction = [ol.render.canvas.Instruction.STROKE]; @@ -1230,7 +1230,7 @@ ol.render.canvas.PolygonReplay.prototype.drawCircleGeometry = this.hitDetectionInstructions.push( [ol.render.canvas.Instruction.SET_FILL_STYLE, ol.color.asString(ol.render.canvas.defaultFillStyle)]); - if (goog.isDef(state.strokeStyle)) { + if (state.strokeStyle !== undefined) { this.hitDetectionInstructions.push( [ol.render.canvas.Instruction.SET_STROKE_STYLE, state.strokeStyle, state.lineWidth, state.lineCap, state.lineJoin, @@ -1247,10 +1247,10 @@ ol.render.canvas.PolygonReplay.prototype.drawCircleGeometry = this.hitDetectionInstructions.push(beginPathInstruction, circleInstruction); var fillInstruction = [ol.render.canvas.Instruction.FILL]; this.hitDetectionInstructions.push(fillInstruction); - if (goog.isDef(state.fillStyle)) { + if (state.fillStyle !== undefined) { this.instructions.push(fillInstruction); } - if (goog.isDef(state.strokeStyle)) { + if (state.strokeStyle !== undefined) { goog.asserts.assert(goog.isDef(state.lineWidth), 'state.lineWidth should be defined'); var strokeInstruction = [ol.render.canvas.Instruction.STROKE]; @@ -1283,7 +1283,7 @@ ol.render.canvas.PolygonReplay.prototype.drawPolygonGeometry = this.hitDetectionInstructions.push( [ol.render.canvas.Instruction.SET_FILL_STYLE, ol.color.asString(ol.render.canvas.defaultFillStyle)]); - if (goog.isDef(state.strokeStyle)) { + if (state.strokeStyle !== undefined) { this.hitDetectionInstructions.push( [ol.render.canvas.Instruction.SET_STROKE_STYLE, state.strokeStyle, state.lineWidth, state.lineCap, state.lineJoin, @@ -1319,7 +1319,7 @@ ol.render.canvas.PolygonReplay.prototype.drawMultiPolygonGeometry = this.hitDetectionInstructions.push( [ol.render.canvas.Instruction.SET_FILL_STYLE, ol.color.asString(ol.render.canvas.defaultFillStyle)]); - if (goog.isDef(state.strokeStyle)) { + if (state.strokeStyle !== undefined) { this.hitDetectionInstructions.push( [ol.render.canvas.Instruction.SET_STROKE_STYLE, state.strokeStyle, state.lineWidth, state.lineCap, state.lineJoin, @@ -1887,7 +1887,7 @@ ol.render.canvas.ReplayGroup.prototype.forEachFeatureAtCoordinate = function( * @type {ol.Extent} */ var hitExtent; - if (goog.isDef(this.renderBuffer_)) { + if (this.renderBuffer_ !== undefined) { hitExtent = ol.extent.createEmpty(); ol.extent.extendCoordinate(hitExtent, coordinate); ol.extent.buffer(hitExtent, resolution * this.renderBuffer_, hitExtent); diff --git a/src/ol/render/webgl/webglreplay.js b/src/ol/render/webgl/webglreplay.js index 0d3b450b1f..44d9bb14bb 100644 --- a/src/ol/render/webgl/webglreplay.js +++ b/src/ol/render/webgl/webglreplay.js @@ -1163,7 +1163,7 @@ ol.render.webgl.ReplayGroup.prototype.forEachFeatureAtCoordinate = function( * @type {ol.Extent} */ var hitExtent; - if (goog.isDef(this.renderBuffer_)) { + if (this.renderBuffer_ !== undefined) { // build an extent around the coordinate, so that only features that // intersect this extent are checked hitExtent = ol.extent.buffer( diff --git a/src/ol/renderer/canvas/canvasimagelayerrenderer.js b/src/ol/renderer/canvas/canvasimagelayerrenderer.js index ee3d0bba4d..2f80579ae7 100644 --- a/src/ol/renderer/canvas/canvasimagelayerrenderer.js +++ b/src/ol/renderer/canvas/canvasimagelayerrenderer.js @@ -163,7 +163,7 @@ ol.renderer.canvas.ImageLayer.prototype.prepareFrame = var hints = frameState.viewHints; var renderedExtent = frameState.extent; - if (goog.isDef(layerState.extent)) { + if (layerState.extent !== undefined) { renderedExtent = ol.extent.getIntersection( renderedExtent, layerState.extent); } diff --git a/src/ol/renderer/canvas/canvastilelayerrenderer.js b/src/ol/renderer/canvas/canvastilelayerrenderer.js index 129fe6cdda..ef44893aeb 100644 --- a/src/ol/renderer/canvas/canvastilelayerrenderer.js +++ b/src/ol/renderer/canvas/canvastilelayerrenderer.js @@ -217,7 +217,7 @@ ol.renderer.canvas.TileLayer.prototype.prepareFrame = extent = frameState.extent; } - if (goog.isDef(layerState.extent)) { + if (layerState.extent !== undefined) { extent = ol.extent.getIntersection(extent, layerState.extent); } if (ol.extent.isEmpty(extent)) { diff --git a/src/ol/renderer/dom/domimagelayerrenderer.js b/src/ol/renderer/dom/domimagelayerrenderer.js index 67d4965b99..f4245e8217 100644 --- a/src/ol/renderer/dom/domimagelayerrenderer.js +++ b/src/ol/renderer/dom/domimagelayerrenderer.js @@ -94,7 +94,7 @@ ol.renderer.dom.ImageLayer.prototype.prepareFrame = var hints = frameState.viewHints; var renderedExtent = frameState.extent; - if (goog.isDef(layerState.extent)) { + if (layerState.extent !== undefined) { renderedExtent = ol.extent.getIntersection( renderedExtent, layerState.extent); } diff --git a/src/ol/renderer/dom/domtilelayerrenderer.js b/src/ol/renderer/dom/domtilelayerrenderer.js index 89b7861f70..03131c27a5 100644 --- a/src/ol/renderer/dom/domtilelayerrenderer.js +++ b/src/ol/renderer/dom/domtilelayerrenderer.js @@ -119,7 +119,7 @@ ol.renderer.dom.TileLayer.prototype.prepareFrame = extent = frameState.extent; } - if (goog.isDef(layerState.extent)) { + if (layerState.extent !== undefined) { extent = ol.extent.getIntersection(extent, layerState.extent); } diff --git a/src/ol/renderer/webgl/webglimagelayerrenderer.js b/src/ol/renderer/webgl/webglimagelayerrenderer.js index 8f9dfb4fb6..dd0db38c27 100644 --- a/src/ol/renderer/webgl/webglimagelayerrenderer.js +++ b/src/ol/renderer/webgl/webglimagelayerrenderer.js @@ -118,7 +118,7 @@ ol.renderer.webgl.ImageLayer.prototype.prepareFrame = var hints = frameState.viewHints; var renderedExtent = frameState.extent; - if (goog.isDef(layerState.extent)) { + if (layerState.extent !== undefined) { renderedExtent = ol.extent.getIntersection( renderedExtent, layerState.extent); } diff --git a/src/ol/renderer/webgl/webgltilelayerrenderer.js b/src/ol/renderer/webgl/webgltilelayerrenderer.js index 91ca9f04d7..b068f71dd6 100644 --- a/src/ol/renderer/webgl/webgltilelayerrenderer.js +++ b/src/ol/renderer/webgl/webgltilelayerrenderer.js @@ -251,7 +251,7 @@ ol.renderer.webgl.TileLayer.prototype.prepareFrame = for (y = tileRange.minY; y <= tileRange.maxY; ++y) { tile = tileSource.getTile(z, x, y, pixelRatio, projection); - if (goog.isDef(layerState.extent)) { + if (layerState.extent !== undefined) { // ignore tiles outside layer extent tileExtent = tileGrid.getTileCoordExtent(tile.tileCoord, tmpExtent); if (!ol.extent.intersects(tileExtent, layerState.extent)) { diff --git a/src/ol/source/imagemapguidesource.js b/src/ol/source/imagemapguidesource.js index ac89d59b48..e3bad37c7e 100644 --- a/src/ol/source/imagemapguidesource.js +++ b/src/ol/source/imagemapguidesource.js @@ -50,7 +50,7 @@ ol.source.ImageMapGuide = function(options) { this.params_ = goog.isDef(options.params) ? options.params : {}; var imageUrlFunction; - if (goog.isDef(options.url)) { + if (options.url !== undefined) { imageUrlFunction = ol.ImageUrlFunction.createFromParamsFunction( options.url, this.params_, goog.bind(this.getUrl, this)); } else { diff --git a/src/ol/source/imagestaticsource.js b/src/ol/source/imagestaticsource.js index 678db8653b..fe7529c477 100644 --- a/src/ol/source/imagestaticsource.js +++ b/src/ol/source/imagestaticsource.js @@ -27,7 +27,7 @@ ol.source.ImageStatic = function(options) { var imageExtent = options.imageExtent; var resolution, resolutions; - if (goog.isDef(options.imageSize)) { + if (options.imageSize !== undefined) { resolution = ol.extent.getHeight(imageExtent) / options.imageSize[1]; resolutions = [resolution]; } diff --git a/src/ol/source/imagevectorsource.js b/src/ol/source/imagevectorsource.js index 6cf21900fa..1e745005c7 100644 --- a/src/ol/source/imagevectorsource.js +++ b/src/ol/source/imagevectorsource.js @@ -261,7 +261,7 @@ ol.source.ImageVector.prototype.renderFeature_ = var styles; if (goog.isDef(feature.getStyleFunction())) { styles = feature.getStyleFunction().call(feature, resolution); - } else if (goog.isDef(this.styleFunction_)) { + } else if (this.styleFunction_ !== undefined) { styles = this.styleFunction_(feature, resolution); } if (!goog.isDefAndNotNull(styles)) { diff --git a/src/ol/source/osmsource.js b/src/ol/source/osmsource.js index 10d9c90b85..9a2c77222c 100644 --- a/src/ol/source/osmsource.js +++ b/src/ol/source/osmsource.js @@ -19,7 +19,7 @@ ol.source.OSM = function(opt_options) { var options = opt_options || {}; var attributions; - if (goog.isDef(options.attributions)) { + if (options.attributions !== undefined) { attributions = options.attributions; } else { attributions = [ol.source.OSM.ATTRIBUTION]; diff --git a/src/ol/source/rastersource.js b/src/ol/source/rastersource.js index 24a2fd0c83..aaa809da4d 100644 --- a/src/ol/source/rastersource.js +++ b/src/ol/source/rastersource.js @@ -133,7 +133,7 @@ ol.source.Raster = function(options) { goog.base(this, {}); - if (goog.isDef(options.operation)) { + if (options.operation !== undefined) { this.setOperation(options.operation, options.lib); } diff --git a/src/ol/source/tilejsonsource.js b/src/ol/source/tilejsonsource.js index ab8b165647..18282462db 100644 --- a/src/ol/source/tilejsonsource.js +++ b/src/ol/source/tilejsonsource.js @@ -57,13 +57,13 @@ ol.source.TileJSON.prototype.handleTileJSONResponse = function(tileJSON) { var sourceProjection = this.getProjection(); var extent; - if (goog.isDef(tileJSON.bounds)) { + if (tileJSON.bounds !== undefined) { var transform = ol.proj.getTransformFromProjections( epsg4326Projection, sourceProjection); extent = ol.extent.applyTransform(tileJSON.bounds, transform); } - if (goog.isDef(tileJSON.scheme)) { + if (tileJSON.scheme !== undefined) { goog.asserts.assert(tileJSON.scheme == 'xyz', 'tileJSON-scheme is "xyz"'); } var minZoom = tileJSON.minzoom || 0; diff --git a/src/ol/source/tileutfgridsource.js b/src/ol/source/tileutfgridsource.js index b5a7b7f8bb..f779822e3b 100644 --- a/src/ol/source/tileutfgridsource.js +++ b/src/ol/source/tileutfgridsource.js @@ -110,13 +110,13 @@ ol.source.TileUTFGrid.prototype.handleTileJSONResponse = function(tileJSON) { var sourceProjection = this.getProjection(); var extent; - if (goog.isDef(tileJSON.bounds)) { + if (tileJSON.bounds !== undefined) { var transform = ol.proj.getTransformFromProjections( epsg4326Projection, sourceProjection); extent = ol.extent.applyTransform(tileJSON.bounds, transform); } - if (goog.isDef(tileJSON.scheme)) { + if (tileJSON.scheme !== undefined) { goog.asserts.assert(tileJSON.scheme == 'xyz', 'tileJSON-scheme is "xyz"'); } var minZoom = tileJSON.minzoom || 0; @@ -138,7 +138,7 @@ ol.source.TileUTFGrid.prototype.handleTileJSONResponse = function(tileJSON) { this.tileUrlFunction_ = ol.TileUrlFunction.createFromTemplates(grids); - if (goog.isDef(tileJSON.attribution)) { + if (tileJSON.attribution !== undefined) { var attributionExtent = goog.isDef(extent) ? extent : epsg4326Projection.getExtent(); /** @type {Object.>} */ diff --git a/src/ol/source/tilevectorsource.js b/src/ol/source/tilevectorsource.js index e1d9b04233..310431a545 100644 --- a/src/ol/source/tilevectorsource.js +++ b/src/ol/source/tilevectorsource.js @@ -67,11 +67,11 @@ ol.source.TileVector = function(options) { */ this.tiles_ = {}; - if (goog.isDef(options.tileUrlFunction)) { + if (options.tileUrlFunction !== undefined) { this.setTileUrlFunction(options.tileUrlFunction); - } else if (goog.isDef(options.urls)) { + } else if (options.urls !== undefined) { this.setUrls(options.urls); - } else if (goog.isDef(options.url)) { + } else if (options.url !== undefined) { this.setUrl(options.url); } diff --git a/src/ol/source/vectorsource.js b/src/ol/source/vectorsource.js index 29aea30397..074154a968 100644 --- a/src/ol/source/vectorsource.js +++ b/src/ol/source/vectorsource.js @@ -91,9 +91,9 @@ ol.source.Vector = function(opt_options) { */ this.loader_ = goog.nullFunction; - if (goog.isDef(options.loader)) { + if (options.loader !== undefined) { this.loader_ = options.loader; - } else if (goog.isDef(options.url)) { + } else if (options.url !== undefined) { goog.asserts.assert(goog.isDef(options.format), 'format must be set when url is set'); // create a XHR feature loader for "url" and "format" diff --git a/src/ol/source/xyzsource.js b/src/ol/source/xyzsource.js index f7cb84768f..7294c312b2 100644 --- a/src/ol/source/xyzsource.js +++ b/src/ol/source/xyzsource.js @@ -56,11 +56,11 @@ ol.source.XYZ = function(options) { wrapX: goog.isDef(options.wrapX) ? options.wrapX : true }); - if (goog.isDef(options.tileUrlFunction)) { + if (options.tileUrlFunction !== undefined) { this.setTileUrlFunction(options.tileUrlFunction); - } else if (goog.isDef(options.urls)) { + } else if (options.urls !== undefined) { this.setUrls(options.urls); - } else if (goog.isDef(options.url)) { + } else if (options.url !== undefined) { this.setUrl(options.url); } diff --git a/src/ol/style/style.js b/src/ol/style/style.js index 0a8ab7a6be..9b43147456 100644 --- a/src/ol/style/style.js +++ b/src/ol/style/style.js @@ -40,7 +40,7 @@ ol.style.Style = function(opt_options) { */ this.geometryFunction_ = ol.style.defaultGeometryFunction; - if (goog.isDef(options.geometry)) { + if (options.geometry !== undefined) { this.setGeometry(options.geometry); } diff --git a/src/ol/tilegrid/tilegrid.js b/src/ol/tilegrid/tilegrid.js index 16318df216..5cf1a4b15b 100644 --- a/src/ol/tilegrid/tilegrid.js +++ b/src/ol/tilegrid/tilegrid.js @@ -64,7 +64,7 @@ ol.tilegrid.TileGrid = function(options) { * @type {Array.} */ this.origins_ = null; - if (goog.isDef(options.origins)) { + if (options.origins !== undefined) { this.origins_ = options.origins; goog.asserts.assert(this.origins_.length == this.resolutions_.length, 'number of origins and resolutions must be equal'); @@ -87,7 +87,7 @@ ol.tilegrid.TileGrid = function(options) { * @type {Array.} */ this.tileSizes_ = null; - if (goog.isDef(options.tileSizes)) { + if (options.tileSizes !== undefined) { this.tileSizes_ = options.tileSizes; goog.asserts.assert(this.tileSizes_.length == this.resolutions_.length, 'number of tileSizes and resolutions must be equal'); @@ -118,7 +118,7 @@ ol.tilegrid.TileGrid = function(options) { */ this.fullTileRanges_ = null; - if (goog.isDef(options.sizes)) { + if (options.sizes !== undefined) { goog.asserts.assert(options.sizes.length == this.resolutions_.length, 'number of sizes and resolutions must be equal'); this.fullTileRanges_ = goog.array.map(options.sizes, function(size, z) { diff --git a/src/ol/view.js b/src/ol/view.js index 7f584d9566..80071f9137 100644 --- a/src/ol/view.js +++ b/src/ol/view.js @@ -154,9 +154,9 @@ ol.View = function(opt_options) { this.constraints_ = new ol.Constraints( centerConstraint, resolutionConstraint, rotationConstraint); - if (goog.isDef(options.resolution)) { + if (options.resolution !== undefined) { properties[ol.ViewProperty.RESOLUTION] = options.resolution; - } else if (goog.isDef(options.zoom)) { + } else if (options.zoom !== undefined) { properties[ol.ViewProperty.RESOLUTION] = this.constrainResolution( this.maxResolution_, options.zoom - this.minZoom_); } @@ -463,9 +463,9 @@ ol.View.prototype.fit = function(geometry, size, opt_options) { options.constrainResolution : true; var nearest = goog.isDef(options.nearest) ? options.nearest : false; var minResolution; - if (goog.isDef(options.minResolution)) { + if (options.minResolution !== undefined) { minResolution = options.minResolution; - } else if (goog.isDef(options.maxZoom)) { + } else if (options.maxZoom !== undefined) { minResolution = this.constrainResolution( this.maxResolution_, options.maxZoom - this.minZoom_, 0); } else { @@ -638,7 +638,7 @@ ol.View.prototype.setZoom = function(zoom) { * @return {ol.CenterConstraintType} */ ol.View.createCenterConstraint_ = function(options) { - if (goog.isDef(options.extent)) { + if (options.extent !== undefined) { return ol.CenterConstraint.createExtent(options.extent); } else { return ol.CenterConstraint.none; @@ -671,7 +671,7 @@ ol.View.createResolutionConstraint_ = function(options) { var zoomFactor = goog.isDef(options.zoomFactor) ? options.zoomFactor : defaultZoomFactor; - if (goog.isDef(options.resolutions)) { + if (options.resolutions !== undefined) { var resolutions = options.resolutions; maxResolution = resolutions[0]; minResolution = resolutions[resolutions.length - 1]; @@ -704,8 +704,8 @@ ol.View.createResolutionConstraint_ = function(options) { // user provided minResolution takes precedence minResolution = options.minResolution; if (!goog.isDef(minResolution)) { - if (goog.isDef(options.maxZoom)) { - if (goog.isDef(options.maxResolution)) { + if (options.maxZoom !== undefined) { + if (options.maxResolution !== undefined) { minResolution = maxResolution / Math.pow(zoomFactor, maxZoom); } else { minResolution = defaultMaxResolution / Math.pow(zoomFactor, maxZoom); From 6638ae855dcf9e62a8d2f646f314cc0b3b3c352b Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Sun, 27 Sep 2015 10:23:30 -0600 Subject: [PATCH 75/93] Inline simple !goog.isDef() checks --- src/ol/proj/epsg3857projection.js | 4 ++-- src/ol/proj/proj.js | 4 ++-- src/ol/render/canvas/canvasimmediate.js | 2 +- src/ol/render/canvas/canvasreplay.js | 4 ++-- src/ol/render/webgl/webglimmediate.js | 2 +- src/ol/render/webgl/webglreplay.js | 4 ++-- src/ol/renderer/canvas/canvasvectorlayerrenderer.js | 2 +- src/ol/renderer/dom/domvectorlayerrenderer.js | 2 +- src/ol/renderer/webgl/webglvectorlayerrenderer.js | 2 +- src/ol/size.js | 6 +++--- src/ol/style/circlestyle.js | 4 ++-- src/ol/style/regularshapestyle.js | 10 +++++----- src/ol/view.js | 2 +- src/ol/xml.js | 6 +++--- 14 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/ol/proj/epsg3857projection.js b/src/ol/proj/epsg3857projection.js index 632e123797..ef2ea19df5 100644 --- a/src/ol/proj/epsg3857projection.js +++ b/src/ol/proj/epsg3857projection.js @@ -110,7 +110,7 @@ ol.proj.EPSG3857.fromEPSG4326 = function(input, opt_output, opt_dimension) { var length = input.length, dimension = opt_dimension > 1 ? opt_dimension : 2, output = opt_output; - if (!goog.isDef(output)) { + if (output === undefined) { if (dimension > 2) { // preserve values beyond second dimension output = input.slice(); @@ -141,7 +141,7 @@ ol.proj.EPSG3857.toEPSG4326 = function(input, opt_output, opt_dimension) { var length = input.length, dimension = opt_dimension > 1 ? opt_dimension : 2, output = opt_output; - if (!goog.isDef(output)) { + if (output === undefined) { if (dimension > 2) { // preserve values beyond second dimension output = input.slice(); diff --git a/src/ol/proj/proj.js b/src/ol/proj/proj.js index f0d5db5c7f..2109dbc766 100644 --- a/src/ol/proj/proj.js +++ b/src/ol/proj/proj.js @@ -154,7 +154,7 @@ ol.proj.Projection = function(options) { } if (!goog.isDef(options.units)) { var units = def.units; - if (!goog.isDef(units)) { + if (units === undefined) { if (def.to_meter !== undefined) { units = def.to_meter.toString(); ol.proj.METERS_PER_UNIT[units] = def.to_meter; @@ -725,7 +725,7 @@ ol.proj.getTransformFromProjections = goog.object.containsKey(transforms[sourceCode], destinationCode)) { transform = transforms[sourceCode][destinationCode]; } - if (!goog.isDef(transform)) { + if (transform === undefined) { goog.asserts.assert(goog.isDef(transform), 'transform should be defined'); transform = ol.proj.identityTransform; } diff --git a/src/ol/render/canvas/canvasimmediate.js b/src/ol/render/canvas/canvasimmediate.js index 65ffc8c08c..368f1ce525 100644 --- a/src/ol/render/canvas/canvasimmediate.js +++ b/src/ol/render/canvas/canvasimmediate.js @@ -485,7 +485,7 @@ ol.render.canvas.Immediate.prototype.drawFeature = function(feature, style) { return; } var zIndex = style.getZIndex(); - if (!goog.isDef(zIndex)) { + if (zIndex === undefined) { zIndex = 0; } this.drawAsync(zIndex, function(render) { diff --git a/src/ol/render/canvas/canvasreplay.js b/src/ol/render/canvas/canvasreplay.js index 980fa998e1..96a96951cb 100644 --- a/src/ol/render/canvas/canvasreplay.js +++ b/src/ol/render/canvas/canvasreplay.js @@ -1919,12 +1919,12 @@ ol.render.canvas.ReplayGroup.prototype.getReplay = function(zIndex, replayType) { var zIndexKey = goog.isDef(zIndex) ? zIndex.toString() : '0'; var replays = this.replaysByZIndex_[zIndexKey]; - if (!goog.isDef(replays)) { + if (replays === undefined) { replays = {}; this.replaysByZIndex_[zIndexKey] = replays; } var replay = replays[replayType]; - if (!goog.isDef(replay)) { + if (replay === undefined) { var Constructor = ol.render.canvas.BATCH_CONSTRUCTORS_[replayType]; goog.asserts.assert(goog.isDef(Constructor), replayType + diff --git a/src/ol/render/webgl/webglimmediate.js b/src/ol/render/webgl/webglimmediate.js index 007d1d2bd0..601dca03b9 100644 --- a/src/ol/render/webgl/webglimmediate.js +++ b/src/ol/render/webgl/webglimmediate.js @@ -131,7 +131,7 @@ ol.render.webgl.Immediate.prototype.drawFeature = function(feature, style) { return; } var zIndex = style.getZIndex(); - if (!goog.isDef(zIndex)) { + if (zIndex === undefined) { zIndex = 0; } this.drawAsync(zIndex, function(render) { diff --git a/src/ol/render/webgl/webglreplay.js b/src/ol/render/webgl/webglreplay.js index 44d9bb14bb..122cafb759 100644 --- a/src/ol/render/webgl/webglreplay.js +++ b/src/ol/render/webgl/webglreplay.js @@ -634,7 +634,7 @@ ol.render.webgl.ImageReplay.prototype.replay = function(context, // draw! var result; - if (!goog.isDef(featureCallback)) { + if (featureCallback === undefined) { this.drawReplay_(gl, context, skippedFeaturesHash, this.textures_, this.groupIndices_); } else { @@ -1037,7 +1037,7 @@ ol.render.webgl.ReplayGroup.prototype.finish = function(context) { ol.render.webgl.ReplayGroup.prototype.getReplay = function(zIndex, replayType) { var replay = this.replays_[replayType]; - if (!goog.isDef(replay)) { + if (replay === undefined) { var constructor = ol.render.webgl.BATCH_CONSTRUCTORS_[replayType]; goog.asserts.assert(goog.isDef(constructor), replayType + diff --git a/src/ol/renderer/canvas/canvasvectorlayerrenderer.js b/src/ol/renderer/canvas/canvasvectorlayerrenderer.js index 4439778d9d..de3fc32f5d 100644 --- a/src/ol/renderer/canvas/canvasvectorlayerrenderer.js +++ b/src/ol/renderer/canvas/canvasvectorlayerrenderer.js @@ -228,7 +228,7 @@ ol.renderer.canvas.VectorLayer.prototype.prepareFrame = var vectorLayerRenderBuffer = vectorLayer.getRenderBuffer(); var vectorLayerRenderOrder = vectorLayer.getRenderOrder(); - if (!goog.isDef(vectorLayerRenderOrder)) { + if (vectorLayerRenderOrder === undefined) { vectorLayerRenderOrder = ol.renderer.vector.defaultOrder; } diff --git a/src/ol/renderer/dom/domvectorlayerrenderer.js b/src/ol/renderer/dom/domvectorlayerrenderer.js index 8a09696b3f..fbddccba80 100644 --- a/src/ol/renderer/dom/domvectorlayerrenderer.js +++ b/src/ol/renderer/dom/domvectorlayerrenderer.js @@ -250,7 +250,7 @@ ol.renderer.dom.VectorLayer.prototype.prepareFrame = var vectorLayerRenderBuffer = vectorLayer.getRenderBuffer(); var vectorLayerRenderOrder = vectorLayer.getRenderOrder(); - if (!goog.isDef(vectorLayerRenderOrder)) { + if (vectorLayerRenderOrder === undefined) { vectorLayerRenderOrder = ol.renderer.vector.defaultOrder; } diff --git a/src/ol/renderer/webgl/webglvectorlayerrenderer.js b/src/ol/renderer/webgl/webglvectorlayerrenderer.js index cc3dde07ca..023b0849e0 100644 --- a/src/ol/renderer/webgl/webglvectorlayerrenderer.js +++ b/src/ol/renderer/webgl/webglvectorlayerrenderer.js @@ -223,7 +223,7 @@ ol.renderer.webgl.VectorLayer.prototype.prepareFrame = var vectorLayerRenderBuffer = vectorLayer.getRenderBuffer(); var vectorLayerRenderOrder = vectorLayer.getRenderOrder(); - if (!goog.isDef(vectorLayerRenderOrder)) { + if (vectorLayerRenderOrder === undefined) { vectorLayerRenderOrder = ol.renderer.vector.defaultOrder; } diff --git a/src/ol/size.js b/src/ol/size.js index b256fdf2e2..876df0dc1f 100644 --- a/src/ol/size.js +++ b/src/ol/size.js @@ -21,7 +21,7 @@ ol.Size; * @return {ol.Size} */ ol.size.buffer = function(size, buffer, opt_size) { - if (!goog.isDef(opt_size)) { + if (opt_size === undefined) { opt_size = [0, 0]; } opt_size[0] = size[0] + 2 * buffer; @@ -59,7 +59,7 @@ ol.size.hasArea = function(size) { * @return {ol.Size} */ ol.size.scale = function(size, ratio, opt_size) { - if (!goog.isDef(opt_size)) { + if (opt_size === undefined) { opt_size = [0, 0]; } opt_size[0] = (size[0] * ratio + 0.5) | 0; @@ -82,7 +82,7 @@ ol.size.toSize = function(size, opt_size) { return size; } else { goog.asserts.assert(goog.isNumber(size)); - if (!goog.isDef(opt_size)) { + if (opt_size === undefined) { opt_size = [size, size]; } else { opt_size[0] = size; diff --git a/src/ol/style/circlestyle.js b/src/ol/style/circlestyle.js index aeb23d8933..9de1b18d4e 100644 --- a/src/ol/style/circlestyle.js +++ b/src/ol/style/circlestyle.js @@ -249,7 +249,7 @@ ol.style.Circle.prototype.render_ = function(atlasManager) { if (!goog.isNull(this.stroke_)) { strokeStyle = ol.color.asString(this.stroke_.getColor()); strokeWidth = this.stroke_.getWidth(); - if (!goog.isDef(strokeWidth)) { + if (strokeWidth === undefined) { strokeWidth = ol.render.canvas.defaultLineWidth; } lineDash = this.stroke_.getLineDash(); @@ -269,7 +269,7 @@ ol.style.Circle.prototype.render_ = function(atlasManager) { lineDash: lineDash }; - if (!goog.isDef(atlasManager)) { + if (atlasManager === undefined) { // no atlas manager is used, create a new canvas this.canvas_ = /** @type {HTMLCanvasElement} */ (goog.dom.createElement(goog.dom.TagName.CANVAS)); diff --git a/src/ol/style/regularshapestyle.js b/src/ol/style/regularshapestyle.js index 38478d73dd..315f8f49cc 100644 --- a/src/ol/style/regularshapestyle.js +++ b/src/ol/style/regularshapestyle.js @@ -315,7 +315,7 @@ ol.style.RegularShape.prototype.render_ = function(atlasManager) { if (!goog.isNull(this.stroke_)) { strokeStyle = ol.color.asString(this.stroke_.getColor()); strokeWidth = this.stroke_.getWidth(); - if (!goog.isDef(strokeWidth)) { + if (strokeWidth === undefined) { strokeWidth = ol.render.canvas.defaultLineWidth; } lineDash = this.stroke_.getLineDash(); @@ -323,15 +323,15 @@ ol.style.RegularShape.prototype.render_ = function(atlasManager) { lineDash = null; } lineJoin = this.stroke_.getLineJoin(); - if (!goog.isDef(lineJoin)) { + if (lineJoin === undefined) { lineJoin = ol.render.canvas.defaultLineJoin; } lineCap = this.stroke_.getLineCap(); - if (!goog.isDef(lineCap)) { + if (lineCap === undefined) { lineCap = ol.render.canvas.defaultLineCap; } miterLimit = this.stroke_.getMiterLimit(); - if (!goog.isDef(miterLimit)) { + if (miterLimit === undefined) { miterLimit = ol.render.canvas.defaultMiterLimit; } } @@ -349,7 +349,7 @@ ol.style.RegularShape.prototype.render_ = function(atlasManager) { miterLimit: miterLimit }; - if (!goog.isDef(atlasManager)) { + if (atlasManager === undefined) { // no atlas manager is used, create a new canvas this.canvas_ = /** @type {HTMLCanvasElement} */ (goog.dom.createElement(goog.dom.TagName.CANVAS)); diff --git a/src/ol/view.js b/src/ol/view.js index 80071f9137..fb2092c2b7 100644 --- a/src/ol/view.js +++ b/src/ol/view.js @@ -703,7 +703,7 @@ ol.View.createResolutionConstraint_ = function(options) { // user provided minResolution takes precedence minResolution = options.minResolution; - if (!goog.isDef(minResolution)) { + if (minResolution === undefined) { if (options.maxZoom !== undefined) { if (options.maxResolution !== undefined) { minResolution = maxResolution / Math.pow(zoomFactor, maxZoom); diff --git a/src/ol/xml.js b/src/ol/xml.js index 68bf281e62..207405c7aa 100644 --- a/src/ol/xml.js +++ b/src/ol/xml.js @@ -537,7 +537,7 @@ ol.xml.makeChildAppender = function(nodeWriter, opt_this) { ol.xml.makeArraySerializer = function(nodeWriter, opt_this) { var serializersNS, nodeFactory; return function(node, value, objectStack) { - if (!goog.isDef(serializersNS)) { + if (serializersNS === undefined) { serializersNS = {}; var serializers = {}; serializers[node.localName] = nodeWriter; @@ -577,11 +577,11 @@ ol.xml.makeSimpleNodeFactory = function(opt_nodeName, opt_namespaceURI) { goog.asserts.assert(ol.xml.isNode(node) || ol.xml.isDocument(node), 'expected node %s to be a Node or a Document', node); var nodeName = fixedNodeName; - if (!goog.isDef(nodeName)) { + if (nodeName === undefined) { nodeName = opt_nodeName; } var namespaceURI = opt_namespaceURI; - if (!goog.isDef(opt_namespaceURI)) { + if (opt_namespaceURI === undefined) { namespaceURI = node.namespaceURI; } goog.asserts.assert(goog.isDef(nodeName), 'nodeName was undefined'); From 3a0683f3731e9b49cfa59276ae732a1cc20ab5ea Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Sun, 27 Sep 2015 10:24:38 -0600 Subject: [PATCH 76/93] Inline !goog.isDef() property checks --- src/ol/image.js | 2 +- src/ol/proj/proj.js | 2 +- src/ol/source/clustersource.js | 2 +- src/ol/source/imagewmssource.js | 4 ++-- src/ol/style/fillstyle.js | 2 +- src/ol/style/strokestyle.js | 2 +- src/ol/tilegrid/tilegrid.js | 2 +- test/spec/ol/extent.test.js | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/ol/image.js b/src/ol/image.js index d98229bc43..8f4245b004 100644 --- a/src/ol/image.js +++ b/src/ol/image.js @@ -114,7 +114,7 @@ ol.Image.prototype.handleImageError_ = function() { * @private */ ol.Image.prototype.handleImageLoad_ = function() { - if (!goog.isDef(this.resolution)) { + if (this.resolution === undefined) { this.resolution = ol.extent.getHeight(this.extent) / this.image_.height; } this.state = ol.ImageState.LOADED; diff --git a/src/ol/proj/proj.js b/src/ol/proj/proj.js index 2109dbc766..821b133e8d 100644 --- a/src/ol/proj/proj.js +++ b/src/ol/proj/proj.js @@ -152,7 +152,7 @@ ol.proj.Projection = function(options) { if (goog.isDef(def.axis) && !goog.isDef(options.axisOrientation)) { this.axisOrientation_ = def.axis; } - if (!goog.isDef(options.units)) { + if (options.units === undefined) { var units = def.units; if (units === undefined) { if (def.to_meter !== undefined) { diff --git a/src/ol/source/clustersource.js b/src/ol/source/clustersource.js index b0aaf7f15e..d1e15c01c3 100644 --- a/src/ol/source/clustersource.js +++ b/src/ol/source/clustersource.js @@ -103,7 +103,7 @@ ol.source.Cluster.prototype.onSourceChange_ = function() { * @private */ ol.source.Cluster.prototype.cluster_ = function() { - if (!goog.isDef(this.resolution_)) { + if (this.resolution_ === undefined) { return; } this.features_.length = 0; diff --git a/src/ol/source/imagewmssource.js b/src/ol/source/imagewmssource.js index ec126ecbd6..06e36fcb85 100644 --- a/src/ol/source/imagewmssource.js +++ b/src/ol/source/imagewmssource.js @@ -142,7 +142,7 @@ ol.source.ImageWMS.prototype.getGetFeatureInfoUrl = goog.asserts.assert(!('VERSION' in params), 'key VERSION is not allowed in params'); - if (!goog.isDef(this.url_)) { + if (this.url_ === undefined) { return undefined; } @@ -188,7 +188,7 @@ ol.source.ImageWMS.prototype.getParams = function() { ol.source.ImageWMS.prototype.getImage = function(extent, resolution, pixelRatio, projection) { - if (!goog.isDef(this.url_)) { + if (this.url_ === undefined) { return null; } diff --git a/src/ol/style/fillstyle.js b/src/ol/style/fillstyle.js index 74f5162b62..19895f0c86 100644 --- a/src/ol/style/fillstyle.js +++ b/src/ol/style/fillstyle.js @@ -58,7 +58,7 @@ ol.style.Fill.prototype.setColor = function(color) { * @inheritDoc */ ol.style.Fill.prototype.getChecksum = function() { - if (!goog.isDef(this.checksum_)) { + if (this.checksum_ === undefined) { this.checksum_ = 'f' + (!goog.isNull(this.color_) ? ol.color.asString(this.color_) : '-'); } diff --git a/src/ol/style/strokestyle.js b/src/ol/style/strokestyle.js index e5599ab044..1fbd7a9a02 100644 --- a/src/ol/style/strokestyle.js +++ b/src/ol/style/strokestyle.js @@ -203,7 +203,7 @@ ol.style.Stroke.prototype.setWidth = function(width) { * @inheritDoc */ ol.style.Stroke.prototype.getChecksum = function() { - if (!goog.isDef(this.checksum_)) { + if (this.checksum_ === undefined) { var raw = 's' + (!goog.isNull(this.color_) ? ol.color.asString(this.color_) : '-') + ',' + diff --git a/src/ol/tilegrid/tilegrid.js b/src/ol/tilegrid/tilegrid.js index 5cf1a4b15b..7efb55ea90 100644 --- a/src/ol/tilegrid/tilegrid.js +++ b/src/ol/tilegrid/tilegrid.js @@ -552,7 +552,7 @@ ol.tilegrid.createXYZ = function(opt_options) { var options = /** @type {olx.tilegrid.TileGridOptions} */ ({}); goog.object.extend(options, goog.isDef(opt_options) ? opt_options : /** @type {olx.tilegrid.XYZOptions} */ ({})); - if (!goog.isDef(options.extent)) { + if (options.extent === undefined) { options.extent = ol.proj.get('EPSG:3857').getExtent(); } options.resolutions = ol.tilegrid.resolutionsFromExtent( diff --git a/test/spec/ol/extent.test.js b/test/spec/ol/extent.test.js index b1e8578ceb..1c0235a69c 100644 --- a/test/spec/ol/extent.test.js +++ b/test/spec/ol/extent.test.js @@ -837,7 +837,7 @@ describe('ol.extent', function() { it('takes arbitrary function', function() { var transformFn = function(input, output, opt_dimension) { var dimension = goog.isDef(opt_dimension) ? opt_dimension : 2; - if (!goog.isDef(output)) { + if (output === undefined) { output = new Array(input.length); } var n = input.length; From a86c270f6aba6a073fe03c233347383d3aa14d8e Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Sun, 27 Sep 2015 10:31:16 -0600 Subject: [PATCH 77/93] Inline simple !goog.isDef() calls --- src/ol/geom/flat/flipflatgeom.js | 2 +- src/ol/overlay.js | 4 ++-- src/ol/proj/proj.js | 2 +- src/ol/render/canvas/canvasreplay.js | 10 +++++----- src/ol/render/webgl/webglreplay.js | 2 +- src/ol/source/tilearcgisrestsource.js | 2 +- src/ol/source/tilewmssource.js | 2 +- src/ol/source/vectorsource.js | 2 +- src/ol/source/wmtssource.js | 2 +- src/ol/style/iconstyle.js | 4 ++-- src/ol/view.js | 2 +- 11 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/ol/geom/flat/flipflatgeom.js b/src/ol/geom/flat/flipflatgeom.js index fbf6bd7c72..8532682e46 100644 --- a/src/ol/geom/flat/flipflatgeom.js +++ b/src/ol/geom/flat/flipflatgeom.js @@ -19,7 +19,7 @@ ol.geom.flat.flip.flipXY = dest = opt_dest; destOffset = goog.isDef(opt_destOffset) ? opt_destOffset : 0; } else { - goog.asserts.assert(!goog.isDef(opt_destOffset), + goog.asserts.assert(opt_destOffset === undefined, 'opt_destOffSet should be defined'); dest = []; destOffset = 0; diff --git a/src/ol/overlay.js b/src/ol/overlay.js index c9bda6cb0b..71b3f649d8 100644 --- a/src/ol/overlay.js +++ b/src/ol/overlay.js @@ -366,7 +366,7 @@ ol.Overlay.prototype.panIntoView_ = function() { goog.asserts.assert(this.autoPan, 'this.autoPan should be true'); var map = this.getMap(); - if (!goog.isDef(map) || goog.isNull(map.getTargetElement())) { + if (map === undefined || goog.isNull(map.getTargetElement())) { return; } @@ -474,7 +474,7 @@ ol.Overlay.prototype.setVisible = function(visible) { ol.Overlay.prototype.updatePixelPosition = function() { var map = this.getMap(); var position = this.getPosition(); - if (!goog.isDef(map) || !map.isRendered() || !goog.isDef(position)) { + if (map === undefined || !map.isRendered() || position === undefined) { this.setVisible(false); return; } diff --git a/src/ol/proj/proj.js b/src/ol/proj/proj.js index 821b133e8d..27d0f42873 100644 --- a/src/ol/proj/proj.js +++ b/src/ol/proj/proj.js @@ -652,7 +652,7 @@ ol.proj.get = function(projectionLike) { } else if (goog.isString(projectionLike)) { var code = projectionLike; projection = ol.proj.projections_[code]; - if (ol.ENABLE_PROJ4JS && !goog.isDef(projection) && + if (ol.ENABLE_PROJ4JS && projection === undefined && typeof proj4 == 'function' && goog.isDef(proj4.defs(code))) { projection = new ol.proj.Projection({code: code}); ol.proj.addProjection(projection); diff --git a/src/ol/render/canvas/canvasreplay.js b/src/ol/render/canvas/canvasreplay.js index 96a96951cb..8de2dbecb3 100644 --- a/src/ol/render/canvas/canvasreplay.js +++ b/src/ol/render/canvas/canvasreplay.js @@ -1007,7 +1007,7 @@ ol.render.canvas.LineStringReplay.prototype.drawLineStringGeometry = goog.asserts.assert(!goog.isNull(state), 'state should not be null'); var strokeStyle = state.strokeStyle; var lineWidth = state.lineWidth; - if (!goog.isDef(strokeStyle) || !goog.isDef(lineWidth)) { + if (strokeStyle === undefined || lineWidth === undefined) { return; } this.setStrokeStyle_(); @@ -1035,7 +1035,7 @@ ol.render.canvas.LineStringReplay.prototype.drawMultiLineStringGeometry = goog.asserts.assert(!goog.isNull(state), 'state should not be null'); var strokeStyle = state.strokeStyle; var lineWidth = state.lineWidth; - if (!goog.isDef(strokeStyle) || !goog.isDef(lineWidth)) { + if (strokeStyle === undefined || lineWidth === undefined) { return; } this.setStrokeStyle_(); @@ -1217,7 +1217,7 @@ ol.render.canvas.PolygonReplay.prototype.drawCircleGeometry = goog.asserts.assert(!goog.isNull(state), 'state should not be null'); var fillStyle = state.fillStyle; var strokeStyle = state.strokeStyle; - if (!goog.isDef(fillStyle) && !goog.isDef(strokeStyle)) { + if (fillStyle === undefined && strokeStyle === undefined) { return; } if (strokeStyle !== undefined) { @@ -1270,7 +1270,7 @@ ol.render.canvas.PolygonReplay.prototype.drawPolygonGeometry = goog.asserts.assert(!goog.isNull(state), 'state should not be null'); var fillStyle = state.fillStyle; var strokeStyle = state.strokeStyle; - if (!goog.isDef(fillStyle) && !goog.isDef(strokeStyle)) { + if (fillStyle === undefined && strokeStyle === undefined) { return; } if (strokeStyle !== undefined) { @@ -1306,7 +1306,7 @@ ol.render.canvas.PolygonReplay.prototype.drawMultiPolygonGeometry = goog.asserts.assert(!goog.isNull(state), 'state should not be null'); var fillStyle = state.fillStyle; var strokeStyle = state.strokeStyle; - if (!goog.isDef(fillStyle) && !goog.isDef(strokeStyle)) { + if (fillStyle === undefined && strokeStyle === undefined) { return; } if (strokeStyle !== undefined) { diff --git a/src/ol/render/webgl/webglreplay.js b/src/ol/render/webgl/webglreplay.js index 122cafb759..9508c34470 100644 --- a/src/ol/render/webgl/webglreplay.js +++ b/src/ol/render/webgl/webglreplay.js @@ -866,7 +866,7 @@ ol.render.webgl.ImageReplay.prototype.drawHitDetectionReplayOneByOne_ = if (!goog.isDef(skippedFeaturesHash[featureUid]) && goog.isDefAndNotNull(feature.getGeometry()) && - (!goog.isDef(opt_hitExtent) || ol.extent.intersects( + (opt_hitExtent === undefined || ol.extent.intersects( opt_hitExtent, feature.getGeometry().getExtent()))) { gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); this.drawElements_(gl, start, end, elementType, elementSize); diff --git a/src/ol/source/tilearcgisrestsource.js b/src/ol/source/tilearcgisrestsource.js index 8ec3c9e74c..e1093f1006 100644 --- a/src/ol/source/tilearcgisrestsource.js +++ b/src/ol/source/tilearcgisrestsource.js @@ -48,7 +48,7 @@ ol.source.TileArcGISRest = function(opt_options) { }); var urls = options.urls; - if (!goog.isDef(urls) && goog.isDef(options.url)) { + if (urls === undefined && goog.isDef(options.url)) { urls = ol.TileUrlFunction.expandUrl(options.url); } diff --git a/src/ol/source/tilewmssource.js b/src/ol/source/tilewmssource.js index 8a17db97da..12f8eff1d3 100644 --- a/src/ol/source/tilewmssource.js +++ b/src/ol/source/tilewmssource.js @@ -52,7 +52,7 @@ ol.source.TileWMS = function(opt_options) { }); var urls = options.urls; - if (!goog.isDef(urls) && goog.isDef(options.url)) { + if (urls === undefined && goog.isDef(options.url)) { urls = ol.TileUrlFunction.expandUrl(options.url); } diff --git a/src/ol/source/vectorsource.js b/src/ol/source/vectorsource.js index 074154a968..bf698e6ea0 100644 --- a/src/ol/source/vectorsource.js +++ b/src/ol/source/vectorsource.js @@ -161,7 +161,7 @@ ol.source.Vector = function(opt_options) { } else if (goog.isArray(options.features)) { features = options.features; } - if (!useSpatialIndex && !goog.isDef(collection)) { + if (!useSpatialIndex && collection === undefined) { collection = new ol.Collection(features); } if (features !== undefined) { diff --git a/src/ol/source/wmtssource.js b/src/ol/source/wmtssource.js index 616c82d843..698a003576 100644 --- a/src/ol/source/wmtssource.js +++ b/src/ol/source/wmtssource.js @@ -83,7 +83,7 @@ ol.source.WMTS = function(options) { this.style_ = options.style; var urls = options.urls; - if (!goog.isDef(urls) && goog.isDef(options.url)) { + if (urls === undefined && goog.isDef(options.url)) { urls = ol.TileUrlFunction.expandUrl(options.url); } diff --git a/src/ol/style/iconstyle.js b/src/ol/style/iconstyle.js index 87d13574a2..edbb76b90c 100644 --- a/src/ol/style/iconstyle.js +++ b/src/ol/style/iconstyle.js @@ -108,13 +108,13 @@ ol.style.Icon = function(opt_options) { goog.asserts.assert(!(goog.isDef(src) && !goog.isNull(image)), 'image and src can not provided at the same time'); goog.asserts.assert( - !goog.isDef(src) || (goog.isDef(src) && goog.isNull(imgSize)), + src === undefined || (goog.isDef(src) && goog.isNull(imgSize)), 'imgSize should not be set when src is provided'); goog.asserts.assert( goog.isNull(image) || (!goog.isNull(image) && !goog.isNull(imgSize)), 'imgSize must be set when image is provided'); - if ((!goog.isDef(src) || src.length === 0) && !goog.isNull(image)) { + if ((src === undefined || src.length === 0) && !goog.isNull(image)) { src = image.src; } goog.asserts.assert(goog.isDef(src) && src.length > 0, diff --git a/src/ol/view.js b/src/ol/view.js index fb2092c2b7..059d0da86a 100644 --- a/src/ol/view.js +++ b/src/ol/view.js @@ -738,7 +738,7 @@ ol.View.createRotationConstraint_ = function(options) { options.enableRotation : true; if (enableRotation) { var constrainRotation = options.constrainRotation; - if (!goog.isDef(constrainRotation) || constrainRotation === true) { + if (constrainRotation === undefined || constrainRotation === true) { return ol.RotationConstraint.createSnapToZero(); } else if (constrainRotation === false) { return ol.RotationConstraint.none; From e3951fa3c6795f6466381ddfe35f9469d8bea017 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Sun, 27 Sep 2015 10:34:44 -0600 Subject: [PATCH 78/93] Inline simple goog.isDef() calls --- src/ol/geom/flat/flipflatgeom.js | 2 +- src/ol/geom/flat/inflateflatgeom.js | 6 +- src/ol/geom/flat/simplifyflatgeom.js | 2 +- src/ol/graticule.js | 16 ++--- src/ol/imagecanvas.js | 4 +- src/ol/layer/layergroup.js | 4 +- src/ol/map.js | 34 +++++----- src/ol/mapbrowserevent.js | 2 +- src/ol/mapevent.js | 2 +- src/ol/overlay.js | 8 +-- src/ol/proj/proj.js | 14 ++-- src/ol/render/canvas/canvasimmediate.js | 36 +++++----- src/ol/render/canvas/canvasreplay.js | 67 ++++++++++--------- src/ol/render/webgl/webglreplay.js | 12 ++-- src/ol/renderer/canvas/canvaslayerrenderer.js | 6 +- .../canvas/canvasvectorlayerrenderer.js | 2 +- src/ol/renderer/dom/domvectorlayerrenderer.js | 2 +- .../renderer/webgl/webglimagelayerrenderer.js | 2 +- .../webgl/webglvectorlayerrenderer.js | 2 +- src/ol/source/imagevectorsource.js | 4 +- src/ol/source/tilearcgisrestsource.js | 2 +- src/ol/source/tiledebugsource.js | 2 +- src/ol/source/tileimagesource.js | 4 +- src/ol/source/tilejsonsource.js | 2 +- src/ol/source/tilesource.js | 2 +- src/ol/source/tileutfgridsource.js | 6 +- src/ol/source/tilewmssource.js | 2 +- src/ol/source/vectorsource.js | 4 +- src/ol/source/wmtssource.js | 4 +- src/ol/source/zoomifysource.js | 3 +- src/ol/structs/lrucache.js | 2 +- src/ol/style/atlasmanager.js | 2 +- src/ol/style/iconstyle.js | 8 +-- src/ol/tilecache.js | 2 +- src/ol/tilegrid/tilegrid.js | 14 ++-- src/ol/view.js | 12 ++-- src/ol/webgl/buffer.js | 4 +- src/ol/xml.js | 26 +++---- test/spec/ol/extent.test.js | 2 +- .../ol/interaction/drawinteraction.test.js | 2 +- .../ol/interaction/modifyinteraction.test.js | 2 +- .../ol/interaction/selectinteraction.test.js | 2 +- .../interaction/translateinteraction.test.js | 2 +- test/spec/ol/pointer/touchsource.test.js | 2 +- test_rendering/spec/ol/layer/tile.test.js | 2 +- 45 files changed, 172 insertions(+), 170 deletions(-) diff --git a/src/ol/geom/flat/flipflatgeom.js b/src/ol/geom/flat/flipflatgeom.js index 8532682e46..5808999797 100644 --- a/src/ol/geom/flat/flipflatgeom.js +++ b/src/ol/geom/flat/flipflatgeom.js @@ -17,7 +17,7 @@ ol.geom.flat.flip.flipXY = var dest, destOffset; if (opt_dest !== undefined) { dest = opt_dest; - destOffset = goog.isDef(opt_destOffset) ? opt_destOffset : 0; + destOffset = opt_destOffset !== undefined ? opt_destOffset : 0; } else { goog.asserts.assert(opt_destOffset === undefined, 'opt_destOffSet should be defined'); diff --git a/src/ol/geom/flat/inflateflatgeom.js b/src/ol/geom/flat/inflateflatgeom.js index 53c4620c3f..e61c194f08 100644 --- a/src/ol/geom/flat/inflateflatgeom.js +++ b/src/ol/geom/flat/inflateflatgeom.js @@ -11,7 +11,7 @@ goog.provide('ol.geom.flat.inflate'); */ ol.geom.flat.inflate.coordinates = function(flatCoordinates, offset, end, stride, opt_coordinates) { - var coordinates = goog.isDef(opt_coordinates) ? opt_coordinates : []; + var coordinates = opt_coordinates !== undefined ? opt_coordinates : []; var i = 0; var j; for (j = offset; j < end; j += stride) { @@ -32,7 +32,7 @@ ol.geom.flat.inflate.coordinates = */ ol.geom.flat.inflate.coordinatess = function(flatCoordinates, offset, ends, stride, opt_coordinatess) { - var coordinatess = goog.isDef(opt_coordinatess) ? opt_coordinatess : []; + var coordinatess = opt_coordinatess !== undefined ? opt_coordinatess : []; var i = 0; var j, jj; for (j = 0, jj = ends.length; j < jj; ++j) { @@ -57,7 +57,7 @@ ol.geom.flat.inflate.coordinatess = */ ol.geom.flat.inflate.coordinatesss = function(flatCoordinates, offset, endss, stride, opt_coordinatesss) { - var coordinatesss = goog.isDef(opt_coordinatesss) ? opt_coordinatesss : []; + var coordinatesss = opt_coordinatesss !== undefined ? opt_coordinatesss : []; var i = 0; var j, jj; for (j = 0, jj = endss.length; j < jj; ++j) { diff --git a/src/ol/geom/flat/simplifyflatgeom.js b/src/ol/geom/flat/simplifyflatgeom.js index 7b747c6280..9e1c45cc9d 100644 --- a/src/ol/geom/flat/simplifyflatgeom.js +++ b/src/ol/geom/flat/simplifyflatgeom.js @@ -42,7 +42,7 @@ goog.require('ol.math'); */ ol.geom.flat.simplify.lineString = function(flatCoordinates, offset, end, stride, squaredTolerance, highQuality, opt_simplifiedFlatCoordinates) { - var simplifiedFlatCoordinates = goog.isDef(opt_simplifiedFlatCoordinates) ? + var simplifiedFlatCoordinates = opt_simplifiedFlatCoordinates !== undefined ? opt_simplifiedFlatCoordinates : []; if (!highQuality) { end = ol.geom.flat.simplify.radialDistance(flatCoordinates, offset, end, diff --git a/src/ol/graticule.js b/src/ol/graticule.js index ab3b84dc98..3a3ca588b7 100644 --- a/src/ol/graticule.js +++ b/src/ol/graticule.js @@ -463,18 +463,18 @@ ol.Graticule.prototype.updateProjectionInfo_ = function(projection) { var minLonP = worldExtentP[0]; goog.asserts.assert(!goog.isNull(extent), 'extent cannot be null'); - goog.asserts.assert(goog.isDef(maxLat), 'maxLat should be defined'); - goog.asserts.assert(goog.isDef(maxLon), 'maxLon should be defined'); - goog.asserts.assert(goog.isDef(minLat), 'minLat should be defined'); - goog.asserts.assert(goog.isDef(minLon), 'minLon should be defined'); + goog.asserts.assert(maxLat !== undefined, 'maxLat should be defined'); + goog.asserts.assert(maxLon !== undefined, 'maxLon should be defined'); + goog.asserts.assert(minLat !== undefined, 'minLat should be defined'); + goog.asserts.assert(minLon !== undefined, 'minLon should be defined'); - goog.asserts.assert(goog.isDef(maxLatP), + goog.asserts.assert(maxLatP !== undefined, 'projected maxLat should be defined'); - goog.asserts.assert(goog.isDef(maxLonP), + goog.asserts.assert(maxLonP !== undefined, 'projected maxLon should be defined'); - goog.asserts.assert(goog.isDef(minLatP), + goog.asserts.assert(minLatP !== undefined, 'projected minLat should be defined'); - goog.asserts.assert(goog.isDef(minLonP), + goog.asserts.assert(minLonP !== undefined, 'projected minLon should be defined'); this.maxLat_ = maxLat; diff --git a/src/ol/imagecanvas.js b/src/ol/imagecanvas.js index 3d903bab06..0d1920d304 100644 --- a/src/ol/imagecanvas.js +++ b/src/ol/imagecanvas.js @@ -25,9 +25,9 @@ ol.ImageCanvas = function(extent, resolution, pixelRatio, attributions, * @type {?ol.ImageCanvasLoader} * @private */ - this.loader_ = goog.isDef(opt_loader) ? opt_loader : null; + this.loader_ = opt_loader !== undefined ? opt_loader : null; - var state = goog.isDef(opt_loader) ? + var state = opt_loader !== undefined ? ol.ImageState.IDLE : ol.ImageState.LOADED; goog.base(this, extent, resolution, pixelRatio, state, attributions); diff --git a/src/ol/layer/layergroup.js b/src/ol/layer/layergroup.js index 0e2c6e84d9..647a882407 100644 --- a/src/ol/layer/layergroup.js +++ b/src/ol/layer/layergroup.js @@ -191,7 +191,7 @@ ol.layer.Group.prototype.setLayers = function(layers) { * @inheritDoc */ ol.layer.Group.prototype.getLayersArray = function(opt_array) { - var array = goog.isDef(opt_array) ? opt_array : []; + var array = opt_array !== undefined ? opt_array : []; this.getLayers().forEach(function(layer) { layer.getLayersArray(array); }); @@ -203,7 +203,7 @@ ol.layer.Group.prototype.getLayersArray = function(opt_array) { * @inheritDoc */ ol.layer.Group.prototype.getLayerStatesArray = function(opt_states) { - var states = goog.isDef(opt_states) ? opt_states : []; + var states = opt_states !== undefined ? opt_states : []; var pos = states.length; diff --git a/src/ol/map.js b/src/ol/map.js index c9eb514a7d..acb08063c9 100644 --- a/src/ol/map.js +++ b/src/ol/map.js @@ -496,7 +496,7 @@ goog.inherits(ol.Map, ol.Object); */ ol.Map.prototype.addControl = function(control) { var controls = this.getControls(); - goog.asserts.assert(goog.isDef(controls), 'controls should be defined'); + goog.asserts.assert(controls !== undefined, 'controls should be defined'); controls.push(control); }; @@ -508,7 +508,7 @@ ol.Map.prototype.addControl = function(control) { */ ol.Map.prototype.addInteraction = function(interaction) { var interactions = this.getInteractions(); - goog.asserts.assert(goog.isDef(interactions), + goog.asserts.assert(interactions !== undefined, 'interactions should be defined'); interactions.push(interaction); }; @@ -534,7 +534,7 @@ ol.Map.prototype.addLayer = function(layer) { */ ol.Map.prototype.addOverlay = function(overlay) { var overlays = this.getOverlays(); - goog.asserts.assert(goog.isDef(overlays), 'overlays should be defined'); + goog.asserts.assert(overlays !== undefined, 'overlays should be defined'); overlays.push(overlay); }; @@ -600,10 +600,10 @@ ol.Map.prototype.forEachFeatureAtPixel = return; } var coordinate = this.getCoordinateFromPixel(pixel); - var thisArg = goog.isDef(opt_this) ? opt_this : null; - var layerFilter = goog.isDef(opt_layerFilter) ? + var thisArg = opt_this !== undefined ? opt_this : null; + var layerFilter = opt_layerFilter !== undefined ? opt_layerFilter : goog.functions.TRUE; - var thisArg2 = goog.isDef(opt_this2) ? opt_this2 : null; + var thisArg2 = opt_this2 !== undefined ? opt_this2 : null; return this.renderer_.forEachFeatureAtCoordinate( coordinate, this.frameState_, callback, thisArg, layerFilter, thisArg2); @@ -637,10 +637,10 @@ ol.Map.prototype.forEachLayerAtPixel = if (goog.isNull(this.frameState_)) { return; } - var thisArg = goog.isDef(opt_this) ? opt_this : null; - var layerFilter = goog.isDef(opt_layerFilter) ? + var thisArg = opt_this !== undefined ? opt_this : null; + var layerFilter = opt_layerFilter !== undefined ? opt_layerFilter : goog.functions.TRUE; - var thisArg2 = goog.isDef(opt_this2) ? opt_this2 : null; + var thisArg2 = opt_this2 !== undefined ? opt_this2 : null; return this.renderer_.forEachLayerAtPixel( pixel, this.frameState_, callback, thisArg, layerFilter, thisArg2); @@ -668,9 +668,9 @@ ol.Map.prototype.hasFeatureAtPixel = return false; } var coordinate = this.getCoordinateFromPixel(pixel); - var layerFilter = goog.isDef(opt_layerFilter) ? + var layerFilter = opt_layerFilter !== undefined ? opt_layerFilter : goog.functions.TRUE; - var thisArg = goog.isDef(opt_this) ? opt_this : null; + var thisArg = opt_this !== undefined ? opt_this : null; return this.renderer_.hasFeatureAtCoordinate( coordinate, this.frameState_, layerFilter, thisArg); }; @@ -723,7 +723,7 @@ ol.Map.prototype.getTarget = function() { */ ol.Map.prototype.getTargetElement = function() { var target = this.getTarget(); - return goog.isDef(target) ? goog.dom.getElement(target) : null; + return target !== undefined ? goog.dom.getElement(target) : null; }; @@ -941,7 +941,7 @@ ol.Map.prototype.handleMapBrowserEvent = function(mapBrowserEvent) { this.focus_ = mapBrowserEvent.coordinate; mapBrowserEvent.frameState = this.frameState_; var interactions = this.getInteractions(); - goog.asserts.assert(goog.isDef(interactions), + goog.asserts.assert(interactions !== undefined, 'interactions should be defined'); var interactionsArray = interactions.getArray(); var i; @@ -1199,7 +1199,7 @@ ol.Map.prototype.render = function() { */ ol.Map.prototype.removeControl = function(control) { var controls = this.getControls(); - goog.asserts.assert(goog.isDef(controls), 'controls should be defined'); + goog.asserts.assert(controls !== undefined, 'controls should be defined'); if (goog.isDef(controls.remove(control))) { return control; } @@ -1217,7 +1217,7 @@ ol.Map.prototype.removeControl = function(control) { ol.Map.prototype.removeInteraction = function(interaction) { var removed; var interactions = this.getInteractions(); - goog.asserts.assert(goog.isDef(interactions), + goog.asserts.assert(interactions !== undefined, 'interactions should be defined'); if (goog.isDef(interactions.remove(interaction))) { removed = interaction; @@ -1248,7 +1248,7 @@ ol.Map.prototype.removeLayer = function(layer) { */ ol.Map.prototype.removeOverlay = function(overlay) { var overlays = this.getOverlays(); - goog.asserts.assert(goog.isDef(overlays), 'overlays should be defined'); + goog.asserts.assert(overlays !== undefined, 'overlays should be defined'); if (goog.isDef(overlays.remove(overlay))) { return overlay; } @@ -1268,7 +1268,7 @@ ol.Map.prototype.renderFrame_ = function(time) { var view = this.getView(); /** @type {?olx.FrameState} */ var frameState = null; - if (goog.isDef(size) && ol.size.hasArea(size) && + if (size !== undefined && ol.size.hasArea(size) && !goog.isNull(view) && view.isDef()) { var viewHints = view.getHints(); var layerStatesArray = this.getLayerGroup().getLayerStatesArray(); diff --git a/src/ol/mapbrowserevent.js b/src/ol/mapbrowserevent.js index 32baec1783..ccfad65fad 100644 --- a/src/ol/mapbrowserevent.js +++ b/src/ol/mapbrowserevent.js @@ -73,7 +73,7 @@ ol.MapBrowserEvent = function(type, map, browserEvent, opt_dragging, * @type {boolean} * @api stable */ - this.dragging = goog.isDef(opt_dragging) ? opt_dragging : false; + this.dragging = opt_dragging !== undefined ? opt_dragging : false; }; goog.inherits(ol.MapBrowserEvent, ol.MapEvent); diff --git a/src/ol/mapevent.js b/src/ol/mapevent.js index 909a774f23..dd37dc2505 100644 --- a/src/ol/mapevent.js +++ b/src/ol/mapevent.js @@ -55,7 +55,7 @@ ol.MapEvent = function(type, map, opt_frameState) { * @type {?olx.FrameState} * @api */ - this.frameState = goog.isDef(opt_frameState) ? opt_frameState : null; + this.frameState = opt_frameState !== undefined ? opt_frameState : null; }; goog.inherits(ol.MapEvent, goog.events.Event); diff --git a/src/ol/overlay.js b/src/ol/overlay.js index 71b3f649d8..97950b21c3 100644 --- a/src/ol/overlay.js +++ b/src/ol/overlay.js @@ -403,7 +403,7 @@ ol.Overlay.prototype.panIntoView_ = function() { if (delta[0] !== 0 || delta[1] !== 0) { var center = map.getView().getCenter(); - goog.asserts.assert(goog.isDef(center), 'center should be defined'); + goog.asserts.assert(center !== undefined, 'center should be defined'); var centerPx = map.getPixelFromCoordinate(center); var newCenterPx = [ centerPx[0] + delta[0], @@ -430,7 +430,7 @@ ol.Overlay.prototype.panIntoView_ = function() { ol.Overlay.prototype.getRect_ = function(element, size) { goog.asserts.assert(goog.isDefAndNotNull(element), 'element should be defined'); - goog.asserts.assert(goog.isDef(size), 'size should be defined'); + goog.asserts.assert(size !== undefined, 'size should be defined'); var offset = goog.style.getPageOffset(element); return [ @@ -492,13 +492,13 @@ ol.Overlay.prototype.updatePixelPosition = function() { */ ol.Overlay.prototype.updateRenderedPosition = function(pixel, mapSize) { goog.asserts.assert(!goog.isNull(pixel), 'pixel should not be null'); - goog.asserts.assert(goog.isDef(mapSize), 'mapSize should be defined'); + goog.asserts.assert(mapSize !== undefined, 'mapSize should be defined'); var style = this.element_.style; var offset = this.getOffset(); goog.asserts.assert(goog.isArray(offset), 'offset should be an array'); var positioning = this.getPositioning(); - goog.asserts.assert(goog.isDef(positioning), + goog.asserts.assert(positioning !== undefined, 'positioning should be defined'); var offsetX = offset[0]; diff --git a/src/ol/proj/proj.js b/src/ol/proj/proj.js index 27d0f42873..a909eba5c0 100644 --- a/src/ol/proj/proj.js +++ b/src/ol/proj/proj.js @@ -143,7 +143,7 @@ ol.proj.Projection = function(options) { var projections = ol.proj.projections_; var code = options.code; - goog.asserts.assert(goog.isDef(code), + goog.asserts.assert(code !== undefined, 'Option "code" is required for constructing instance'); if (ol.ENABLE_PROJ4JS && typeof proj4 == 'function' && !goog.isDef(projections[code])) { @@ -563,8 +563,8 @@ ol.proj.createTransformFromCoordinateTransform = function(transform) { */ function(input, opt_output, opt_dimension) { var length = input.length; - var dimension = goog.isDef(opt_dimension) ? opt_dimension : 2; - var output = goog.isDef(opt_output) ? opt_output : new Array(length); + var dimension = opt_dimension !== undefined ? opt_dimension : 2; + var output = opt_output !== undefined ? opt_output : new Array(length); var point, i, j; for (i = 0; i < length; i += dimension) { point = transform([input[i], input[i + 1]]); @@ -617,7 +617,7 @@ ol.proj.removeTransform = function(source, destination) { */ ol.proj.fromLonLat = function(coordinate, opt_projection) { return ol.proj.transform(coordinate, 'EPSG:4326', - goog.isDef(opt_projection) ? opt_projection : 'EPSG:3857'); + opt_projection !== undefined ? opt_projection : 'EPSG:3857'); }; @@ -632,7 +632,7 @@ ol.proj.fromLonLat = function(coordinate, opt_projection) { */ ol.proj.toLonLat = function(coordinate, opt_projection) { return ol.proj.transform(coordinate, - goog.isDef(opt_projection) ? opt_projection : 'EPSG:3857', 'EPSG:4326'); + opt_projection !== undefined ? opt_projection : 'EPSG:3857', 'EPSG:4326'); }; @@ -726,7 +726,7 @@ ol.proj.getTransformFromProjections = transform = transforms[sourceCode][destinationCode]; } if (transform === undefined) { - goog.asserts.assert(goog.isDef(transform), 'transform should be defined'); + goog.asserts.assert(transform !== undefined, 'transform should be defined'); transform = ol.proj.identityTransform; } return transform; @@ -740,7 +740,7 @@ ol.proj.getTransformFromProjections = * @return {Array.} Input coordinate array (same array as input). */ ol.proj.identityTransform = function(input, opt_output, opt_dimension) { - if (goog.isDef(opt_output) && input !== opt_output) { + if (opt_output !== undefined && input !== opt_output) { // TODO: consider making this a warning instead goog.asserts.fail('This should not be used internally.'); for (var i = 0, ii = input.length; i < ii; ++i) { diff --git a/src/ol/render/canvas/canvasimmediate.js b/src/ol/render/canvas/canvasimmediate.js index 368f1ce525..85e5f65673 100644 --- a/src/ol/render/canvas/canvasimmediate.js +++ b/src/ol/render/canvas/canvasimmediate.js @@ -494,7 +494,7 @@ ol.render.canvas.Immediate.prototype.drawFeature = function(feature, style) { render.setTextStyle(style.getText()); var renderGeometry = ol.render.canvas.Immediate.GEOMETRY_RENDERERS_[geometry.getType()]; - goog.asserts.assert(goog.isDef(renderGeometry), + goog.asserts.assert(renderGeometry !== undefined, 'renderGeometry should be defined'); renderGeometry.call(render, geometry, null); }); @@ -517,7 +517,7 @@ ol.render.canvas.Immediate.prototype.drawGeometryCollectionGeometry = var geometry = geometries[i]; var geometryRenderer = ol.render.canvas.Immediate.GEOMETRY_RENDERERS_[geometry.getType()]; - goog.asserts.assert(goog.isDef(geometryRenderer), + goog.asserts.assert(geometryRenderer !== undefined, 'geometryRenderer should be defined'); geometryRenderer.call(this, geometry, feature); } @@ -872,15 +872,15 @@ ol.render.canvas.Immediate.prototype.setFillStrokeStyle = var strokeStyleWidth = strokeStyle.getWidth(); var strokeStyleMiterLimit = strokeStyle.getMiterLimit(); this.strokeState_ = { - lineCap: goog.isDef(strokeStyleLineCap) ? + lineCap: strokeStyleLineCap !== undefined ? strokeStyleLineCap : ol.render.canvas.defaultLineCap, lineDash: goog.isDefAndNotNull(strokeStyleLineDash) ? strokeStyleLineDash : ol.render.canvas.defaultLineDash, - lineJoin: goog.isDef(strokeStyleLineJoin) ? + lineJoin: strokeStyleLineJoin !== undefined ? strokeStyleLineJoin : ol.render.canvas.defaultLineJoin, - lineWidth: this.pixelRatio_ * (goog.isDef(strokeStyleWidth) ? + lineWidth: this.pixelRatio_ * (strokeStyleWidth !== undefined ? strokeStyleWidth : ol.render.canvas.defaultLineWidth), - miterLimit: goog.isDef(strokeStyleMiterLimit) ? + miterLimit: strokeStyleMiterLimit !== undefined ? strokeStyleMiterLimit : ol.render.canvas.defaultMiterLimit, strokeStyle: ol.color.asString(!goog.isNull(strokeStyleColor) ? strokeStyleColor : ol.render.canvas.defaultStrokeStyle) @@ -961,15 +961,15 @@ ol.render.canvas.Immediate.prototype.setTextStyle = function(textStyle) { var textStrokeStyleWidth = textStrokeStyle.getWidth(); var textStrokeStyleMiterLimit = textStrokeStyle.getMiterLimit(); this.textStrokeState_ = { - lineCap: goog.isDef(textStrokeStyleLineCap) ? + lineCap: textStrokeStyleLineCap !== undefined ? textStrokeStyleLineCap : ol.render.canvas.defaultLineCap, lineDash: goog.isDefAndNotNull(textStrokeStyleLineDash) ? textStrokeStyleLineDash : ol.render.canvas.defaultLineDash, - lineJoin: goog.isDef(textStrokeStyleLineJoin) ? + lineJoin: textStrokeStyleLineJoin !== undefined ? textStrokeStyleLineJoin : ol.render.canvas.defaultLineJoin, - lineWidth: goog.isDef(textStrokeStyleWidth) ? + lineWidth: textStrokeStyleWidth !== undefined ? textStrokeStyleWidth : ol.render.canvas.defaultLineWidth, - miterLimit: goog.isDef(textStrokeStyleMiterLimit) ? + miterLimit: textStrokeStyleMiterLimit !== undefined ? textStrokeStyleMiterLimit : ol.render.canvas.defaultMiterLimit, strokeStyle: ol.color.asString(!goog.isNull(textStrokeStyleColor) ? textStrokeStyleColor : ol.render.canvas.defaultStrokeStyle) @@ -984,20 +984,20 @@ ol.render.canvas.Immediate.prototype.setTextStyle = function(textStyle) { var textTextAlign = textStyle.getTextAlign(); var textTextBaseline = textStyle.getTextBaseline(); this.textState_ = { - font: goog.isDef(textFont) ? + font: textFont !== undefined ? textFont : ol.render.canvas.defaultFont, - textAlign: goog.isDef(textTextAlign) ? + textAlign: textTextAlign !== undefined ? textTextAlign : ol.render.canvas.defaultTextAlign, - textBaseline: goog.isDef(textTextBaseline) ? + textBaseline: textTextBaseline !== undefined ? textTextBaseline : ol.render.canvas.defaultTextBaseline }; - this.text_ = goog.isDef(textText) ? textText : ''; + this.text_ = textText !== undefined ? textText : ''; this.textOffsetX_ = - goog.isDef(textOffsetX) ? (this.pixelRatio_ * textOffsetX) : 0; + textOffsetX !== undefined ? (this.pixelRatio_ * textOffsetX) : 0; this.textOffsetY_ = - goog.isDef(textOffsetY) ? (this.pixelRatio_ * textOffsetY) : 0; - this.textRotation_ = goog.isDef(textRotation) ? textRotation : 0; - this.textScale_ = this.pixelRatio_ * (goog.isDef(textScale) ? + textOffsetY !== undefined ? (this.pixelRatio_ * textOffsetY) : 0; + this.textRotation_ = textRotation !== undefined ? textRotation : 0; + this.textScale_ = this.pixelRatio_ * (textScale !== undefined ? textScale : 1); } }; diff --git a/src/ol/render/canvas/canvasreplay.js b/src/ol/render/canvas/canvasreplay.js index 8de2dbecb3..8e33020d22 100644 --- a/src/ol/render/canvas/canvasreplay.js +++ b/src/ol/render/canvas/canvasreplay.js @@ -260,7 +260,7 @@ ol.render.canvas.Replay.prototype.replay_ = function( if (goog.isDef(skippedFeaturesHash[featureUid]) || !goog.isDefAndNotNull(feature.getGeometry())) { i = /** @type {number} */ (instruction[2]); - } else if (goog.isDef(opt_hitExtent) && !ol.extent.intersects( + } else if (opt_hitExtent !== undefined && !ol.extent.intersects( opt_hitExtent, feature.getGeometry().getExtent())) { i = /** @type {number} */ (instruction[2]); } else { @@ -966,13 +966,13 @@ ol.render.canvas.LineStringReplay.prototype.setStrokeStyle_ = function() { var lineJoin = state.lineJoin; var lineWidth = state.lineWidth; var miterLimit = state.miterLimit; - goog.asserts.assert(goog.isDef(strokeStyle), + goog.asserts.assert(strokeStyle !== undefined, 'strokeStyle should be defined'); - goog.asserts.assert(goog.isDef(lineCap), 'lineCap should be defined'); + goog.asserts.assert(lineCap !== undefined, 'lineCap should be defined'); goog.asserts.assert(!goog.isNull(lineDash), 'lineDash should not be null'); - goog.asserts.assert(goog.isDef(lineJoin), 'lineJoin should be defined'); - goog.asserts.assert(goog.isDef(lineWidth), 'lineWidth should be defined'); - goog.asserts.assert(goog.isDef(miterLimit), 'miterLimit should be defined'); + goog.asserts.assert(lineJoin !== undefined, 'lineJoin should be defined'); + goog.asserts.assert(lineWidth !== undefined, 'lineWidth should be defined'); + goog.asserts.assert(miterLimit !== undefined, 'miterLimit should be defined'); if (state.currentStrokeStyle != strokeStyle || state.currentLineCap != lineCap || !goog.array.equals(state.currentLineDash, lineDash) || @@ -1087,19 +1087,19 @@ ol.render.canvas.LineStringReplay.prototype.setFillStrokeStyle = this.state_.strokeStyle = ol.color.asString(!goog.isNull(strokeStyleColor) ? strokeStyleColor : ol.render.canvas.defaultStrokeStyle); var strokeStyleLineCap = strokeStyle.getLineCap(); - this.state_.lineCap = goog.isDef(strokeStyleLineCap) ? + this.state_.lineCap = strokeStyleLineCap !== undefined ? strokeStyleLineCap : ol.render.canvas.defaultLineCap; var strokeStyleLineDash = strokeStyle.getLineDash(); this.state_.lineDash = !goog.isNull(strokeStyleLineDash) ? strokeStyleLineDash : ol.render.canvas.defaultLineDash; var strokeStyleLineJoin = strokeStyle.getLineJoin(); - this.state_.lineJoin = goog.isDef(strokeStyleLineJoin) ? + this.state_.lineJoin = strokeStyleLineJoin !== undefined ? strokeStyleLineJoin : ol.render.canvas.defaultLineJoin; var strokeStyleWidth = strokeStyle.getWidth(); - this.state_.lineWidth = goog.isDef(strokeStyleWidth) ? + this.state_.lineWidth = strokeStyleWidth !== undefined ? strokeStyleWidth : ol.render.canvas.defaultLineWidth; var strokeStyleMiterLimit = strokeStyle.getMiterLimit(); - this.state_.miterLimit = goog.isDef(strokeStyleMiterLimit) ? + this.state_.miterLimit = strokeStyleMiterLimit !== undefined ? strokeStyleMiterLimit : ol.render.canvas.defaultMiterLimit; if (this.state_.lineWidth > this.maxLineWidth) { @@ -1398,19 +1398,19 @@ ol.render.canvas.PolygonReplay.prototype.setFillStrokeStyle = state.strokeStyle = ol.color.asString(!goog.isNull(strokeStyleColor) ? strokeStyleColor : ol.render.canvas.defaultStrokeStyle); var strokeStyleLineCap = strokeStyle.getLineCap(); - state.lineCap = goog.isDef(strokeStyleLineCap) ? + state.lineCap = strokeStyleLineCap !== undefined ? strokeStyleLineCap : ol.render.canvas.defaultLineCap; var strokeStyleLineDash = strokeStyle.getLineDash(); state.lineDash = !goog.isNull(strokeStyleLineDash) ? strokeStyleLineDash.slice() : ol.render.canvas.defaultLineDash; var strokeStyleLineJoin = strokeStyle.getLineJoin(); - state.lineJoin = goog.isDef(strokeStyleLineJoin) ? + state.lineJoin = strokeStyleLineJoin !== undefined ? strokeStyleLineJoin : ol.render.canvas.defaultLineJoin; var strokeStyleWidth = strokeStyle.getWidth(); - state.lineWidth = goog.isDef(strokeStyleWidth) ? + state.lineWidth = strokeStyleWidth !== undefined ? strokeStyleWidth : ol.render.canvas.defaultLineWidth; var strokeStyleMiterLimit = strokeStyle.getMiterLimit(); - state.miterLimit = goog.isDef(strokeStyleMiterLimit) ? + state.miterLimit = strokeStyleMiterLimit !== undefined ? strokeStyleMiterLimit : ol.render.canvas.defaultMiterLimit; if (state.lineWidth > this.maxLineWidth) { @@ -1441,17 +1441,18 @@ ol.render.canvas.PolygonReplay.prototype.setFillStrokeStyles_ = function() { var lineJoin = state.lineJoin; var lineWidth = state.lineWidth; var miterLimit = state.miterLimit; - if (goog.isDef(fillStyle) && state.currentFillStyle != fillStyle) { + if (fillStyle !== undefined && state.currentFillStyle != fillStyle) { this.instructions.push( [ol.render.canvas.Instruction.SET_FILL_STYLE, fillStyle]); state.currentFillStyle = state.fillStyle; } if (strokeStyle !== undefined) { - goog.asserts.assert(goog.isDef(lineCap), 'lineCap should be defined'); + goog.asserts.assert(lineCap !== undefined, 'lineCap should be defined'); goog.asserts.assert(!goog.isNull(lineDash), 'lineDash should not be null'); - goog.asserts.assert(goog.isDef(lineJoin), 'lineJoin should be defined'); - goog.asserts.assert(goog.isDef(lineWidth), 'lineWidth should be defined'); - goog.asserts.assert(goog.isDef(miterLimit), 'miterLimit should be defined'); + goog.asserts.assert(lineJoin !== undefined, 'lineJoin should be defined'); + goog.asserts.assert(lineWidth !== undefined, 'lineWidth should be defined'); + goog.asserts.assert(miterLimit !== undefined, + 'miterLimit should be defined'); if (state.currentStrokeStyle != strokeStyle || state.currentLineCap != lineCap || state.currentLineDash != lineDash || @@ -1722,15 +1723,15 @@ ol.render.canvas.TextReplay.prototype.setTextStyle = function(textStyle) { var textStrokeStyleLineJoin = textStrokeStyle.getLineJoin(); var textStrokeStyleWidth = textStrokeStyle.getWidth(); var textStrokeStyleMiterLimit = textStrokeStyle.getMiterLimit(); - var lineCap = goog.isDef(textStrokeStyleLineCap) ? + var lineCap = textStrokeStyleLineCap !== undefined ? textStrokeStyleLineCap : ol.render.canvas.defaultLineCap; var lineDash = goog.isDefAndNotNull(textStrokeStyleLineDash) ? textStrokeStyleLineDash.slice() : ol.render.canvas.defaultLineDash; - var lineJoin = goog.isDef(textStrokeStyleLineJoin) ? + var lineJoin = textStrokeStyleLineJoin !== undefined ? textStrokeStyleLineJoin : ol.render.canvas.defaultLineJoin; - var lineWidth = goog.isDef(textStrokeStyleWidth) ? + var lineWidth = textStrokeStyleWidth !== undefined ? textStrokeStyleWidth : ol.render.canvas.defaultLineWidth; - var miterLimit = goog.isDef(textStrokeStyleMiterLimit) ? + var miterLimit = textStrokeStyleMiterLimit !== undefined ? textStrokeStyleMiterLimit : ol.render.canvas.defaultMiterLimit; var strokeStyle = ol.color.asString(!goog.isNull(textStrokeStyleColor) ? textStrokeStyleColor : ol.render.canvas.defaultStrokeStyle); @@ -1761,11 +1762,11 @@ ol.render.canvas.TextReplay.prototype.setTextStyle = function(textStyle) { var textText = textStyle.getText(); var textTextAlign = textStyle.getTextAlign(); var textTextBaseline = textStyle.getTextBaseline(); - var font = goog.isDef(textFont) ? + var font = textFont !== undefined ? textFont : ol.render.canvas.defaultFont; - var textAlign = goog.isDef(textTextAlign) ? + var textAlign = textTextAlign !== undefined ? textTextAlign : ol.render.canvas.defaultTextAlign; - var textBaseline = goog.isDef(textTextBaseline) ? + var textBaseline = textTextBaseline !== undefined ? textTextBaseline : ol.render.canvas.defaultTextBaseline; if (goog.isNull(this.textState_)) { this.textState_ = { @@ -1779,11 +1780,11 @@ ol.render.canvas.TextReplay.prototype.setTextStyle = function(textStyle) { textState.textAlign = textAlign; textState.textBaseline = textBaseline; } - this.text_ = goog.isDef(textText) ? textText : ''; - this.textOffsetX_ = goog.isDef(textOffsetX) ? textOffsetX : 0; - this.textOffsetY_ = goog.isDef(textOffsetY) ? textOffsetY : 0; - this.textRotation_ = goog.isDef(textRotation) ? textRotation : 0; - this.textScale_ = goog.isDef(textScale) ? textScale : 1; + this.text_ = textText !== undefined ? textText : ''; + this.textOffsetX_ = textOffsetX !== undefined ? textOffsetX : 0; + this.textOffsetY_ = textOffsetY !== undefined ? textOffsetY : 0; + this.textRotation_ = textRotation !== undefined ? textRotation : 0; + this.textScale_ = textScale !== undefined ? textScale : 1; } }; @@ -1917,7 +1918,7 @@ ol.render.canvas.ReplayGroup.prototype.forEachFeatureAtCoordinate = function( */ ol.render.canvas.ReplayGroup.prototype.getReplay = function(zIndex, replayType) { - var zIndexKey = goog.isDef(zIndex) ? zIndex.toString() : '0'; + var zIndexKey = zIndex !== undefined ? zIndex.toString() : '0'; var replays = this.replaysByZIndex_[zIndexKey]; if (replays === undefined) { replays = {}; @@ -1926,7 +1927,7 @@ ol.render.canvas.ReplayGroup.prototype.getReplay = var replay = replays[replayType]; if (replay === undefined) { var Constructor = ol.render.canvas.BATCH_CONSTRUCTORS_[replayType]; - goog.asserts.assert(goog.isDef(Constructor), + goog.asserts.assert(Constructor !== undefined, replayType + ' constructor missing from ol.render.canvas.BATCH_CONSTRUCTORS_'); replay = new Constructor(this.tolerance_, this.maxExtent_, diff --git a/src/ol/render/webgl/webglreplay.js b/src/ol/render/webgl/webglreplay.js index 9508c34470..bb9e91f52b 100644 --- a/src/ol/render/webgl/webglreplay.js +++ b/src/ol/render/webgl/webglreplay.js @@ -914,13 +914,13 @@ ol.render.webgl.ImageReplay.prototype.setImageStyle = function(imageStyle) { 'imageStyle hitDetectionImage is not null'); goog.asserts.assert(!goog.isNull(hitDetectionImageSize), 'imageStyle hitDetectionImageSize is not null'); - goog.asserts.assert(goog.isDef(opacity), 'imageStyle opacity is defined'); + goog.asserts.assert(opacity !== undefined, 'imageStyle opacity is defined'); goog.asserts.assert(!goog.isNull(origin), 'imageStyle origin is not null'); - goog.asserts.assert(goog.isDef(rotateWithView), + goog.asserts.assert(rotateWithView !== undefined, 'imageStyle rotateWithView is defined'); - goog.asserts.assert(goog.isDef(rotation), 'imageStyle rotation is defined'); + goog.asserts.assert(rotation !== undefined, 'imageStyle rotation is defined'); goog.asserts.assert(!goog.isNull(size), 'imageStyle size is not null'); - goog.asserts.assert(goog.isDef(scale), 'imageStyle scale is defined'); + goog.asserts.assert(scale !== undefined, 'imageStyle scale is defined'); var currentImage; if (this.images_.length === 0) { @@ -1039,7 +1039,7 @@ ol.render.webgl.ReplayGroup.prototype.getReplay = var replay = this.replays_[replayType]; if (replay === undefined) { var constructor = ol.render.webgl.BATCH_CONSTRUCTORS_[replayType]; - goog.asserts.assert(goog.isDef(constructor), + goog.asserts.assert(constructor !== undefined, replayType + ' constructor missing from ol.render.webgl.BATCH_CONSTRUCTORS_'); replay = new constructor(this.tolerance_, this.maxExtent_); @@ -1231,7 +1231,7 @@ ol.render.webgl.ReplayGroup.prototype.hasFeatureAtCoordinate = function( return imageData[3] > 0; }, false); - return goog.isDef(hasFeature); + return hasFeature !== undefined; }; diff --git a/src/ol/renderer/canvas/canvaslayerrenderer.js b/src/ol/renderer/canvas/canvaslayerrenderer.js index 7e85d22355..b011d30222 100644 --- a/src/ol/renderer/canvas/canvaslayerrenderer.js +++ b/src/ol/renderer/canvas/canvaslayerrenderer.js @@ -48,9 +48,9 @@ ol.renderer.canvas.Layer.prototype.composeFrame = // clipped rendering if layer extent is set var extent = layerState.extent; - var clipped = goog.isDef(extent); + var clipped = extent !== undefined; if (clipped) { - goog.asserts.assert(goog.isDef(extent), + goog.asserts.assert(extent !== undefined, 'layerState extent is defined'); var pixelRatio = frameState.pixelRatio; var topLeft = ol.extent.getTopLeft(extent); @@ -126,7 +126,7 @@ ol.renderer.canvas.Layer.prototype.dispatchComposeEvent_ = function(type, context, frameState, opt_transform) { var layer = this.getLayer(); if (layer.hasListener(type)) { - var transform = goog.isDef(opt_transform) ? + var transform = opt_transform !== undefined ? opt_transform : this.getTransform(frameState, 0); var render = new ol.render.canvas.Immediate( context, frameState.pixelRatio, frameState.extent, transform, diff --git a/src/ol/renderer/canvas/canvasvectorlayerrenderer.js b/src/ol/renderer/canvas/canvasvectorlayerrenderer.js index de3fc32f5d..6c55c66bbd 100644 --- a/src/ol/renderer/canvas/canvasvectorlayerrenderer.js +++ b/src/ol/renderer/canvas/canvasvectorlayerrenderer.js @@ -172,7 +172,7 @@ ol.renderer.canvas.VectorLayer.prototype.forEachFeatureAtCoordinate = * @return {?} Callback result. */ function(feature) { - goog.asserts.assert(goog.isDef(feature), 'received a feature'); + goog.asserts.assert(feature !== undefined, 'received a feature'); var key = goog.getUid(feature).toString(); if (!(key in features)) { features[key] = true; diff --git a/src/ol/renderer/dom/domvectorlayerrenderer.js b/src/ol/renderer/dom/domvectorlayerrenderer.js index fbddccba80..65603d5586 100644 --- a/src/ol/renderer/dom/domvectorlayerrenderer.js +++ b/src/ol/renderer/dom/domvectorlayerrenderer.js @@ -194,7 +194,7 @@ ol.renderer.dom.VectorLayer.prototype.forEachFeatureAtCoordinate = * @return {?} Callback result. */ function(feature) { - goog.asserts.assert(goog.isDef(feature), 'received a feature'); + goog.asserts.assert(feature !== undefined, 'received a feature'); var key = goog.getUid(feature).toString(); if (!(key in features)) { features[key] = true; diff --git a/src/ol/renderer/webgl/webglimagelayerrenderer.js b/src/ol/renderer/webgl/webglimagelayerrenderer.js index dd0db38c27..8f8964d65e 100644 --- a/src/ol/renderer/webgl/webglimagelayerrenderer.js +++ b/src/ol/renderer/webgl/webglimagelayerrenderer.js @@ -225,7 +225,7 @@ ol.renderer.webgl.ImageLayer.prototype.hasFeatureAtCoordinate = function(coordinate, frameState) { var hasFeature = this.forEachFeatureAtCoordinate( coordinate, frameState, goog.functions.TRUE, this); - return goog.isDef(hasFeature); + return hasFeature !== undefined; }; diff --git a/src/ol/renderer/webgl/webglvectorlayerrenderer.js b/src/ol/renderer/webgl/webglvectorlayerrenderer.js index 023b0849e0..4d5a28f72b 100644 --- a/src/ol/renderer/webgl/webglvectorlayerrenderer.js +++ b/src/ol/renderer/webgl/webglvectorlayerrenderer.js @@ -129,7 +129,7 @@ ol.renderer.webgl.VectorLayer.prototype.forEachFeatureAtCoordinate = * @return {?} Callback result. */ function(feature) { - goog.asserts.assert(goog.isDef(feature), 'received a feature'); + goog.asserts.assert(feature !== undefined, 'received a feature'); var key = goog.getUid(feature).toString(); if (!(key in features)) { features[key] = true; diff --git a/src/ol/source/imagevectorsource.js b/src/ol/source/imagevectorsource.js index 1e745005c7..f1dd179192 100644 --- a/src/ol/source/imagevectorsource.js +++ b/src/ol/source/imagevectorsource.js @@ -166,7 +166,7 @@ ol.source.ImageVector.prototype.forEachFeatureAtCoordinate = function( * @return {?} Callback result. */ function(feature) { - goog.asserts.assert(goog.isDef(feature), 'passed a feature'); + goog.asserts.assert(feature !== undefined, 'passed a feature'); var key = goog.getUid(feature).toString(); if (!(key in features)) { features[key] = true; @@ -290,7 +290,7 @@ ol.source.ImageVector.prototype.renderFeature_ = * @api stable */ ol.source.ImageVector.prototype.setStyle = function(style) { - this.style_ = goog.isDef(style) ? style : ol.style.defaultStyleFunction; + this.style_ = style !== undefined ? style : ol.style.defaultStyleFunction; this.styleFunction_ = goog.isNull(style) ? undefined : ol.style.createStyleFunction(this.style_); this.changed(); diff --git a/src/ol/source/tilearcgisrestsource.js b/src/ol/source/tilearcgisrestsource.js index e1093f1006..29c7e19d22 100644 --- a/src/ol/source/tilearcgisrestsource.js +++ b/src/ol/source/tilearcgisrestsource.js @@ -173,7 +173,7 @@ ol.source.TileArcGISRest.prototype.getUrls = function() { * @api stable */ ol.source.TileArcGISRest.prototype.setUrl = function(url) { - var urls = goog.isDef(url) ? ol.TileUrlFunction.expandUrl(url) : null; + var urls = url !== undefined ? ol.TileUrlFunction.expandUrl(url) : null; this.setUrls(urls); }; diff --git a/src/ol/source/tiledebugsource.js b/src/ol/source/tiledebugsource.js index 01d884bb8f..66b7409fbd 100644 --- a/src/ol/source/tiledebugsource.js +++ b/src/ol/source/tiledebugsource.js @@ -48,7 +48,7 @@ goog.inherits(ol.DebugTile_, ol.Tile); * @inheritDoc */ ol.DebugTile_.prototype.getImage = function(opt_context) { - var key = goog.isDef(opt_context) ? goog.getUid(opt_context) : -1; + var key = opt_context !== undefined ? goog.getUid(opt_context) : -1; if (key in this.canvasByContext_) { return this.canvasByContext_[key]; } else { diff --git a/src/ol/source/tileimagesource.js b/src/ol/source/tileimagesource.js index 1701f19e86..457143f702 100644 --- a/src/ol/source/tileimagesource.js +++ b/src/ol/source/tileimagesource.js @@ -99,8 +99,8 @@ ol.source.TileImage.prototype.getTile = this.tileUrlFunction(urlTileCoord, pixelRatio, projection); var tile = new this.tileClass( tileCoord, - goog.isDef(tileUrl) ? ol.TileState.IDLE : ol.TileState.EMPTY, - goog.isDef(tileUrl) ? tileUrl : '', + tileUrl !== undefined ? ol.TileState.IDLE : ol.TileState.EMPTY, + tileUrl !== undefined ? tileUrl : '', this.crossOrigin, this.tileLoadFunction); goog.events.listen(tile, goog.events.EventType.CHANGE, diff --git a/src/ol/source/tilejsonsource.js b/src/ol/source/tilejsonsource.js index 18282462db..472cfbd181 100644 --- a/src/ol/source/tilejsonsource.js +++ b/src/ol/source/tilejsonsource.js @@ -79,7 +79,7 @@ ol.source.TileJSON.prototype.handleTileJSONResponse = function(tileJSON) { if (goog.isDef(tileJSON.attribution) && goog.isNull(this.getAttributions())) { - var attributionExtent = goog.isDef(extent) ? + var attributionExtent = extent !== undefined ? extent : epsg4326Projection.getExtent(); /** @type {Object.>} */ var tileRanges = {}; diff --git a/src/ol/source/tilesource.js b/src/ol/source/tilesource.js index 4384434899..b0546ecaaa 100644 --- a/src/ol/source/tilesource.js +++ b/src/ol/source/tilesource.js @@ -227,7 +227,7 @@ ol.source.Tile.prototype.getTilePixelSize = */ ol.source.Tile.prototype.getTileCoordForTileUrlFunction = function(tileCoord, opt_projection) { - var projection = goog.isDef(opt_projection) ? + var projection = opt_projection !== undefined ? opt_projection : this.getProjection(); var tileGrid = this.getTileGridForProjection(projection); goog.asserts.assert(!goog.isNull(tileGrid), 'tile grid needed'); diff --git a/src/ol/source/tileutfgridsource.js b/src/ol/source/tileutfgridsource.js index f779822e3b..4786fd8d70 100644 --- a/src/ol/source/tileutfgridsource.js +++ b/src/ol/source/tileutfgridsource.js @@ -139,7 +139,7 @@ ol.source.TileUTFGrid.prototype.handleTileJSONResponse = function(tileJSON) { this.tileUrlFunction_ = ol.TileUrlFunction.createFromTemplates(grids); if (tileJSON.attribution !== undefined) { - var attributionExtent = goog.isDef(extent) ? + var attributionExtent = extent !== undefined ? extent : epsg4326Projection.getExtent(); /** @type {Object.>} */ var tileRanges = {}; @@ -178,8 +178,8 @@ ol.source.TileUTFGrid.prototype.getTile = var tileUrl = this.tileUrlFunction_(urlTileCoord, pixelRatio, projection); var tile = new ol.source.TileUTFGridTile_( tileCoord, - goog.isDef(tileUrl) ? ol.TileState.IDLE : ol.TileState.EMPTY, - goog.isDef(tileUrl) ? tileUrl : '', + tileUrl !== undefined ? ol.TileState.IDLE : ol.TileState.EMPTY, + tileUrl !== undefined ? tileUrl : '', this.tileGrid.getTileCoordExtent(tileCoord), this.preemptive_); this.tileCache.set(tileCoordKey, tile); diff --git a/src/ol/source/tilewmssource.js b/src/ol/source/tilewmssource.js index 12f8eff1d3..4d1ae44934 100644 --- a/src/ol/source/tilewmssource.js +++ b/src/ol/source/tilewmssource.js @@ -337,7 +337,7 @@ ol.source.TileWMS.prototype.resetCoordKeyPrefix_ = function() { * @api stable */ ol.source.TileWMS.prototype.setUrl = function(url) { - var urls = goog.isDef(url) ? ol.TileUrlFunction.expandUrl(url) : null; + var urls = url !== undefined ? ol.TileUrlFunction.expandUrl(url) : null; this.setUrls(urls); }; diff --git a/src/ol/source/vectorsource.js b/src/ol/source/vectorsource.js index bf698e6ea0..48cd84f0e5 100644 --- a/src/ol/source/vectorsource.js +++ b/src/ol/source/vectorsource.js @@ -572,7 +572,7 @@ ol.source.Vector.prototype.getFeatures = function() { features, goog.object.getValues(this.nullGeometryFeatures_)); } } - goog.asserts.assert(goog.isDef(features), + goog.asserts.assert(features !== undefined, 'Neither featuresRtree_ nor featuresCollection_ are available'); return features; }; @@ -692,7 +692,7 @@ ol.source.Vector.prototype.getExtent = function() { */ ol.source.Vector.prototype.getFeatureById = function(id) { var feature = this.idIndex_[id.toString()]; - return goog.isDef(feature) ? feature : null; + return feature !== undefined ? feature : null; }; diff --git a/src/ol/source/wmtssource.js b/src/ol/source/wmtssource.js index 698a003576..05d646d527 100644 --- a/src/ol/source/wmtssource.js +++ b/src/ol/source/wmtssource.js @@ -410,7 +410,7 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) { } else { value = elt['values'][0]; } - goog.asserts.assert(goog.isDef(value), 'value could be found'); + goog.asserts.assert(value !== undefined, 'value could be found'); dimensions[key] = value; }); } @@ -454,7 +454,7 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) { /** @type {!Array.} */ var urls = []; var requestEncoding = config['requestEncoding']; - requestEncoding = goog.isDef(requestEncoding) ? requestEncoding : ''; + requestEncoding = requestEncoding !== undefined ? requestEncoding : ''; goog.asserts.assert( goog.array.contains(['REST', 'RESTful', 'KVP', ''], requestEncoding), diff --git a/src/ol/source/zoomifysource.js b/src/ol/source/zoomifysource.js index bad8153fbc..235b69fccb 100644 --- a/src/ol/source/zoomifysource.js +++ b/src/ol/source/zoomifysource.js @@ -165,7 +165,8 @@ goog.inherits(ol.source.ZoomifyTile_, ol.ImageTile); */ ol.source.ZoomifyTile_.prototype.getImage = function(opt_context) { var tileSize = ol.DEFAULT_TILE_SIZE; - var key = goog.isDef(opt_context) ? goog.getUid(opt_context).toString() : ''; + var key = opt_context !== undefined ? + goog.getUid(opt_context).toString() : ''; if (key in this.zoomifyImageByContext_) { return this.zoomifyImageByContext_[key]; } else { diff --git a/src/ol/structs/lrucache.js b/src/ol/structs/lrucache.js index 8aac72c41d..656524ad04 100644 --- a/src/ol/structs/lrucache.js +++ b/src/ol/structs/lrucache.js @@ -130,7 +130,7 @@ ol.structs.LRUCache.prototype.forEach = function(f, opt_this) { */ ol.structs.LRUCache.prototype.get = function(key) { var entry = this.entries_[key]; - goog.asserts.assert(goog.isDef(entry), 'an entry exists for key %s', key); + goog.asserts.assert(entry !== undefined, 'an entry exists for key %s', key); if (entry === this.newest_) { return entry.value_; } else if (entry === this.oldest_) { diff --git a/src/ol/style/atlasmanager.js b/src/ol/style/atlasmanager.js index 2c64a703f4..33cc672112 100644 --- a/src/ol/style/atlasmanager.js +++ b/src/ol/style/atlasmanager.js @@ -191,7 +191,7 @@ ol.style.AtlasManager.prototype.add = // even if no hit-detection entry is requested, we insert a fake entry into // the hit-detection atlas, to make sure that the offset is the same for // the original image and the hit-detection image. - var renderHitCallback = goog.isDef(opt_renderHitCallback) ? + var renderHitCallback = opt_renderHitCallback !== undefined ? opt_renderHitCallback : goog.functions.NULL; /** @type {?ol.style.AtlasInfo} */ diff --git a/src/ol/style/iconstyle.js b/src/ol/style/iconstyle.js index edbb76b90c..df3d85452b 100644 --- a/src/ol/style/iconstyle.js +++ b/src/ol/style/iconstyle.js @@ -105,10 +105,10 @@ ol.style.Icon = function(opt_options) { */ var src = options.src; - goog.asserts.assert(!(goog.isDef(src) && !goog.isNull(image)), + goog.asserts.assert(!(src !== undefined && !goog.isNull(image)), 'image and src can not provided at the same time'); goog.asserts.assert( - src === undefined || (goog.isDef(src) && goog.isNull(imgSize)), + src === undefined || (src !== undefined && goog.isNull(imgSize)), 'imgSize should not be set when src is provided'); goog.asserts.assert( goog.isNull(image) || (!goog.isNull(image) && !goog.isNull(imgSize)), @@ -117,7 +117,7 @@ ol.style.Icon = function(opt_options) { if ((src === undefined || src.length === 0) && !goog.isNull(image)) { src = image.src; } - goog.asserts.assert(goog.isDef(src) && src.length > 0, + goog.asserts.assert(src !== undefined && src.length > 0, 'must provide a defined and non-empty src or image'); /** @@ -620,7 +620,7 @@ goog.addSingletonGetter(ol.style.IconImageCache); * @return {string} Cache key. */ ol.style.IconImageCache.getKey = function(src, crossOrigin) { - goog.asserts.assert(goog.isDef(crossOrigin), + goog.asserts.assert(crossOrigin !== undefined, 'argument crossOrigin must be defined'); return crossOrigin + ':' + src; }; diff --git a/src/ol/tilecache.js b/src/ol/tilecache.js index 2ced7117eb..a06962f998 100644 --- a/src/ol/tilecache.js +++ b/src/ol/tilecache.js @@ -21,7 +21,7 @@ ol.TileCache = function(opt_highWaterMark) { * @private * @type {number} */ - this.highWaterMark_ = goog.isDef(opt_highWaterMark) ? + this.highWaterMark_ = opt_highWaterMark !== undefined ? opt_highWaterMark : ol.DEFAULT_TILE_CACHE_HIGH_WATER_MARK; }; diff --git a/src/ol/tilegrid/tilegrid.js b/src/ol/tilegrid/tilegrid.js index 7efb55ea90..8eb794267b 100644 --- a/src/ol/tilegrid/tilegrid.js +++ b/src/ol/tilegrid/tilegrid.js @@ -72,7 +72,7 @@ ol.tilegrid.TileGrid = function(options) { var extent = options.extent; - if (goog.isDef(extent) && + if (extent !== undefined && goog.isNull(this.origin_) && goog.isNull(this.origins_)) { this.origin_ = ol.extent.getTopLeft(extent); } @@ -109,7 +109,7 @@ ol.tilegrid.TileGrid = function(options) { * @private * @type {ol.Extent} */ - this.extent_ = goog.isDef(extent) ? extent : null; + this.extent_ = extent !== undefined ? extent : null; /** @@ -127,7 +127,7 @@ ol.tilegrid.TileGrid = function(options) { var tileRange = new ol.TileRange( Math.min(0, size[0]), Math.max(size[0] - 1, -1), Math.min(0, size[1]), Math.max(size[1] - 1, -1)); - if (this.minZoom <= z && z <= this.maxZoom && goog.isDef(extent)) { + if (this.minZoom <= z && z <= this.maxZoom && extent !== undefined) { goog.asserts.assert(tileRange.containsTileRange( this.getTileRangeForExtentAndZ(extent, z)), 'extent tile range must not exceed tilegrid width and height'); @@ -527,7 +527,7 @@ ol.tilegrid.getForProjection = function(projection) { */ ol.tilegrid.createForExtent = function(extent, opt_maxZoom, opt_tileSize, opt_corner) { - var corner = goog.isDef(opt_corner) ? + var corner = opt_corner !== undefined ? opt_corner : ol.extent.Corner.TOP_LEFT; var resolutions = ol.tilegrid.resolutionsFromExtent( @@ -550,7 +550,7 @@ ol.tilegrid.createForExtent = */ ol.tilegrid.createXYZ = function(opt_options) { var options = /** @type {olx.tilegrid.TileGridOptions} */ ({}); - goog.object.extend(options, goog.isDef(opt_options) ? + goog.object.extend(options, opt_options !== undefined ? opt_options : /** @type {olx.tilegrid.XYZOptions} */ ({})); if (options.extent === undefined) { options.extent = ol.proj.get('EPSG:3857').getExtent(); @@ -574,13 +574,13 @@ ol.tilegrid.createXYZ = function(opt_options) { */ ol.tilegrid.resolutionsFromExtent = function(extent, opt_maxZoom, opt_tileSize) { - var maxZoom = goog.isDef(opt_maxZoom) ? + var maxZoom = opt_maxZoom !== undefined ? opt_maxZoom : ol.DEFAULT_MAX_ZOOM; var height = ol.extent.getHeight(extent); var width = ol.extent.getWidth(extent); - var tileSize = ol.size.toSize(goog.isDef(opt_tileSize) ? + var tileSize = ol.size.toSize(opt_tileSize !== undefined ? opt_tileSize : ol.DEFAULT_TILE_SIZE); var maxResolution = Math.max( width / tileSize[0], height / tileSize[1]); diff --git a/src/ol/view.js b/src/ol/view.js index 059d0da86a..b787868f9e 100644 --- a/src/ol/view.js +++ b/src/ol/view.js @@ -193,7 +193,7 @@ ol.View.prototype.calculateCenterZoom = function(resolution, anchor) { var center; var currentCenter = this.getCenter(); var currentResolution = this.getResolution(); - if (goog.isDef(currentCenter) && goog.isDef(currentResolution)) { + if (currentCenter !== undefined && currentResolution !== undefined) { var x = anchor[0] - resolution * (anchor[0] - currentCenter[0]) / currentResolution; var y = anchor[1] - @@ -278,10 +278,10 @@ ol.View.prototype.calculateExtent = function(size) { goog.asserts.assert(goog.isDefAndNotNull(center), 'The view center is not defined'); var resolution = this.getResolution(); - goog.asserts.assert(goog.isDef(resolution), + goog.asserts.assert(resolution !== undefined, 'The view resolution is not defined'); var rotation = this.getRotation(); - goog.asserts.assert(goog.isDef(rotation), + goog.asserts.assert(rotation !== undefined, 'The view rotation is not defined'); return ol.extent.getForViewAndSize(center, resolution, rotation, size); @@ -404,7 +404,7 @@ ol.View.prototype.getState = function() { Math.round(center[0] / resolution) * resolution, Math.round(center[1] / resolution) * resolution ], - projection: goog.isDef(projection) ? projection : null, + projection: projection !== undefined ? projection : null, resolution: resolution, rotation: rotation }); @@ -433,7 +433,7 @@ ol.View.prototype.getZoom = function() { } while (res > this.minResolution_); } - return goog.isDef(offset) ? this.minZoom_ + offset : offset; + return offset !== undefined ? this.minZoom_ + offset : offset; }; @@ -475,7 +475,7 @@ ol.View.prototype.fit = function(geometry, size, opt_options) { // calculate rotated extent var rotation = this.getRotation(); - goog.asserts.assert(goog.isDef(rotation), 'rotation was not defined'); + goog.asserts.assert(rotation !== undefined, 'rotation was not defined'); var cosAngle = Math.cos(-rotation); var sinAngle = Math.sin(-rotation); var minRotX = +Infinity; diff --git a/src/ol/webgl/buffer.js b/src/ol/webgl/buffer.js index 422ca62f6f..023847fc78 100644 --- a/src/ol/webgl/buffer.js +++ b/src/ol/webgl/buffer.js @@ -27,13 +27,13 @@ ol.webgl.Buffer = function(opt_arr, opt_usage) { * @private * @type {Array.} */ - this.arr_ = goog.isDef(opt_arr) ? opt_arr : []; + this.arr_ = opt_arr !== undefined ? opt_arr : []; /** * @private * @type {number} */ - this.usage_ = goog.isDef(opt_usage) ? + this.usage_ = opt_usage !== undefined ? opt_usage : ol.webgl.BufferUsage.STATIC_DRAW; }; diff --git a/src/ol/xml.js b/src/ol/xml.js index 207405c7aa..622b18569e 100644 --- a/src/ol/xml.js +++ b/src/ol/xml.js @@ -391,7 +391,7 @@ ol.xml.makeArrayPusher = function(valueReader, opt_this) { * @param {Array.<*>} objectStack Object stack. */ function(node, objectStack) { - var value = valueReader.call(goog.isDef(opt_this) ? opt_this : this, + var value = valueReader.call(opt_this !== undefined ? opt_this : this, node, objectStack); if (value !== undefined) { var array = objectStack[objectStack.length - 1]; @@ -418,7 +418,7 @@ ol.xml.makeReplacer = function(valueReader, opt_this) { * @param {Array.<*>} objectStack Object stack. */ function(node, objectStack) { - var value = valueReader.call(goog.isDef(opt_this) ? opt_this : this, + var value = valueReader.call(opt_this !== undefined ? opt_this : this, node, objectStack); if (value !== undefined) { objectStack[objectStack.length - 1] = value; @@ -438,7 +438,7 @@ ol.xml.makeReplacer = function(valueReader, opt_this) { */ ol.xml.makeObjectPropertyPusher = function(valueReader, opt_property, opt_this) { - goog.asserts.assert(goog.isDef(valueReader), + goog.asserts.assert(valueReader !== undefined, 'undefined valueReader, expected function(this: T, Node, Array.<*>)'); return ( /** @@ -446,12 +446,12 @@ ol.xml.makeObjectPropertyPusher = * @param {Array.<*>} objectStack Object stack. */ function(node, objectStack) { - var value = valueReader.call(goog.isDef(opt_this) ? opt_this : this, + var value = valueReader.call(opt_this !== undefined ? opt_this : this, node, objectStack); if (value !== undefined) { var object = /** @type {Object} */ (objectStack[objectStack.length - 1]); - var property = goog.isDef(opt_property) ? + var property = opt_property !== undefined ? opt_property : node.localName; goog.asserts.assert(goog.isObject(object), 'entity from stack was not an object'); @@ -472,7 +472,7 @@ ol.xml.makeObjectPropertyPusher = */ ol.xml.makeObjectPropertySetter = function(valueReader, opt_property, opt_this) { - goog.asserts.assert(goog.isDef(valueReader), + goog.asserts.assert(valueReader !== undefined, 'undefined valueReader, expected function(this: T, Node, Array.<*>)'); return ( /** @@ -480,12 +480,12 @@ ol.xml.makeObjectPropertySetter = * @param {Array.<*>} objectStack Object stack. */ function(node, objectStack) { - var value = valueReader.call(goog.isDef(opt_this) ? opt_this : this, + var value = valueReader.call(opt_this !== undefined ? opt_this : this, node, objectStack); if (value !== undefined) { var object = /** @type {Object} */ (objectStack[objectStack.length - 1]); - var property = goog.isDef(opt_property) ? + var property = opt_property !== undefined ? opt_property : node.localName; goog.asserts.assert(goog.isObject(object), 'entity from stack was not an object'); @@ -507,7 +507,7 @@ ol.xml.makeObjectPropertySetter = */ ol.xml.makeChildAppender = function(nodeWriter, opt_this) { return function(node, value, objectStack) { - nodeWriter.call(goog.isDef(opt_this) ? opt_this : this, + nodeWriter.call(opt_this !== undefined ? opt_this : this, node, value, objectStack); var parent = objectStack[objectStack.length - 1]; goog.asserts.assert(goog.isObject(parent), @@ -584,7 +584,7 @@ ol.xml.makeSimpleNodeFactory = function(opt_nodeName, opt_namespaceURI) { if (opt_namespaceURI === undefined) { namespaceURI = node.namespaceURI; } - goog.asserts.assert(goog.isDef(nodeName), 'nodeName was undefined'); + goog.asserts.assert(nodeName !== undefined, 'nodeName was undefined'); return ol.xml.createElementNS(namespaceURI, nodeName); } ); @@ -637,7 +637,7 @@ ol.xml.makeStructureNS = function(namespaceURIs, structure, opt_structureNS) { /** * @type {Object.} */ - var structureNS = goog.isDef(opt_structureNS) ? opt_structureNS : {}; + var structureNS = opt_structureNS !== undefined ? opt_structureNS : {}; var i, ii; for (i = 0, ii = namespaceURIs.length; i < ii; ++i) { structureNS[namespaceURIs[i]] = structure; @@ -711,13 +711,13 @@ ol.xml.pushParseAndPop = function( */ ol.xml.serialize = function( serializersNS, nodeFactory, values, objectStack, opt_keys, opt_this) { - var length = (goog.isDef(opt_keys) ? opt_keys : values).length; + var length = (opt_keys !== undefined ? opt_keys : values).length; var value, node; for (var i = 0; i < length; ++i) { value = values[i]; if (value !== undefined) { node = nodeFactory.call(opt_this, value, objectStack, - goog.isDef(opt_keys) ? opt_keys[i] : undefined); + opt_keys !== undefined ? opt_keys[i] : undefined); if (node !== undefined) { serializersNS[node.namespaceURI][node.localName] .call(opt_this, node, value, objectStack); diff --git a/test/spec/ol/extent.test.js b/test/spec/ol/extent.test.js index 1c0235a69c..de372d3f67 100644 --- a/test/spec/ol/extent.test.js +++ b/test/spec/ol/extent.test.js @@ -836,7 +836,7 @@ describe('ol.extent', function() { it('takes arbitrary function', function() { var transformFn = function(input, output, opt_dimension) { - var dimension = goog.isDef(opt_dimension) ? opt_dimension : 2; + var dimension = opt_dimension !== undefined ? opt_dimension : 2; if (output === undefined) { output = new Array(input.length); } diff --git a/test/spec/ol/interaction/drawinteraction.test.js b/test/spec/ol/interaction/drawinteraction.test.js index e46d26287d..5deaaf3502 100644 --- a/test/spec/ol/interaction/drawinteraction.test.js +++ b/test/spec/ol/interaction/drawinteraction.test.js @@ -48,7 +48,7 @@ describe('ol.interaction.Draw', function() { var viewport = map.getViewport(); // calculated in case body has top < 0 (test runner with small window) var position = goog.style.getClientPosition(viewport); - var shiftKey = goog.isDef(opt_shiftKey) ? opt_shiftKey : false; + var shiftKey = opt_shiftKey !== undefined ? opt_shiftKey : false; var event = new ol.MapBrowserPointerEvent(type, map, new ol.pointer.PointerEvent(type, new goog.events.BrowserEvent({ diff --git a/test/spec/ol/interaction/modifyinteraction.test.js b/test/spec/ol/interaction/modifyinteraction.test.js index 7fff57b64f..52f5fd1627 100644 --- a/test/spec/ol/interaction/modifyinteraction.test.js +++ b/test/spec/ol/interaction/modifyinteraction.test.js @@ -64,7 +64,7 @@ describe('ol.interaction.Modify', function() { var viewport = map.getViewport(); // calculated in case body has top < 0 (test runner with small window) var position = goog.style.getClientPosition(viewport); - var shiftKey = goog.isDef(opt_shiftKey) ? opt_shiftKey : false; + var shiftKey = opt_shiftKey !== undefined ? opt_shiftKey : false; var event = new ol.MapBrowserPointerEvent(type, map, new ol.pointer.PointerEvent(type, new goog.events.BrowserEvent({ diff --git a/test/spec/ol/interaction/selectinteraction.test.js b/test/spec/ol/interaction/selectinteraction.test.js index af3b98a8da..6e8e331e16 100644 --- a/test/spec/ol/interaction/selectinteraction.test.js +++ b/test/spec/ol/interaction/selectinteraction.test.js @@ -79,7 +79,7 @@ describe('ol.interaction.Select', function() { var viewport = map.getViewport(); // calculated in case body has top < 0 (test runner with small window) var position = goog.style.getClientPosition(viewport); - var shiftKey = goog.isDef(opt_shiftKey) ? opt_shiftKey : false; + var shiftKey = opt_shiftKey !== undefined ? opt_shiftKey : false; var event = new ol.MapBrowserPointerEvent(type, map, new ol.pointer.PointerEvent(type, new goog.events.BrowserEvent({ diff --git a/test/spec/ol/interaction/translateinteraction.test.js b/test/spec/ol/interaction/translateinteraction.test.js index 8526796ae4..fb71855f53 100644 --- a/test/spec/ol/interaction/translateinteraction.test.js +++ b/test/spec/ol/interaction/translateinteraction.test.js @@ -54,7 +54,7 @@ describe('ol.interaction.Translate', function() { var viewport = map.getViewport(); // calculated in case body has top < 0 (test runner with small window) var position = goog.style.getClientPosition(viewport); - var shiftKey = goog.isDef(opt_shiftKey) ? opt_shiftKey : false; + var shiftKey = opt_shiftKey !== undefined ? opt_shiftKey : false; var event = new ol.MapBrowserPointerEvent(type, map, new ol.pointer.PointerEvent(type, new goog.events.BrowserEvent({ diff --git a/test/spec/ol/pointer/touchsource.test.js b/test/spec/ol/pointer/touchsource.test.js index c5d6be0b92..3d4f16adcb 100644 --- a/test/spec/ol/pointer/touchsource.test.js +++ b/test/spec/ol/pointer/touchsource.test.js @@ -118,7 +118,7 @@ describe('ol.pointer.TouchSource', function() { }); function simulateTouchEvent(type, changedTouches, touches) { - touches = goog.isDef(touches) ? touches : changedTouches; + touches = touches !== undefined ? touches : changedTouches; var event = new goog.events.BrowserEvent({ type: type, diff --git a/test_rendering/spec/ol/layer/tile.test.js b/test_rendering/spec/ol/layer/tile.test.js index 0a2bd57d25..c83c974736 100644 --- a/test_rendering/spec/ol/layer/tile.test.js +++ b/test_rendering/spec/ol/layer/tile.test.js @@ -11,7 +11,7 @@ describe('ol.rendering.layer.Tile', function() { target: target, renderer: renderer, view: new ol.View({ - center: goog.isDef(opt_center) ? opt_center : ol.proj.transform( + center: opt_center !== undefined ? opt_center : ol.proj.transform( [-122.416667, 37.783333], 'EPSG:4326', 'EPSG:3857'), zoom: 5 }) From 36e336f406beb177e38bf29f5e801b692a6726e1 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Sun, 27 Sep 2015 10:37:20 -0600 Subject: [PATCH 79/93] Inline !goog.isDef() calls for properties --- src/ol/geolocation.js | 2 +- src/ol/map.js | 2 +- src/ol/proj/proj.js | 2 +- src/ol/renderer/webgl/webgllayerrenderer.js | 2 +- src/ol/source/imagewmssource.js | 2 +- src/ol/source/tilewmssource.js | 4 ++-- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/ol/geolocation.js b/src/ol/geolocation.js index c218792596..c6d35470d8 100644 --- a/src/ol/geolocation.js +++ b/src/ol/geolocation.js @@ -134,7 +134,7 @@ ol.Geolocation.prototype.handleProjectionChanged_ = function() { ol.Geolocation.prototype.handleTrackingChanged_ = function() { if (ol.has.GEOLOCATION) { var tracking = this.getTracking(); - if (tracking && !goog.isDef(this.watchId_)) { + if (tracking && this.watchId_ === undefined) { this.watchId_ = goog.global.navigator.geolocation.watchPosition( goog.bind(this.positionChange_, this), goog.bind(this.positionError_, this), diff --git a/src/ol/map.js b/src/ol/map.js index acb08063c9..cf7e509e68 100644 --- a/src/ol/map.js +++ b/src/ol/map.js @@ -1466,7 +1466,7 @@ ol.Map.createOptionsInternal = function(options) { var values = {}; var logos = {}; - if (!goog.isDef(options.logo) || + if (options.logo === undefined || (goog.isBoolean(options.logo) && options.logo)) { logos[ol.OL3_LOGO_URL] = ol.OL3_URL; } else { diff --git a/src/ol/proj/proj.js b/src/ol/proj/proj.js index a909eba5c0..dd14c7fded 100644 --- a/src/ol/proj/proj.js +++ b/src/ol/proj/proj.js @@ -149,7 +149,7 @@ ol.proj.Projection = function(options) { !goog.isDef(projections[code])) { var def = proj4.defs(code); if (def !== undefined) { - if (goog.isDef(def.axis) && !goog.isDef(options.axisOrientation)) { + if (goog.isDef(def.axis) && options.axisOrientation === undefined) { this.axisOrientation_ = def.axis; } if (options.units === undefined) { diff --git a/src/ol/renderer/webgl/webgllayerrenderer.js b/src/ol/renderer/webgl/webgllayerrenderer.js index 1a152affec..9363754aac 100644 --- a/src/ol/renderer/webgl/webgllayerrenderer.js +++ b/src/ol/renderer/webgl/webgllayerrenderer.js @@ -110,7 +110,7 @@ ol.renderer.webgl.Layer.prototype.bindFramebuffer = var gl = this.mapRenderer.getGL(); - if (!goog.isDef(this.framebufferDimension) || + if (this.framebufferDimension === undefined || this.framebufferDimension != framebufferDimension) { frameState.postRenderFunctions.push( diff --git a/src/ol/source/imagewmssource.js b/src/ol/source/imagewmssource.js index 06e36fcb85..4f99ac2a82 100644 --- a/src/ol/source/imagewmssource.js +++ b/src/ol/source/imagewmssource.js @@ -194,7 +194,7 @@ ol.source.ImageWMS.prototype.getImage = resolution = this.findNearestResolution(resolution); - if (pixelRatio != 1 && (!this.hidpi_ || !goog.isDef(this.serverType_))) { + if (pixelRatio != 1 && (!this.hidpi_ || this.serverType_ === undefined)) { pixelRatio = 1; } diff --git a/src/ol/source/tilewmssource.js b/src/ol/source/tilewmssource.js index 4d1ae44934..09c7f6e504 100644 --- a/src/ol/source/tilewmssource.js +++ b/src/ol/source/tilewmssource.js @@ -292,7 +292,7 @@ ol.source.TileWMS.prototype.getRequestUrl_ = ol.source.TileWMS.prototype.getTilePixelSize = function(z, pixelRatio, projection) { var tileSize = goog.base(this, 'getTilePixelSize', z, pixelRatio, projection); - if (pixelRatio == 1 || !this.hidpi_ || !goog.isDef(this.serverType_)) { + if (pixelRatio == 1 || !this.hidpi_ || this.serverType_ === undefined) { return tileSize; } else { return ol.size.scale(tileSize, pixelRatio, this.tmpSize); @@ -373,7 +373,7 @@ ol.source.TileWMS.prototype.tileUrlFunction_ = return undefined; } - if (pixelRatio != 1 && (!this.hidpi_ || !goog.isDef(this.serverType_))) { + if (pixelRatio != 1 && (!this.hidpi_ || this.serverType_ === undefined)) { pixelRatio = 1; } From 83c59ee255f60ba53433853b3c6ada5628a22672 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Sun, 27 Sep 2015 10:40:20 -0600 Subject: [PATCH 80/93] Inline goog.isDef() calls for properties --- src/ol/geolocation.js | 4 +- src/ol/graticule.js | 8 ++-- src/ol/imagebase.js | 2 +- src/ol/interaction/translateinteraction.js | 4 +- src/ol/map.js | 11 ++--- src/ol/overlay.js | 14 +++--- src/ol/proj/proj.js | 12 +++--- src/ol/render/canvas/canvasreplay.js | 50 +++++++++++----------- src/ol/render/webgl/webglreplay.js | 25 +++++------ src/ol/source/bingmapssource.js | 6 +-- src/ol/source/clustersource.js | 2 +- src/ol/source/imagecanvassource.js | 4 +- src/ol/source/imagemapguidesource.js | 16 +++---- src/ol/source/imagesource.js | 2 +- src/ol/source/imagestaticsource.js | 6 +-- src/ol/source/imagewmssource.js | 10 ++--- src/ol/source/mapquestsource.js | 2 +- src/ol/source/osmsource.js | 6 +-- src/ol/source/rastersource.js | 4 +- src/ol/source/source.js | 6 +-- src/ol/source/stamensource.js | 2 +- src/ol/source/tilearcgisrestsource.js | 6 +-- src/ol/source/tiledebugsource.js | 2 +- src/ol/source/tileimagesource.js | 10 ++--- src/ol/source/tilejsonsource.js | 4 +- src/ol/source/tilesource.js | 6 +-- src/ol/source/tileutfgridsource.js | 2 +- src/ol/source/tilevectorsource.js | 4 +- src/ol/source/tilewmssource.js | 10 ++--- src/ol/source/vectorsource.js | 8 ++-- src/ol/source/wmtssource.js | 12 +++--- src/ol/source/xyzsource.js | 6 +-- src/ol/source/zoomifysource.js | 2 +- src/ol/style/atlasmanager.js | 8 ++-- src/ol/style/circlestyle.js | 8 ++-- src/ol/style/fillstyle.js | 2 +- src/ol/style/iconstyle.js | 34 +++++++-------- src/ol/style/regularshapestyle.js | 24 +++++------ src/ol/style/strokestyle.js | 12 +++--- src/ol/style/style.js | 8 ++-- src/ol/style/textstyle.js | 8 ++-- src/ol/tilegrid/tilegrid.js | 6 +-- src/ol/view.js | 18 ++++---- src/ol/xml.js | 2 +- 44 files changed, 200 insertions(+), 198 deletions(-) diff --git a/src/ol/geolocation.js b/src/ol/geolocation.js index c6d35470d8..c6d14c2a51 100644 --- a/src/ol/geolocation.js +++ b/src/ol/geolocation.js @@ -97,7 +97,7 @@ ol.Geolocation = function(opt_options) { this.setTrackingOptions(options.trackingOptions); } - this.setTracking(goog.isDef(options.tracking) ? options.tracking : false); + this.setTracking(options.tracking !== undefined ? options.tracking : false); }; goog.inherits(ol.Geolocation, ol.Object); @@ -139,7 +139,7 @@ ol.Geolocation.prototype.handleTrackingChanged_ = function() { goog.bind(this.positionChange_, this), goog.bind(this.positionError_, this), this.getTrackingOptions()); - } else if (!tracking && goog.isDef(this.watchId_)) { + } else if (!tracking && this.watchId_ !== undefined) { goog.global.navigator.geolocation.clearWatch(this.watchId_); this.watchId_ = undefined; } diff --git a/src/ol/graticule.js b/src/ol/graticule.js index 3a3ca588b7..4d5b012042 100644 --- a/src/ol/graticule.js +++ b/src/ol/graticule.js @@ -86,14 +86,14 @@ ol.Graticule = function(opt_options) { * @type {number} * @private */ - this.targetSize_ = goog.isDef(options.targetSize) ? + this.targetSize_ = options.targetSize !== undefined ? options.targetSize : 100; /** * @type {number} * @private */ - this.maxLines_ = goog.isDef(options.maxLines) ? options.maxLines : 100; + this.maxLines_ = options.maxLines !== undefined ? options.maxLines : 100; goog.asserts.assert(this.maxLines_ > 0, 'this.maxLines_ should be more than 0'); @@ -113,7 +113,7 @@ ol.Graticule = function(opt_options) { * @type {ol.style.Stroke} * @private */ - this.strokeStyle_ = goog.isDef(options.strokeStyle) ? + this.strokeStyle_ = options.strokeStyle !== undefined ? options.strokeStyle : ol.Graticule.DEFAULT_STROKE_STYLE_; /** @@ -134,7 +134,7 @@ ol.Graticule = function(opt_options) { */ this.projectionCenterLonLat_ = null; - this.setMap(goog.isDef(options.map) ? options.map : null); + this.setMap(options.map !== undefined ? options.map : null); }; diff --git a/src/ol/imagebase.js b/src/ol/imagebase.js index 5e0a464fbb..e188221977 100644 --- a/src/ol/imagebase.js +++ b/src/ol/imagebase.js @@ -110,7 +110,7 @@ ol.ImageBase.prototype.getPixelRatio = function() { * @return {number} Resolution. */ ol.ImageBase.prototype.getResolution = function() { - goog.asserts.assert(goog.isDef(this.resolution), 'resolution not yet set'); + goog.asserts.assert(this.resolution !== undefined, 'resolution not yet set'); return this.resolution; }; diff --git a/src/ol/interaction/translateinteraction.js b/src/ol/interaction/translateinteraction.js index 09fbe8c349..1f2ec0bd1e 100644 --- a/src/ol/interaction/translateinteraction.js +++ b/src/ol/interaction/translateinteraction.js @@ -42,7 +42,7 @@ ol.interaction.Translate = function(options) { * @type {ol.Collection.} * @private */ - this.features_ = goog.isDef(options.features) ? options.features : null; + this.features_ = options.features !== undefined ? options.features : null; /** * @type {ol.Feature} @@ -147,7 +147,7 @@ ol.interaction.Translate.handleMoveEvent_ = function(event) 'grabbing' : (isSelected ? 'grab' : 'pointer'); } else { - elem.style.cursor = goog.isDef(this.previousCursor_) ? + elem.style.cursor = this.previousCursor_ !== undefined ? this.previousCursor_ : ''; this.previousCursor_ = undefined; } diff --git a/src/ol/map.js b/src/ol/map.js index cf7e509e68..dfb9618635 100644 --- a/src/ol/map.js +++ b/src/ol/map.js @@ -181,22 +181,23 @@ ol.Map = function(options) { * @type {boolean} * @private */ - this.loadTilesWhileAnimating_ = goog.isDef(options.loadTilesWhileAnimating) ? - options.loadTilesWhileAnimating : false; + this.loadTilesWhileAnimating_ = + options.loadTilesWhileAnimating !== undefined ? + options.loadTilesWhileAnimating : false; /** * @type {boolean} * @private */ this.loadTilesWhileInteracting_ = - goog.isDef(options.loadTilesWhileInteracting) ? + options.loadTilesWhileInteracting !== undefined ? options.loadTilesWhileInteracting : false; /** * @private * @type {number} */ - this.pixelRatio_ = goog.isDef(options.pixelRatio) ? + this.pixelRatio_ = options.pixelRatio !== undefined ? options.pixelRatio : ol.has.DEVICE_PIXEL_RATIO; /** @@ -1486,7 +1487,7 @@ ol.Map.createOptionsInternal = function(options) { values[ol.MapProperty.TARGET] = options.target; - values[ol.MapProperty.VIEW] = goog.isDef(options.view) ? + values[ol.MapProperty.VIEW] = options.view !== undefined ? options.view : new ol.View(); /** diff --git a/src/ol/overlay.js b/src/ol/overlay.js index 97950b21c3..33c12c7cf9 100644 --- a/src/ol/overlay.js +++ b/src/ol/overlay.js @@ -78,14 +78,14 @@ ol.Overlay = function(options) { * @private * @type {boolean} */ - this.insertFirst_ = goog.isDef(options.insertFirst) ? + this.insertFirst_ = options.insertFirst !== undefined ? options.insertFirst : true; /** * @private * @type {boolean} */ - this.stopEvent_ = goog.isDef(options.stopEvent) ? options.stopEvent : true; + this.stopEvent_ = options.stopEvent !== undefined ? options.stopEvent : true; /** * @private @@ -100,20 +100,20 @@ ol.Overlay = function(options) { * @protected * @type {boolean} */ - this.autoPan = goog.isDef(options.autoPan) ? options.autoPan : false; + this.autoPan = options.autoPan !== undefined ? options.autoPan : false; /** * @private * @type {olx.animation.PanOptions} */ - this.autoPanAnimation_ = goog.isDef(options.autoPanAnimation) ? + this.autoPanAnimation_ = options.autoPanAnimation !== undefined ? options.autoPanAnimation : /** @type {olx.animation.PanOptions} */ ({}); /** * @private * @type {number} */ - this.autoPanMargin_ = goog.isDef(options.autoPanMargin) ? + this.autoPanMargin_ = options.autoPanMargin !== undefined ? options.autoPanMargin : 20; /** @@ -162,9 +162,9 @@ ol.Overlay = function(options) { this.setElement(options.element); } - this.setOffset(goog.isDef(options.offset) ? options.offset : [0, 0]); + this.setOffset(options.offset !== undefined ? options.offset : [0, 0]); - this.setPositioning(goog.isDef(options.positioning) ? + this.setPositioning(options.positioning !== undefined ? /** @type {ol.OverlayPositioning} */ (options.positioning) : ol.OverlayPositioning.TOP_LEFT); diff --git a/src/ol/proj/proj.js b/src/ol/proj/proj.js index dd14c7fded..47b209dff2 100644 --- a/src/ol/proj/proj.js +++ b/src/ol/proj/proj.js @@ -99,27 +99,27 @@ ol.proj.Projection = function(options) { * @private * @type {ol.Extent} */ - this.extent_ = goog.isDef(options.extent) ? options.extent : null; + this.extent_ = options.extent !== undefined ? options.extent : null; /** * @private * @type {ol.Extent} */ - this.worldExtent_ = goog.isDef(options.worldExtent) ? + this.worldExtent_ = options.worldExtent !== undefined ? options.worldExtent : null; /** * @private * @type {string} */ - this.axisOrientation_ = goog.isDef(options.axisOrientation) ? + this.axisOrientation_ = options.axisOrientation !== undefined ? options.axisOrientation : 'enu'; /** * @private * @type {boolean} */ - this.global_ = goog.isDef(options.global) ? options.global : false; + this.global_ = options.global !== undefined ? options.global : false; /** @@ -132,7 +132,7 @@ ol.proj.Projection = function(options) { * @private * @type {function(number, ol.Coordinate):number} */ - this.getPointResolutionFunc_ = goog.isDef(options.getPointResolution) ? + this.getPointResolutionFunc_ = options.getPointResolution !== undefined ? options.getPointResolution : this.getPointResolution_; /** @@ -149,7 +149,7 @@ ol.proj.Projection = function(options) { !goog.isDef(projections[code])) { var def = proj4.defs(code); if (def !== undefined) { - if (goog.isDef(def.axis) && options.axisOrientation === undefined) { + if (def.axis !== undefined && options.axisOrientation === undefined) { this.axisOrientation_ = def.axis; } if (options.units === undefined) { diff --git a/src/ol/render/canvas/canvasreplay.js b/src/ol/render/canvas/canvasreplay.js index 8e33020d22..a3a44356d3 100644 --- a/src/ol/render/canvas/canvasreplay.js +++ b/src/ol/render/canvas/canvasreplay.js @@ -716,25 +716,25 @@ ol.render.canvas.ImageReplay.prototype.drawPointGeometry = if (goog.isNull(this.image_)) { return; } - goog.asserts.assert(goog.isDef(this.anchorX_), + goog.asserts.assert(this.anchorX_ !== undefined, 'this.anchorX_ should be defined'); - goog.asserts.assert(goog.isDef(this.anchorY_), + goog.asserts.assert(this.anchorY_ !== undefined, 'this.anchorY_ should be defined'); - goog.asserts.assert(goog.isDef(this.height_), + goog.asserts.assert(this.height_ !== undefined, 'this.height_ should be defined'); - goog.asserts.assert(goog.isDef(this.opacity_), + goog.asserts.assert(this.opacity_ !== undefined, 'this.opacity_ should be defined'); - goog.asserts.assert(goog.isDef(this.originX_), + goog.asserts.assert(this.originX_ !== undefined, 'this.originX_ should be defined'); - goog.asserts.assert(goog.isDef(this.originY_), + goog.asserts.assert(this.originY_ !== undefined, 'this.originY_ should be defined'); - goog.asserts.assert(goog.isDef(this.rotateWithView_), + goog.asserts.assert(this.rotateWithView_ !== undefined, 'this.rotateWithView_ should be defined'); - goog.asserts.assert(goog.isDef(this.rotation_), + goog.asserts.assert(this.rotation_ !== undefined, 'this.rotation_ should be defined'); - goog.asserts.assert(goog.isDef(this.scale_), + goog.asserts.assert(this.scale_ !== undefined, 'this.scale_ should be defined'); - goog.asserts.assert(goog.isDef(this.width_), + goog.asserts.assert(this.width_ !== undefined, 'this.width_ should be defined'); this.beginGeometry(pointGeometry, feature); var flatCoordinates = pointGeometry.getFlatCoordinates(); @@ -769,25 +769,25 @@ ol.render.canvas.ImageReplay.prototype.drawMultiPointGeometry = if (goog.isNull(this.image_)) { return; } - goog.asserts.assert(goog.isDef(this.anchorX_), + goog.asserts.assert(this.anchorX_ !== undefined, 'this.anchorX_ should be defined'); - goog.asserts.assert(goog.isDef(this.anchorY_), + goog.asserts.assert(this.anchorY_ !== undefined, 'this.anchorY_ should be defined'); - goog.asserts.assert(goog.isDef(this.height_), + goog.asserts.assert(this.height_ !== undefined, 'this.height_ should be defined'); - goog.asserts.assert(goog.isDef(this.opacity_), + goog.asserts.assert(this.opacity_ !== undefined, 'this.opacity_ should be defined'); - goog.asserts.assert(goog.isDef(this.originX_), + goog.asserts.assert(this.originX_ !== undefined, 'this.originX_ should be defined'); - goog.asserts.assert(goog.isDef(this.originY_), + goog.asserts.assert(this.originY_ !== undefined, 'this.originY_ should be defined'); - goog.asserts.assert(goog.isDef(this.rotateWithView_), + goog.asserts.assert(this.rotateWithView_ !== undefined, 'this.rotateWithView_ should be defined'); - goog.asserts.assert(goog.isDef(this.rotation_), + goog.asserts.assert(this.rotation_ !== undefined, 'this.rotation_ should be defined'); - goog.asserts.assert(goog.isDef(this.scale_), + goog.asserts.assert(this.scale_ !== undefined, 'this.scale_ should be defined'); - goog.asserts.assert(goog.isDef(this.width_), + goog.asserts.assert(this.width_ !== undefined, 'this.width_ should be defined'); this.beginGeometry(multiPointGeometry, feature); var flatCoordinates = multiPointGeometry.getFlatCoordinates(); @@ -1198,7 +1198,7 @@ ol.render.canvas.PolygonReplay.prototype.drawFlatCoordinatess_ = this.instructions.push(fillInstruction); } if (state.strokeStyle !== undefined) { - goog.asserts.assert(goog.isDef(state.lineWidth), + goog.asserts.assert(state.lineWidth !== undefined, 'state.lineWidth should be defined'); var strokeInstruction = [ol.render.canvas.Instruction.STROKE]; this.instructions.push(strokeInstruction); @@ -1221,7 +1221,7 @@ ol.render.canvas.PolygonReplay.prototype.drawCircleGeometry = return; } if (strokeStyle !== undefined) { - goog.asserts.assert(goog.isDef(state.lineWidth), + goog.asserts.assert(state.lineWidth !== undefined, 'state.lineWidth should be defined'); } this.setFillStrokeStyles_(); @@ -1251,7 +1251,7 @@ ol.render.canvas.PolygonReplay.prototype.drawCircleGeometry = this.instructions.push(fillInstruction); } if (state.strokeStyle !== undefined) { - goog.asserts.assert(goog.isDef(state.lineWidth), + goog.asserts.assert(state.lineWidth !== undefined, 'state.lineWidth should be defined'); var strokeInstruction = [ol.render.canvas.Instruction.STROKE]; this.instructions.push(strokeInstruction); @@ -1274,7 +1274,7 @@ ol.render.canvas.PolygonReplay.prototype.drawPolygonGeometry = return; } if (strokeStyle !== undefined) { - goog.asserts.assert(goog.isDef(state.lineWidth), + goog.asserts.assert(state.lineWidth !== undefined, 'state.lineWidth should be defined'); } this.setFillStrokeStyles_(); @@ -1310,7 +1310,7 @@ ol.render.canvas.PolygonReplay.prototype.drawMultiPolygonGeometry = return; } if (strokeStyle !== undefined) { - goog.asserts.assert(goog.isDef(state.lineWidth), + goog.asserts.assert(state.lineWidth !== undefined, 'state.lineWidth should be defined'); } this.setFillStrokeStyles_(); diff --git a/src/ol/render/webgl/webglreplay.js b/src/ol/render/webgl/webglreplay.js index bb9e91f52b..b450e650db 100644 --- a/src/ol/render/webgl/webglreplay.js +++ b/src/ol/render/webgl/webglreplay.js @@ -280,19 +280,20 @@ ol.render.webgl.ImageReplay.prototype.drawAsync = goog.abstractMethod; */ ol.render.webgl.ImageReplay.prototype.drawCoordinates_ = function(flatCoordinates, offset, end, stride) { - goog.asserts.assert(goog.isDef(this.anchorX_), 'anchorX is defined'); - goog.asserts.assert(goog.isDef(this.anchorY_), 'anchorY is defined'); - goog.asserts.assert(goog.isDef(this.height_), 'height is defined'); - goog.asserts.assert(goog.isDef(this.imageHeight_), 'imageHeight is defined'); - goog.asserts.assert(goog.isDef(this.imageWidth_), 'imageWidth is defined'); - goog.asserts.assert(goog.isDef(this.opacity_), 'opacity is defined'); - goog.asserts.assert(goog.isDef(this.originX_), 'originX is defined'); - goog.asserts.assert(goog.isDef(this.originY_), 'originY is defined'); - goog.asserts.assert(goog.isDef(this.rotateWithView_), + goog.asserts.assert(this.anchorX_ !== undefined, 'anchorX is defined'); + goog.asserts.assert(this.anchorY_ !== undefined, 'anchorY is defined'); + goog.asserts.assert(this.height_ !== undefined, 'height is defined'); + goog.asserts.assert(this.imageHeight_ !== undefined, + 'imageHeight is defined'); + goog.asserts.assert(this.imageWidth_ !== undefined, 'imageWidth is defined'); + goog.asserts.assert(this.opacity_ !== undefined, 'opacity is defined'); + goog.asserts.assert(this.originX_ !== undefined, 'originX is defined'); + goog.asserts.assert(this.originY_ !== undefined, 'originY is defined'); + goog.asserts.assert(this.rotateWithView_ !== undefined, 'rotateWithView is defined'); - goog.asserts.assert(goog.isDef(this.rotation_), 'rotation is defined'); - goog.asserts.assert(goog.isDef(this.scale_), 'scale is defined'); - goog.asserts.assert(goog.isDef(this.width_), 'width is defined'); + goog.asserts.assert(this.rotation_ !== undefined, 'rotation is defined'); + goog.asserts.assert(this.scale_ !== undefined, 'scale is defined'); + goog.asserts.assert(this.width_ !== undefined, 'width is defined'); var anchorX = this.anchorX_; var anchorY = this.anchorY_; var height = this.height_; diff --git a/src/ol/source/bingmapssource.js b/src/ol/source/bingmapssource.js index 4e2da51682..490bd7e2a2 100644 --- a/src/ol/source/bingmapssource.js +++ b/src/ol/source/bingmapssource.js @@ -32,20 +32,20 @@ ol.source.BingMaps = function(options) { projection: ol.proj.get('EPSG:3857'), state: ol.source.State.LOADING, tileLoadFunction: options.tileLoadFunction, - wrapX: goog.isDef(options.wrapX) ? options.wrapX : true + wrapX: options.wrapX !== undefined ? options.wrapX : true }); /** * @private * @type {string} */ - this.culture_ = goog.isDef(options.culture) ? options.culture : 'en-us'; + this.culture_ = options.culture !== undefined ? options.culture : 'en-us'; /** * @private * @type {number} */ - this.maxZoom_ = goog.isDef(options.maxZoom) ? options.maxZoom : -1; + this.maxZoom_ = options.maxZoom !== undefined ? options.maxZoom : -1; var uri = new goog.Uri( 'https://dev.virtualearth.net/REST/v1/Imagery/Metadata/' + diff --git a/src/ol/source/clustersource.js b/src/ol/source/clustersource.js index d1e15c01c3..c2ba38a1d0 100644 --- a/src/ol/source/clustersource.js +++ b/src/ol/source/clustersource.js @@ -42,7 +42,7 @@ ol.source.Cluster = function(options) { * @type {number} * @private */ - this.distance_ = goog.isDef(options.distance) ? options.distance : 20; + this.distance_ = options.distance !== undefined ? options.distance : 20; /** * @type {Array.} diff --git a/src/ol/source/imagecanvassource.js b/src/ol/source/imagecanvassource.js index 16e390ea17..ba8e8a15f4 100644 --- a/src/ol/source/imagecanvassource.js +++ b/src/ol/source/imagecanvassource.js @@ -23,7 +23,7 @@ ol.source.ImageCanvas = function(options) { logo: options.logo, projection: options.projection, resolutions: options.resolutions, - state: goog.isDef(options.state) ? + state: options.state !== undefined ? /** @type {ol.source.State} */ (options.state) : undefined }); @@ -49,7 +49,7 @@ ol.source.ImageCanvas = function(options) { * @private * @type {number} */ - this.ratio_ = goog.isDef(options.ratio) ? + this.ratio_ = options.ratio !== undefined ? options.ratio : 1.5; }; diff --git a/src/ol/source/imagemapguidesource.js b/src/ol/source/imagemapguidesource.js index e3bad37c7e..899d8663d0 100644 --- a/src/ol/source/imagemapguidesource.js +++ b/src/ol/source/imagemapguidesource.js @@ -34,20 +34,20 @@ ol.source.ImageMapGuide = function(options) { * @type {?string} */ this.crossOrigin_ = - goog.isDef(options.crossOrigin) ? options.crossOrigin : null; + options.crossOrigin !== undefined ? options.crossOrigin : null; /** * @private * @type {number} */ - this.displayDpi_ = goog.isDef(options.displayDpi) ? + this.displayDpi_ = options.displayDpi !== undefined ? options.displayDpi : 96; /** * @private * @type {Object} */ - this.params_ = goog.isDef(options.params) ? options.params : {}; + this.params_ = options.params !== undefined ? options.params : {}; var imageUrlFunction; if (options.url !== undefined) { @@ -67,33 +67,33 @@ ol.source.ImageMapGuide = function(options) { * @private * @type {ol.ImageLoadFunctionType} */ - this.imageLoadFunction_ = goog.isDef(options.imageLoadFunction) ? + this.imageLoadFunction_ = options.imageLoadFunction !== undefined ? options.imageLoadFunction : ol.source.Image.defaultImageLoadFunction; /** * @private * @type {boolean} */ - this.hidpi_ = goog.isDef(options.hidpi) ? options.hidpi : true; + this.hidpi_ = options.hidpi !== undefined ? options.hidpi : true; /** * @private * @type {number} */ - this.metersPerUnit_ = goog.isDef(options.metersPerUnit) ? + this.metersPerUnit_ = options.metersPerUnit !== undefined ? options.metersPerUnit : 1; /** * @private * @type {number} */ - this.ratio_ = goog.isDef(options.ratio) ? options.ratio : 1; + this.ratio_ = options.ratio !== undefined ? options.ratio : 1; /** * @private * @type {boolean} */ - this.useOverlay_ = goog.isDef(options.useOverlay) ? + this.useOverlay_ = options.useOverlay !== undefined ? options.useOverlay : false; /** diff --git a/src/ol/source/imagesource.js b/src/ol/source/imagesource.js index 38f726b0eb..2865fb6511 100644 --- a/src/ol/source/imagesource.js +++ b/src/ol/source/imagesource.js @@ -48,7 +48,7 @@ ol.source.Image = function(options) { * @private * @type {Array.} */ - this.resolutions_ = goog.isDef(options.resolutions) ? + this.resolutions_ = options.resolutions !== undefined ? options.resolutions : null; goog.asserts.assert(goog.isNull(this.resolutions_) || goog.array.isSorted(this.resolutions_, diff --git a/src/ol/source/imagestaticsource.js b/src/ol/source/imagestaticsource.js index fe7529c477..8bffee68fe 100644 --- a/src/ol/source/imagestaticsource.js +++ b/src/ol/source/imagestaticsource.js @@ -21,7 +21,7 @@ goog.require('ol.source.Image'); */ ol.source.ImageStatic = function(options) { - var attributions = goog.isDef(options.attributions) ? + var attributions = options.attributions !== undefined ? options.attributions : null; var imageExtent = options.imageExtent; @@ -32,11 +32,11 @@ ol.source.ImageStatic = function(options) { resolutions = [resolution]; } - var crossOrigin = goog.isDef(options.crossOrigin) ? + var crossOrigin = options.crossOrigin !== undefined ? options.crossOrigin : null; var /** @type {ol.ImageLoadFunctionType} */ imageLoadFunction = - goog.isDef(options.imageLoadFunction) ? + options.imageLoadFunction !== undefined ? options.imageLoadFunction : ol.source.Image.defaultImageLoadFunction; goog.base(this, { diff --git a/src/ol/source/imagewmssource.js b/src/ol/source/imagewmssource.js index 4f99ac2a82..9b1b51df26 100644 --- a/src/ol/source/imagewmssource.js +++ b/src/ol/source/imagewmssource.js @@ -45,7 +45,7 @@ ol.source.ImageWMS = function(opt_options) { * @type {?string} */ this.crossOrigin_ = - goog.isDef(options.crossOrigin) ? options.crossOrigin : null; + options.crossOrigin !== undefined ? options.crossOrigin : null; /** * @private @@ -57,7 +57,7 @@ ol.source.ImageWMS = function(opt_options) { * @private * @type {ol.ImageLoadFunctionType} */ - this.imageLoadFunction_ = goog.isDef(options.imageLoadFunction) ? + this.imageLoadFunction_ = options.imageLoadFunction !== undefined ? options.imageLoadFunction : ol.source.Image.defaultImageLoadFunction; /** @@ -84,7 +84,7 @@ ol.source.ImageWMS = function(opt_options) { * @private * @type {boolean} */ - this.hidpi_ = goog.isDef(options.hidpi) ? options.hidpi : true; + this.hidpi_ = options.hidpi !== undefined ? options.hidpi : true; /** * @private @@ -108,7 +108,7 @@ ol.source.ImageWMS = function(opt_options) { * @private * @type {number} */ - this.ratio_ = goog.isDef(options.ratio) ? options.ratio : 1.5; + this.ratio_ = options.ratio !== undefined ? options.ratio : 1.5; }; goog.inherits(ol.source.ImageWMS, ol.source.Image); @@ -281,7 +281,7 @@ ol.source.ImageWMS.prototype.getImageLoadFunction = function() { ol.source.ImageWMS.prototype.getRequestUrl_ = function(extent, size, pixelRatio, projection, params) { - goog.asserts.assert(goog.isDef(this.url_), 'url is defined'); + goog.asserts.assert(this.url_ !== undefined, 'url is defined'); params[this.v13_ ? 'CRS' : 'SRS'] = projection.getCode(); diff --git a/src/ol/source/mapquestsource.js b/src/ol/source/mapquestsource.js index f073c13f00..69ecc336b7 100644 --- a/src/ol/source/mapquestsource.js +++ b/src/ol/source/mapquestsource.js @@ -31,7 +31,7 @@ ol.source.MapQuest = function(opt_options) { */ this.layer_ = options.layer; - var url = goog.isDef(options.url) ? options.url : + var url = options.url !== undefined ? options.url : 'https://otile{1-4}-s.mqcdn.com/tiles/1.0.0/' + this.layer_ + '/{z}/{x}/{y}.jpg'; diff --git a/src/ol/source/osmsource.js b/src/ol/source/osmsource.js index 9a2c77222c..af17595c5e 100644 --- a/src/ol/source/osmsource.js +++ b/src/ol/source/osmsource.js @@ -25,17 +25,17 @@ ol.source.OSM = function(opt_options) { attributions = [ol.source.OSM.ATTRIBUTION]; } - var crossOrigin = goog.isDef(options.crossOrigin) ? + var crossOrigin = options.crossOrigin !== undefined ? options.crossOrigin : 'anonymous'; - var url = goog.isDef(options.url) ? + var url = options.url !== undefined ? options.url : 'https://{a-c}.tile.openstreetmap.org/{z}/{x}/{y}.png'; goog.base(this, { attributions: attributions, crossOrigin: crossOrigin, opaque: true, - maxZoom: goog.isDef(options.maxZoom) ? options.maxZoom : 19, + maxZoom: options.maxZoom !== undefined ? options.maxZoom : 19, tileLoadFunction: options.tileLoadFunction, url: url, wrapX: options.wrapX diff --git a/src/ol/source/rastersource.js b/src/ol/source/rastersource.js index aaa809da4d..70083ab502 100644 --- a/src/ol/source/rastersource.js +++ b/src/ol/source/rastersource.js @@ -48,14 +48,14 @@ ol.source.Raster = function(options) { * @private * @type {ol.raster.OperationType} */ - this.operationType_ = goog.isDef(options.operationType) ? + this.operationType_ = options.operationType !== undefined ? options.operationType : ol.raster.OperationType.PIXEL; /** * @private * @type {number} */ - this.threads_ = goog.isDef(options.threads) ? options.threads : 1; + this.threads_ = options.threads !== undefined ? options.threads : 1; /** * @private diff --git a/src/ol/source/source.js b/src/ol/source/source.js index fe83c31468..98dc3124ec 100644 --- a/src/ol/source/source.js +++ b/src/ol/source/source.js @@ -57,7 +57,7 @@ ol.source.Source = function(options) { * @private * @type {Array.} */ - this.attributions_ = goog.isDef(options.attributions) ? + this.attributions_ = options.attributions !== undefined ? options.attributions : null; /** @@ -70,14 +70,14 @@ ol.source.Source = function(options) { * @private * @type {ol.source.State} */ - this.state_ = goog.isDef(options.state) ? + this.state_ = options.state !== undefined ? options.state : ol.source.State.READY; /** * @private * @type {boolean} */ - this.wrapX_ = goog.isDef(options.wrapX) ? options.wrapX : false; + this.wrapX_ = options.wrapX !== undefined ? options.wrapX : false; }; goog.inherits(ol.source.Source, ol.Object); diff --git a/src/ol/source/stamensource.js b/src/ol/source/stamensource.js index ed34cb7988..f49f2d8b98 100644 --- a/src/ol/source/stamensource.js +++ b/src/ol/source/stamensource.js @@ -98,7 +98,7 @@ ol.source.Stamen = function(options) { 'known layer configured'); var layerConfig = ol.source.StamenLayerConfig[options.layer]; - var url = goog.isDef(options.url) ? options.url : + var url = options.url !== undefined ? options.url : 'https://stamen-tiles-{a-d}.a.ssl.fastly.net/' + options.layer + '/{z}/{x}/{y}.' + layerConfig.extension; diff --git a/src/ol/source/tilearcgisrestsource.js b/src/ol/source/tilearcgisrestsource.js index 29c7e19d22..663574695c 100644 --- a/src/ol/source/tilearcgisrestsource.js +++ b/src/ol/source/tilearcgisrestsource.js @@ -34,7 +34,7 @@ ol.source.TileArcGISRest = function(opt_options) { var options = opt_options || {}; - var params = goog.isDef(options.params) ? options.params : {}; + var params = options.params !== undefined ? options.params : {}; goog.base(this, { attributions: options.attributions, @@ -44,11 +44,11 @@ ol.source.TileArcGISRest = function(opt_options) { tileGrid: options.tileGrid, tileLoadFunction: options.tileLoadFunction, tileUrlFunction: goog.bind(this.tileUrlFunction_, this), - wrapX: goog.isDef(options.wrapX) ? options.wrapX : true + wrapX: options.wrapX !== undefined ? options.wrapX : true }); var urls = options.urls; - if (urls === undefined && goog.isDef(options.url)) { + if (urls === undefined && options.url !== undefined) { urls = ol.TileUrlFunction.expandUrl(options.url); } diff --git a/src/ol/source/tiledebugsource.js b/src/ol/source/tiledebugsource.js index 66b7409fbd..41aed6df4a 100644 --- a/src/ol/source/tiledebugsource.js +++ b/src/ol/source/tiledebugsource.js @@ -92,7 +92,7 @@ ol.source.TileDebug = function(options) { opaque: false, projection: options.projection, tileGrid: options.tileGrid, - wrapX: goog.isDef(options.wrapX) ? options.wrapX : true + wrapX: options.wrapX !== undefined ? options.wrapX : true }); }; diff --git a/src/ol/source/tileimagesource.js b/src/ol/source/tileimagesource.js index 457143f702..1fddb16652 100644 --- a/src/ol/source/tileimagesource.js +++ b/src/ol/source/tileimagesource.js @@ -32,7 +32,7 @@ ol.source.TileImage = function(options) { logo: options.logo, opaque: options.opaque, projection: options.projection, - state: goog.isDef(options.state) ? + state: options.state !== undefined ? /** @type {ol.source.State} */ (options.state) : undefined, tileGrid: options.tileGrid, tilePixelRatio: options.tilePixelRatio, @@ -43,7 +43,7 @@ ol.source.TileImage = function(options) { * @protected * @type {ol.TileUrlFunctionType} */ - this.tileUrlFunction = goog.isDef(options.tileUrlFunction) ? + this.tileUrlFunction = options.tileUrlFunction !== undefined ? options.tileUrlFunction : ol.TileUrlFunction.nullTileUrlFunction; @@ -52,13 +52,13 @@ ol.source.TileImage = function(options) { * @type {?string} */ this.crossOrigin = - goog.isDef(options.crossOrigin) ? options.crossOrigin : null; + options.crossOrigin !== undefined ? options.crossOrigin : null; /** * @protected * @type {ol.TileLoadFunctionType} */ - this.tileLoadFunction = goog.isDef(options.tileLoadFunction) ? + this.tileLoadFunction = options.tileLoadFunction !== undefined ? options.tileLoadFunction : ol.source.TileImage.defaultTileLoadFunction; /** @@ -66,7 +66,7 @@ ol.source.TileImage = function(options) { * @type {function(new: ol.ImageTile, ol.TileCoord, ol.TileState, string, * ?string, ol.TileLoadFunctionType)} */ - this.tileClass = goog.isDef(options.tileClass) ? + this.tileClass = options.tileClass !== undefined ? options.tileClass : ol.ImageTile; }; diff --git a/src/ol/source/tilejsonsource.js b/src/ol/source/tilejsonsource.js index 472cfbd181..01982fd896 100644 --- a/src/ol/source/tilejsonsource.js +++ b/src/ol/source/tilejsonsource.js @@ -36,7 +36,7 @@ ol.source.TileJSON = function(options) { projection: ol.proj.get('EPSG:3857'), state: ol.source.State.LOADING, tileLoadFunction: options.tileLoadFunction, - wrapX: goog.isDef(options.wrapX) ? options.wrapX : true + wrapX: options.wrapX !== undefined ? options.wrapX : true }); var request = new goog.net.Jsonp(options.url); @@ -77,7 +77,7 @@ ol.source.TileJSON.prototype.handleTileJSONResponse = function(tileJSON) { this.tileUrlFunction = ol.TileUrlFunction.createFromTemplates(tileJSON.tiles); - if (goog.isDef(tileJSON.attribution) && + if (tileJSON.attribution !== undefined && goog.isNull(this.getAttributions())) { var attributionExtent = extent !== undefined ? extent : epsg4326Projection.getExtent(); diff --git a/src/ol/source/tilesource.js b/src/ol/source/tilesource.js index b0546ecaaa..ad707f5042 100644 --- a/src/ol/source/tilesource.js +++ b/src/ol/source/tilesource.js @@ -56,20 +56,20 @@ ol.source.Tile = function(options) { * @private * @type {boolean} */ - this.opaque_ = goog.isDef(options.opaque) ? options.opaque : false; + this.opaque_ = options.opaque !== undefined ? options.opaque : false; /** * @private * @type {number} */ - this.tilePixelRatio_ = goog.isDef(options.tilePixelRatio) ? + this.tilePixelRatio_ = options.tilePixelRatio !== undefined ? options.tilePixelRatio : 1; /** * @protected * @type {ol.tilegrid.TileGrid} */ - this.tileGrid = goog.isDef(options.tileGrid) ? options.tileGrid : null; + this.tileGrid = options.tileGrid !== undefined ? options.tileGrid : null; /** * @protected diff --git a/src/ol/source/tileutfgridsource.js b/src/ol/source/tileutfgridsource.js index 4786fd8d70..28e96efabb 100644 --- a/src/ol/source/tileutfgridsource.js +++ b/src/ol/source/tileutfgridsource.js @@ -35,7 +35,7 @@ ol.source.TileUTFGrid = function(options) { * @private * @type {boolean} */ - this.preemptive_ = goog.isDef(options.preemptive) ? + this.preemptive_ = options.preemptive !== undefined ? options.preemptive : true; /** diff --git a/src/ol/source/tilevectorsource.js b/src/ol/source/tilevectorsource.js index 310431a545..af66f75ed9 100644 --- a/src/ol/source/tilevectorsource.js +++ b/src/ol/source/tilevectorsource.js @@ -36,7 +36,7 @@ ol.source.TileVector = function(options) { * @private * @type {ol.format.Feature|undefined} */ - this.format_ = goog.isDef(options.format) ? options.format : null; + this.format_ = options.format !== undefined ? options.format : null; /** * @private @@ -54,7 +54,7 @@ ol.source.TileVector = function(options) { * @private * @type {?ol.TileVectorLoadFunctionType} */ - this.tileLoadFunction_ = goog.isDef(options.tileLoadFunction) ? + this.tileLoadFunction_ = options.tileLoadFunction !== undefined ? options.tileLoadFunction : null; goog.asserts.assert(!goog.isNull(this.format_) || diff --git a/src/ol/source/tilewmssource.js b/src/ol/source/tilewmssource.js index 09c7f6e504..a76089d048 100644 --- a/src/ol/source/tilewmssource.js +++ b/src/ol/source/tilewmssource.js @@ -35,7 +35,7 @@ ol.source.TileWMS = function(opt_options) { var options = opt_options || {}; - var params = goog.isDef(options.params) ? options.params : {}; + var params = options.params !== undefined ? options.params : {}; var transparent = goog.object.get(params, 'TRANSPARENT', true); @@ -48,11 +48,11 @@ ol.source.TileWMS = function(opt_options) { tileGrid: options.tileGrid, tileLoadFunction: options.tileLoadFunction, tileUrlFunction: goog.bind(this.tileUrlFunction_, this), - wrapX: goog.isDef(options.wrapX) ? options.wrapX : true + wrapX: options.wrapX !== undefined ? options.wrapX : true }); var urls = options.urls; - if (urls === undefined && goog.isDef(options.url)) { + if (urls === undefined && options.url !== undefined) { urls = ol.TileUrlFunction.expandUrl(options.url); } @@ -66,7 +66,7 @@ ol.source.TileWMS = function(opt_options) { * @private * @type {number} */ - this.gutter_ = goog.isDef(options.gutter) ? options.gutter : 0; + this.gutter_ = options.gutter !== undefined ? options.gutter : 0; /** * @private @@ -91,7 +91,7 @@ ol.source.TileWMS = function(opt_options) { * @private * @type {boolean} */ - this.hidpi_ = goog.isDef(options.hidpi) ? options.hidpi : true; + this.hidpi_ = options.hidpi !== undefined ? options.hidpi : true; /** * @private diff --git a/src/ol/source/vectorsource.js b/src/ol/source/vectorsource.js index 48cd84f0e5..fee984991c 100644 --- a/src/ol/source/vectorsource.js +++ b/src/ol/source/vectorsource.js @@ -82,7 +82,7 @@ ol.source.Vector = function(opt_options) { logo: options.logo, projection: undefined, state: ol.source.State.READY, - wrapX: goog.isDef(options.wrapX) ? options.wrapX : true + wrapX: options.wrapX !== undefined ? options.wrapX : true }); /** @@ -94,7 +94,7 @@ ol.source.Vector = function(opt_options) { if (options.loader !== undefined) { this.loader_ = options.loader; } else if (options.url !== undefined) { - goog.asserts.assert(goog.isDef(options.format), + goog.asserts.assert(options.format !== undefined, 'format must be set when url is set'); // create a XHR feature loader for "url" and "format" this.loader_ = ol.featureloader.xhr(options.url, options.format); @@ -104,11 +104,11 @@ ol.source.Vector = function(opt_options) { * @private * @type {ol.LoadingStrategy} */ - this.strategy_ = goog.isDef(options.strategy) ? options.strategy : + this.strategy_ = options.strategy !== undefined ? options.strategy : ol.loadingstrategy.all; var useSpatialIndex = - goog.isDef(options.useSpatialIndex) ? options.useSpatialIndex : true; + options.useSpatialIndex !== undefined ? options.useSpatialIndex : true; /** * @private diff --git a/src/ol/source/wmtssource.js b/src/ol/source/wmtssource.js index 05d646d527..17e24ef6c1 100644 --- a/src/ol/source/wmtssource.js +++ b/src/ol/source/wmtssource.js @@ -43,19 +43,19 @@ ol.source.WMTS = function(options) { * @private * @type {string} */ - this.version_ = goog.isDef(options.version) ? options.version : '1.0.0'; + this.version_ = options.version !== undefined ? options.version : '1.0.0'; /** * @private * @type {string} */ - this.format_ = goog.isDef(options.format) ? options.format : 'image/jpeg'; + this.format_ = options.format !== undefined ? options.format : 'image/jpeg'; /** * @private * @type {Object} */ - this.dimensions_ = goog.isDef(options.dimensions) ? options.dimensions : {}; + this.dimensions_ = options.dimensions !== undefined ? options.dimensions : {}; /** * @private @@ -83,7 +83,7 @@ ol.source.WMTS = function(options) { this.style_ = options.style; var urls = options.urls; - if (urls === undefined && goog.isDef(options.url)) { + if (urls === undefined && options.url !== undefined) { urls = ol.TileUrlFunction.expandUrl(options.url); } @@ -100,7 +100,7 @@ ol.source.WMTS = function(options) { * @private * @type {ol.source.WMTSRequestEncoding} */ - this.requestEncoding_ = goog.isDef(options.requestEncoding) ? + this.requestEncoding_ = options.requestEncoding !== undefined ? /** @type {ol.source.WMTSRequestEncoding} */ (options.requestEncoding) : ol.source.WMTSRequestEncoding.KVP; @@ -190,7 +190,7 @@ ol.source.WMTS = function(options) { tileLoadFunction: options.tileLoadFunction, tilePixelRatio: options.tilePixelRatio, tileUrlFunction: tileUrlFunction, - wrapX: goog.isDef(options.wrapX) ? options.wrapX : false + wrapX: options.wrapX !== undefined ? options.wrapX : false }); }; diff --git a/src/ol/source/xyzsource.js b/src/ol/source/xyzsource.js index 7294c312b2..7b8bdbb0c6 100644 --- a/src/ol/source/xyzsource.js +++ b/src/ol/source/xyzsource.js @@ -28,10 +28,10 @@ goog.require('ol.source.TileImage'); * @api stable */ ol.source.XYZ = function(options) { - var projection = goog.isDef(options.projection) ? + var projection = options.projection !== undefined ? options.projection : 'EPSG:3857'; - var tileGrid = goog.isDef(options.tileGrid) ? options.tileGrid : + var tileGrid = options.tileGrid !== undefined ? options.tileGrid : ol.tilegrid.createXYZ({ extent: ol.tilegrid.extentFromProjection(projection), maxZoom: options.maxZoom, @@ -53,7 +53,7 @@ ol.source.XYZ = function(options) { tileLoadFunction: options.tileLoadFunction, tilePixelRatio: options.tilePixelRatio, tileUrlFunction: ol.TileUrlFunction.nullTileUrlFunction, - wrapX: goog.isDef(options.wrapX) ? options.wrapX : true + wrapX: options.wrapX !== undefined ? options.wrapX : true }); if (options.tileUrlFunction !== undefined) { diff --git a/src/ol/source/zoomifysource.js b/src/ol/source/zoomifysource.js index 235b69fccb..ca2166d101 100644 --- a/src/ol/source/zoomifysource.js +++ b/src/ol/source/zoomifysource.js @@ -36,7 +36,7 @@ ol.source.Zoomify = function(opt_options) { var options = opt_options || {}; var size = options.size; - var tierSizeCalculation = goog.isDef(options.tierSizeCalculation) ? + var tierSizeCalculation = options.tierSizeCalculation !== undefined ? options.tierSizeCalculation : ol.source.ZoomifyTierSizeCalculation.DEFAULT; diff --git a/src/ol/style/atlasmanager.js b/src/ol/style/atlasmanager.js index 33cc672112..01967f8bcd 100644 --- a/src/ol/style/atlasmanager.js +++ b/src/ol/style/atlasmanager.js @@ -47,7 +47,7 @@ ol.style.AtlasManager = function(opt_options) { * @private * @type {number} */ - this.currentSize_ = goog.isDef(options.initialSize) ? + this.currentSize_ = options.initialSize !== undefined ? options.initialSize : ol.INITIAL_ATLAS_SIZE; /** @@ -55,9 +55,9 @@ ol.style.AtlasManager = function(opt_options) { * @private * @type {number} */ - this.maxSize_ = goog.isDef(options.maxSize) ? + this.maxSize_ = options.maxSize !== undefined ? options.maxSize : ol.MAX_ATLAS_SIZE != -1 ? - ol.MAX_ATLAS_SIZE : goog.isDef(ol.WEBGL_MAX_TEXTURE_SIZE) ? + ol.MAX_ATLAS_SIZE : ol.WEBGL_MAX_TEXTURE_SIZE !== undefined ? ol.WEBGL_MAX_TEXTURE_SIZE : 2048; /** @@ -65,7 +65,7 @@ ol.style.AtlasManager = function(opt_options) { * @private * @type {number} */ - this.space_ = goog.isDef(options.space) ? options.space : 1; + this.space_ = options.space !== undefined ? options.space : 1; /** * @private diff --git a/src/ol/style/circlestyle.js b/src/ol/style/circlestyle.js index 9de1b18d4e..34eb334b87 100644 --- a/src/ol/style/circlestyle.js +++ b/src/ol/style/circlestyle.js @@ -50,13 +50,13 @@ ol.style.Circle = function(opt_options) { * @private * @type {ol.style.Fill} */ - this.fill_ = goog.isDef(options.fill) ? options.fill : null; + this.fill_ = options.fill !== undefined ? options.fill : null; /** * @private * @type {ol.style.Stroke} */ - this.stroke_ = goog.isDef(options.stroke) ? options.stroke : null; + this.stroke_ = options.stroke !== undefined ? options.stroke : null; /** * @private @@ -99,7 +99,7 @@ ol.style.Circle = function(opt_options) { /** * @type {boolean} */ - var snapToPixel = goog.isDef(options.snapToPixel) ? + var snapToPixel = options.snapToPixel !== undefined ? options.snapToPixel : true; goog.base(this, { @@ -435,7 +435,7 @@ ol.style.Circle.prototype.getChecksum = function() { if (recalculate) { var checksum = 'c' + strokeChecksum + fillChecksum + - (goog.isDef(this.radius_) ? this.radius_.toString() : '-'); + (this.radius_ !== undefined ? this.radius_.toString() : '-'); this.checksums_ = [checksum, strokeChecksum, fillChecksum, this.radius_]; } diff --git a/src/ol/style/fillstyle.js b/src/ol/style/fillstyle.js index 19895f0c86..5b9d320bc7 100644 --- a/src/ol/style/fillstyle.js +++ b/src/ol/style/fillstyle.js @@ -22,7 +22,7 @@ ol.style.Fill = function(opt_options) { * @private * @type {ol.Color|string} */ - this.color_ = goog.isDef(options.color) ? options.color : null; + this.color_ = options.color !== undefined ? options.color : null; /** * @private diff --git a/src/ol/style/iconstyle.js b/src/ol/style/iconstyle.js index df3d85452b..e65dc9b4b0 100644 --- a/src/ol/style/iconstyle.js +++ b/src/ol/style/iconstyle.js @@ -55,7 +55,7 @@ ol.style.Icon = function(opt_options) { * @private * @type {Array.} */ - this.anchor_ = goog.isDef(options.anchor) ? options.anchor : [0.5, 0.5]; + this.anchor_ = options.anchor !== undefined ? options.anchor : [0.5, 0.5]; /** * @private @@ -67,38 +67,38 @@ ol.style.Icon = function(opt_options) { * @private * @type {ol.style.IconOrigin} */ - this.anchorOrigin_ = goog.isDef(options.anchorOrigin) ? + this.anchorOrigin_ = options.anchorOrigin !== undefined ? options.anchorOrigin : ol.style.IconOrigin.TOP_LEFT; /** * @private * @type {ol.style.IconAnchorUnits} */ - this.anchorXUnits_ = goog.isDef(options.anchorXUnits) ? + this.anchorXUnits_ = options.anchorXUnits !== undefined ? options.anchorXUnits : ol.style.IconAnchorUnits.FRACTION; /** * @private * @type {ol.style.IconAnchorUnits} */ - this.anchorYUnits_ = goog.isDef(options.anchorYUnits) ? + this.anchorYUnits_ = options.anchorYUnits !== undefined ? options.anchorYUnits : ol.style.IconAnchorUnits.FRACTION; /** * @type {?string} */ var crossOrigin = - goog.isDef(options.crossOrigin) ? options.crossOrigin : null; + options.crossOrigin !== undefined ? options.crossOrigin : null; /** * @type {Image} */ - var image = goog.isDef(options.img) ? options.img : null; + var image = options.img !== undefined ? options.img : null; /** * @type {ol.Size} */ - var imgSize = goog.isDef(options.imgSize) ? options.imgSize : null; + var imgSize = options.imgSize !== undefined ? options.imgSize : null; /** * @type {string|undefined} @@ -123,7 +123,7 @@ ol.style.Icon = function(opt_options) { /** * @type {ol.style.ImageState} */ - var imageState = goog.isDef(options.src) ? + var imageState = options.src !== undefined ? ol.style.ImageState.IDLE : ol.style.ImageState.LOADED; /** @@ -137,13 +137,13 @@ ol.style.Icon = function(opt_options) { * @private * @type {Array.} */ - this.offset_ = goog.isDef(options.offset) ? options.offset : [0, 0]; + this.offset_ = options.offset !== undefined ? options.offset : [0, 0]; /** * @private * @type {ol.style.IconOrigin} */ - this.offsetOrigin_ = goog.isDef(options.offsetOrigin) ? + this.offsetOrigin_ = options.offsetOrigin !== undefined ? options.offsetOrigin : ol.style.IconOrigin.TOP_LEFT; /** @@ -156,33 +156,33 @@ ol.style.Icon = function(opt_options) { * @private * @type {ol.Size} */ - this.size_ = goog.isDef(options.size) ? options.size : null; + this.size_ = options.size !== undefined ? options.size : null; /** * @type {number} */ - var opacity = goog.isDef(options.opacity) ? options.opacity : 1; + var opacity = options.opacity !== undefined ? options.opacity : 1; /** * @type {boolean} */ - var rotateWithView = goog.isDef(options.rotateWithView) ? + var rotateWithView = options.rotateWithView !== undefined ? options.rotateWithView : false; /** * @type {number} */ - var rotation = goog.isDef(options.rotation) ? options.rotation : 0; + var rotation = options.rotation !== undefined ? options.rotation : 0; /** * @type {number} */ - var scale = goog.isDef(options.scale) ? options.scale : 1; + var scale = options.scale !== undefined ? options.scale : 1; /** * @type {boolean} */ - var snapToPixel = goog.isDef(options.snapToPixel) ? + var snapToPixel = options.snapToPixel !== undefined ? options.snapToPixel : true; goog.base(this, { @@ -553,7 +553,7 @@ ol.style.IconImage_.prototype.getSrc = function() { */ ol.style.IconImage_.prototype.load = function() { if (this.imageState_ == ol.style.ImageState.IDLE) { - goog.asserts.assert(goog.isDef(this.src_), + goog.asserts.assert(this.src_ !== undefined, 'this.src_ must not be undefined'); goog.asserts.assert(goog.isNull(this.imageListenerKeys_), 'no listener keys existing'); diff --git a/src/ol/style/regularshapestyle.js b/src/ol/style/regularshapestyle.js index 315f8f49cc..2994738547 100644 --- a/src/ol/style/regularshapestyle.js +++ b/src/ol/style/regularshapestyle.js @@ -30,7 +30,7 @@ goog.require('ol.style.Stroke'); ol.style.RegularShape = function(options) { goog.asserts.assert( - goog.isDef(options.radius) || goog.isDef(options.radius1), + options.radius !== undefined || options.radius1 !== undefined, 'must provide either "radius" or "radius1"'); /** @@ -55,7 +55,7 @@ ol.style.RegularShape = function(options) { * @private * @type {ol.style.Fill} */ - this.fill_ = goog.isDef(options.fill) ? options.fill : null; + this.fill_ = options.fill !== undefined ? options.fill : null; /** * @private @@ -73,7 +73,7 @@ ol.style.RegularShape = function(options) { * @private * @type {number} */ - this.radius_ = /** @type {number} */ (goog.isDef(options.radius) ? + this.radius_ = /** @type {number} */ (options.radius !== undefined ? options.radius : options.radius1); /** @@ -81,19 +81,19 @@ ol.style.RegularShape = function(options) { * @type {number} */ this.radius2_ = - goog.isDef(options.radius2) ? options.radius2 : this.radius_; + options.radius2 !== undefined ? options.radius2 : this.radius_; /** * @private * @type {number} */ - this.angle_ = goog.isDef(options.angle) ? options.angle : 0; + this.angle_ = options.angle !== undefined ? options.angle : 0; /** * @private * @type {ol.style.Stroke} */ - this.stroke_ = goog.isDef(options.stroke) ? options.stroke : null; + this.stroke_ = options.stroke !== undefined ? options.stroke : null; /** * @private @@ -124,13 +124,13 @@ ol.style.RegularShape = function(options) { /** * @type {boolean} */ - var snapToPixel = goog.isDef(options.snapToPixel) ? + var snapToPixel = options.snapToPixel !== undefined ? options.snapToPixel : true; goog.base(this, { opacity: 1, rotateWithView: false, - rotation: goog.isDef(options.rotation) ? options.rotation : 0, + rotation: options.rotation !== undefined ? options.rotation : 0, scale: 1, snapToPixel: snapToPixel }); @@ -536,10 +536,10 @@ ol.style.RegularShape.prototype.getChecksum = function() { if (recalculate) { var checksum = 'r' + strokeChecksum + fillChecksum + - (goog.isDef(this.radius_) ? this.radius_.toString() : '-') + - (goog.isDef(this.radius2_) ? this.radius2_.toString() : '-') + - (goog.isDef(this.angle_) ? this.angle_.toString() : '-') + - (goog.isDef(this.points_) ? this.points_.toString() : '-'); + (this.radius_ !== undefined ? this.radius_.toString() : '-') + + (this.radius2_ !== undefined ? this.radius2_.toString() : '-') + + (this.angle_ !== undefined ? this.angle_.toString() : '-') + + (this.points_ !== undefined ? this.points_.toString() : '-'); this.checksums_ = [checksum, strokeChecksum, fillChecksum, this.radius_, this.radius2_, this.angle_, this.points_]; } diff --git a/src/ol/style/strokestyle.js b/src/ol/style/strokestyle.js index 1fbd7a9a02..230f32e1fc 100644 --- a/src/ol/style/strokestyle.js +++ b/src/ol/style/strokestyle.js @@ -27,7 +27,7 @@ ol.style.Stroke = function(opt_options) { * @private * @type {ol.Color|string} */ - this.color_ = goog.isDef(options.color) ? options.color : null; + this.color_ = options.color !== undefined ? options.color : null; /** * @private @@ -39,7 +39,7 @@ ol.style.Stroke = function(opt_options) { * @private * @type {Array.} */ - this.lineDash_ = goog.isDef(options.lineDash) ? options.lineDash : null; + this.lineDash_ = options.lineDash !== undefined ? options.lineDash : null; /** * @private @@ -207,15 +207,15 @@ ol.style.Stroke.prototype.getChecksum = function() { var raw = 's' + (!goog.isNull(this.color_) ? ol.color.asString(this.color_) : '-') + ',' + - (goog.isDef(this.lineCap_) ? + (this.lineCap_ !== undefined ? this.lineCap_.toString() : '-') + ',' + (!goog.isNull(this.lineDash_) ? this.lineDash_.toString() : '-') + ',' + - (goog.isDef(this.lineJoin_) ? + (this.lineJoin_ !== undefined ? this.lineJoin_ : '-') + ',' + - (goog.isDef(this.miterLimit_) ? + (this.miterLimit_ !== undefined ? this.miterLimit_.toString() : '-') + ',' + - (goog.isDef(this.width_) ? + (this.width_ !== undefined ? this.width_.toString() : '-'); var md5 = new goog.crypt.Md5(); diff --git a/src/ol/style/style.js b/src/ol/style/style.js index 9b43147456..8cb9910baa 100644 --- a/src/ol/style/style.js +++ b/src/ol/style/style.js @@ -48,25 +48,25 @@ ol.style.Style = function(opt_options) { * @private * @type {ol.style.Fill} */ - this.fill_ = goog.isDef(options.fill) ? options.fill : null; + this.fill_ = options.fill !== undefined ? options.fill : null; /** * @private * @type {ol.style.Image} */ - this.image_ = goog.isDef(options.image) ? options.image : null; + this.image_ = options.image !== undefined ? options.image : null; /** * @private * @type {ol.style.Stroke} */ - this.stroke_ = goog.isDef(options.stroke) ? options.stroke : null; + this.stroke_ = options.stroke !== undefined ? options.stroke : null; /** * @private * @type {ol.style.Text} */ - this.text_ = goog.isDef(options.text) ? options.text : null; + this.text_ = options.text !== undefined ? options.text : null; /** * @private diff --git a/src/ol/style/textstyle.js b/src/ol/style/textstyle.js index a8e127047b..f2ff125499 100644 --- a/src/ol/style/textstyle.js +++ b/src/ol/style/textstyle.js @@ -57,26 +57,26 @@ ol.style.Text = function(opt_options) { * @private * @type {ol.style.Fill} */ - this.fill_ = goog.isDef(options.fill) ? options.fill : + this.fill_ = options.fill !== undefined ? options.fill : new ol.style.Fill({color: ol.style.Text.DEFAULT_FILL_COLOR_}); /** * @private * @type {ol.style.Stroke} */ - this.stroke_ = goog.isDef(options.stroke) ? options.stroke : null; + this.stroke_ = options.stroke !== undefined ? options.stroke : null; /** * @private * @type {number} */ - this.offsetX_ = goog.isDef(options.offsetX) ? options.offsetX : 0; + this.offsetX_ = options.offsetX !== undefined ? options.offsetX : 0; /** * @private * @type {number} */ - this.offsetY_ = goog.isDef(options.offsetY) ? options.offsetY : 0; + this.offsetY_ = options.offsetY !== undefined ? options.offsetY : 0; }; diff --git a/src/ol/tilegrid/tilegrid.js b/src/ol/tilegrid/tilegrid.js index 8eb794267b..8d6073eb2a 100644 --- a/src/ol/tilegrid/tilegrid.js +++ b/src/ol/tilegrid/tilegrid.js @@ -36,7 +36,7 @@ ol.tilegrid.TileGrid = function(options) { * @protected * @type {number} */ - this.minZoom = goog.isDef(options.minZoom) ? options.minZoom : 0; + this.minZoom = options.minZoom !== undefined ? options.minZoom : 0; /** * @private @@ -57,7 +57,7 @@ ol.tilegrid.TileGrid = function(options) { * @private * @type {ol.Coordinate} */ - this.origin_ = goog.isDef(options.origin) ? options.origin : null; + this.origin_ = options.origin !== undefined ? options.origin : null; /** * @private @@ -97,7 +97,7 @@ ol.tilegrid.TileGrid = function(options) { * @private * @type {number|ol.Size} */ - this.tileSize_ = goog.isDef(options.tileSize) ? + this.tileSize_ = options.tileSize !== undefined ? options.tileSize : goog.isNull(this.tileSizes_) ? ol.DEFAULT_TILE_SIZE : null; goog.asserts.assert( diff --git a/src/ol/view.js b/src/ol/view.js index b787868f9e..137fa94dd0 100644 --- a/src/ol/view.js +++ b/src/ol/view.js @@ -112,7 +112,7 @@ ol.View = function(opt_options) { * @type {Object.} */ var properties = {}; - properties[ol.ViewProperty.CENTER] = goog.isDef(options.center) ? + properties[ol.ViewProperty.CENTER] = options.center !== undefined ? options.center : null; /** @@ -161,7 +161,7 @@ ol.View = function(opt_options) { this.maxResolution_, options.zoom - this.minZoom_); } properties[ol.ViewProperty.ROTATION] = - goog.isDef(options.rotation) ? options.rotation : 0; + options.rotation !== undefined ? options.rotation : 0; this.setProperties(properties); }; goog.inherits(ol.View, ol.Object); @@ -458,10 +458,10 @@ ol.View.prototype.fit = function(geometry, size, opt_options) { var options = opt_options || {}; - var padding = goog.isDef(options.padding) ? options.padding : [0, 0, 0, 0]; - var constrainResolution = goog.isDef(options.constrainResolution) ? + var padding = options.padding !== undefined ? options.padding : [0, 0, 0, 0]; + var constrainResolution = options.constrainResolution !== undefined ? options.constrainResolution : true; - var nearest = goog.isDef(options.nearest) ? options.nearest : false; + var nearest = options.nearest !== undefined ? options.nearest : false; var minResolution; if (options.minResolution !== undefined) { minResolution = options.minResolution; @@ -662,13 +662,13 @@ ol.View.createResolutionConstraint_ = function(options) { var defaultMaxZoom = 28; var defaultZoomFactor = 2; - var minZoom = goog.isDef(options.minZoom) ? + var minZoom = options.minZoom !== undefined ? options.minZoom : ol.DEFAULT_MIN_ZOOM; - var maxZoom = goog.isDef(options.maxZoom) ? + var maxZoom = options.maxZoom !== undefined ? options.maxZoom : defaultMaxZoom; - var zoomFactor = goog.isDef(options.zoomFactor) ? + var zoomFactor = options.zoomFactor !== undefined ? options.zoomFactor : defaultZoomFactor; if (options.resolutions !== undefined) { @@ -734,7 +734,7 @@ ol.View.createResolutionConstraint_ = function(options) { * @return {ol.RotationConstraintType} Rotation constraint. */ ol.View.createRotationConstraint_ = function(options) { - var enableRotation = goog.isDef(options.enableRotation) ? + var enableRotation = options.enableRotation !== undefined ? options.enableRotation : true; if (enableRotation) { var constrainRotation = options.constrainRotation; diff --git a/src/ol/xml.js b/src/ol/xml.js index 622b18569e..b45fdbe183 100644 --- a/src/ol/xml.js +++ b/src/ol/xml.js @@ -194,7 +194,7 @@ ol.xml.isNode_ = function(value) { * @return {boolean} Is node. */ ol.xml.isNodeIE_ = function(value) { - return goog.isObject(value) && goog.isDef(value.nodeType); + return goog.isObject(value) && value.nodeType !== undefined; }; From b3b31ea16d033f318544e05de0a0909fcced8c68 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Sun, 27 Sep 2015 10:51:03 -0600 Subject: [PATCH 81/93] Inline various goog.isDef() calls --- src/ol/graticule.js | 4 ++-- src/ol/imagetile.js | 2 +- src/ol/proj/proj.js | 2 +- src/ol/render/canvas/canvasreplay.js | 8 +++++--- src/ol/render/webgl/webglreplay.js | 7 ++++--- 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/ol/graticule.js b/src/ol/graticule.js index 4d5b012042..10b76a8470 100644 --- a/src/ol/graticule.js +++ b/src/ol/graticule.js @@ -346,7 +346,7 @@ ol.Graticule.prototype.getMeridian_ = function(lon, minLat, maxLat, minLat, maxLat, this.projection_, squaredTolerance); goog.asserts.assert(flatCoordinates.length > 0, 'flatCoordinates cannot be empty'); - var lineString = goog.isDef(this.meridians_[index]) ? + var lineString = this.meridians_[index] !== undefined ? this.meridians_[index] : new ol.geom.LineString(null); lineString.setFlatCoordinates(ol.geom.GeometryLayout.XY, flatCoordinates); return lineString; @@ -382,7 +382,7 @@ ol.Graticule.prototype.getParallel_ = function(lat, minLon, maxLon, this.minLon_, this.maxLon_, this.projection_, squaredTolerance); goog.asserts.assert(flatCoordinates.length > 0, 'flatCoordinates cannot be empty'); - var lineString = goog.isDef(this.parallels_[index]) ? + var lineString = this.parallels_[index] !== undefined ? this.parallels_[index] : new ol.geom.LineString(null); lineString.setFlatCoordinates(ol.geom.GeometryLayout.XY, flatCoordinates); return lineString; diff --git a/src/ol/imagetile.js b/src/ol/imagetile.js index 60e7730387..3b893b58df 100644 --- a/src/ol/imagetile.js +++ b/src/ol/imagetile.js @@ -126,7 +126,7 @@ ol.ImageTile.prototype.handleImageError_ = function() { */ ol.ImageTile.prototype.handleImageLoad_ = function() { if (ol.LEGACY_IE_SUPPORT && ol.IS_LEGACY_IE) { - if (!goog.isDef(this.image_.naturalWidth)) { + if (this.image_.naturalWidth === undefined) { this.image_.naturalWidth = this.image_.width; this.image_.naturalHeight = this.image_.height; } diff --git a/src/ol/proj/proj.js b/src/ol/proj/proj.js index 47b209dff2..b79aadfefb 100644 --- a/src/ol/proj/proj.js +++ b/src/ol/proj/proj.js @@ -146,7 +146,7 @@ ol.proj.Projection = function(options) { goog.asserts.assert(code !== undefined, 'Option "code" is required for constructing instance'); if (ol.ENABLE_PROJ4JS && typeof proj4 == 'function' && - !goog.isDef(projections[code])) { + projections[code] === undefined) { var def = proj4.defs(code); if (def !== undefined) { if (def.axis !== undefined && options.axisOrientation === undefined) { diff --git a/src/ol/render/canvas/canvasreplay.js b/src/ol/render/canvas/canvasreplay.js index a3a44356d3..f5805b5f25 100644 --- a/src/ol/render/canvas/canvasreplay.js +++ b/src/ol/render/canvas/canvasreplay.js @@ -257,11 +257,12 @@ ol.render.canvas.Replay.prototype.replay_ = function( case ol.render.canvas.Instruction.BEGIN_GEOMETRY: feature = /** @type {ol.Feature} */ (instruction[1]); var featureUid = goog.getUid(feature).toString(); - if (goog.isDef(skippedFeaturesHash[featureUid]) || + if (skippedFeaturesHash[featureUid] !== undefined || !goog.isDefAndNotNull(feature.getGeometry())) { i = /** @type {number} */ (instruction[2]); } else if (opt_hitExtent !== undefined && !ol.extent.intersects( - opt_hitExtent, feature.getGeometry().getExtent())) { + /** @type {Array} */ (opt_hitExtent), + feature.getGeometry().getExtent())) { i = /** @type {number} */ (instruction[2]); } else { ++i; @@ -451,7 +452,8 @@ ol.render.canvas.Replay.prototype.replay_ = function( '6th instruction should be a number'); goog.asserts.assert(!goog.isNull(instruction[6]), '7th instruction should not be null'); - var usePixelRatio = goog.isDef(instruction[7]) ? instruction[7] : true; + var usePixelRatio = instruction[7] !== undefined ? + instruction[7] : true; var lineWidth = /** @type {number} */ (instruction[2]); context.strokeStyle = /** @type {string} */ (instruction[1]); context.lineWidth = usePixelRatio ? lineWidth * pixelRatio : lineWidth; diff --git a/src/ol/render/webgl/webglreplay.js b/src/ol/render/webgl/webglreplay.js index b450e650db..b5ef477371 100644 --- a/src/ol/render/webgl/webglreplay.js +++ b/src/ol/render/webgl/webglreplay.js @@ -733,7 +733,7 @@ ol.render.webgl.ImageReplay.prototype.drawReplaySkipping_ = var feature = this.startIndicesFeature_[featureIndex]; var featureUid = goog.getUid(feature).toString(); - if (goog.isDef(skippedFeaturesHash[featureUid])) { + if (skippedFeaturesHash[featureUid] !== undefined) { // feature should be skipped if (start !== end) { // draw the features so far @@ -865,10 +865,11 @@ ol.render.webgl.ImageReplay.prototype.drawHitDetectionReplayOneByOne_ = feature = this.startIndicesFeature_[featureIndex]; featureUid = goog.getUid(feature).toString(); - if (!goog.isDef(skippedFeaturesHash[featureUid]) && + if (skippedFeaturesHash[featureUid] === undefined && goog.isDefAndNotNull(feature.getGeometry()) && (opt_hitExtent === undefined || ol.extent.intersects( - opt_hitExtent, feature.getGeometry().getExtent()))) { + /** @type {Array} */ (opt_hitExtent), + feature.getGeometry().getExtent()))) { gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); this.drawElements_(gl, start, end, elementType, elementSize); From 27d1e808b8dc0601ddd36f59c7383d3e05338c60 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Sun, 27 Sep 2015 10:58:39 -0600 Subject: [PATCH 82/93] Replace `goog.isDef(foo[bar])` with `bar in foo` --- src/ol/source/imagewmssource.js | 2 +- src/ol/source/tilewmssource.js | 2 +- src/ol/source/wmtssource.js | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/ol/source/imagewmssource.js b/src/ol/source/imagewmssource.js index 9b1b51df26..c7e25299d0 100644 --- a/src/ol/source/imagewmssource.js +++ b/src/ol/source/imagewmssource.js @@ -295,7 +295,7 @@ ol.source.ImageWMS.prototype.getRequestUrl_ = switch (this.serverType_) { case ol.source.wms.ServerType.GEOSERVER: var dpi = (90 * pixelRatio + 0.5) | 0; - if (goog.isDef(params['FORMAT_OPTIONS'])) { + if ('FORMAT_OPTIONS' in params) { params['FORMAT_OPTIONS'] += ';dpi:' + dpi; } else { params['FORMAT_OPTIONS'] = 'dpi:' + dpi; diff --git a/src/ol/source/tilewmssource.js b/src/ol/source/tilewmssource.js index a76089d048..c54ab82dd1 100644 --- a/src/ol/source/tilewmssource.js +++ b/src/ol/source/tilewmssource.js @@ -240,7 +240,7 @@ ol.source.TileWMS.prototype.getRequestUrl_ = switch (this.serverType_) { case ol.source.wms.ServerType.GEOSERVER: var dpi = (90 * pixelRatio + 0.5) | 0; - if (goog.isDef(params['FORMAT_OPTIONS'])) { + if ('FORMAT_OPTIONS' in params) { params['FORMAT_OPTIONS'] += ';dpi:' + dpi; } else { params['FORMAT_OPTIONS'] = 'dpi:' + dpi; diff --git a/src/ol/source/wmtssource.js b/src/ol/source/wmtssource.js index 17e24ef6c1..4b6c126538 100644 --- a/src/ol/source/wmtssource.js +++ b/src/ol/source/wmtssource.js @@ -355,7 +355,7 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) { var tileMatrixSets = wmtsCap['Contents']['TileMatrixSet']; var idx, matrixSet; if (l['TileMatrixSetLink'].length > 1) { - if (goog.isDef(config['projection'])) { + if ('projection' in config) { idx = goog.array.findIndex(l['TileMatrixSetLink'], function(elt, index, array) { var tileMatrixSet = goog.array.find(tileMatrixSets, function(el) { @@ -384,11 +384,11 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) { 'TileMatrixSet must not be null'); var format = /** @type {string} */ (l['Format'][0]); - if (goog.isDef(config['format'])) { + if ('format' in config) { format = config['format']; } idx = goog.array.findIndex(l['Style'], function(elt, index, array) { - if (goog.isDef(config['style'])) { + if ('style' in config) { return elt['Title'] == config['style']; } else { return elt['isDefault']; @@ -400,7 +400,7 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) { var style = /** @type {string} */ (l['Style'][idx]['Identifier']); var dimensions = {}; - if (goog.isDef(l['Dimension'])) { + if ('Dimension' in l) { goog.array.forEach(l['Dimension'], function(elt, index, array) { var key = elt['Identifier']; var value = elt['default']; @@ -423,7 +423,7 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) { 'found matrixSet in Contents/TileMatrixSet'); var projection; - if (goog.isDef(config['projection'])) { + if ('projection' in config) { projection = ol.proj.get(config['projection']); } else { projection = ol.proj.get(matrixSetObj['SupportedCRS'].replace( From c48ce003ba4013d8fb31a3679a26b8af11b0fe10 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Sun, 27 Sep 2015 11:03:27 -0600 Subject: [PATCH 83/93] Remove unnecessary goog.isDef() checks from map.js --- src/ol/map.js | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/src/ol/map.js b/src/ol/map.js index dfb9618635..072811a674 100644 --- a/src/ol/map.js +++ b/src/ol/map.js @@ -1201,10 +1201,7 @@ ol.Map.prototype.render = function() { ol.Map.prototype.removeControl = function(control) { var controls = this.getControls(); goog.asserts.assert(controls !== undefined, 'controls should be defined'); - if (goog.isDef(controls.remove(control))) { - return control; - } - return undefined; + return controls.remove(control); }; @@ -1216,14 +1213,10 @@ ol.Map.prototype.removeControl = function(control) { * @api stable */ ol.Map.prototype.removeInteraction = function(interaction) { - var removed; var interactions = this.getInteractions(); goog.asserts.assert(interactions !== undefined, 'interactions should be defined'); - if (goog.isDef(interactions.remove(interaction))) { - removed = interaction; - } - return removed; + return interactions.remove(interaction); }; @@ -1250,10 +1243,7 @@ ol.Map.prototype.removeLayer = function(layer) { ol.Map.prototype.removeOverlay = function(overlay) { var overlays = this.getOverlays(); goog.asserts.assert(overlays !== undefined, 'overlays should be defined'); - if (goog.isDef(overlays.remove(overlay))) { - return overlay; - } - return undefined; + return overlays.remove(overlay); }; From 29a1ea9ae36977482203d81a97e0917b1659e04a Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Sun, 27 Sep 2015 11:13:58 -0600 Subject: [PATCH 84/93] Remove remaining goog.isDef() calls --- src/ol/overlay.js | 2 +- src/ol/proj/proj.js | 2 +- src/ol/renderer/canvas/canvasvectorlayerrenderer.js | 12 ++++++++---- src/ol/renderer/dom/domvectorlayerrenderer.js | 12 ++++++++---- src/ol/renderer/webgl/webglvectorlayerrenderer.js | 12 ++++++++---- src/ol/source/imagevectorsource.js | 7 ++++--- src/ol/view.js | 2 +- 7 files changed, 31 insertions(+), 18 deletions(-) diff --git a/src/ol/overlay.js b/src/ol/overlay.js index 33c12c7cf9..9b2a103c4b 100644 --- a/src/ol/overlay.js +++ b/src/ol/overlay.js @@ -297,7 +297,7 @@ ol.Overlay.prototype.handleOffsetChanged = function() { */ ol.Overlay.prototype.handlePositionChanged = function() { this.updatePixelPosition(); - if (goog.isDef(this.get(ol.OverlayProperty.POSITION)) && this.autoPan) { + if (this.get(ol.OverlayProperty.POSITION) !== undefined && this.autoPan) { this.panIntoView_(); } }; diff --git a/src/ol/proj/proj.js b/src/ol/proj/proj.js index b79aadfefb..260b72d2aa 100644 --- a/src/ol/proj/proj.js +++ b/src/ol/proj/proj.js @@ -653,7 +653,7 @@ ol.proj.get = function(projectionLike) { var code = projectionLike; projection = ol.proj.projections_[code]; if (ol.ENABLE_PROJ4JS && projection === undefined && - typeof proj4 == 'function' && goog.isDef(proj4.defs(code))) { + typeof proj4 == 'function' && proj4.defs(code) !== undefined) { projection = new ol.proj.Projection({code: code}); ol.proj.addProjection(projection); } diff --git a/src/ol/renderer/canvas/canvasvectorlayerrenderer.js b/src/ol/renderer/canvas/canvasvectorlayerrenderer.js index 6c55c66bbd..669937ec61 100644 --- a/src/ol/renderer/canvas/canvasvectorlayerrenderer.js +++ b/src/ol/renderer/canvas/canvasvectorlayerrenderer.js @@ -275,10 +275,14 @@ ol.renderer.canvas.VectorLayer.prototype.prepareFrame = */ function(feature) { var styles; - if (goog.isDef(feature.getStyleFunction())) { - styles = feature.getStyleFunction().call(feature, resolution); - } else if (goog.isDef(vectorLayer.getStyleFunction())) { - styles = vectorLayer.getStyleFunction()(feature, resolution); + var styleFunction = feature.getStyleFunction(); + if (styleFunction) { + styles = styleFunction.call(feature, resolution); + } else { + styleFunction = vectorLayer.getStyleFunction(); + if (styleFunction) { + styles = styleFunction(feature, resolution); + } } if (goog.isDefAndNotNull(styles)) { var dirty = this.renderFeature( diff --git a/src/ol/renderer/dom/domvectorlayerrenderer.js b/src/ol/renderer/dom/domvectorlayerrenderer.js index 65603d5586..0cda31c2a3 100644 --- a/src/ol/renderer/dom/domvectorlayerrenderer.js +++ b/src/ol/renderer/dom/domvectorlayerrenderer.js @@ -283,10 +283,14 @@ ol.renderer.dom.VectorLayer.prototype.prepareFrame = */ function(feature) { var styles; - if (goog.isDef(feature.getStyleFunction())) { - styles = feature.getStyleFunction().call(feature, resolution); - } else if (goog.isDef(vectorLayer.getStyleFunction())) { - styles = vectorLayer.getStyleFunction()(feature, resolution); + var styleFunction = feature.getStyleFunction(); + if (styleFunction) { + styles = styleFunction.call(feature, resolution); + } else { + styleFunction = vectorLayer.getStyleFunction(); + if (styleFunction) { + styles = styleFunction(feature, resolution); + } } if (goog.isDefAndNotNull(styles)) { var dirty = this.renderFeature( diff --git a/src/ol/renderer/webgl/webglvectorlayerrenderer.js b/src/ol/renderer/webgl/webglvectorlayerrenderer.js index 4d5a28f72b..551d4caeff 100644 --- a/src/ol/renderer/webgl/webglvectorlayerrenderer.js +++ b/src/ol/renderer/webgl/webglvectorlayerrenderer.js @@ -256,10 +256,14 @@ ol.renderer.webgl.VectorLayer.prototype.prepareFrame = */ function(feature) { var styles; - if (goog.isDef(feature.getStyleFunction())) { - styles = feature.getStyleFunction().call(feature, resolution); - } else if (goog.isDef(vectorLayer.getStyleFunction())) { - styles = vectorLayer.getStyleFunction()(feature, resolution); + var styleFunction = feature.getStyleFunction(); + if (styleFunction) { + styles = styleFunction.call(feature, resolution); + } else { + styleFunction = vectorLayer.getStyleFunction(); + if (styleFunction) { + styles = styleFunction(feature, resolution); + } } if (goog.isDefAndNotNull(styles)) { var dirty = this.renderFeature( diff --git a/src/ol/source/imagevectorsource.js b/src/ol/source/imagevectorsource.js index f1dd179192..86594e4188 100644 --- a/src/ol/source/imagevectorsource.js +++ b/src/ol/source/imagevectorsource.js @@ -259,9 +259,10 @@ ol.source.ImageVector.prototype.handleSourceChange_ = function() { ol.source.ImageVector.prototype.renderFeature_ = function(feature, resolution, pixelRatio, replayGroup) { var styles; - if (goog.isDef(feature.getStyleFunction())) { - styles = feature.getStyleFunction().call(feature, resolution); - } else if (this.styleFunction_ !== undefined) { + var styleFunction = feature.getStyleFunction(); + if (styleFunction) { + styles = styleFunction.call(feature, resolution); + } else if (this.styleFunction_) { styles = this.styleFunction_(feature, resolution); } if (!goog.isDefAndNotNull(styles)) { diff --git a/src/ol/view.js b/src/ol/view.js index 137fa94dd0..e06c0e670c 100644 --- a/src/ol/view.js +++ b/src/ol/view.js @@ -553,7 +553,7 @@ ol.View.prototype.centerOn = function(coordinate, size, position) { */ ol.View.prototype.isDef = function() { return goog.isDefAndNotNull(this.getCenter()) && - goog.isDef(this.getResolution()); + this.getResolution() !== undefined; }; From f746cb7f57b4e73edcf15a27e074b12cc48c02d1 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Sun, 27 Sep 2015 09:54:11 -0600 Subject: [PATCH 85/93] Use ol.math.clamp() --- src/ol/centerconstraint.js | 6 ++--- src/ol/color/color.js | 12 ++++----- src/ol/control/zoomslidercontrol.js | 4 +-- src/ol/graticule.js | 10 ++++---- .../interaction/mousewheelzoominteraction.js | 4 +-- src/ol/layer/heatmaplayer.js | 5 ++-- src/ol/layer/layerbase.js | 6 ++--- src/ol/layer/layergroup.js | 4 +-- src/ol/math.js | 13 ++++++++++ src/ol/resolutionconstraint.js | 4 +-- src/ol/tilegrid/tilegrid.js | 4 +-- test/spec/ol/math.test.js | 25 +++++++++++++++++++ 12 files changed, 67 insertions(+), 30 deletions(-) diff --git a/src/ol/centerconstraint.js b/src/ol/centerconstraint.js index e67c91082d..b02dd21fa4 100644 --- a/src/ol/centerconstraint.js +++ b/src/ol/centerconstraint.js @@ -1,7 +1,7 @@ goog.provide('ol.CenterConstraint'); goog.provide('ol.CenterConstraintType'); -goog.require('goog.math'); +goog.require('ol.math'); /** @@ -23,8 +23,8 @@ ol.CenterConstraint.createExtent = function(extent) { function(center) { if (center) { return [ - goog.math.clamp(center[0], extent[0], extent[2]), - goog.math.clamp(center[1], extent[1], extent[3]) + ol.math.clamp(center[0], extent[0], extent[2]), + ol.math.clamp(center[1], extent[1], extent[3]) ]; } else { return undefined; diff --git a/src/ol/color/color.js b/src/ol/color/color.js index 98f8cf6abb..519f3a45f6 100644 --- a/src/ol/color/color.js +++ b/src/ol/color/color.js @@ -9,9 +9,9 @@ goog.provide('ol.color'); goog.require('goog.asserts'); goog.require('goog.color'); goog.require('goog.color.names'); -goog.require('goog.math'); goog.require('goog.vec.Mat4'); goog.require('ol'); +goog.require('ol.math'); /** @@ -271,11 +271,11 @@ ol.color.isValid = function(color) { * @return {ol.Color} Clamped color. */ ol.color.normalize = function(color, opt_color) { - var result = opt_color ? opt_color : []; - result[0] = goog.math.clamp((color[0] + 0.5) | 0, 0, 255); - result[1] = goog.math.clamp((color[1] + 0.5) | 0, 0, 255); - result[2] = goog.math.clamp((color[2] + 0.5) | 0, 0, 255); - result[3] = goog.math.clamp(color[3], 0, 1); + var result = opt_color || []; + result[0] = ol.math.clamp((color[0] + 0.5) | 0, 0, 255); + result[1] = ol.math.clamp((color[1] + 0.5) | 0, 0, 255); + result[2] = ol.math.clamp((color[2] + 0.5) | 0, 0, 255); + result[3] = ol.math.clamp(color[3], 0, 1); return result; }; diff --git a/src/ol/control/zoomslidercontrol.js b/src/ol/control/zoomslidercontrol.js index 1f42abdb27..d15c8781d8 100644 --- a/src/ol/control/zoomslidercontrol.js +++ b/src/ol/control/zoomslidercontrol.js @@ -11,7 +11,6 @@ goog.require('goog.events.EventType'); goog.require('goog.fx.DragEvent'); goog.require('goog.fx.Dragger'); goog.require('goog.fx.Dragger.EventType'); -goog.require('goog.math'); goog.require('goog.math.Rect'); goog.require('goog.style'); goog.require('ol.Size'); @@ -20,6 +19,7 @@ goog.require('ol.animation'); goog.require('ol.control.Control'); goog.require('ol.css'); goog.require('ol.easing'); +goog.require('ol.math'); @@ -301,7 +301,7 @@ ol.control.ZoomSlider.prototype.getRelativePosition_ = function(x, y) { } else { amount = (y - draggerLimits.top) / draggerLimits.height; } - return goog.math.clamp(amount, 0, 1); + return ol.math.clamp(amount, 0, 1); }; diff --git a/src/ol/graticule.js b/src/ol/graticule.js index 10b76a8470..9fa4b93be3 100644 --- a/src/ol/graticule.js +++ b/src/ol/graticule.js @@ -1,11 +1,11 @@ goog.provide('ol.Graticule'); goog.require('goog.asserts'); -goog.require('goog.math'); goog.require('ol.extent'); goog.require('ol.geom.GeometryLayout'); goog.require('ol.geom.LineString'); goog.require('ol.geom.flat.geodesic'); +goog.require('ol.math'); goog.require('ol.proj'); goog.require('ol.render.EventType'); goog.require('ol.style.Stroke'); @@ -238,7 +238,7 @@ ol.Graticule.prototype.createGraticule_ = // Create meridians centerLon = Math.floor(centerLon / interval) * interval; - lon = goog.math.clamp(centerLon, this.minLon_, this.maxLon_); + lon = ol.math.clamp(centerLon, this.minLon_, this.maxLon_); idx = this.addMeridian_(lon, minLat, maxLat, squaredTolerance, extent, 0); @@ -248,7 +248,7 @@ ol.Graticule.prototype.createGraticule_ = idx = this.addMeridian_(lon, minLat, maxLat, squaredTolerance, extent, idx); } - lon = goog.math.clamp(centerLon, this.minLon_, this.maxLon_); + lon = ol.math.clamp(centerLon, this.minLon_, this.maxLon_); cnt = 0; while (lon != this.maxLon_ && cnt++ < maxLines) { @@ -261,7 +261,7 @@ ol.Graticule.prototype.createGraticule_ = // Create parallels centerLat = Math.floor(centerLat / interval) * interval; - lat = goog.math.clamp(centerLat, this.minLat_, this.maxLat_); + lat = ol.math.clamp(centerLat, this.minLat_, this.maxLat_); idx = this.addParallel_(lat, minLon, maxLon, squaredTolerance, extent, 0); @@ -271,7 +271,7 @@ ol.Graticule.prototype.createGraticule_ = idx = this.addParallel_(lat, minLon, maxLon, squaredTolerance, extent, idx); } - lat = goog.math.clamp(centerLat, this.minLat_, this.maxLat_); + lat = ol.math.clamp(centerLat, this.minLat_, this.maxLat_); cnt = 0; while (lat != this.maxLat_ && cnt++ < maxLines) { diff --git a/src/ol/interaction/mousewheelzoominteraction.js b/src/ol/interaction/mousewheelzoominteraction.js index 5bbfa95577..6d55735bf8 100644 --- a/src/ol/interaction/mousewheelzoominteraction.js +++ b/src/ol/interaction/mousewheelzoominteraction.js @@ -3,10 +3,10 @@ goog.provide('ol.interaction.MouseWheelZoom'); goog.require('goog.asserts'); goog.require('goog.events.MouseWheelEvent'); goog.require('goog.events.MouseWheelHandler.EventType'); -goog.require('goog.math'); goog.require('ol'); goog.require('ol.Coordinate'); goog.require('ol.interaction.Interaction'); +goog.require('ol.math'); @@ -114,7 +114,7 @@ ol.interaction.MouseWheelZoom.handleEvent = function(mapBrowserEvent) { */ ol.interaction.MouseWheelZoom.prototype.doZoom_ = function(map) { var maxDelta = ol.MOUSEWHEELZOOM_MAXDELTA; - var delta = goog.math.clamp(this.delta_, -maxDelta, maxDelta); + var delta = ol.math.clamp(this.delta_, -maxDelta, maxDelta); var view = map.getView(); goog.asserts.assert(!goog.isNull(view), 'view should not be null'); diff --git a/src/ol/layer/heatmaplayer.js b/src/ol/layer/heatmaplayer.js index 8e9779aa8a..c4bc708a85 100644 --- a/src/ol/layer/heatmaplayer.js +++ b/src/ol/layer/heatmaplayer.js @@ -2,12 +2,12 @@ goog.provide('ol.layer.Heatmap'); goog.require('goog.asserts'); goog.require('goog.events'); -goog.require('goog.math'); goog.require('goog.object'); goog.require('ol'); goog.require('ol.Object'); goog.require('ol.dom'); goog.require('ol.layer.Vector'); +goog.require('ol.math'); goog.require('ol.render.EventType'); goog.require('ol.style.Icon'); goog.require('ol.style.Style'); @@ -111,8 +111,7 @@ ol.layer.Heatmap = function(opt_options) { goog.asserts.assert(this.circleImage_ !== undefined, 'this.circleImage_ should be defined'); var weight = weightFunction(feature); - var opacity = weight !== undefined ? - goog.math.clamp(weight, 0, 1) : 1; + var opacity = weight !== undefined ? ol.math.clamp(weight, 0, 1) : 1; // cast to 8 bits var index = (255 * opacity) | 0; var style = this.styleCache_[index]; diff --git a/src/ol/layer/layerbase.js b/src/ol/layer/layerbase.js index 7417c982b4..f4a3d6d47c 100644 --- a/src/ol/layer/layerbase.js +++ b/src/ol/layer/layerbase.js @@ -2,10 +2,10 @@ goog.provide('ol.layer.Base'); goog.provide('ol.layer.LayerProperty'); goog.provide('ol.layer.LayerState'); -goog.require('goog.math'); goog.require('goog.object'); goog.require('ol'); goog.require('ol.Object'); +goog.require('ol.math'); goog.require('ol.source.State'); @@ -141,10 +141,10 @@ ol.layer.Base.prototype.getLayerState = function() { var minResolution = this.getMinResolution(); return { layer: /** @type {ol.layer.Layer} */ (this), - brightness: goog.math.clamp(brightness, -1, 1), + brightness: ol.math.clamp(brightness, -1, 1), contrast: Math.max(contrast, 0), hue: hue, - opacity: goog.math.clamp(opacity, 0, 1), + opacity: ol.math.clamp(opacity, 0, 1), saturation: Math.max(saturation, 0), sourceState: sourceState, visible: visible, diff --git a/src/ol/layer/layergroup.js b/src/ol/layer/layergroup.js index 647a882407..51c90d5151 100644 --- a/src/ol/layer/layergroup.js +++ b/src/ol/layer/layergroup.js @@ -4,7 +4,6 @@ goog.require('goog.array'); goog.require('goog.asserts'); goog.require('goog.events'); goog.require('goog.events.EventType'); -goog.require('goog.math'); goog.require('goog.object'); goog.require('ol.Collection'); goog.require('ol.CollectionEvent'); @@ -13,6 +12,7 @@ goog.require('ol.Object'); goog.require('ol.ObjectEventType'); goog.require('ol.extent'); goog.require('ol.layer.Base'); +goog.require('ol.math'); goog.require('ol.source.State'); @@ -215,7 +215,7 @@ ol.layer.Group.prototype.getLayerStatesArray = function(opt_states) { var i, ii, layerState; for (i = pos, ii = states.length; i < ii; i++) { layerState = states[i]; - layerState.brightness = goog.math.clamp( + layerState.brightness = ol.math.clamp( layerState.brightness + ownLayerState.brightness, -1, 1); layerState.contrast *= ownLayerState.contrast; layerState.hue += ownLayerState.hue; diff --git a/src/ol/math.js b/src/ol/math.js index c6a3a94f81..0d2e582d44 100644 --- a/src/ol/math.js +++ b/src/ol/math.js @@ -3,6 +3,19 @@ goog.provide('ol.math'); goog.require('goog.asserts'); +/** + * Takes a number and clamps it to within the provided bounds. + * @param {number} value The input number. + * @param {number} min The minimum value to return. + * @param {number} max The maximum value to return. + * @return {number} The input number if it is within bounds, or the nearest + * number within the bounds. + */ +ol.math.clamp = function(value, min, max) { + return Math.min(Math.max(value, min), max); +}; + + /** * @param {number} x X. * @return {number} Hyperbolic cosine of x. diff --git a/src/ol/resolutionconstraint.js b/src/ol/resolutionconstraint.js index be38b6d2aa..9c128ff2e7 100644 --- a/src/ol/resolutionconstraint.js +++ b/src/ol/resolutionconstraint.js @@ -1,8 +1,8 @@ goog.provide('ol.ResolutionConstraint'); goog.provide('ol.ResolutionConstraintType'); -goog.require('goog.math'); goog.require('ol.array'); +goog.require('ol.math'); /** @@ -28,7 +28,7 @@ ol.ResolutionConstraint.createSnapToResolutions = if (resolution !== undefined) { var z = ol.array.linearFindNearest(resolutions, resolution, direction); - z = goog.math.clamp(z + delta, 0, resolutions.length - 1); + z = ol.math.clamp(z + delta, 0, resolutions.length - 1); return resolutions[z]; } else { return undefined; diff --git a/src/ol/tilegrid/tilegrid.js b/src/ol/tilegrid/tilegrid.js index 8d6073eb2a..08b03610c7 100644 --- a/src/ol/tilegrid/tilegrid.js +++ b/src/ol/tilegrid/tilegrid.js @@ -2,7 +2,6 @@ goog.provide('ol.tilegrid.TileGrid'); goog.require('goog.array'); goog.require('goog.asserts'); -goog.require('goog.math'); goog.require('goog.object'); goog.require('ol'); goog.require('ol.Coordinate'); @@ -11,6 +10,7 @@ goog.require('ol.TileRange'); goog.require('ol.array'); goog.require('ol.extent'); goog.require('ol.extent.Corner'); +goog.require('ol.math'); goog.require('ol.proj'); goog.require('ol.proj.METERS_PER_UNIT'); goog.require('ol.proj.Projection'); @@ -483,7 +483,7 @@ ol.tilegrid.TileGrid.prototype.getFullTileRange = function(z) { */ ol.tilegrid.TileGrid.prototype.getZForResolution = function(resolution) { var z = ol.array.linearFindNearest(this.resolutions_, resolution, 0); - return goog.math.clamp(z, this.minZoom, this.maxZoom); + return ol.math.clamp(z, this.minZoom, this.maxZoom); }; diff --git a/test/spec/ol/math.test.js b/test/spec/ol/math.test.js index a73247469a..44b41ccc23 100644 --- a/test/spec/ol/math.test.js +++ b/test/spec/ol/math.test.js @@ -1,6 +1,31 @@ goog.provide('ol.test.math'); +describe('ol.math.clamp', function() { + + it('returns the correct value at -Infinity', function() { + expect(ol.math.clamp(-Infinity, 10, 20)).to.eql(10); + }); + + it('returns the correct value at min', function() { + expect(ol.math.clamp(10, 10, 20)).to.eql(10); + }); + + it('returns the correct value at mid point', function() { + expect(ol.math.clamp(15, 10, 20)).to.eql(15); + }); + + it('returns the correct value at max', function() { + expect(ol.math.clamp(20, 10, 20)).to.eql(20); + }); + + it('returns the correct value at Infinity', function() { + expect(ol.math.clamp(Infinity, 10, 20)).to.eql(20); + }); + +}); + + describe('ol.math.cosh', function() { it('returns the correct value at -Infinity', function() { From 4e48170fac5cd53929f9ec8ebb1f5f85e3a77881 Mon Sep 17 00:00:00 2001 From: Andreas Hocevar Date: Sat, 26 Sep 2015 10:50:50 +0200 Subject: [PATCH 86/93] Only animate when resolution is about to be changed --- src/ol/interaction/interaction.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ol/interaction/interaction.js b/src/ol/interaction/interaction.js index 07cbff4518..be0aa3cbfd 100644 --- a/src/ol/interaction/interaction.js +++ b/src/ol/interaction/interaction.js @@ -222,6 +222,7 @@ ol.interaction.Interaction.zoomWithoutConstraints = var currentResolution = view.getResolution(); var currentCenter = view.getCenter(); if (currentResolution !== undefined && currentCenter && + resolution !== currentResolution && opt_duration && opt_duration > 0) { map.beforeRender(ol.animation.zoom({ resolution: /** @type {number} */ (currentResolution), From d6f03697d7673ed57decdf92cb5d37f03a1f5323 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Mon, 21 Sep 2015 07:34:41 +0900 Subject: [PATCH 87/93] Remove hue, saturation, contrast, and brightness --- examples/brightness-contrast.css | 7 - examples/brightness-contrast.html | 27 -- examples/brightness-contrast.js | 75 ----- examples/hue-saturation.css | 6 - examples/hue-saturation.html | 26 -- examples/hue-saturation.js | 79 ------ examples/layer-group.html | 32 --- examples/layer-group.js | 14 +- externs/olx.js | 266 +----------------- src/ol/color/colormatrix.js | 209 -------------- src/ol/layer/layerbase.js | 136 --------- src/ol/layer/layergroup.js | 5 - src/ol/render/webgl/webglimagecolor.glsl | 46 --- src/ol/render/webgl/webglimagecolorshader.js | 156 ---------- src/ol/render/webgl/webglimmediate.js | 17 +- src/ol/render/webgl/webglreplay.js | 103 ++----- src/ol/renderer/webgl/webgllayerrenderer.js | 65 +---- src/ol/renderer/webgl/webglmapcolor.glsl | 32 --- src/ol/renderer/webgl/webglmapcolorshader.js | 132 --------- .../webgl/webglvectorlayerrenderer.js | 11 +- test/spec/ol/layer/layer.test.js | 208 -------------- test/spec/ol/layer/layergroup.test.js | 80 ------ 22 files changed, 46 insertions(+), 1686 deletions(-) delete mode 100644 examples/brightness-contrast.css delete mode 100644 examples/brightness-contrast.html delete mode 100644 examples/brightness-contrast.js delete mode 100644 examples/hue-saturation.css delete mode 100644 examples/hue-saturation.html delete mode 100644 examples/hue-saturation.js delete mode 100644 src/ol/color/colormatrix.js delete mode 100644 src/ol/render/webgl/webglimagecolor.glsl delete mode 100644 src/ol/render/webgl/webglimagecolorshader.js delete mode 100644 src/ol/renderer/webgl/webglmapcolor.glsl delete mode 100644 src/ol/renderer/webgl/webglmapcolorshader.js diff --git a/examples/brightness-contrast.css b/examples/brightness-contrast.css deleted file mode 100644 index 273b443f89..0000000000 --- a/examples/brightness-contrast.css +++ /dev/null @@ -1,7 +0,0 @@ -#reset-brightness { - min-width: 138px; -} -#reset-contrast { - min-width: 120px; -} - diff --git a/examples/brightness-contrast.html b/examples/brightness-contrast.html deleted file mode 100644 index 14022384e2..0000000000 --- a/examples/brightness-contrast.html +++ /dev/null @@ -1,27 +0,0 @@ ---- -template: example.html -title: Brightness/contrast example -shortdesc: Example of brightness/contrast control on the client (WebGL only). -docs: > - This example shows how to control brightness/contrast on the client, - the example is limited to WebGL. -tags: "brightness, contrast, webgl" ---- -
-
-
- -
- - - -
-
- - - -
-
-
diff --git a/examples/brightness-contrast.js b/examples/brightness-contrast.js deleted file mode 100644 index b5d38b0f89..0000000000 --- a/examples/brightness-contrast.js +++ /dev/null @@ -1,75 +0,0 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.has'); -goog.require('ol.layer.Tile'); -goog.require('ol.source.MapQuest'); - - -function setResetBrightnessButtonHTML() { - resetBrightness.innerHTML = 'Brightness (' + - layer.getBrightness().toFixed(3) + ')'; -} - -function setResetContrastButtonHTML() { - resetContrast.innerHTML = 'Contrast (' + layer.getContrast().toFixed(3) + ')'; -} - -if (!ol.has.WEBGL) { - var info = document.getElementById('no-webgl'); - /** - * display error message - */ - info.style.display = ''; -} else { - var layer = new ol.layer.Tile({ - source: new ol.source.MapQuest({layer: 'sat'}) - }); - - var map = new ol.Map({ - layers: [layer], - renderer: 'webgl', - target: 'map', - view: new ol.View({ - center: [0, 0], - zoom: 2 - }) - }); - - var increaseBrightness = document.getElementById('increase-brightness'); - var resetBrightness = document.getElementById('reset-brightness'); - var decreaseBrightness = document.getElementById('decrease-brightness'); - - setResetBrightnessButtonHTML(); - - increaseBrightness.addEventListener('click', function() { - layer.setBrightness(Math.min(layer.getBrightness() + 0.125, 1)); - setResetBrightnessButtonHTML(); - }, false); - resetBrightness.addEventListener('click', function() { - layer.setBrightness(0); - setResetBrightnessButtonHTML(); - }, false); - decreaseBrightness.addEventListener('click', function() { - layer.setBrightness(Math.max(layer.getBrightness() - 0.125, -1)); - setResetBrightnessButtonHTML(); - }, false); - - var increaseContrast = document.getElementById('increase-contrast'); - var resetContrast = document.getElementById('reset-contrast'); - var decreaseContrast = document.getElementById('decrease-contrast'); - - setResetContrastButtonHTML(); - - increaseContrast.addEventListener('click', function() { - layer.setContrast(layer.getContrast() + 0.125); - setResetContrastButtonHTML(); - }, false); - resetContrast.addEventListener('click', function() { - layer.setContrast(1); - setResetContrastButtonHTML(); - }, false); - decreaseContrast.addEventListener('click', function() { - layer.setContrast(Math.max(layer.getContrast() - 0.125, 0)); - setResetContrastButtonHTML(); - }, false); -} diff --git a/examples/hue-saturation.css b/examples/hue-saturation.css deleted file mode 100644 index 59a9ea8a69..0000000000 --- a/examples/hue-saturation.css +++ /dev/null @@ -1,6 +0,0 @@ -#reset-hue { - min-width: 90px; -} -#reset-saturation { - min-width: 124px; -} diff --git a/examples/hue-saturation.html b/examples/hue-saturation.html deleted file mode 100644 index 59d4d34f56..0000000000 --- a/examples/hue-saturation.html +++ /dev/null @@ -1,26 +0,0 @@ ---- -template: example.html -title: Hue/saturation example -shortdesc: Example of hue/saturation control on the client (WebGL only). -docs: > - Example of hue/saturation control on the client (WebGL only). -tags: "custom, control" ---- -
-
-
- -
- - - -
-
- - - -
-
-
diff --git a/examples/hue-saturation.js b/examples/hue-saturation.js deleted file mode 100644 index afbbf3a79a..0000000000 --- a/examples/hue-saturation.js +++ /dev/null @@ -1,79 +0,0 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.has'); -goog.require('ol.layer.Tile'); -goog.require('ol.proj'); -goog.require('ol.source.BingMaps'); - - -function setResetHueButtonHTML() { - resetHue.innerHTML = 'Hue (' + layer.getHue().toFixed(2) + ')'; -} - -function setResetSaturationButtonHTML() { - resetSaturation.innerHTML = 'Saturation (' + - layer.getSaturation().toFixed(2) + ')'; -} - -if (!ol.has.WEBGL) { - var info = document.getElementById('no-webgl'); - /** - * display error message - */ - info.style.display = ''; -} else { - var layer = new ol.layer.Tile({ - source: new ol.source.BingMaps({ - key: 'Ak-dzM4wZjSqTlzveKz5u0d4IQ4bRzVI309GxmkgSVr1ewS6iPSrOvOKhA-CJlm3', - imagerySet: 'Aerial' - }) - }); - - var map = new ol.Map({ - layers: [layer], - renderer: 'webgl', - target: 'map', - view: new ol.View({ - center: ol.proj.fromLonLat([-9.375, 51.483333]), - zoom: 15 - }) - }); - - var increaseHue = document.getElementById('increase-hue'); - var resetHue = document.getElementById('reset-hue'); - var decreaseHue = document.getElementById('decrease-hue'); - - setResetHueButtonHTML(); - - increaseHue.addEventListener('click', function() { - layer.setHue(layer.getHue() + 0.25); - setResetHueButtonHTML(); - }, false); - resetHue.addEventListener('click', function() { - layer.setHue(0); - setResetHueButtonHTML(); - }, false); - decreaseHue.addEventListener('click', function() { - layer.setHue(layer.getHue() - 0.25); - setResetHueButtonHTML(); - }, false); - - var increaseSaturation = document.getElementById('increase-saturation'); - var resetSaturation = document.getElementById('reset-saturation'); - var decreaseSaturation = document.getElementById('decrease-saturation'); - - setResetSaturationButtonHTML(); - - increaseSaturation.addEventListener('click', function() { - layer.setSaturation(layer.getSaturation() + 0.25); - setResetSaturationButtonHTML(); - }, false); - resetSaturation.addEventListener('click', function() { - layer.setSaturation(1); - setResetSaturationButtonHTML(); - }, false); - decreaseSaturation.addEventListener('click', function() { - layer.setSaturation(Math.max(layer.getSaturation() - 0.25, 0)); - setResetSaturationButtonHTML(); - }, false); -} diff --git a/examples/layer-group.html b/examples/layer-group.html index cf3104cc98..c593f289c0 100644 --- a/examples/layer-group.html +++ b/examples/layer-group.html @@ -20,14 +20,6 @@ tags: "tilejson, input, bind, group, layergroup" - - - - - - - -
  • Layer group @@ -37,14 +29,6 @@ tags: "tilejson, input, bind, group, layergroup" - - - - - - - -
    • Food insecurity layer @@ -54,14 +38,6 @@ tags: "tilejson, input, bind, group, layergroup" - - - - - - - -
    • World borders layer @@ -71,14 +47,6 @@ tags: "tilejson, input, bind, group, layergroup" - - - - - - - -
    diff --git a/examples/layer-group.js b/examples/layer-group.js index 701feb38c3..f3e6f1400b 100644 --- a/examples/layer-group.js +++ b/examples/layer-group.js @@ -44,15 +44,11 @@ function bindInputs(layerid, layer) { }); visibilityInput.prop('checked', layer.getVisible()); - $.each(['opacity', 'hue', 'saturation', 'contrast', 'brightness'], - function(i, v) { - var input = $(layerid + ' input.' + v); - input.on('input change', function() { - layer.set(v, parseFloat(this.value)); - }); - input.val(String(layer.get(v))); - } - ); + var opacityInput = $(layerid + ' input.opacity'); + opacityInput.on('input change', function() { + layer.setOpacity(parseFloat(this.value)); + }); + opacityInput.val(String(layer.getOpacity())); } map.getLayers().forEach(function(layer, i) { bindInputs('#layer' + i, layer); diff --git a/externs/olx.js b/externs/olx.js index a430044773..4a0cdeec82 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -2964,11 +2964,7 @@ olx.layer; /** - * @typedef {{brightness: (number|undefined), - * contrast: (number|undefined), - * hue: (number|undefined), - * opacity: (number|undefined), - * saturation: (number|undefined), + * @typedef {{opacity: (number|undefined), * visible: (boolean|undefined), * extent: (ol.Extent|undefined), * zIndex: (number|undefined), @@ -2979,30 +2975,6 @@ olx.layer; olx.layer.BaseOptions; -/** - * Brightness. Default is `0`. - * @type {number|undefined} - * @api - */ -olx.layer.BaseOptions.prototype.brightness; - - -/** - * Contrast. Default is `1`. - * @type {number|undefined} - * @api - */ -olx.layer.BaseOptions.prototype.contrast; - - -/** - * Hue. Default is `0`. - * @type {number|undefined} - * @api - */ -olx.layer.BaseOptions.prototype.hue; - - /** * Opacity (0, 1). Default is `1`. * @type {number|undefined} @@ -3011,14 +2983,6 @@ olx.layer.BaseOptions.prototype.hue; olx.layer.BaseOptions.prototype.opacity; -/** - * Saturation. Default is `1`. - * @type {number|undefined} - * @api - */ -olx.layer.BaseOptions.prototype.saturation; - - /** * Visibility. Default is `true`. * @type {boolean|undefined} @@ -3062,11 +3026,7 @@ olx.layer.BaseOptions.prototype.maxResolution; /** - * @typedef {{brightness: (number|undefined), - * contrast: (number|undefined), - * hue: (number|undefined), - * opacity: (number|undefined), - * saturation: (number|undefined), + * @typedef {{opacity: (number|undefined), * source: (ol.source.Source|undefined), * visible: (boolean|undefined), * extent: (ol.Extent|undefined), @@ -3078,30 +3038,6 @@ olx.layer.BaseOptions.prototype.maxResolution; olx.layer.LayerOptions; -/** - * Brightness. Default is `0`. - * @type {number|undefined} - * @api - */ -olx.layer.LayerOptions.prototype.brightness; - - -/** - * Contrast. Default is `1`. - * @type {number|undefined} - * @api - */ -olx.layer.LayerOptions.prototype.contrast; - - -/** - * Hue. Default is `0`. - * @type {number|undefined} - * @api - */ -olx.layer.LayerOptions.prototype.hue; - - /** * Opacity (0, 1). Default is `1`. * @type {number|undefined} @@ -3110,14 +3046,6 @@ olx.layer.LayerOptions.prototype.hue; olx.layer.LayerOptions.prototype.opacity; -/** - * Saturation. Default is `1`. - * @type {number|undefined} - * @api - */ -olx.layer.LayerOptions.prototype.saturation; - - /** * Source for this layer. If not provided to the constructor, the source can * be set by calling {@link ol.layer.Layer#setSource layer.setSource(source)} @@ -3171,11 +3099,7 @@ olx.layer.LayerOptions.prototype.maxResolution; /** - * @typedef {{brightness: (number|undefined), - * contrast: (number|undefined), - * hue: (number|undefined), - * opacity: (number|undefined), - * saturation: (number|undefined), + * @typedef {{opacity: (number|undefined), * visible: (boolean|undefined), * extent: (ol.Extent|undefined), * zIndex: (number|undefined), @@ -3187,30 +3111,6 @@ olx.layer.LayerOptions.prototype.maxResolution; olx.layer.GroupOptions; -/** - * Brightness. Default is `0`. - * @type {number|undefined} - * @api - */ -olx.layer.GroupOptions.prototype.brightness; - - -/** - * Contrast. Default is `1`. - * @type {number|undefined} - * @api - */ -olx.layer.GroupOptions.prototype.contrast; - - -/** - * Hue. Default is `0`. - * @type {number|undefined} - * @api - */ -olx.layer.GroupOptions.prototype.hue; - - /** * Opacity (0, 1). Default is `1`. * @type {number|undefined} @@ -3219,14 +3119,6 @@ olx.layer.GroupOptions.prototype.hue; olx.layer.GroupOptions.prototype.opacity; -/** - * Saturation. Default is `1`. - * @type {number|undefined} - * @api - */ -olx.layer.GroupOptions.prototype.saturation; - - /** * Visibility. Default is `true`. * @type {boolean|undefined} @@ -3278,10 +3170,7 @@ olx.layer.GroupOptions.prototype.layers; /** - * @typedef {{brightness: (number|undefined), - * contrast: (number|undefined), - * hue: (number|undefined), - * gradient: (Array.|undefined), + * @typedef {{gradient: (Array.|undefined), * radius: (number|undefined), * blur: (number|undefined), * shadow: (number|undefined), @@ -3290,7 +3179,6 @@ olx.layer.GroupOptions.prototype.layers; * minResolution: (number|undefined), * maxResolution: (number|undefined), * opacity: (number|undefined), - * saturation: (number|undefined), * source: (ol.source.Vector|undefined), * visible: (boolean|undefined)}} * @api @@ -3298,30 +3186,6 @@ olx.layer.GroupOptions.prototype.layers; olx.layer.HeatmapOptions; -/** - * Brightness. - * @type {number|undefined} - * @api - */ -olx.layer.HeatmapOptions.prototype.brightness; - - -/** - * Contrast. - * @type {number|undefined} - * @api - */ -olx.layer.HeatmapOptions.prototype.contrast; - - -/** - * Hue. - * @type {number|undefined} - * @api - */ -olx.layer.HeatmapOptions.prototype.hue; - - /** * The color gradient of the heatmap, specified as an array of CSS color * strings. Default is `['#00f', '#0ff', '#0f0', '#ff0', '#f00']`. @@ -3398,14 +3262,6 @@ olx.layer.HeatmapOptions.prototype.maxResolution; olx.layer.HeatmapOptions.prototype.opacity; -/** - * Saturation. - * @type {number|undefined} - * @api - */ -olx.layer.HeatmapOptions.prototype.saturation; - - /** * Source. * @type {ol.source.Vector} @@ -3423,11 +3279,7 @@ olx.layer.HeatmapOptions.prototype.visible; /** - * @typedef {{brightness: (number|undefined), - * contrast: (number|undefined), - * hue: (number|undefined), - * opacity: (number|undefined), - * saturation: (number|undefined), + * @typedef {{opacity: (number|undefined), * map: (ol.Map|undefined), * source: (ol.source.Image|undefined), * visible: (boolean|undefined), @@ -3439,30 +3291,6 @@ olx.layer.HeatmapOptions.prototype.visible; olx.layer.ImageOptions; -/** - * Brightness. Default is `0`. - * @type {number|undefined} - * @api - */ -olx.layer.ImageOptions.prototype.brightness; - - -/** - * Contrast. Default is `1`. - * @type {number|undefined} - * @api - */ -olx.layer.ImageOptions.prototype.contrast; - - -/** - * Hue. Default is `0`. - * @type {number|undefined} - * @api - */ -olx.layer.ImageOptions.prototype.hue; - - /** * Opacity (0, 1). Default is `1`. * @type {number|undefined} @@ -3471,14 +3299,6 @@ olx.layer.ImageOptions.prototype.hue; olx.layer.ImageOptions.prototype.opacity; -/** - * Saturation. Default is `1`. - * @type {number|undefined} - * @api - */ -olx.layer.ImageOptions.prototype.saturation; - - /** * Source for this layer. * @type {ol.source.Image} @@ -3532,12 +3352,8 @@ olx.layer.ImageOptions.prototype.maxResolution; /** - * @typedef {{brightness: (number|undefined), - * contrast: (number|undefined), - * hue: (number|undefined), - * opacity: (number|undefined), + * @typedef {{opacity: (number|undefined), * preload: (number|undefined), - * saturation: (number|undefined), * source: (ol.source.Tile|undefined), * map: (ol.Map|undefined), * visible: (boolean|undefined), @@ -3550,30 +3366,6 @@ olx.layer.ImageOptions.prototype.maxResolution; olx.layer.TileOptions; -/** - * Brightness. Default is `0`. - * @type {number|undefined} - * @api - */ -olx.layer.TileOptions.prototype.brightness; - - -/** - * Contrast. Default is `1`. - * @type {number|undefined} - * @api - */ -olx.layer.TileOptions.prototype.contrast; - - -/** - * Hue. Default is `0`. - * @type {number|undefined} - * @api - */ -olx.layer.TileOptions.prototype.hue; - - /** * Opacity (0, 1). Default is `1`. * @type {number|undefined} @@ -3591,14 +3383,6 @@ olx.layer.TileOptions.prototype.opacity; olx.layer.TileOptions.prototype.preload; -/** - * Saturation. Default is `1`. - * @type {number|undefined} - * @api - */ -olx.layer.TileOptions.prototype.saturation; - - /** * Source for this layer. * @type {ol.source.Tile} @@ -3660,15 +3444,11 @@ olx.layer.TileOptions.prototype.useInterimTilesOnError; /** - * @typedef {{brightness: (number|undefined), - * contrast: (number|undefined), - * renderOrder: (function(ol.Feature, ol.Feature):number|null|undefined), - * hue: (number|undefined), + * @typedef {{renderOrder: (function(ol.Feature, ol.Feature):number|null|undefined), * minResolution: (number|undefined), * maxResolution: (number|undefined), * opacity: (number|undefined), * renderBuffer: (number|undefined), - * saturation: (number|undefined), * source: (ol.source.Vector|undefined), * map: (ol.Map|undefined), * style: (ol.style.Style|Array.|ol.style.StyleFunction|undefined), @@ -3680,22 +3460,6 @@ olx.layer.TileOptions.prototype.useInterimTilesOnError; olx.layer.VectorOptions; -/** - * Brightness. - * @type {number|undefined} - * @api - */ -olx.layer.VectorOptions.prototype.brightness; - - -/** - * Contrast. - * @type {number|undefined} - * @api - */ -olx.layer.VectorOptions.prototype.contrast; - - /** * Render order. Function to be used when sorting features before rendering. By * default features are drawn in the order that they are created. Use `null` to @@ -3706,14 +3470,6 @@ olx.layer.VectorOptions.prototype.contrast; olx.layer.VectorOptions.prototype.renderOrder; -/** - * Hue. - * @type {number|undefined} - * @api - */ -olx.layer.VectorOptions.prototype.hue; - - /** * Sets the layer as overlay on a map. The map will not manage this layer in its * layers collection, and the layer will be rendered on top. This is useful for @@ -3769,14 +3525,6 @@ olx.layer.VectorOptions.prototype.opacity; olx.layer.VectorOptions.prototype.renderBuffer; -/** - * Saturation. - * @type {number|undefined} - * @api - */ -olx.layer.VectorOptions.prototype.saturation; - - /** * Source. * @type {ol.source.Vector} diff --git a/src/ol/color/colormatrix.js b/src/ol/color/colormatrix.js deleted file mode 100644 index 31ae21d1aa..0000000000 --- a/src/ol/color/colormatrix.js +++ /dev/null @@ -1,209 +0,0 @@ -goog.provide('ol.color.Matrix'); - -goog.require('goog.vec.Mat4'); -goog.require('ol'); - - - -/** - * @constructor - */ -ol.color.Matrix = function() { - - /** - * @private - * @type {!goog.vec.Mat4.Number} - */ - this.colorMatrix_ = goog.vec.Mat4.createNumber(); - - /** - * @private - * @type {number|undefined} - */ - this.brightness_ = undefined; - - /** - * @private - * @type {!goog.vec.Mat4.Number} - */ - this.brightnessMatrix_ = goog.vec.Mat4.createNumber(); - - /** - * @private - * @type {number|undefined} - */ - this.contrast_ = undefined; - - /** - * @private - * @type {!goog.vec.Mat4.Number} - */ - this.contrastMatrix_ = goog.vec.Mat4.createNumber(); - - /** - * @private - * @type {number|undefined} - */ - this.hue_ = undefined; - - /** - * @private - * @type {!goog.vec.Mat4.Number} - */ - this.hueMatrix_ = goog.vec.Mat4.createNumber(); - - /** - * @private - * @type {number|undefined} - */ - this.saturation_ = undefined; - - /** - * @private - * @type {!goog.vec.Mat4.Number} - */ - this.saturationMatrix_ = goog.vec.Mat4.createNumber(); - -}; - - -/** - * @param {!goog.vec.Mat4.Number} matrix Matrix. - * @param {number} value Brightness value. - * @return {!goog.vec.Mat4.Number} Matrix. - */ -ol.color.Matrix.makeBrightness = function(matrix, value) { - goog.vec.Mat4.makeTranslate(matrix, value, value, value); - return matrix; -}; - - -/** - * @param {!goog.vec.Mat4.Number} matrix Matrix. - * @param {number} value Contrast value. - * @return {!goog.vec.Mat4.Number} Matrix. - */ -ol.color.Matrix.makeContrast = function(matrix, value) { - goog.vec.Mat4.makeScale(matrix, value, value, value); - var translateValue = (-0.5 * value + 0.5); - goog.vec.Mat4.setColumnValues(matrix, 3, - translateValue, translateValue, translateValue, 1); - return matrix; -}; - - -/** - * @param {!goog.vec.Mat4.Number} matrix Matrix. - * @param {number} value Hue value. - * @return {!goog.vec.Mat4.Number} Matrix. - */ -ol.color.Matrix.makeHue = function(matrix, value) { - var cosHue = Math.cos(value); - var sinHue = Math.sin(value); - var v00 = 0.213 + cosHue * 0.787 - sinHue * 0.213; - var v01 = 0.715 - cosHue * 0.715 - sinHue * 0.715; - var v02 = 0.072 - cosHue * 0.072 + sinHue * 0.928; - var v03 = 0; - var v10 = 0.213 - cosHue * 0.213 + sinHue * 0.143; - var v11 = 0.715 + cosHue * 0.285 + sinHue * 0.140; - var v12 = 0.072 - cosHue * 0.072 - sinHue * 0.283; - var v13 = 0; - var v20 = 0.213 - cosHue * 0.213 - sinHue * 0.787; - var v21 = 0.715 - cosHue * 0.715 + sinHue * 0.715; - var v22 = 0.072 + cosHue * 0.928 + sinHue * 0.072; - var v23 = 0; - var v30 = 0; - var v31 = 0; - var v32 = 0; - var v33 = 1; - goog.vec.Mat4.setFromValues(matrix, - v00, v10, v20, v30, - v01, v11, v21, v31, - v02, v12, v22, v32, - v03, v13, v23, v33); - return matrix; -}; - - -/** - * @param {!goog.vec.Mat4.Number} matrix Matrix. - * @param {number} value Saturation value. - * @return {!goog.vec.Mat4.Number} Matrix. - */ -ol.color.Matrix.makeSaturation = function(matrix, value) { - var v00 = 0.213 + 0.787 * value; - var v01 = 0.715 - 0.715 * value; - var v02 = 0.072 - 0.072 * value; - var v03 = 0; - var v10 = 0.213 - 0.213 * value; - var v11 = 0.715 + 0.285 * value; - var v12 = 0.072 - 0.072 * value; - var v13 = 0; - var v20 = 0.213 - 0.213 * value; - var v21 = 0.715 - 0.715 * value; - var v22 = 0.072 + 0.928 * value; - var v23 = 0; - var v30 = 0; - var v31 = 0; - var v32 = 0; - var v33 = 1; - goog.vec.Mat4.setFromValues(matrix, - v00, v10, v20, v30, - v01, v11, v21, v31, - v02, v12, v22, v32, - v03, v13, v23, v33); - return matrix; -}; - - -/** - * @param {number|undefined} brightness Brightness. - * @param {number|undefined} contrast Contrast. - * @param {number|undefined} hue Hue. - * @param {number|undefined} saturation Saturation. - * @return {!goog.vec.Mat4.Number} Matrix. - */ -ol.color.Matrix.prototype.getMatrix = function( - brightness, contrast, hue, saturation) { - var colorMatrixDirty = false; - if (brightness !== undefined && brightness !== this.brightness_) { - ol.color.Matrix.makeBrightness(this.brightnessMatrix_, - /** @type {number} */ (brightness)); - this.brightness_ = brightness; - colorMatrixDirty = true; - } - if (contrast !== undefined && contrast !== this.contrast_) { - ol.color.Matrix.makeContrast(this.contrastMatrix_, - /** @type {number} */ (contrast)); - this.contrast_ = contrast; - colorMatrixDirty = true; - } - if (hue !== undefined && hue !== this.hue_) { - ol.color.Matrix.makeHue(this.hueMatrix_, /** @type {number} */ (hue)); - this.hue_ = hue; - colorMatrixDirty = true; - } - if (saturation !== undefined && saturation !== this.saturation_) { - ol.color.Matrix.makeSaturation(this.saturationMatrix_, - /** @type {number} */ (saturation)); - this.saturation_ = saturation; - colorMatrixDirty = true; - } - if (colorMatrixDirty) { - var colorMatrix = this.colorMatrix_; - goog.vec.Mat4.makeIdentity(colorMatrix); - if (contrast !== undefined) { - goog.vec.Mat4.multMat(colorMatrix, this.contrastMatrix_, colorMatrix); - } - if (brightness !== undefined) { - goog.vec.Mat4.multMat(colorMatrix, this.brightnessMatrix_, colorMatrix); - } - if (saturation !== undefined) { - goog.vec.Mat4.multMat(colorMatrix, this.saturationMatrix_, colorMatrix); - } - if (hue !== undefined) { - goog.vec.Mat4.multMat(colorMatrix, this.hueMatrix_, colorMatrix); - } - } - return this.colorMatrix_; -}; diff --git a/src/ol/layer/layerbase.js b/src/ol/layer/layerbase.js index f4a3d6d47c..610111f2d8 100644 --- a/src/ol/layer/layerbase.js +++ b/src/ol/layer/layerbase.js @@ -13,11 +13,7 @@ goog.require('ol.source.State'); * @enum {string} */ ol.layer.LayerProperty = { - BRIGHTNESS: 'brightness', - CONTRAST: 'contrast', - HUE: 'hue', OPACITY: 'opacity', - SATURATION: 'saturation', VISIBLE: 'visible', EXTENT: 'extent', Z_INDEX: 'zIndex', @@ -29,11 +25,7 @@ ol.layer.LayerProperty = { /** * @typedef {{layer: ol.layer.Layer, - * brightness: number, - * contrast: number, - * hue: number, * opacity: number, - * saturation: number, * sourceState: ol.source.State, * visible: boolean, * managed: boolean, @@ -67,16 +59,8 @@ ol.layer.Base = function(options) { * @type {Object.} */ var properties = goog.object.clone(options); - properties[ol.layer.LayerProperty.BRIGHTNESS] = - options.brightness !== undefined ? options.brightness : 0; - properties[ol.layer.LayerProperty.CONTRAST] = - options.contrast !== undefined ? options.contrast : 1; - properties[ol.layer.LayerProperty.HUE] = - options.hue !== undefined ? options.hue : 0; properties[ol.layer.LayerProperty.OPACITY] = options.opacity !== undefined ? options.opacity : 1; - properties[ol.layer.LayerProperty.SATURATION] = - options.saturation !== undefined ? options.saturation : 1; properties[ol.layer.LayerProperty.VISIBLE] = options.visible !== undefined ? options.visible : true; properties[ol.layer.LayerProperty.Z_INDEX] = @@ -91,48 +75,11 @@ ol.layer.Base = function(options) { goog.inherits(ol.layer.Base, ol.Object); -/** - * Return the brightness of the layer. - * @return {number} The brightness of the layer. - * @observable - * @api - */ -ol.layer.Base.prototype.getBrightness = function() { - return /** @type {number} */ (this.get(ol.layer.LayerProperty.BRIGHTNESS)); -}; - - -/** - * Return the contrast of the layer. - * @return {number} The contrast of the layer. - * @observable - * @api - */ -ol.layer.Base.prototype.getContrast = function() { - return /** @type {number} */ (this.get(ol.layer.LayerProperty.CONTRAST)); -}; - - -/** - * Return the hue of the layer. - * @return {number} The hue of the layer. - * @observable - * @api - */ -ol.layer.Base.prototype.getHue = function() { - return /** @type {number} */ (this.get(ol.layer.LayerProperty.HUE)); -}; - - /** * @return {ol.layer.LayerState} Layer state. */ ol.layer.Base.prototype.getLayerState = function() { - var brightness = this.getBrightness(); - var contrast = this.getContrast(); - var hue = this.getHue(); var opacity = this.getOpacity(); - var saturation = this.getSaturation(); var sourceState = this.getSourceState(); var visible = this.getVisible(); var extent = this.getExtent(); @@ -141,11 +88,7 @@ ol.layer.Base.prototype.getLayerState = function() { var minResolution = this.getMinResolution(); return { layer: /** @type {ol.layer.Layer} */ (this), - brightness: ol.math.clamp(brightness, -1, 1), - contrast: Math.max(contrast, 0), - hue: hue, opacity: ol.math.clamp(opacity, 0, 1), - saturation: Math.max(saturation, 0), sourceState: sourceState, visible: visible, managed: true, @@ -221,17 +164,6 @@ ol.layer.Base.prototype.getOpacity = function() { }; -/** - * Return the saturation of the layer. - * @return {number} The saturation of the layer. - * @observable - * @api - */ -ol.layer.Base.prototype.getSaturation = function() { - return /** @type {number} */ (this.get(ol.layer.LayerProperty.SATURATION)); -}; - - /** * @return {ol.source.State} Source state. */ @@ -261,59 +193,6 @@ ol.layer.Base.prototype.getZIndex = function() { }; -/** - * Adjust the layer brightness. A value of -1 will render the layer completely - * black. A value of 0 will leave the brightness unchanged. A value of 1 will - * render the layer completely white. Other values are linear multipliers on - * the effect (values are clamped between -1 and 1). - * - * The filter effects draft [1] says the brightness function is supposed to - * render 0 black, 1 unchanged, and all other values as a linear multiplier. - * - * The current WebKit implementation clamps values between -1 (black) and 1 - * (white) [2]. There is a bug open to change the filter effect spec [3]. - * - * TODO: revisit this if the spec is still unmodified before we release - * - * [1] https://dvcs.w3.org/hg/FXTF/raw-file/tip/filters/index.html - * [2] https://github.com/WebKit/webkit/commit/8f4765e569 - * [3] https://www.w3.org/Bugs/Public/show_bug.cgi?id=15647 - * - * @param {number} brightness The brightness of the layer. - * @observable - * @api - */ -ol.layer.Base.prototype.setBrightness = function(brightness) { - this.set(ol.layer.LayerProperty.BRIGHTNESS, brightness); -}; - - -/** - * Adjust the layer contrast. A value of 0 will render the layer completely - * grey. A value of 1 will leave the contrast unchanged. Other values are - * linear multipliers on the effect (and values over 1 are permitted). - * - * @param {number} contrast The contrast of the layer. - * @observable - * @api - */ -ol.layer.Base.prototype.setContrast = function(contrast) { - this.set(ol.layer.LayerProperty.CONTRAST, contrast); -}; - - -/** - * Apply a hue-rotation to the layer. A value of 0 will leave the hue - * unchanged. Other values are radians around the color circle. - * @param {number} hue The hue of the layer. - * @observable - * @api - */ -ol.layer.Base.prototype.setHue = function(hue) { - this.set(ol.layer.LayerProperty.HUE, hue); -}; - - /** * Set the extent at which the layer is visible. If `undefined`, the layer * will be visible at all extents. @@ -359,21 +238,6 @@ ol.layer.Base.prototype.setOpacity = function(opacity) { }; -/** - * Adjust layer saturation. A value of 0 will render the layer completely - * unsaturated. A value of 1 will leave the saturation unchanged. Other - * values are linear multipliers of the effect (and values over 1 are - * permitted). - * - * @param {number} saturation The saturation of the layer. - * @observable - * @api - */ -ol.layer.Base.prototype.setSaturation = function(saturation) { - this.set(ol.layer.LayerProperty.SATURATION, saturation); -}; - - /** * Set the visibility of the layer (`true` or `false`). * @param {boolean} visible The visibility of the layer. diff --git a/src/ol/layer/layergroup.js b/src/ol/layer/layergroup.js index 51c90d5151..db477342c5 100644 --- a/src/ol/layer/layergroup.js +++ b/src/ol/layer/layergroup.js @@ -215,12 +215,7 @@ ol.layer.Group.prototype.getLayerStatesArray = function(opt_states) { var i, ii, layerState; for (i = pos, ii = states.length; i < ii; i++) { layerState = states[i]; - layerState.brightness = ol.math.clamp( - layerState.brightness + ownLayerState.brightness, -1, 1); - layerState.contrast *= ownLayerState.contrast; - layerState.hue += ownLayerState.hue; layerState.opacity *= ownLayerState.opacity; - layerState.saturation *= ownLayerState.saturation; layerState.visible = layerState.visible && ownLayerState.visible; layerState.maxResolution = Math.min( layerState.maxResolution, ownLayerState.maxResolution); diff --git a/src/ol/render/webgl/webglimagecolor.glsl b/src/ol/render/webgl/webglimagecolor.glsl deleted file mode 100644 index 56e045f402..0000000000 --- a/src/ol/render/webgl/webglimagecolor.glsl +++ /dev/null @@ -1,46 +0,0 @@ -//! NAMESPACE=ol.render.webgl.imagereplay.shader.Color -//! CLASS=ol.render.webgl.imagereplay.shader.Color - - -//! COMMON -varying vec2 v_texCoord; -varying float v_opacity; - -//! VERTEX -attribute vec2 a_position; -attribute vec2 a_texCoord; -attribute vec2 a_offsets; -attribute float a_opacity; -attribute float a_rotateWithView; - -uniform mat4 u_projectionMatrix; -uniform mat4 u_offsetScaleMatrix; -uniform mat4 u_offsetRotateMatrix; - -void main(void) { - mat4 offsetMatrix = u_offsetScaleMatrix; - if (a_rotateWithView == 1.0) { - offsetMatrix = u_offsetScaleMatrix * u_offsetRotateMatrix; - } - vec4 offsets = offsetMatrix * vec4(a_offsets, 0., 0.); - gl_Position = u_projectionMatrix * vec4(a_position, 0., 1.) + offsets; - v_texCoord = a_texCoord; - v_opacity = a_opacity; -} - - -//! FRAGMENT -// @see https://svn.webkit.org/repository/webkit/trunk/Source/WebCore/platform/graphics/filters/skia/SkiaImageFilterBuilder.cpp -uniform mat4 u_colorMatrix; -uniform float u_opacity; -uniform sampler2D u_image; - -void main(void) { - vec4 texColor = texture2D(u_image, v_texCoord); - float alpha = texColor.a * v_opacity * u_opacity; - if (alpha == 0.0) { - discard; - } - gl_FragColor.a = alpha; - gl_FragColor.rgb = (u_colorMatrix * vec4(texColor.rgb, 1.)).rgb; -} diff --git a/src/ol/render/webgl/webglimagecolorshader.js b/src/ol/render/webgl/webglimagecolorshader.js deleted file mode 100644 index 1e21a4b95e..0000000000 --- a/src/ol/render/webgl/webglimagecolorshader.js +++ /dev/null @@ -1,156 +0,0 @@ -// This file is automatically generated, do not edit -goog.provide('ol.render.webgl.imagereplay.shader.Color'); -goog.provide('ol.render.webgl.imagereplay.shader.Color.Locations'); -goog.provide('ol.render.webgl.imagereplay.shader.ColorFragment'); -goog.provide('ol.render.webgl.imagereplay.shader.ColorVertex'); - -goog.require('ol.webgl.shader'); - - - -/** - * @constructor - * @extends {ol.webgl.shader.Fragment} - * @struct - */ -ol.render.webgl.imagereplay.shader.ColorFragment = function() { - goog.base(this, ol.render.webgl.imagereplay.shader.ColorFragment.SOURCE); -}; -goog.inherits(ol.render.webgl.imagereplay.shader.ColorFragment, ol.webgl.shader.Fragment); -goog.addSingletonGetter(ol.render.webgl.imagereplay.shader.ColorFragment); - - -/** - * @const - * @type {string} - */ -ol.render.webgl.imagereplay.shader.ColorFragment.DEBUG_SOURCE = 'precision mediump float;\nvarying vec2 v_texCoord;\nvarying float v_opacity;\n\n// @see https://svn.webkit.org/repository/webkit/trunk/Source/WebCore/platform/graphics/filters/skia/SkiaImageFilterBuilder.cpp\nuniform mat4 u_colorMatrix;\nuniform float u_opacity;\nuniform sampler2D u_image;\n\nvoid main(void) {\n vec4 texColor = texture2D(u_image, v_texCoord);\n float alpha = texColor.a * v_opacity * u_opacity;\n if (alpha == 0.0) {\n discard;\n }\n gl_FragColor.a = alpha;\n gl_FragColor.rgb = (u_colorMatrix * vec4(texColor.rgb, 1.)).rgb;\n}\n'; - - -/** - * @const - * @type {string} - */ -ol.render.webgl.imagereplay.shader.ColorFragment.OPTIMIZED_SOURCE = 'precision mediump float;varying vec2 a;varying float b;uniform mat4 k;uniform float l;uniform sampler2D m;void main(void){vec4 texColor=texture2D(m,a);float alpha=texColor.a*b*l;if(alpha==0.0){discard;}gl_FragColor.a=alpha;gl_FragColor.rgb=(k*vec4(texColor.rgb,1.)).rgb;}'; - - -/** - * @const - * @type {string} - */ -ol.render.webgl.imagereplay.shader.ColorFragment.SOURCE = goog.DEBUG ? - ol.render.webgl.imagereplay.shader.ColorFragment.DEBUG_SOURCE : - ol.render.webgl.imagereplay.shader.ColorFragment.OPTIMIZED_SOURCE; - - - -/** - * @constructor - * @extends {ol.webgl.shader.Vertex} - * @struct - */ -ol.render.webgl.imagereplay.shader.ColorVertex = function() { - goog.base(this, ol.render.webgl.imagereplay.shader.ColorVertex.SOURCE); -}; -goog.inherits(ol.render.webgl.imagereplay.shader.ColorVertex, ol.webgl.shader.Vertex); -goog.addSingletonGetter(ol.render.webgl.imagereplay.shader.ColorVertex); - - -/** - * @const - * @type {string} - */ -ol.render.webgl.imagereplay.shader.ColorVertex.DEBUG_SOURCE = 'varying vec2 v_texCoord;\nvarying float v_opacity;\n\nattribute vec2 a_position;\nattribute vec2 a_texCoord;\nattribute vec2 a_offsets;\nattribute float a_opacity;\nattribute float a_rotateWithView;\n\nuniform mat4 u_projectionMatrix;\nuniform mat4 u_offsetScaleMatrix;\nuniform mat4 u_offsetRotateMatrix;\n\nvoid main(void) {\n mat4 offsetMatrix = u_offsetScaleMatrix;\n if (a_rotateWithView == 1.0) {\n offsetMatrix = u_offsetScaleMatrix * u_offsetRotateMatrix;\n }\n vec4 offsets = offsetMatrix * vec4(a_offsets, 0., 0.);\n gl_Position = u_projectionMatrix * vec4(a_position, 0., 1.) + offsets;\n v_texCoord = a_texCoord;\n v_opacity = a_opacity;\n}\n\n\n'; - - -/** - * @const - * @type {string} - */ -ol.render.webgl.imagereplay.shader.ColorVertex.OPTIMIZED_SOURCE = 'varying vec2 a;varying float b;attribute vec2 c;attribute vec2 d;attribute vec2 e;attribute float f;attribute float g;uniform mat4 h;uniform mat4 i;uniform mat4 j;void main(void){mat4 offsetMatrix=i;if(g==1.0){offsetMatrix=i*j;}vec4 offsets=offsetMatrix*vec4(e,0.,0.);gl_Position=h*vec4(c,0.,1.)+offsets;a=d;b=f;}'; - - -/** - * @const - * @type {string} - */ -ol.render.webgl.imagereplay.shader.ColorVertex.SOURCE = goog.DEBUG ? - ol.render.webgl.imagereplay.shader.ColorVertex.DEBUG_SOURCE : - ol.render.webgl.imagereplay.shader.ColorVertex.OPTIMIZED_SOURCE; - - - -/** - * @constructor - * @param {WebGLRenderingContext} gl GL. - * @param {WebGLProgram} program Program. - * @struct - */ -ol.render.webgl.imagereplay.shader.Color.Locations = function(gl, program) { - - /** - * @type {WebGLUniformLocation} - */ - this.u_colorMatrix = gl.getUniformLocation( - program, goog.DEBUG ? 'u_colorMatrix' : 'k'); - - /** - * @type {WebGLUniformLocation} - */ - this.u_image = gl.getUniformLocation( - program, goog.DEBUG ? 'u_image' : 'm'); - - /** - * @type {WebGLUniformLocation} - */ - this.u_offsetRotateMatrix = gl.getUniformLocation( - program, goog.DEBUG ? 'u_offsetRotateMatrix' : 'j'); - - /** - * @type {WebGLUniformLocation} - */ - this.u_offsetScaleMatrix = gl.getUniformLocation( - program, goog.DEBUG ? 'u_offsetScaleMatrix' : 'i'); - - /** - * @type {WebGLUniformLocation} - */ - this.u_opacity = gl.getUniformLocation( - program, goog.DEBUG ? 'u_opacity' : 'l'); - - /** - * @type {WebGLUniformLocation} - */ - this.u_projectionMatrix = gl.getUniformLocation( - program, goog.DEBUG ? 'u_projectionMatrix' : 'h'); - - /** - * @type {number} - */ - this.a_offsets = gl.getAttribLocation( - program, goog.DEBUG ? 'a_offsets' : 'e'); - - /** - * @type {number} - */ - this.a_opacity = gl.getAttribLocation( - program, goog.DEBUG ? 'a_opacity' : 'f'); - - /** - * @type {number} - */ - this.a_position = gl.getAttribLocation( - program, goog.DEBUG ? 'a_position' : 'c'); - - /** - * @type {number} - */ - this.a_rotateWithView = gl.getAttribLocation( - program, goog.DEBUG ? 'a_rotateWithView' : 'g'); - - /** - * @type {number} - */ - this.a_texCoord = gl.getAttribLocation( - program, goog.DEBUG ? 'a_texCoord' : 'd'); -}; diff --git a/src/ol/render/webgl/webglimmediate.js b/src/ol/render/webgl/webglimmediate.js index 601dca03b9..0a311aff89 100644 --- a/src/ol/render/webgl/webglimmediate.js +++ b/src/ol/render/webgl/webglimmediate.js @@ -186,16 +186,12 @@ ol.render.webgl.Immediate.prototype.drawPointGeometry = replay.finish(context); // default colors var opacity = 1; - var brightness = 0; - var contrast = 1; - var hue = 0; - var saturation = 1; var skippedFeatures = {}; var featureCallback; var oneByOne = false; replay.replay(this.context_, this.center_, this.resolution_, this.rotation_, - this.size_, this.pixelRatio_, opacity, brightness, - contrast, hue, saturation, skippedFeatures, featureCallback, oneByOne); + this.size_, this.pixelRatio_, opacity, skippedFeatures, featureCallback, + oneByOne); replay.getDeleteResourcesFunction(context)(); }; @@ -231,18 +227,13 @@ ol.render.webgl.Immediate.prototype.drawMultiPointGeometry = replay.setImageStyle(this.imageStyle_); replay.drawMultiPointGeometry(multiPointGeometry, data); replay.finish(context); - // default colors var opacity = 1; - var brightness = 0; - var contrast = 1; - var hue = 0; - var saturation = 1; var skippedFeatures = {}; var featureCallback; var oneByOne = false; replay.replay(this.context_, this.center_, this.resolution_, this.rotation_, - this.size_, this.pixelRatio_, opacity, brightness, - contrast, hue, saturation, skippedFeatures, featureCallback, oneByOne); + this.size_, this.pixelRatio_, opacity, skippedFeatures, featureCallback, + oneByOne); replay.getDeleteResourcesFunction(context)(); }; diff --git a/src/ol/render/webgl/webglreplay.js b/src/ol/render/webgl/webglreplay.js index b5ef477371..3bffb7c0b4 100644 --- a/src/ol/render/webgl/webglreplay.js +++ b/src/ol/render/webgl/webglreplay.js @@ -5,14 +5,9 @@ goog.require('goog.asserts'); goog.require('goog.functions'); goog.require('goog.object'); goog.require('goog.vec.Mat4'); -goog.require('ol.color.Matrix'); goog.require('ol.extent'); goog.require('ol.render.IReplayGroup'); goog.require('ol.render.VectorContext'); -goog.require('ol.render.webgl.imagereplay.shader.Color'); -goog.require('ol.render.webgl.imagereplay.shader.Color.Locations'); -goog.require('ol.render.webgl.imagereplay.shader.ColorFragment'); -goog.require('ol.render.webgl.imagereplay.shader.ColorVertex'); goog.require('ol.render.webgl.imagereplay.shader.Default'); goog.require('ol.render.webgl.imagereplay.shader.Default.Locations'); goog.require('ol.render.webgl.imagereplay.shader.DefaultFragment'); @@ -46,12 +41,6 @@ ol.render.webgl.ImageReplay = function(tolerance, maxExtent) { */ this.anchorY_ = undefined; - /** - * @private - * @type {ol.color.Matrix} - */ - this.colorMatrix_ = new ol.color.Matrix(); - /** * The origin of the coordinate system for the point coordinates sent to * the GPU. To eliminate jitter caused by precision problems in the GPU @@ -116,12 +105,6 @@ ol.render.webgl.ImageReplay = function(tolerance, maxExtent) { */ this.indicesBuffer_ = null; - /** - * @private - * @type {ol.render.webgl.imagereplay.shader.Color.Locations} - */ - this.colorLocations_ = null; - /** * @private * @type {ol.render.webgl.imagereplay.shader.Default.Locations} @@ -515,10 +498,6 @@ ol.render.webgl.ImageReplay.prototype.createTextures_ = * @param {ol.Size} size Size. * @param {number} pixelRatio Pixel ratio. * @param {number} opacity Global opacity. - * @param {number} brightness Global brightness. - * @param {number} contrast Global contrast. - * @param {number} hue Global hue. - * @param {number} saturation Global saturation. * @param {Object.} skippedFeaturesHash Ids of features * to skip. * @param {function(ol.Feature): T|undefined} featureCallback Feature callback. @@ -530,7 +509,7 @@ ol.render.webgl.ImageReplay.prototype.createTextures_ = */ ol.render.webgl.ImageReplay.prototype.replay = function(context, center, resolution, rotation, size, pixelRatio, - opacity, brightness, contrast, hue, saturation, skippedFeaturesHash, + opacity, skippedFeaturesHash, featureCallback, oneByOne, opt_hitExtent) { var gl = context.getGL(); @@ -544,41 +523,21 @@ ol.render.webgl.ImageReplay.prototype.replay = function(context, 'indecesBuffer must not be null'); context.bindBuffer(goog.webgl.ELEMENT_ARRAY_BUFFER, this.indicesBuffer_); - var useColor = brightness || contrast != 1 || hue || saturation != 1; - // get the program - var fragmentShader, vertexShader; - if (useColor) { - fragmentShader = - ol.render.webgl.imagereplay.shader.ColorFragment.getInstance(); - vertexShader = - ol.render.webgl.imagereplay.shader.ColorVertex.getInstance(); - } else { - fragmentShader = - ol.render.webgl.imagereplay.shader.DefaultFragment.getInstance(); - vertexShader = - ol.render.webgl.imagereplay.shader.DefaultVertex.getInstance(); - } + var fragmentShader = + ol.render.webgl.imagereplay.shader.DefaultFragment.getInstance(); + var vertexShader = + ol.render.webgl.imagereplay.shader.DefaultVertex.getInstance(); var program = context.getProgram(fragmentShader, vertexShader); // get the locations var locations; - if (useColor) { - if (goog.isNull(this.colorLocations_)) { - locations = - new ol.render.webgl.imagereplay.shader.Color.Locations(gl, program); - this.colorLocations_ = locations; - } else { - locations = this.colorLocations_; - } + if (goog.isNull(this.defaultLocations_)) { + locations = + new ol.render.webgl.imagereplay.shader.Default.Locations(gl, program); + this.defaultLocations_ = locations; } else { - if (goog.isNull(this.defaultLocations_)) { - locations = - new ol.render.webgl.imagereplay.shader.Default.Locations(gl, program); - this.defaultLocations_ = locations; - } else { - locations = this.defaultLocations_; - } + locations = this.defaultLocations_; } // use the program (FIXME: use the return value) @@ -628,10 +587,6 @@ ol.render.webgl.ImageReplay.prototype.replay = function(context, gl.uniformMatrix4fv(locations.u_offsetRotateMatrix, false, offsetRotateMatrix); gl.uniform1f(locations.u_opacity, opacity); - if (useColor) { - gl.uniformMatrix4fv(locations.u_colorMatrix, false, - this.colorMatrix_.getMatrix(brightness, contrast, hue, saturation)); - } // draw! var result; @@ -1067,23 +1022,19 @@ ol.render.webgl.ReplayGroup.prototype.isEmpty = function() { * @param {ol.Size} size Size. * @param {number} pixelRatio Pixel ratio. * @param {number} opacity Global opacity. - * @param {number} brightness Global brightness. - * @param {number} contrast Global contrast. - * @param {number} hue Global hue. - * @param {number} saturation Global saturation. * @param {Object.} skippedFeaturesHash Ids of features * to skip. */ ol.render.webgl.ReplayGroup.prototype.replay = function(context, center, resolution, rotation, size, pixelRatio, - opacity, brightness, contrast, hue, saturation, skippedFeaturesHash) { + opacity, skippedFeaturesHash) { var i, ii, replay, result; for (i = 0, ii = ol.render.REPLAY_ORDER.length; i < ii; ++i) { replay = this.replays_[ol.render.REPLAY_ORDER[i]]; if (replay !== undefined) { replay.replay(context, center, resolution, rotation, size, pixelRatio, - opacity, brightness, contrast, hue, saturation, skippedFeaturesHash, + opacity, skippedFeaturesHash, undefined, false); } } @@ -1099,10 +1050,6 @@ ol.render.webgl.ReplayGroup.prototype.replay = function(context, * @param {ol.Size} size Size. * @param {number} pixelRatio Pixel ratio. * @param {number} opacity Global opacity. - * @param {number} brightness Global brightness. - * @param {number} contrast Global contrast. - * @param {number} hue Global hue. - * @param {number} saturation Global saturation. * @param {Object.} skippedFeaturesHash Ids of features * to skip. * @param {function(ol.Feature): T|undefined} featureCallback Feature callback. @@ -1113,16 +1060,14 @@ ol.render.webgl.ReplayGroup.prototype.replay = function(context, * @template T */ ol.render.webgl.ReplayGroup.prototype.replayHitDetection_ = function(context, - center, resolution, rotation, size, pixelRatio, - opacity, brightness, contrast, hue, saturation, skippedFeaturesHash, - featureCallback, oneByOne, opt_hitExtent) { + center, resolution, rotation, size, pixelRatio, opacity, + skippedFeaturesHash, featureCallback, oneByOne, opt_hitExtent) { var i, replay, result; for (i = ol.render.REPLAY_ORDER.length - 1; i >= 0; --i) { replay = this.replays_[ol.render.REPLAY_ORDER[i]]; if (replay !== undefined) { result = replay.replay(context, - center, resolution, rotation, size, pixelRatio, - opacity, brightness, contrast, hue, saturation, + center, resolution, rotation, size, pixelRatio, opacity, skippedFeaturesHash, featureCallback, oneByOne, opt_hitExtent); if (result) { return result; @@ -1142,10 +1087,6 @@ ol.render.webgl.ReplayGroup.prototype.replayHitDetection_ = function(context, * @param {ol.Size} size Size. * @param {number} pixelRatio Pixel ratio. * @param {number} opacity Global opacity. - * @param {number} brightness Global brightness. - * @param {number} contrast Global contrast. - * @param {number} hue Global hue. - * @param {number} saturation Global saturation. * @param {Object.} skippedFeaturesHash Ids of features * to skip. * @param {function(ol.Feature): T|undefined} callback Feature callback. @@ -1154,7 +1095,7 @@ ol.render.webgl.ReplayGroup.prototype.replayHitDetection_ = function(context, */ ol.render.webgl.ReplayGroup.prototype.forEachFeatureAtCoordinate = function( coordinate, context, center, resolution, rotation, size, pixelRatio, - opacity, brightness, contrast, hue, saturation, skippedFeaturesHash, + opacity, skippedFeaturesHash, callback) { var gl = context.getGL(); gl.bindFramebuffer( @@ -1175,8 +1116,7 @@ ol.render.webgl.ReplayGroup.prototype.forEachFeatureAtCoordinate = function( return this.replayHitDetection_(context, coordinate, resolution, rotation, ol.render.webgl.HIT_DETECTION_SIZE_, - pixelRatio, opacity, brightness, contrast, hue, saturation, - skippedFeaturesHash, + pixelRatio, opacity, skippedFeaturesHash, /** * @param {ol.Feature} feature Feature. * @return {?} Callback result. @@ -1204,25 +1144,20 @@ ol.render.webgl.ReplayGroup.prototype.forEachFeatureAtCoordinate = function( * @param {ol.Size} size Size. * @param {number} pixelRatio Pixel ratio. * @param {number} opacity Global opacity. - * @param {number} brightness Global brightness. - * @param {number} contrast Global contrast. - * @param {number} hue Global hue. - * @param {number} saturation Global saturation. * @param {Object.} skippedFeaturesHash Ids of features * to skip. * @return {boolean} Is there a feature at the given coordinate? */ ol.render.webgl.ReplayGroup.prototype.hasFeatureAtCoordinate = function( coordinate, context, center, resolution, rotation, size, pixelRatio, - opacity, brightness, contrast, hue, saturation, skippedFeaturesHash) { + opacity, skippedFeaturesHash) { var gl = context.getGL(); gl.bindFramebuffer( gl.FRAMEBUFFER, context.getHitDetectionFramebuffer()); var hasFeature = this.replayHitDetection_(context, coordinate, resolution, rotation, ol.render.webgl.HIT_DETECTION_SIZE_, - pixelRatio, opacity, brightness, contrast, hue, saturation, - skippedFeaturesHash, + pixelRatio, opacity, skippedFeaturesHash, /** * @param {ol.Feature} feature Feature. * @return {boolean} Is there a feature? diff --git a/src/ol/renderer/webgl/webgllayerrenderer.js b/src/ol/renderer/webgl/webgllayerrenderer.js index 9363754aac..3e5a56c3b6 100644 --- a/src/ol/renderer/webgl/webgllayerrenderer.js +++ b/src/ol/renderer/webgl/webgllayerrenderer.js @@ -2,16 +2,11 @@ goog.provide('ol.renderer.webgl.Layer'); goog.require('goog.vec.Mat4'); goog.require('goog.webgl'); -goog.require('ol.color.Matrix'); goog.require('ol.layer.Layer'); goog.require('ol.render.Event'); goog.require('ol.render.EventType'); goog.require('ol.render.webgl.Immediate'); goog.require('ol.renderer.Layer'); -goog.require('ol.renderer.webgl.map.shader.Color'); -goog.require('ol.renderer.webgl.map.shader.Color.Locations'); -goog.require('ol.renderer.webgl.map.shader.ColorFragment'); -goog.require('ol.renderer.webgl.map.shader.ColorVertex'); goog.require('ol.renderer.webgl.map.shader.Default'); goog.require('ol.renderer.webgl.map.shader.Default.Locations'); goog.require('ol.renderer.webgl.map.shader.DefaultFragment'); @@ -78,18 +73,6 @@ ol.renderer.webgl.Layer = function(mapRenderer, layer) { */ this.projectionMatrix = goog.vec.Mat4.createNumberIdentity(); - /** - * @private - * @type {ol.color.Matrix} - */ - this.colorMatrix_ = new ol.color.Matrix(); - - /** - * @private - * @type {ol.renderer.webgl.map.shader.Color.Locations} - */ - this.colorLocations_ = null; - /** * @private * @type {ol.renderer.webgl.map.shader.Default.Locations} @@ -161,42 +144,19 @@ ol.renderer.webgl.Layer.prototype.composeFrame = var gl = context.getGL(); - var useColor = - layerState.brightness || - layerState.contrast != 1 || - layerState.hue || - layerState.saturation != 1; - - var fragmentShader, vertexShader; - if (useColor) { - fragmentShader = ol.renderer.webgl.map.shader.ColorFragment.getInstance(); - vertexShader = ol.renderer.webgl.map.shader.ColorVertex.getInstance(); - } else { - fragmentShader = - ol.renderer.webgl.map.shader.DefaultFragment.getInstance(); - vertexShader = ol.renderer.webgl.map.shader.DefaultVertex.getInstance(); - } + var fragmentShader = + ol.renderer.webgl.map.shader.DefaultFragment.getInstance(); + var vertexShader = ol.renderer.webgl.map.shader.DefaultVertex.getInstance(); var program = context.getProgram(fragmentShader, vertexShader); - // FIXME colorLocations_ and defaultLocations_ should be shared somehow var locations; - if (useColor) { - if (goog.isNull(this.colorLocations_)) { - locations = - new ol.renderer.webgl.map.shader.Color.Locations(gl, program); - this.colorLocations_ = locations; - } else { - locations = this.colorLocations_; - } + if (goog.isNull(this.defaultLocations_)) { + locations = + new ol.renderer.webgl.map.shader.Default.Locations(gl, program); + this.defaultLocations_ = locations; } else { - if (goog.isNull(this.defaultLocations_)) { - locations = - new ol.renderer.webgl.map.shader.Default.Locations(gl, program); - this.defaultLocations_ = locations; - } else { - locations = this.defaultLocations_; - } + locations = this.defaultLocations_; } if (context.useProgram(program)) { @@ -213,15 +173,6 @@ ol.renderer.webgl.Layer.prototype.composeFrame = locations.u_texCoordMatrix, false, this.getTexCoordMatrix()); gl.uniformMatrix4fv(locations.u_projectionMatrix, false, this.getProjectionMatrix()); - if (useColor) { - gl.uniformMatrix4fv(locations.u_colorMatrix, false, - this.colorMatrix_.getMatrix( - layerState.brightness, - layerState.contrast, - layerState.hue, - layerState.saturation - )); - } gl.uniform1f(locations.u_opacity, layerState.opacity); gl.bindTexture(goog.webgl.TEXTURE_2D, this.getTexture()); gl.drawArrays(goog.webgl.TRIANGLE_STRIP, 0, 4); diff --git a/src/ol/renderer/webgl/webglmapcolor.glsl b/src/ol/renderer/webgl/webglmapcolor.glsl deleted file mode 100644 index 4ed15cd954..0000000000 --- a/src/ol/renderer/webgl/webglmapcolor.glsl +++ /dev/null @@ -1,32 +0,0 @@ -//! NAMESPACE=ol.renderer.webgl.map.shader.Color -//! CLASS=ol.renderer.webgl.map.shader.Color - - -//! COMMON -varying vec2 v_texCoord; - - -//! VERTEX -attribute vec2 a_position; -attribute vec2 a_texCoord; - -uniform mat4 u_texCoordMatrix; -uniform mat4 u_projectionMatrix; - -void main(void) { - gl_Position = u_projectionMatrix * vec4(a_position, 0., 1.); - v_texCoord = (u_texCoordMatrix * vec4(a_texCoord, 0., 1.)).st; -} - - -//! FRAGMENT -// @see https://svn.webkit.org/repository/webkit/trunk/Source/WebCore/platform/graphics/filters/skia/SkiaImageFilterBuilder.cpp -uniform mat4 u_colorMatrix; -uniform float u_opacity; -uniform sampler2D u_texture; - -void main(void) { - vec4 texColor = texture2D(u_texture, v_texCoord); - gl_FragColor.rgb = (u_colorMatrix * vec4(texColor.rgb, 1.)).rgb; - gl_FragColor.a = texColor.a * u_opacity; -} diff --git a/src/ol/renderer/webgl/webglmapcolorshader.js b/src/ol/renderer/webgl/webglmapcolorshader.js deleted file mode 100644 index 66ff4e8949..0000000000 --- a/src/ol/renderer/webgl/webglmapcolorshader.js +++ /dev/null @@ -1,132 +0,0 @@ -// This file is automatically generated, do not edit -goog.provide('ol.renderer.webgl.map.shader.Color'); -goog.provide('ol.renderer.webgl.map.shader.Color.Locations'); -goog.provide('ol.renderer.webgl.map.shader.ColorFragment'); -goog.provide('ol.renderer.webgl.map.shader.ColorVertex'); - -goog.require('ol.webgl.shader'); - - - -/** - * @constructor - * @extends {ol.webgl.shader.Fragment} - * @struct - */ -ol.renderer.webgl.map.shader.ColorFragment = function() { - goog.base(this, ol.renderer.webgl.map.shader.ColorFragment.SOURCE); -}; -goog.inherits(ol.renderer.webgl.map.shader.ColorFragment, ol.webgl.shader.Fragment); -goog.addSingletonGetter(ol.renderer.webgl.map.shader.ColorFragment); - - -/** - * @const - * @type {string} - */ -ol.renderer.webgl.map.shader.ColorFragment.DEBUG_SOURCE = 'precision mediump float;\nvarying vec2 v_texCoord;\n\n\n// @see https://svn.webkit.org/repository/webkit/trunk/Source/WebCore/platform/graphics/filters/skia/SkiaImageFilterBuilder.cpp\nuniform mat4 u_colorMatrix;\nuniform float u_opacity;\nuniform sampler2D u_texture;\n\nvoid main(void) {\n vec4 texColor = texture2D(u_texture, v_texCoord);\n gl_FragColor.rgb = (u_colorMatrix * vec4(texColor.rgb, 1.)).rgb;\n gl_FragColor.a = texColor.a * u_opacity;\n}\n'; - - -/** - * @const - * @type {string} - */ -ol.renderer.webgl.map.shader.ColorFragment.OPTIMIZED_SOURCE = 'precision mediump float;varying vec2 a;uniform mat4 f;uniform float g;uniform sampler2D h;void main(void){vec4 texColor=texture2D(h,a);gl_FragColor.rgb=(f*vec4(texColor.rgb,1.)).rgb;gl_FragColor.a=texColor.a*g;}'; - - -/** - * @const - * @type {string} - */ -ol.renderer.webgl.map.shader.ColorFragment.SOURCE = goog.DEBUG ? - ol.renderer.webgl.map.shader.ColorFragment.DEBUG_SOURCE : - ol.renderer.webgl.map.shader.ColorFragment.OPTIMIZED_SOURCE; - - - -/** - * @constructor - * @extends {ol.webgl.shader.Vertex} - * @struct - */ -ol.renderer.webgl.map.shader.ColorVertex = function() { - goog.base(this, ol.renderer.webgl.map.shader.ColorVertex.SOURCE); -}; -goog.inherits(ol.renderer.webgl.map.shader.ColorVertex, ol.webgl.shader.Vertex); -goog.addSingletonGetter(ol.renderer.webgl.map.shader.ColorVertex); - - -/** - * @const - * @type {string} - */ -ol.renderer.webgl.map.shader.ColorVertex.DEBUG_SOURCE = 'varying vec2 v_texCoord;\n\n\nattribute vec2 a_position;\nattribute vec2 a_texCoord;\n\nuniform mat4 u_texCoordMatrix;\nuniform mat4 u_projectionMatrix;\n\nvoid main(void) {\n gl_Position = u_projectionMatrix * vec4(a_position, 0., 1.);\n v_texCoord = (u_texCoordMatrix * vec4(a_texCoord, 0., 1.)).st;\n}\n\n\n'; - - -/** - * @const - * @type {string} - */ -ol.renderer.webgl.map.shader.ColorVertex.OPTIMIZED_SOURCE = 'varying vec2 a;attribute vec2 b;attribute vec2 c;uniform mat4 d;uniform mat4 e;void main(void){gl_Position=e*vec4(b,0.,1.);a=(d*vec4(c,0.,1.)).st;}'; - - -/** - * @const - * @type {string} - */ -ol.renderer.webgl.map.shader.ColorVertex.SOURCE = goog.DEBUG ? - ol.renderer.webgl.map.shader.ColorVertex.DEBUG_SOURCE : - ol.renderer.webgl.map.shader.ColorVertex.OPTIMIZED_SOURCE; - - - -/** - * @constructor - * @param {WebGLRenderingContext} gl GL. - * @param {WebGLProgram} program Program. - * @struct - */ -ol.renderer.webgl.map.shader.Color.Locations = function(gl, program) { - - /** - * @type {WebGLUniformLocation} - */ - this.u_colorMatrix = gl.getUniformLocation( - program, goog.DEBUG ? 'u_colorMatrix' : 'f'); - - /** - * @type {WebGLUniformLocation} - */ - this.u_opacity = gl.getUniformLocation( - program, goog.DEBUG ? 'u_opacity' : 'g'); - - /** - * @type {WebGLUniformLocation} - */ - this.u_projectionMatrix = gl.getUniformLocation( - program, goog.DEBUG ? 'u_projectionMatrix' : 'e'); - - /** - * @type {WebGLUniformLocation} - */ - this.u_texCoordMatrix = gl.getUniformLocation( - program, goog.DEBUG ? 'u_texCoordMatrix' : 'd'); - - /** - * @type {WebGLUniformLocation} - */ - this.u_texture = gl.getUniformLocation( - program, goog.DEBUG ? 'u_texture' : 'h'); - - /** - * @type {number} - */ - this.a_position = gl.getAttribLocation( - program, goog.DEBUG ? 'a_position' : 'b'); - - /** - * @type {number} - */ - this.a_texCoord = gl.getAttribLocation( - program, goog.DEBUG ? 'a_texCoord' : 'c'); -}; diff --git a/src/ol/renderer/webgl/webglvectorlayerrenderer.js b/src/ol/renderer/webgl/webglvectorlayerrenderer.js index 551d4caeff..bebd636888 100644 --- a/src/ol/renderer/webgl/webglvectorlayerrenderer.js +++ b/src/ol/renderer/webgl/webglvectorlayerrenderer.js @@ -82,8 +82,6 @@ ol.renderer.webgl.VectorLayer.prototype.composeFrame = replayGroup.replay(context, viewState.center, viewState.resolution, viewState.rotation, frameState.size, frameState.pixelRatio, layerState.opacity, - layerState.brightness, layerState.contrast, layerState.hue, - layerState.saturation, layerState.managed ? frameState.skippedFeatureUids : {}); } @@ -120,9 +118,7 @@ ol.renderer.webgl.VectorLayer.prototype.forEachFeatureAtCoordinate = var features = {}; return this.replayGroup_.forEachFeatureAtCoordinate(coordinate, context, viewState.center, viewState.resolution, viewState.rotation, - frameState.size, frameState.pixelRatio, - layerState.opacity, layerState.brightness, layerState.contrast, - layerState.hue, layerState.saturation, + frameState.size, frameState.pixelRatio, layerState.opacity, layerState.managed ? frameState.skippedFeatureUids : {}, /** * @param {ol.Feature} feature Feature. @@ -153,9 +149,8 @@ ol.renderer.webgl.VectorLayer.prototype.hasFeatureAtCoordinate = var layerState = this.layerState_; return this.replayGroup_.hasFeatureAtCoordinate(coordinate, context, viewState.center, viewState.resolution, viewState.rotation, - frameState.size, frameState.pixelRatio, - layerState.opacity, layerState.brightness, layerState.contrast, - layerState.hue, layerState.saturation, frameState.skippedFeatureUids); + frameState.size, frameState.pixelRatio, layerState.opacity, + frameState.skippedFeatureUids); } }; diff --git a/test/spec/ol/layer/layer.test.js b/test/spec/ol/layer/layer.test.js index a5618b8165..19681abddb 100644 --- a/test/spec/ol/layer/layer.test.js +++ b/test/spec/ol/layer/layer.test.js @@ -22,26 +22,10 @@ describe('ol.layer.Layer', function() { expect(layer).to.be.a(ol.layer.Layer); }); - it('provides default brightness', function() { - expect(layer.getBrightness()).to.be(0); - }); - - it('provides default contrast', function() { - expect(layer.getContrast()).to.be(1); - }); - - it('provides default hue', function() { - expect(layer.getHue()).to.be(0); - }); - it('provides default opacity', function() { expect(layer.getOpacity()).to.be(1); }); - it('provides default saturation', function() { - expect(layer.getSaturation()).to.be(1); - }); - it('provides default visibility', function() { expect(layer.getVisible()).to.be(true); }); @@ -57,11 +41,7 @@ describe('ol.layer.Layer', function() { it('provides default layerState', function() { expect(layer.getLayerState()).to.eql({ layer: layer, - brightness: 0, - contrast: 1, - hue: 0, opacity: 1, - saturation: 1, visible: true, managed: true, sourceState: ol.source.State.READY, @@ -81,11 +61,7 @@ describe('ol.layer.Layer', function() { source: new ol.source.Source({ projection: ol.proj.get('EPSG:4326') }), - brightness: 0.5, - contrast: 10, - hue: 180, opacity: 0.5, - saturation: 5, visible: false, zIndex: 10, maxResolution: 500, @@ -93,22 +69,14 @@ describe('ol.layer.Layer', function() { foo: 42 }); - expect(layer.getBrightness()).to.be(0.5); - expect(layer.getContrast()).to.be(10); - expect(layer.getHue()).to.be(180); expect(layer.getOpacity()).to.be(0.5); - expect(layer.getSaturation()).to.be(5); expect(layer.getVisible()).to.be(false); expect(layer.getMaxResolution()).to.be(500); expect(layer.getMinResolution()).to.be(0.25); expect(layer.get('foo')).to.be(42); expect(layer.getLayerState()).to.eql({ layer: layer, - brightness: 0.5, - contrast: 10, - hue: 180, opacity: 0.5, - saturation: 5, visible: false, managed: true, sourceState: ol.source.State.READY, @@ -189,22 +157,14 @@ describe('ol.layer.Layer', function() { }); it('returns a layerState from the properties values', function() { - layer.setBrightness(-0.7); - layer.setContrast(0.3); - layer.setHue(-0.3); layer.setOpacity(0.3); - layer.setSaturation(0.3); layer.setVisible(false); layer.setMaxResolution(500); layer.setMinResolution(0.25); layer.setZIndex(10); expect(layer.getLayerState()).to.eql({ layer: layer, - brightness: -0.7, - contrast: 0.3, - hue: -0.3, opacity: 0.3, - saturation: 0.3, visible: false, managed: true, sourceState: ol.source.State.READY, @@ -216,19 +176,11 @@ describe('ol.layer.Layer', function() { }); it('returns a layerState with clamped values', function() { - layer.setBrightness(1.5); - layer.setContrast(-0.7); - layer.setHue(42); layer.setOpacity(-1.5); - layer.setSaturation(-0.7); layer.setVisible(false); expect(layer.getLayerState()).to.eql({ layer: layer, - brightness: 1, - contrast: 0, - hue: 42, opacity: 0, - saturation: 0, visible: false, managed: true, sourceState: ol.source.State.READY, @@ -238,19 +190,11 @@ describe('ol.layer.Layer', function() { minResolution: 0 }); - layer.setBrightness(-3); - layer.setContrast(42); - layer.setHue(-100); layer.setOpacity(3); - layer.setSaturation(42); layer.setVisible(true); expect(layer.getLayerState()).to.eql({ layer: layer, - brightness: -1, - contrast: 42, - hue: -100, opacity: 1, - saturation: 42, visible: true, managed: true, sourceState: ol.source.State.READY, @@ -365,122 +309,6 @@ describe('ol.layer.Layer', function() { }); - describe('#setBrightness', function() { - - var layer; - - beforeEach(function() { - layer = new ol.layer.Layer({ - source: new ol.source.Source({ - projection: ol.proj.get('EPSG:4326') - }) - }); - }); - - afterEach(function() { - goog.dispose(layer); - }); - - it('accepts a positive number', function() { - layer.setBrightness(0.3); - expect(layer.getBrightness()).to.be(0.3); - }); - - it('accepts a negative number', function() { - layer.setBrightness(-0.7); - expect(layer.getBrightness()).to.be(-0.7); - }); - - it('triggers a change event', function() { - var listener = sinon.spy(); - layer.on(ol.ObjectEventType.PROPERTYCHANGE, listener); - layer.setBrightness(0.5); - expect(listener.calledOnce).to.be(true); - }); - - }); - - describe('#setContrast', function() { - - var layer; - - beforeEach(function() { - layer = new ol.layer.Layer({ - source: new ol.source.Source({ - projection: ol.proj.get('EPSG:4326') - }) - }); - }); - - afterEach(function() { - goog.dispose(layer); - }); - - it('accepts a small positive number', function() { - layer.setContrast(0.3); - expect(layer.getContrast()).to.be(0.3); - }); - - it('accepts a big positive number', function() { - layer.setContrast(42); - expect(layer.getContrast()).to.be(42); - }); - - it('triggers a change event', function() { - var listener = sinon.spy(); - layer.on(ol.ObjectEventType.PROPERTYCHANGE, listener); - layer.setContrast(43); - expect(listener.calledOnce).to.be(true); - }); - - }); - - - describe('#setHue', function() { - - var layer; - - beforeEach(function() { - layer = new ol.layer.Layer({ - source: new ol.source.Source({ - projection: ol.proj.get('EPSG:4326') - }) - }); - }); - - afterEach(function() { - goog.dispose(layer); - }); - - it('accepts a small positive number', function() { - layer.setHue(0.3); - expect(layer.getHue()).to.be(0.3); - }); - - it('accepts a small negative number', function() { - layer.setHue(-0.7); - expect(layer.getHue()).to.be(-0.7); - }); - - it('accepts a big positive number', function() { - layer.setHue(42); - expect(layer.getHue()).to.be(42); - }); - - it('accepts a big negative number', function() { - layer.setHue(-100); - expect(layer.getHue()).to.be(-100); - }); - - it('triggers a change event', function() { - var listener = sinon.spy(); - layer.on(ol.ObjectEventType.PROPERTYCHANGE, listener); - layer.setHue(0.5); - expect(listener.calledOnce).to.be(true); - }); - - }); - describe('#setOpacity', function() { @@ -513,42 +341,6 @@ describe('ol.layer.Layer', function() { }); - describe('#setSaturation', function() { - - var layer; - - beforeEach(function() { - layer = new ol.layer.Layer({ - source: new ol.source.Source({ - projection: ol.proj.get('EPSG:4326') - }) - }); - }); - - afterEach(function() { - goog.dispose(layer); - }); - - it('accepts a small positive number', function() { - layer.setSaturation(0.3); - expect(layer.getSaturation()).to.be(0.3); - }); - - it('accepts a big positive number', function() { - layer.setSaturation(42); - expect(layer.getSaturation()).to.be(42); - }); - - it('triggers a change event', function() { - var listener = sinon.spy(); - layer.on(ol.ObjectEventType.PROPERTYCHANGE, listener); - layer.setSaturation(42); - expect(listener.calledOnce).to.be(true); - }); - - }); - - describe('#setVisible', function() { var layer; diff --git a/test/spec/ol/layer/layergroup.test.js b/test/spec/ol/layer/layergroup.test.js index 7cc123524c..c9bbf07bd1 100644 --- a/test/spec/ol/layer/layergroup.test.js +++ b/test/spec/ol/layer/layergroup.test.js @@ -18,26 +18,10 @@ describe('ol.layer.Group', function() { expect(layerGroup).to.be.a(ol.layer.Group); }); - it('provides default brightness', function() { - expect(layerGroup.getBrightness()).to.be(0); - }); - - it('provides default contrast', function() { - expect(layerGroup.getContrast()).to.be(1); - }); - - it('provides default hue', function() { - expect(layerGroup.getHue()).to.be(0); - }); - it('provides default opacity', function() { expect(layerGroup.getOpacity()).to.be(1); }); - it('provides default saturation', function() { - expect(layerGroup.getSaturation()).to.be(1); - }); - it('provides default visibility', function() { expect(layerGroup.getVisible()).to.be(true); }); @@ -45,11 +29,7 @@ describe('ol.layer.Group', function() { it('provides default layerState', function() { expect(layerGroup.getLayerState()).to.eql({ layer: layerGroup, - brightness: 0, - contrast: 1, - hue: 0, opacity: 1, - saturation: 1, visible: true, managed: true, sourceState: ol.source.State.READY, @@ -155,32 +135,20 @@ describe('ol.layer.Group', function() { }); var layerGroup = new ol.layer.Group({ layers: [layer], - brightness: 0.5, - contrast: 10, - hue: 180, opacity: 0.5, - saturation: 5, visible: false, zIndex: 10, maxResolution: 500, minResolution: 0.25 }); - expect(layerGroup.getBrightness()).to.be(0.5); - expect(layerGroup.getContrast()).to.be(10); - expect(layerGroup.getHue()).to.be(180); expect(layerGroup.getOpacity()).to.be(0.5); - expect(layerGroup.getSaturation()).to.be(5); expect(layerGroup.getVisible()).to.be(false); expect(layerGroup.getMaxResolution()).to.be(500); expect(layerGroup.getMinResolution()).to.be(0.25); expect(layerGroup.getLayerState()).to.eql({ layer: layerGroup, - brightness: 0.5, - contrast: 10, - hue: 180, opacity: 0.5, - saturation: 5, visible: false, managed: true, sourceState: ol.source.State.READY, @@ -207,33 +175,21 @@ describe('ol.layer.Group', function() { var groupExtent = [-10, -5, 10, 5]; var layerGroup = new ol.layer.Group({ layers: [layer], - brightness: 0.5, - contrast: 10, - hue: 180, opacity: 0.5, - saturation: 5, visible: false, extent: groupExtent, maxResolution: 500, minResolution: 0.25 }); - expect(layerGroup.getBrightness()).to.be(0.5); - expect(layerGroup.getContrast()).to.be(10); - expect(layerGroup.getHue()).to.be(180); expect(layerGroup.getOpacity()).to.be(0.5); - expect(layerGroup.getSaturation()).to.be(5); expect(layerGroup.getVisible()).to.be(false); expect(layerGroup.getExtent()).to.eql(groupExtent); expect(layerGroup.getMaxResolution()).to.be(500); expect(layerGroup.getMinResolution()).to.be(0.25); expect(layerGroup.getLayerState()).to.eql({ layer: layerGroup, - brightness: 0.5, - contrast: 10, - hue: 180, opacity: 0.5, - saturation: 5, visible: false, managed: true, sourceState: ol.source.State.READY, @@ -264,11 +220,7 @@ describe('ol.layer.Group', function() { }); it('returns a layerState from the properties values', function() { - layerGroup.setBrightness(-0.7); - layerGroup.setContrast(0.3); - layerGroup.setHue(-0.3); layerGroup.setOpacity(0.3); - layerGroup.setSaturation(0.3); layerGroup.setVisible(false); layerGroup.setZIndex(10); var groupExtent = [-100, 50, 100, 50]; @@ -277,11 +229,7 @@ describe('ol.layer.Group', function() { layerGroup.setMinResolution(0.25); expect(layerGroup.getLayerState()).to.eql({ layer: layerGroup, - brightness: -0.7, - contrast: 0.3, - hue: -0.3, opacity: 0.3, - saturation: 0.3, visible: false, managed: true, sourceState: ol.source.State.READY, @@ -293,19 +241,11 @@ describe('ol.layer.Group', function() { }); it('returns a layerState with clamped values', function() { - layerGroup.setBrightness(1.5); - layerGroup.setContrast(-0.7); - layerGroup.setHue(42); layerGroup.setOpacity(-1.5); - layerGroup.setSaturation(-0.7); layerGroup.setVisible(false); expect(layerGroup.getLayerState()).to.eql({ layer: layerGroup, - brightness: 1, - contrast: 0, - hue: 42, opacity: 0, - saturation: 0, visible: false, managed: true, sourceState: ol.source.State.READY, @@ -315,19 +255,11 @@ describe('ol.layer.Group', function() { minResolution: 0 }); - layerGroup.setBrightness(-3); - layerGroup.setContrast(42); - layerGroup.setHue(-100); layerGroup.setOpacity(3); - layerGroup.setSaturation(42); layerGroup.setVisible(true); expect(layerGroup.getLayerState()).to.eql({ layer: layerGroup, - brightness: -1, - contrast: 42, - hue: -100, opacity: 1, - saturation: 42, visible: true, managed: true, sourceState: ol.source.State.READY, @@ -409,11 +341,7 @@ describe('ol.layer.Group', function() { source: new ol.source.Source({ projection: 'EPSG:4326' }), - brightness: 0.5, - contrast: 10, - hue: 180, opacity: 0.5, - saturation: 5, visible: false, maxResolution: 500, minResolution: 0.25 @@ -473,11 +401,7 @@ describe('ol.layer.Group', function() { it('transforms layerStates correctly', function() { var layerGroup = new ol.layer.Group({ layers: [layer1, layer2], - brightness: 0.5, - contrast: 10, - hue: 180, opacity: 0.5, - saturation: 5, visible: false, maxResolution: 150, minResolution: 0.2 @@ -499,11 +423,7 @@ describe('ol.layer.Group', function() { layerState = goog.object.clone(layerStatesArray[1]); delete layerState.layer; expect(layerState).to.eql({ - brightness: 1, - contrast: 100, - hue: 360, opacity: 0.25, - saturation: 25, visible: false, managed: true, sourceState: ol.source.State.READY, From 55908485f2427eb15b5f9f5c76eab927ccce030f Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Fri, 25 Sep 2015 12:26:58 -0600 Subject: [PATCH 88/93] Add detail to the upgrade notes --- changelog/upgrade-notes.md | 4 ++++ src/ol/layer/layergroup.js | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/changelog/upgrade-notes.md b/changelog/upgrade-notes.md index 5b429f783f..863d3f0520 100644 --- a/changelog/upgrade-notes.md +++ b/changelog/upgrade-notes.md @@ -2,6 +2,10 @@ ### v3.10.0 +#### `ol.layer.Layer` changes + +The experimental `setHue`, `setContrast`, `setBrightness`, `setSaturation`, and the corresponding getter methods have been removed. These properties only worked with the WebGL renderer. If are interested in applying color transforms, look for the `postcompose` event in the API docs. In addition, the `ol.source.Raster` source provides a way to create new raster data based on arbitrary transforms run on any number of input sources. + ### v3.9.0 #### `ol.style.Circle` changes diff --git a/src/ol/layer/layergroup.js b/src/ol/layer/layergroup.js index db477342c5..8f3d8a0e57 100644 --- a/src/ol/layer/layergroup.js +++ b/src/ol/layer/layergroup.js @@ -12,7 +12,6 @@ goog.require('ol.Object'); goog.require('ol.ObjectEventType'); goog.require('ol.extent'); goog.require('ol.layer.Base'); -goog.require('ol.math'); goog.require('ol.source.State'); From 2ed3f28ab83687bcafd358088c03c85195dec5f6 Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Mon, 28 Sep 2015 15:23:36 +0200 Subject: [PATCH 89/93] Use Date.now() instead of goog.now() --- src/ol/animation.js | 8 ++++---- src/ol/interaction/mousewheelzoominteraction.js | 4 ++-- src/ol/kinetic.js | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/ol/animation.js b/src/ol/animation.js index 6358452621..84acd4a2d8 100644 --- a/src/ol/animation.js +++ b/src/ol/animation.js @@ -16,7 +16,7 @@ goog.require('ol.easing'); */ ol.animation.bounce = function(options) { var resolution = options.resolution; - var start = options.start ? options.start : goog.now(); + var start = options.start ? options.start : Date.now(); var duration = options.duration !== undefined ? options.duration : 1000; var easing = options.easing ? options.easing : ol.easing.upAndDown; @@ -52,7 +52,7 @@ ol.animation.bounce = function(options) { */ ol.animation.pan = function(options) { var source = options.source; - var start = options.start ? options.start : goog.now(); + var start = options.start ? options.start : Date.now(); var sourceX = source[0]; var sourceY = source[1]; var duration = options.duration !== undefined ? options.duration : 1000; @@ -92,7 +92,7 @@ ol.animation.pan = function(options) { */ ol.animation.rotate = function(options) { var sourceRotation = options.rotation ? options.rotation : 0; - var start = options.start ? options.start : goog.now(); + var start = options.start ? options.start : Date.now(); var duration = options.duration !== undefined ? options.duration : 1000; var easing = options.easing ? options.easing : ol.easing.inAndOut; @@ -138,7 +138,7 @@ ol.animation.rotate = function(options) { */ ol.animation.zoom = function(options) { var sourceResolution = options.resolution; - var start = options.start ? options.start : goog.now(); + var start = options.start ? options.start : Date.now(); var duration = options.duration !== undefined ? options.duration : 1000; var easing = options.easing ? options.easing : ol.easing.inAndOut; diff --git a/src/ol/interaction/mousewheelzoominteraction.js b/src/ol/interaction/mousewheelzoominteraction.js index 6d55735bf8..d906967b21 100644 --- a/src/ol/interaction/mousewheelzoominteraction.js +++ b/src/ol/interaction/mousewheelzoominteraction.js @@ -91,11 +91,11 @@ ol.interaction.MouseWheelZoom.handleEvent = function(mapBrowserEvent) { this.delta_ += mouseWheelEvent.deltaY; if (this.startTime_ === undefined) { - this.startTime_ = goog.now(); + this.startTime_ = Date.now(); } var duration = ol.MOUSEWHEELZOOM_TIMEOUT_DURATION; - var timeLeft = Math.max(duration - (goog.now() - this.startTime_), 0); + var timeLeft = Math.max(duration - (Date.now() - this.startTime_), 0); goog.global.clearTimeout(this.timeoutId_); this.timeoutId_ = goog.global.setTimeout( diff --git a/src/ol/kinetic.js b/src/ol/kinetic.js index c4cf3b99c2..492f1df049 100644 --- a/src/ol/kinetic.js +++ b/src/ol/kinetic.js @@ -73,7 +73,7 @@ ol.Kinetic.prototype.begin = function() { * @param {number} y Y. */ ol.Kinetic.prototype.update = function(x, y) { - this.points_.push(x, y, goog.now()); + this.points_.push(x, y, Date.now()); }; @@ -86,7 +86,7 @@ ol.Kinetic.prototype.end = function() { // in the array) return false; } - var delay = goog.now() - this.delay_; + var delay = Date.now() - this.delay_; var lastIndex = this.points_.length - 3; if (this.points_[lastIndex + 2] < delay) { // the last tracked point is too old, which means that the user stopped From e877a21b8ef6f8ac5aac603ad092e9e8c810e6d5 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Mon, 28 Sep 2015 15:36:43 +0200 Subject: [PATCH 90/93] Remove legacy IE support --- src/ol/dom/dom.js | 114 +------------------- src/ol/imagetile.js | 7 -- src/ol/mapbrowserevent.js | 44 +------- src/ol/ol.js | 19 ---- src/ol/renderer/dom/dommaprenderer.js | 68 +++--------- src/ol/renderer/dom/domtilelayerrenderer.js | 37 +------ 6 files changed, 18 insertions(+), 271 deletions(-) diff --git a/src/ol/dom/dom.js b/src/ol/dom/dom.js index 72bfd45696..cdd43f4bd3 100644 --- a/src/ol/dom/dom.js +++ b/src/ol/dom/dom.js @@ -29,15 +29,6 @@ ol.dom.createCanvasContext2D = function(opt_width, opt_height) { }; -/** - * @enum {boolean} - */ -ol.dom.BrowserFeature = { - USE_MS_MATRIX_TRANSFORM: ol.LEGACY_IE_SUPPORT && ol.IS_LEGACY_IE, - USE_MS_ALPHA_FILTER: ol.LEGACY_IE_SUPPORT && ol.IS_LEGACY_IE -}; - - /** * Detect 2d transform. * Adapted from http://stackoverflow.com/q/5661671/130442 @@ -137,87 +128,18 @@ ol.dom.setTransform = function(element, value) { style.transform = value; // IE 9+ seems to assume transform-origin: 100% 100%; for some unknown reason - if (goog.userAgent.IE && !ol.IS_LEGACY_IE) { + if (goog.userAgent.IE && goog.userAgent.isVersionOrHigher('9.0')) { element.style.transformOrigin = '0 0'; } }; -/** - * Sets the opacity of an element, in an IE-compatible way - * @param {!Element} element Element - * @param {number} value Opacity, [0..1] - */ -ol.dom.setOpacity = function(element, value) { - if (ol.dom.BrowserFeature.USE_MS_ALPHA_FILTER) { - /** @type {string} */ - var filter = element.currentStyle.filter; - - /** @type {RegExp} */ - var regex; - - /** @type {string} */ - var alpha; - - if (goog.userAgent.VERSION == '8.0') { - regex = /progid:DXImageTransform\.Microsoft\.Alpha\(.*?\)/i; - alpha = 'progid:DXImageTransform.Microsoft.Alpha(Opacity=' + - (value * 100) + ')'; - } else { - regex = /alpha\(.*?\)/i; - alpha = 'alpha(opacity=' + (value * 100) + ')'; - } - - var newFilter = filter.replace(regex, alpha); - if (newFilter === filter) { - // no replace was made? just append the new alpha filter instead - newFilter += ' ' + alpha; - } - - element.style.filter = newFilter; - - // Fix to apply filter to absolutely-positioned children element - if (element.currentStyle.zIndex === 'auto') { - element.style.zIndex = 0; - } - } else { - element.style.opacity = value; - } -}; - - -/** - * Sets the IE matrix transform without replacing other filters - * @private - * @param {!Element} element Element - * @param {string} value The new progid string - */ -ol.dom.setIEMatrix_ = function(element, value) { - var filter = element.currentStyle.filter; - var newFilter = - filter.replace(/progid:DXImageTransform.Microsoft.Matrix\(.*?\)/i, value); - - if (newFilter === filter) { - newFilter = ' ' + value; - } - - element.style.filter = newFilter; - - // Fix to apply filter to absolutely-positioned children element - if (element.currentStyle.zIndex === 'auto') { - element.style.zIndex = 0; - } -}; - - /** * @param {!Element} element Element. * @param {goog.vec.Mat4.Number} transform Matrix. * @param {number=} opt_precision Precision. - * @param {Element=} opt_translationElement Required for IE7-8 */ -ol.dom.transformElement2D = - function(element, transform, opt_precision, opt_translationElement) { +ol.dom.transformElement2D = function(element, transform, opt_precision) { // using matrix() causes gaps in Chrome and Firefox on Mac OS X, so prefer // matrix3d() var i; @@ -257,38 +179,6 @@ ol.dom.transformElement2D = value2D = transform2D.join(','); } ol.dom.setTransform(element, 'matrix(' + value2D + ')'); - } else if (ol.dom.BrowserFeature.USE_MS_MATRIX_TRANSFORM) { - var m11 = goog.vec.Mat4.getElement(transform, 0, 0), - m12 = goog.vec.Mat4.getElement(transform, 0, 1), - m21 = goog.vec.Mat4.getElement(transform, 1, 0), - m22 = goog.vec.Mat4.getElement(transform, 1, 1), - dx = goog.vec.Mat4.getElement(transform, 0, 3), - dy = goog.vec.Mat4.getElement(transform, 1, 3); - - // See: http://msdn.microsoft.com/en-us/library/ms533014(v=vs.85).aspx - // and: http://extremelysatisfactorytotalitarianism.com/blog/?p=1002 - // @TODO: fix terrible IE bbox rotation issue. - var s = 'progid:DXImageTransform.Microsoft.Matrix('; - s += 'sizingMethod="auto expand"'; - s += ',M11=' + m11.toFixed(opt_precision || 20); - s += ',M12=' + m12.toFixed(opt_precision || 20); - s += ',M21=' + m21.toFixed(opt_precision || 20); - s += ',M22=' + m22.toFixed(opt_precision || 20); - s += ')'; - ol.dom.setIEMatrix_(element, s); - - // scale = m11 = m22 = target resolution [m/px] / current res [m/px] - // dx = (viewport width [px] / 2) * scale - // + (layer.x [m] - view.x [m]) / target resolution [m / px] - // except that we're positioning the child element relative to the - // viewport, not the map. - // dividing by the scale factor isn't the exact correction, but it's - // close enough that you can barely tell unless you're looking for it - dx /= m11; - dy /= m22; - - opt_translationElement.style.left = Math.round(dx) + 'px'; - opt_translationElement.style.top = Math.round(dy) + 'px'; } else { element.style.left = Math.round(goog.vec.Mat4.getElement(transform, 0, 3)) + 'px'; diff --git a/src/ol/imagetile.js b/src/ol/imagetile.js index 3b893b58df..fc01a0168d 100644 --- a/src/ol/imagetile.js +++ b/src/ol/imagetile.js @@ -125,13 +125,6 @@ ol.ImageTile.prototype.handleImageError_ = function() { * @private */ ol.ImageTile.prototype.handleImageLoad_ = function() { - if (ol.LEGACY_IE_SUPPORT && ol.IS_LEGACY_IE) { - if (this.image_.naturalWidth === undefined) { - this.image_.naturalWidth = this.image_.width; - this.image_.naturalHeight = this.image_.height; - } - } - if (this.image_.naturalWidth && this.image_.naturalHeight) { this.state = ol.TileState.LOADED; } else { diff --git a/src/ol/mapbrowserevent.js b/src/ol/mapbrowserevent.js index ccfad65fad..3be01693d5 100644 --- a/src/ol/mapbrowserevent.js +++ b/src/ol/mapbrowserevent.js @@ -170,14 +170,6 @@ ol.MapBrowserEventHandler = function(map) { */ this.pointerdownListenerKey_ = null; - if (ol.LEGACY_IE_SUPPORT && ol.IS_LEGACY_IE) { - /** - * @type {goog.events.Key} - * @private - */ - this.ieDblclickListenerKey_ = null; - } - /** * The most recent "down" type event (or null if none have occurred). * Set on pointerdown. @@ -226,35 +218,10 @@ ol.MapBrowserEventHandler = function(map) { ol.pointer.EventType.POINTERMOVE, this.relayEvent_, false, this); - if (ol.LEGACY_IE_SUPPORT && ol.IS_LEGACY_IE) { - /* - * On legacy IE, double clicks do not produce two mousedown and - * mouseup events. That is why a separate DBLCLICK event listener - * is used. - */ - this.ieDblclickListenerKey_ = goog.events.listen(element, - goog.events.EventType.DBLCLICK, - this.emulateClickLegacyIE_, false, this); - } - }; goog.inherits(ol.MapBrowserEventHandler, goog.events.EventTarget); -/** - * @param {goog.events.BrowserEvent} browserEvent Pointer event. - * @private - */ -ol.MapBrowserEventHandler.prototype.emulateClickLegacyIE_ = - function(browserEvent) { - var pointerEvent = this.pointerEventHandler_.wrapMouseEvent( - ol.MapBrowserEvent.EventType.POINTERUP, - browserEvent - ); - this.emulateClick_(pointerEvent); -}; - - /** * @param {ol.pointer.PointerEvent} pointerEvent Pointer event. * @private @@ -343,11 +310,7 @@ ol.MapBrowserEventHandler.prototype.handlePointerUp_ = function(pointerEvent) { */ ol.MapBrowserEventHandler.prototype.isMouseActionButton_ = function(pointerEvent) { - if (ol.LEGACY_IE_SUPPORT && ol.IS_LEGACY_IE) { - return pointerEvent.button == 1; - } else { - return pointerEvent.button === 0; - } + return pointerEvent.button === 0; }; @@ -475,11 +438,6 @@ ol.MapBrowserEventHandler.prototype.disposeInternal = function() { goog.dispose(this.pointerEventHandler_); this.pointerEventHandler_ = null; } - if (ol.LEGACY_IE_SUPPORT && ol.IS_LEGACY_IE && - !goog.isNull(this.ieDblclickListenerKey_)) { - goog.events.unlistenByKey(this.ieDblclickListenerKey_); - this.ieDblclickListenerKey_ = null; - } goog.base(this, 'disposeInternal'); }; diff --git a/src/ol/ol.js b/src/ol/ol.js index ba1c7e6282..e3b9f8be1f 100644 --- a/src/ol/ol.js +++ b/src/ol/ol.js @@ -1,5 +1,3 @@ -goog.require('goog.userAgent'); - goog.provide('ol'); @@ -120,14 +118,6 @@ ol.ENABLE_VECTOR = true; ol.ENABLE_WEBGL = true; -/** - * @define {boolean} Support legacy IE (7-8). Default is `false`. - * If set to `true`, `goog.array.ASSUME_NATIVE_FUNCTIONS` must be set - * to `false` because legacy IE do not support ECMAScript 5 array functions. - */ -ol.LEGACY_IE_SUPPORT = false; - - /** * @define {number} The size in pixels of the first atlas image. Default is * `256`. @@ -135,15 +125,6 @@ ol.LEGACY_IE_SUPPORT = false; ol.INITIAL_ATLAS_SIZE = 256; -/** - * Whether the current browser is legacy IE - * @const - * @type {boolean} - */ -ol.IS_LEGACY_IE = goog.userAgent.IE && - !goog.userAgent.isVersionOrHigher('9.0') && goog.userAgent.VERSION !== ''; - - /** * @define {number} The maximum size in pixels of atlas images. Default is * `-1`, meaning it is not used (and `ol.WEBGL_MAX_TEXTURE_SIZE` is diff --git a/src/ol/renderer/dom/dommaprenderer.js b/src/ol/renderer/dom/dommaprenderer.js index fd471785d8..67f86cefcd 100644 --- a/src/ol/renderer/dom/dommaprenderer.js +++ b/src/ol/renderer/dom/dommaprenderer.js @@ -7,7 +7,6 @@ goog.require('goog.dom.TagName'); goog.require('goog.events'); goog.require('goog.events.Event'); goog.require('goog.events.EventType'); -goog.require('goog.functions'); goog.require('goog.style'); goog.require('goog.vec.Mat4'); goog.require('ol'); @@ -45,16 +44,13 @@ ol.renderer.dom.Map = function(container, map) { * @private * @type {CanvasRenderingContext2D} */ - this.context_ = null; - if (!(ol.LEGACY_IE_SUPPORT && ol.IS_LEGACY_IE)) { - this.context_ = ol.dom.createCanvasContext2D(); - var canvas = this.context_.canvas; - canvas.style.position = 'absolute'; - canvas.style.width = '100%'; - canvas.style.height = '100%'; - canvas.className = ol.css.CLASS_UNSELECTABLE; - goog.dom.insertChildAt(container, canvas, 0); - } + this.context_ = ol.dom.createCanvasContext2D(); + var canvas = this.context_.canvas; + canvas.style.position = 'absolute'; + canvas.style.width = '100%'; + canvas.style.height = '100%'; + canvas.className = ol.css.CLASS_UNSELECTABLE; + goog.dom.insertChildAt(container, canvas, 0); /** * @private @@ -73,14 +69,6 @@ ol.renderer.dom.Map = function(container, map) { style.width = '100%'; style.height = '100%'; - // in IE < 9, we need to return false from ondragstart to cancel the default - // behavior of dragging images, which is interfering with the custom handler - // in the Drag interaction subclasses - if (ol.LEGACY_IE_SUPPORT && ol.IS_LEGACY_IE) { - this.layersPane_.ondragstart = goog.functions.FALSE; - this.layersPane_.onselectstart = goog.functions.FALSE; - } - // prevent the img context menu on mobile devices goog.events.listen(this.layersPane_, goog.events.EventType.TOUCHSTART, goog.events.Event.preventDefault); @@ -115,8 +103,7 @@ ol.renderer.dom.Map.prototype.createLayerRenderer = function(layer) { layerRenderer = new ol.renderer.dom.ImageLayer(layer); } else if (ol.ENABLE_TILE && layer instanceof ol.layer.Tile) { layerRenderer = new ol.renderer.dom.TileLayer(layer); - } else if (!(ol.LEGACY_IE_SUPPORT && ol.IS_LEGACY_IE) && - ol.ENABLE_VECTOR && layer instanceof ol.layer.Vector) { + } else if (ol.ENABLE_VECTOR && layer instanceof ol.layer.Vector) { layerRenderer = new ol.renderer.dom.VectorLayer(layer); } else { goog.asserts.fail('unexpected layer configuration'); @@ -134,7 +121,7 @@ ol.renderer.dom.Map.prototype.createLayerRenderer = function(layer) { ol.renderer.dom.Map.prototype.dispatchComposeEvent_ = function(type, frameState) { var map = this.getMap(); - if (!(ol.LEGACY_IE_SUPPORT && ol.IS_LEGACY_IE) && map.hasListener(type)) { + if (map.hasListener(type)) { var extent = frameState.extent; var pixelRatio = frameState.pixelRatio; var viewState = frameState.viewState; @@ -180,40 +167,9 @@ ol.renderer.dom.Map.prototype.renderFrame = function(frameState) { return; } - /** - * @this {ol.renderer.dom.Map} - * @param {Element} elem - * @param {number} i - */ - var addChild; - - // appendChild is actually more performant than insertBefore - // in IE 7 and 8. http://jsperf.com/reattaching-dom-nodes - if (ol.LEGACY_IE_SUPPORT && ol.IS_LEGACY_IE) { - addChild = - /** - * @this {ol.renderer.dom.Map} - * @param {Element} elem - */ ( - function(elem) { - goog.dom.appendChild(this.layersPane_, elem); - }); - } else { - addChild = - /** - * @this {ol.renderer.dom.Map} - * @param {Element} elem - * @param {number} i - */ ( - function(elem, i) { - goog.dom.insertChildAt(this.layersPane_, elem, i); - }); - } - var map = this.getMap(); - if (!(ol.LEGACY_IE_SUPPORT && ol.IS_LEGACY_IE) && - (map.hasListener(ol.render.EventType.PRECOMPOSE) || - map.hasListener(ol.render.EventType.POSTCOMPOSE))) { + if (map.hasListener(ol.render.EventType.PRECOMPOSE) || + map.hasListener(ol.render.EventType.POSTCOMPOSE)) { var canvas = this.context_.canvas; var pixelRatio = frameState.pixelRatio; canvas.width = frameState.size[0] * pixelRatio; @@ -234,7 +190,7 @@ ol.renderer.dom.Map.prototype.renderFrame = function(frameState) { this.getLayerRenderer(layer)); goog.asserts.assertInstanceof(layerRenderer, ol.renderer.dom.Layer, 'renderer is an instance of ol.renderer.dom.Layer'); - addChild.call(this, layerRenderer.getTarget(), i); + goog.dom.insertChildAt(this.layersPane_, layerRenderer.getTarget(), i); if (ol.layer.Layer.visibleAtResolution(layerState, viewResolution) && layerState.sourceState == ol.source.State.READY) { if (layerRenderer.prepareFrame(frameState, layerState)) { diff --git a/src/ol/renderer/dom/domtilelayerrenderer.js b/src/ol/renderer/dom/domtilelayerrenderer.js index 03131c27a5..2cfa051a2e 100644 --- a/src/ol/renderer/dom/domtilelayerrenderer.js +++ b/src/ol/renderer/dom/domtilelayerrenderer.js @@ -17,7 +17,6 @@ goog.require('ol.TileRange'); goog.require('ol.TileState'); goog.require('ol.ViewHint'); goog.require('ol.dom'); -goog.require('ol.dom.BrowserFeature'); goog.require('ol.extent'); goog.require('ol.layer.Tile'); goog.require('ol.renderer.dom.Layer'); @@ -38,12 +37,6 @@ ol.renderer.dom.TileLayer = function(tileLayer) { var target = goog.dom.createElement(goog.dom.TagName.DIV); target.style.position = 'absolute'; - // Needed for IE7-8 to render a transformed element correctly - if (ol.dom.BrowserFeature.USE_MS_MATRIX_TRANSFORM) { - target.style.width = '100%'; - target.style.height = '100%'; - } - goog.base(this, tileLayer, target); /** @@ -249,7 +242,7 @@ ol.renderer.dom.TileLayer.prototype.prepareFrame = } if (layerState.opacity != this.renderedOpacity_) { - ol.dom.setOpacity(this.target, layerState.opacity); + this.target.style.opacity = layerState.opacity; this.renderedOpacity_ = layerState.opacity; } @@ -285,21 +278,6 @@ ol.renderer.dom.TileLayerZ_ = function(tileGrid, tileCoordOrigin) { this.target.style.width = '100%'; this.target.style.height = '100%'; - if (ol.LEGACY_IE_SUPPORT && ol.IS_LEGACY_IE) { - /** - * Needed due to issues with IE7-8 clipping of transformed elements - * Solution is to translate separately from the scaled/rotated elements - * @private - * @type {!Element} - */ - this.translateTarget_ = goog.dom.createElement(goog.dom.TagName.DIV); - this.translateTarget_.style.position = 'absolute'; - this.translateTarget_.style.width = '100%'; - this.translateTarget_.style.height = '100%'; - - goog.dom.appendChild(this.target, this.translateTarget_); - } - /** * @private * @type {ol.tilegrid.TileGrid} @@ -413,11 +391,7 @@ ol.renderer.dom.TileLayerZ_.prototype.addTile = function(tile, tileGutter) { */ ol.renderer.dom.TileLayerZ_.prototype.finalizeAddTiles = function() { if (!goog.isNull(this.documentFragment_)) { - if (ol.LEGACY_IE_SUPPORT && ol.IS_LEGACY_IE) { - goog.dom.appendChild(this.translateTarget_, this.documentFragment_); - } else { - goog.dom.appendChild(this.target, this.documentFragment_); - } + goog.dom.appendChild(this.target, this.documentFragment_); this.documentFragment_ = null; } }; @@ -471,12 +445,7 @@ ol.renderer.dom.TileLayerZ_.prototype.removeTilesOutsideExtent = */ ol.renderer.dom.TileLayerZ_.prototype.setTransform = function(transform) { if (!ol.vec.Mat4.equals2D(transform, this.transform_)) { - if (ol.LEGACY_IE_SUPPORT && ol.IS_LEGACY_IE) { - ol.dom.transformElement2D(this.target, transform, 6, - this.translateTarget_); - } else { - ol.dom.transformElement2D(this.target, transform, 6); - } + ol.dom.transformElement2D(this.target, transform, 6); goog.vec.Mat4.setFromArray(this.transform_, transform); } }; From 4c32ec4d67c07789496f062b44e076225d672539 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Mon, 28 Sep 2015 16:11:54 +0200 Subject: [PATCH 91/93] Remove @api on getHitDetectionFramebuffer This removes the `@api` marker on `getHitDetectionFramebuffer`. I think this was added by mistake in 7404204. --- src/ol/webgl/context.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ol/webgl/context.js b/src/ol/webgl/context.js index 2357e7884f..f5cba1baa2 100644 --- a/src/ol/webgl/context.js +++ b/src/ol/webgl/context.js @@ -203,7 +203,6 @@ ol.webgl.Context.prototype.getGL = function() { /** * Get the frame buffer for hit detection. * @return {WebGLFramebuffer} The hit detection frame buffer. - * @api */ ol.webgl.Context.prototype.getHitDetectionFramebuffer = function() { if (goog.isNull(this.hitDetectionFramebuffer_)) { From 88c3891bef07a143d8e9e16da973306dd19aba0c Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Mon, 28 Sep 2015 16:57:24 +0200 Subject: [PATCH 92/93] Replace goog.array.contains with ol.array.includes --- src/ol/array.js | 11 +++++++++++ src/ol/format/gpxformat.js | 6 +++--- src/ol/format/kmlformat.js | 19 ++++++++++--------- src/ol/interaction/selectinteraction.js | 3 ++- src/ol/interaction/translateinteraction.js | 6 +++--- src/ol/source/wmtssource.js | 7 ++++--- src/ol/webgl/context.js | 4 ++-- 7 files changed, 35 insertions(+), 21 deletions(-) diff --git a/src/ol/array.js b/src/ol/array.js index d630a7ed6c..e2744ce3b7 100644 --- a/src/ol/array.js +++ b/src/ol/array.js @@ -37,6 +37,17 @@ ol.array.binaryFindNearest = function(arr, target) { }; +/** + * Whether the array contains the given object. + * @param {Array.<*>} arr The array to test for the presence of the element. + * @param {*} obj The object for which to test. + * @return {boolean} The object is in the array. + */ +ol.array.includes = function(arr, obj) { + return arr.indexOf(obj) >= 0; +}; + + /** * @param {Array.} arr Array. * @param {number} target Target. diff --git a/src/ol/format/gpxformat.js b/src/ol/format/gpxformat.js index 2da803bf43..25a7363357 100644 --- a/src/ol/format/gpxformat.js +++ b/src/ol/format/gpxformat.js @@ -1,9 +1,9 @@ goog.provide('ol.format.GPX'); -goog.require('goog.array'); goog.require('goog.asserts'); goog.require('goog.dom.NodeType'); goog.require('ol.Feature'); +goog.require('ol.array'); goog.require('ol.format.Feature'); goog.require('ol.format.XMLFeature'); goog.require('ol.format.XSD'); @@ -449,7 +449,7 @@ ol.format.GPX.prototype.readFeature; ol.format.GPX.prototype.readFeatureFromNode = function(node, opt_options) { goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT, 'node.nodeType should be ELEMENT'); - if (!goog.array.contains(ol.format.GPX.NAMESPACE_URIS_, node.namespaceURI)) { + if (!ol.array.includes(ol.format.GPX.NAMESPACE_URIS_, node.namespaceURI)) { return null; } var featureReader = ol.format.GPX.FEATURE_READER_[node.localName]; @@ -483,7 +483,7 @@ ol.format.GPX.prototype.readFeatures; ol.format.GPX.prototype.readFeaturesFromNode = function(node, opt_options) { goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT, 'node.nodeType should be ELEMENT'); - if (!goog.array.contains(ol.format.GPX.NAMESPACE_URIS_, node.namespaceURI)) { + if (!ol.array.includes(ol.format.GPX.NAMESPACE_URIS_, node.namespaceURI)) { return []; } if (node.localName == 'gpx') { diff --git a/src/ol/format/kmlformat.js b/src/ol/format/kmlformat.js index 51d3427b7a..dc401f94c6 100644 --- a/src/ol/format/kmlformat.js +++ b/src/ol/format/kmlformat.js @@ -16,6 +16,7 @@ goog.require('goog.string'); goog.require('ol'); goog.require('ol.Feature'); goog.require('ol.FeatureStyleFunction'); +goog.require('ol.array'); goog.require('ol.color'); goog.require('ol.format.Feature'); goog.require('ol.format.XMLFeature'); @@ -683,7 +684,7 @@ ol.format.KML.readFlatLinearRing_ = function(node, objectStack) { ol.format.KML.gxCoordParser_ = function(node, objectStack) { goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT, 'node.nodeType should be ELEMENT'); - goog.asserts.assert(goog.array.contains( + goog.asserts.assert(ol.array.includes( ol.format.KML.GX_NAMESPACE_URIS_, node.namespaceURI), 'namespaceURI of the node should be known to the KML parser'); goog.asserts.assert(node.localName == 'coord', 'localName should be coord'); @@ -716,7 +717,7 @@ ol.format.KML.gxCoordParser_ = function(node, objectStack) { ol.format.KML.readGxMultiTrack_ = function(node, objectStack) { goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT, 'node.nodeType should be ELEMENT'); - goog.asserts.assert(goog.array.contains( + goog.asserts.assert(ol.array.includes( ol.format.KML.GX_NAMESPACE_URIS_, node.namespaceURI), 'namespaceURI of the node should be known to the KML parser'); goog.asserts.assert(node.localName == 'MultiTrack', @@ -742,7 +743,7 @@ ol.format.KML.readGxMultiTrack_ = function(node, objectStack) { ol.format.KML.readGxTrack_ = function(node, objectStack) { goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT, 'node.nodeType should be ELEMENT'); - goog.asserts.assert(goog.array.contains( + goog.asserts.assert(ol.array.includes( ol.format.KML.GX_NAMESPACE_URIS_, node.namespaceURI), 'namespaceURI of the node should be known to the KML parser'); goog.asserts.assert(node.localName == 'Track', 'localName should be Track'); @@ -1777,7 +1778,7 @@ ol.format.KML.prototype.readFeature; ol.format.KML.prototype.readFeatureFromNode = function(node, opt_options) { goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT, 'node.nodeType should be ELEMENT'); - if (!goog.array.contains(ol.format.KML.NAMESPACE_URIS_, node.namespaceURI)) { + if (!ol.array.includes(ol.format.KML.NAMESPACE_URIS_, node.namespaceURI)) { return null; } goog.asserts.assert(node.localName == 'Placemark', @@ -1810,7 +1811,7 @@ ol.format.KML.prototype.readFeatures; ol.format.KML.prototype.readFeaturesFromNode = function(node, opt_options) { goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT, 'node.nodeType should be ELEMENT'); - if (!goog.array.contains(ol.format.KML.NAMESPACE_URIS_, node.namespaceURI)) { + if (!ol.array.includes(ol.format.KML.NAMESPACE_URIS_, node.namespaceURI)) { return []; } var features; @@ -1895,14 +1896,14 @@ ol.format.KML.prototype.readNameFromDocument = function(doc) { ol.format.KML.prototype.readNameFromNode = function(node) { var n; for (n = node.firstElementChild; !goog.isNull(n); n = n.nextElementSibling) { - if (goog.array.contains(ol.format.KML.NAMESPACE_URIS_, n.namespaceURI) && + if (ol.array.includes(ol.format.KML.NAMESPACE_URIS_, n.namespaceURI) && n.localName == 'name') { return ol.format.XSD.readString(n); } } for (n = node.firstElementChild; !goog.isNull(n); n = n.nextElementSibling) { var localName = ol.xml.getLocalName(n); - if (goog.array.contains(ol.format.KML.NAMESPACE_URIS_, n.namespaceURI) && + if (ol.array.includes(ol.format.KML.NAMESPACE_URIS_, n.namespaceURI) && (localName == 'Document' || localName == 'Folder' || localName == 'Placemark' || @@ -1964,7 +1965,7 @@ ol.format.KML.prototype.readNetworkLinksFromDocument = function(doc) { ol.format.KML.prototype.readNetworkLinksFromNode = function(node) { var n, networkLinks = []; for (n = node.firstElementChild; !goog.isNull(n); n = n.nextElementSibling) { - if (goog.array.contains(ol.format.KML.NAMESPACE_URIS_, n.namespaceURI) && + if (ol.array.includes(ol.format.KML.NAMESPACE_URIS_, n.namespaceURI) && n.localName == 'NetworkLink') { var obj = ol.xml.pushParseAndPop({}, ol.format.KML.NETWORK_LINK_PARSERS_, n, []); @@ -1973,7 +1974,7 @@ ol.format.KML.prototype.readNetworkLinksFromNode = function(node) { } for (n = node.firstElementChild; !goog.isNull(n); n = n.nextElementSibling) { var localName = ol.xml.getLocalName(n); - if (goog.array.contains(ol.format.KML.NAMESPACE_URIS_, n.namespaceURI) && + if (ol.array.includes(ol.format.KML.NAMESPACE_URIS_, n.namespaceURI) && (localName == 'Document' || localName == 'Folder' || localName == 'kml')) { diff --git a/src/ol/interaction/selectinteraction.js b/src/ol/interaction/selectinteraction.js index 57a0d506ae..4d5653b863 100644 --- a/src/ol/interaction/selectinteraction.js +++ b/src/ol/interaction/selectinteraction.js @@ -10,6 +10,7 @@ goog.require('goog.events.Event'); goog.require('goog.functions'); goog.require('ol.CollectionEventType'); goog.require('ol.Feature'); +goog.require('ol.array'); goog.require('ol.events.condition'); goog.require('ol.geom.GeometryType'); goog.require('ol.interaction.Interaction'); @@ -160,7 +161,7 @@ ol.interaction.Select = function(opt_options) { * @return {boolean} Include. */ function(layer) { - return goog.array.contains(layers, layer); + return ol.array.includes(layers, layer); }; } } else { diff --git a/src/ol/interaction/translateinteraction.js b/src/ol/interaction/translateinteraction.js index 1f2ec0bd1e..50642851d8 100644 --- a/src/ol/interaction/translateinteraction.js +++ b/src/ol/interaction/translateinteraction.js @@ -1,6 +1,6 @@ goog.provide('ol.interaction.Translate'); -goog.require('goog.array'); +goog.require('ol.array'); goog.require('ol.interaction.Pointer'); @@ -131,7 +131,7 @@ ol.interaction.Translate.handleMoveEvent_ = function(event) var isSelected = false; if (!goog.isNull(this.features_) && - goog.array.contains(this.features_.getArray(), intersectingFeature)) { + ol.array.includes(this.features_.getArray(), intersectingFeature)) { isSelected = true; } @@ -172,7 +172,7 @@ ol.interaction.Translate.prototype.featuresAtPixel_ = function(pixel, map) { }); if (!goog.isNull(this.features_) && - goog.array.contains(this.features_.getArray(), intersectingFeature)) { + ol.array.includes(this.features_.getArray(), intersectingFeature)) { found = intersectingFeature; } diff --git a/src/ol/source/wmtssource.js b/src/ol/source/wmtssource.js index 4b6c126538..d4317d8fe6 100644 --- a/src/ol/source/wmtssource.js +++ b/src/ol/source/wmtssource.js @@ -8,6 +8,7 @@ goog.require('goog.string'); goog.require('goog.uri.utils'); goog.require('ol.TileUrlFunction'); goog.require('ol.TileUrlFunctionType'); +goog.require('ol.array'); goog.require('ol.extent'); goog.require('ol.proj'); goog.require('ol.source.TileImage'); @@ -405,7 +406,7 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) { var key = elt['Identifier']; var value = elt['default']; if (value !== undefined) { - goog.asserts.assert(goog.array.contains(elt['values'], value), + goog.asserts.assert(ol.array.includes(elt['values'], value), 'default value contained in values'); } else { value = elt['values'][0]; @@ -457,7 +458,7 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) { requestEncoding = requestEncoding !== undefined ? requestEncoding : ''; goog.asserts.assert( - goog.array.contains(['REST', 'RESTful', 'KVP', ''], requestEncoding), + ol.array.includes(['REST', 'RESTful', 'KVP', ''], requestEncoding), 'requestEncoding (%s) is one of "REST", "RESTful", "KVP" or ""', requestEncoding); @@ -481,7 +482,7 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) { return elt['name'] == 'GetEncoding'; }); var encodings = constraint['AllowedValues']['Value']; - if (encodings.length > 0 && goog.array.contains(encodings, 'KVP')) { + if (encodings.length > 0 && ol.array.includes(encodings, 'KVP')) { requestEncoding = ol.source.WMTSRequestEncoding.KVP; urls.push(/** @type {string} */ (gets[i]['href'])); } diff --git a/src/ol/webgl/context.js b/src/ol/webgl/context.js index f5cba1baa2..6b95937be5 100644 --- a/src/ol/webgl/context.js +++ b/src/ol/webgl/context.js @@ -1,11 +1,11 @@ goog.provide('ol.webgl.Context'); -goog.require('goog.array'); goog.require('goog.asserts'); goog.require('goog.events'); goog.require('goog.log'); goog.require('goog.object'); goog.require('ol'); +goog.require('ol.array'); goog.require('ol.webgl.Buffer'); goog.require('ol.webgl.WebGLContextEventType'); @@ -87,7 +87,7 @@ ol.webgl.Context = function(canvas, gl) { /** * @type {boolean} */ - this.hasOESElementIndexUint = goog.array.contains( + this.hasOESElementIndexUint = ol.array.includes( ol.WEBGL_EXTENSIONS, 'OES_element_index_uint'); // use the OES_element_index_uint extension if available From da611b9cb54ca6627b9b07a2a89a2447002a0531 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Tue, 29 Sep 2015 10:46:04 +0200 Subject: [PATCH 93/93] Use ol.array.includes instead of goog.array.indexOf --- src/ol/interaction/selectinteraction.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/ol/interaction/selectinteraction.js b/src/ol/interaction/selectinteraction.js index 4d5653b863..6a84a8b477 100644 --- a/src/ol/interaction/selectinteraction.js +++ b/src/ol/interaction/selectinteraction.js @@ -265,8 +265,7 @@ ol.interaction.Select.handleEvent = function(mapBrowserEvent) { * @param {ol.layer.Layer} layer Layer. */ function(feature, layer) { - var index = goog.array.indexOf(features.getArray(), feature); - if (index == -1) { + if (!ol.array.includes(features.getArray(), feature)) { if (add || toggle) { if (this.filter_(feature, layer)) { selected.push(feature);