Toward natural JavaScript syntax

This commit is contained in:
Tim Schaub
2015-09-25 12:16:42 -06:00
parent d610b206f7
commit 0927c55b3c
40 changed files with 146 additions and 188 deletions

View File

@@ -17,8 +17,7 @@ goog.require('ol.easing');
ol.animation.bounce = function(options) { ol.animation.bounce = function(options) {
var resolution = options.resolution; var resolution = options.resolution;
var start = options.start ? options.start : goog.now(); var start = options.start ? options.start : goog.now();
var duration = ol.isDef(options.duration) ? var duration = options.duration !== undefined ? options.duration : 1000;
/** @type {number} */ (options.duration) : 1000;
var easing = options.easing ? var easing = options.easing ?
options.easing : ol.easing.upAndDown; options.easing : ol.easing.upAndDown;
return ( return (
@@ -56,8 +55,7 @@ ol.animation.pan = function(options) {
var start = options.start ? options.start : goog.now(); var start = options.start ? options.start : goog.now();
var sourceX = source[0]; var sourceX = source[0];
var sourceY = source[1]; var sourceY = source[1];
var duration = ol.isDef(options.duration) ? var duration = options.duration !== undefined ? options.duration : 1000;
/** @type {number} */ (options.duration) : 1000;
var easing = options.easing ? var easing = options.easing ?
options.easing : ol.easing.inAndOut; options.easing : ol.easing.inAndOut;
return ( return (
@@ -95,8 +93,7 @@ ol.animation.pan = function(options) {
ol.animation.rotate = function(options) { ol.animation.rotate = function(options) {
var sourceRotation = options.rotation ? options.rotation : 0; var sourceRotation = options.rotation ? options.rotation : 0;
var start = options.start ? options.start : goog.now(); var start = options.start ? options.start : goog.now();
var duration = ol.isDef(options.duration) ? var duration = options.duration !== undefined ? options.duration : 1000;
/** @type {number} */ (options.duration) : 1000;
var easing = options.easing ? var easing = options.easing ?
options.easing : ol.easing.inAndOut; options.easing : ol.easing.inAndOut;
var anchor = options.anchor ? var anchor = options.anchor ?
@@ -142,8 +139,7 @@ ol.animation.rotate = function(options) {
ol.animation.zoom = function(options) { ol.animation.zoom = function(options) {
var sourceResolution = options.resolution; var sourceResolution = options.resolution;
var start = options.start ? options.start : goog.now(); var start = options.start ? options.start : goog.now();
var duration = ol.isDef(options.duration) ? var duration = options.duration !== undefined ? options.duration : 1000;
/** @type {number} */ (options.duration) : 1000;
var easing = options.easing ? var easing = options.easing ?
options.easing : ol.easing.inAndOut; options.easing : ol.easing.inAndOut;
return ( return (

View File

@@ -166,24 +166,24 @@ ol.color.Matrix.makeSaturation = function(matrix, value) {
ol.color.Matrix.prototype.getMatrix = function( ol.color.Matrix.prototype.getMatrix = function(
brightness, contrast, hue, saturation) { brightness, contrast, hue, saturation) {
var colorMatrixDirty = false; var colorMatrixDirty = false;
if (ol.isDef(brightness) && brightness !== this.brightness_) { if (brightness !== undefined && brightness !== this.brightness_) {
ol.color.Matrix.makeBrightness(this.brightnessMatrix_, ol.color.Matrix.makeBrightness(this.brightnessMatrix_,
/** @type {number} */ (brightness)); /** @type {number} */ (brightness));
this.brightness_ = brightness; this.brightness_ = brightness;
colorMatrixDirty = true; colorMatrixDirty = true;
} }
if (ol.isDef(contrast) && contrast !== this.contrast_) { if (contrast !== undefined && contrast !== this.contrast_) {
ol.color.Matrix.makeContrast(this.contrastMatrix_, ol.color.Matrix.makeContrast(this.contrastMatrix_,
/** @type {number} */ (contrast)); /** @type {number} */ (contrast));
this.contrast_ = contrast; this.contrast_ = contrast;
colorMatrixDirty = true; colorMatrixDirty = true;
} }
if (ol.isDef(hue) && hue !== this.hue_) { if (hue !== undefined && hue !== this.hue_) {
ol.color.Matrix.makeHue(this.hueMatrix_, /** @type {number} */ (hue)); ol.color.Matrix.makeHue(this.hueMatrix_, /** @type {number} */ (hue));
this.hue_ = hue; this.hue_ = hue;
colorMatrixDirty = true; colorMatrixDirty = true;
} }
if (ol.isDef(saturation) && saturation !== this.saturation_) { if (saturation !== undefined && saturation !== this.saturation_) {
ol.color.Matrix.makeSaturation(this.saturationMatrix_, ol.color.Matrix.makeSaturation(this.saturationMatrix_,
/** @type {number} */ (saturation)); /** @type {number} */ (saturation));
this.saturation_ = saturation; this.saturation_ = saturation;
@@ -192,16 +192,16 @@ ol.color.Matrix.prototype.getMatrix = function(
if (colorMatrixDirty) { if (colorMatrixDirty) {
var colorMatrix = this.colorMatrix_; var colorMatrix = this.colorMatrix_;
goog.vec.Mat4.makeIdentity(colorMatrix); goog.vec.Mat4.makeIdentity(colorMatrix);
if (ol.isDef(contrast)) { if (contrast !== undefined) {
goog.vec.Mat4.multMat(colorMatrix, this.contrastMatrix_, colorMatrix); goog.vec.Mat4.multMat(colorMatrix, this.contrastMatrix_, colorMatrix);
} }
if (ol.isDef(brightness)) { if (brightness !== undefined) {
goog.vec.Mat4.multMat(colorMatrix, this.brightnessMatrix_, colorMatrix); goog.vec.Mat4.multMat(colorMatrix, this.brightnessMatrix_, colorMatrix);
} }
if (ol.isDef(saturation)) { if (saturation !== undefined) {
goog.vec.Mat4.multMat(colorMatrix, this.saturationMatrix_, colorMatrix); goog.vec.Mat4.multMat(colorMatrix, this.saturationMatrix_, colorMatrix);
} }
if (ol.isDef(hue)) { if (hue !== undefined) {
goog.vec.Mat4.multMat(colorMatrix, this.hueMatrix_, colorMatrix); goog.vec.Mat4.multMat(colorMatrix, this.hueMatrix_, colorMatrix);
} }
} }

View File

@@ -53,15 +53,14 @@ ol.control.Attribution = function(opt_options) {
* @private * @private
* @type {boolean} * @type {boolean}
*/ */
this.collapsed_ = ol.isDef(options.collapsed) ? this.collapsed_ = options.collapsed !== undefined ? options.collapsed : true;
/** @type {boolean} */ (options.collapsed) : true;
/** /**
* @private * @private
* @type {boolean} * @type {boolean}
*/ */
this.collapsible_ = ol.isDef(options.collapsible) ? this.collapsible_ = options.collapsible !== undefined ?
/** @type {boolean} */ (options.collapsible) : true; options.collapsible : true;
if (!this.collapsible_) { if (!this.collapsible_) {
this.collapsed_ = false; this.collapsed_ = false;

View File

@@ -25,19 +25,17 @@ ol.control.defaults = function(opt_options) {
var controls = new ol.Collection(); var controls = new ol.Collection();
var zoomControl = ol.isDef(options.zoom) ? var zoomControl = options.zoom !== undefined ? options.zoom : true;
options.zoom : true;
if (zoomControl) { if (zoomControl) {
controls.push(new ol.control.Zoom(options.zoomOptions)); controls.push(new ol.control.Zoom(options.zoomOptions));
} }
var rotateControl = ol.isDef(options.rotate) ? var rotateControl = options.rotate !== undefined ? options.rotate : true;
options.rotate : true;
if (rotateControl) { if (rotateControl) {
controls.push(new ol.control.Rotate(options.rotateOptions)); controls.push(new ol.control.Rotate(options.rotateOptions));
} }
var attributionControl = ol.isDef(options.attribution) ? var attributionControl = options.attribution !== undefined ?
options.attribution : true; options.attribution : true;
if (attributionControl) { if (attributionControl) {
controls.push(new ol.control.Attribution(options.attributionOptions)); controls.push(new ol.control.Attribution(options.attributionOptions));

View File

@@ -83,8 +83,7 @@ ol.control.FullScreen = function(opt_options) {
* @private * @private
* @type {boolean} * @type {boolean}
*/ */
this.keys_ = ol.isDef(options.keys) ? this.keys_ = options.keys !== undefined ? options.keys : false;
/** @type {boolean} */ (options.keys) : false;
}; };
goog.inherits(ol.control.FullScreen, ol.control.Control); goog.inherits(ol.control.FullScreen, ol.control.Control);

View File

@@ -41,15 +41,14 @@ ol.control.OverviewMap = function(opt_options) {
* @type {boolean} * @type {boolean}
* @private * @private
*/ */
this.collapsed_ = ol.isDef(options.collapsed) ? this.collapsed_ = options.collapsed !== undefined ? options.collapsed : true;
/** @type {boolean} */ (options.collapsed) : true;
/** /**
* @private * @private
* @type {boolean} * @type {boolean}
*/ */
this.collapsible_ = ol.isDef(options.collapsible) ? this.collapsible_ = options.collapsible !== undefined ?
/** @type {boolean} */ (options.collapsible) : true; options.collapsible : true;
if (!this.collapsible_) { if (!this.collapsible_) {
this.collapsed_ = false; this.collapsed_ = false;
@@ -382,7 +381,7 @@ ol.control.OverviewMap.prototype.updateBox_ = function() {
goog.asserts.assertArray(ovmapSize, 'ovmapSize should be an array'); goog.asserts.assertArray(ovmapSize, 'ovmapSize should be an array');
var rotation = view.getRotation(); 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 overlay = this.boxOverlay_;
var box = this.boxOverlay_.getElement(); var box = this.boxOverlay_.getElement();

View File

@@ -81,8 +81,7 @@ ol.control.Rotate = function(opt_options) {
* @type {boolean} * @type {boolean}
* @private * @private
*/ */
this.autoHide_ = ol.isDef(options.autoHide) ? this.autoHide_ = options.autoHide !== undefined ? options.autoHide : true;
/** @type {boolean} */ (options.autoHide) : true;
/** /**
* @private * @private
@@ -126,7 +125,7 @@ ol.control.Rotate.prototype.resetNorth_ = function() {
while (currentRotation > Math.PI) { while (currentRotation > Math.PI) {
currentRotation -= 2 * Math.PI; currentRotation -= 2 * Math.PI;
} }
if (ol.isDef(currentRotation)) { if (currentRotation !== undefined) {
if (this.duration_ > 0) { if (this.duration_ > 0) {
map.beforeRender(ol.animation.rotate({ map.beforeRender(ol.animation.rotate({
rotation: currentRotation, rotation: currentRotation,

View File

@@ -87,8 +87,7 @@ ol.control.ScaleLine = function(opt_options) {
* @private * @private
* @type {number} * @type {number}
*/ */
this.minWidth_ = ol.isDef(options.minWidth) ? this.minWidth_ = options.minWidth !== undefined ? options.minWidth : 64;
/** @type {number} */ (options.minWidth) : 64;
/** /**
* @private * @private

View File

@@ -92,8 +92,7 @@ ol.DeviceOrientation = function(opt_options) {
ol.Object.getChangeEventType(ol.DeviceOrientationProperty.TRACKING), ol.Object.getChangeEventType(ol.DeviceOrientationProperty.TRACKING),
this.handleTrackingChanged_, false, this); this.handleTrackingChanged_, false, this);
this.setTracking(ol.isDef(options.tracking) ? this.setTracking(options.tracking !== undefined ? options.tracking : false);
/** @type {boolean} */ (options.tracking) : false);
}; };
goog.inherits(ol.DeviceOrientation, ol.Object); goog.inherits(ol.DeviceOrientation, ol.Object);

View File

@@ -47,7 +47,7 @@ ol.dom.BrowserFeature = {
ol.dom.canUseCssTransform = (function() { ol.dom.canUseCssTransform = (function() {
var canUseCssTransform; var canUseCssTransform;
return function() { return function() {
if (!ol.isDef(canUseCssTransform)) { if (canUseCssTransform === undefined) {
goog.asserts.assert(!goog.isNull(document.body), goog.asserts.assert(!goog.isNull(document.body),
'document.body should not be null'); 'document.body should not be null');
if (!goog.global.getComputedStyle) { if (!goog.global.getComputedStyle) {
@@ -90,7 +90,7 @@ ol.dom.canUseCssTransform = (function() {
ol.dom.canUseCssTransform3D = (function() { ol.dom.canUseCssTransform3D = (function() {
var canUseCssTransform3D; var canUseCssTransform3D;
return function() { return function() {
if (!ol.isDef(canUseCssTransform3D)) { if (canUseCssTransform3D === undefined) {
goog.asserts.assert(!goog.isNull(document.body), goog.asserts.assert(!goog.isNull(document.body),
'document.body should not be null'); 'document.body should not be null');
if (!goog.global.getComputedStyle) { if (!goog.global.getComputedStyle) {
@@ -224,7 +224,7 @@ ol.dom.transformElement2D =
if (ol.dom.canUseCssTransform3D()) { if (ol.dom.canUseCssTransform3D()) {
var value3D; var value3D;
if (ol.isDef(opt_precision)) { if (opt_precision !== undefined) {
/** @type {Array.<string>} */ /** @type {Array.<string>} */
var strings3D = new Array(16); var strings3D = new Array(16);
for (i = 0; i < 16; ++i) { for (i = 0; i < 16; ++i) {
@@ -246,7 +246,7 @@ ol.dom.transformElement2D =
goog.vec.Mat4.getElement(transform, 1, 3) goog.vec.Mat4.getElement(transform, 1, 3)
]; ];
var value2D; var value2D;
if (ol.isDef(opt_precision)) { if (opt_precision !== undefined) {
/** @type {Array.<string>} */ /** @type {Array.<string>} */
var strings2D = new Array(6); var strings2D = new Array(6);
for (i = 0; i < 6; ++i) { for (i = 0; i < 6; ++i) {

View File

@@ -97,7 +97,7 @@ ol.Feature = function(opt_geometryOrProperties) {
this, ol.Object.getChangeEventType(this.geometryName_), this, ol.Object.getChangeEventType(this.geometryName_),
this.handleGeometryChanged_, false, this); this.handleGeometryChanged_, false, this);
if (ol.isDef(opt_geometryOrProperties)) { if (opt_geometryOrProperties !== undefined) {
if (opt_geometryOrProperties instanceof ol.geom.Geometry || if (opt_geometryOrProperties instanceof ol.geom.Geometry ||
goog.isNull(opt_geometryOrProperties)) { goog.isNull(opt_geometryOrProperties)) {
var geometry = /** @type {ol.geom.Geometry} */ (opt_geometryOrProperties); var geometry = /** @type {ol.geom.Geometry} */ (opt_geometryOrProperties);

View File

@@ -46,28 +46,26 @@ ol.format.GML3 = function(opt_options) {
* @private * @private
* @type {boolean} * @type {boolean}
*/ */
this.surface_ = ol.isDef(options.surface) ? this.surface_ = options.surface !== undefined ? options.surface : false;
/** @type {boolean} */ (options.surface) : false;
/** /**
* @private * @private
* @type {boolean} * @type {boolean}
*/ */
this.curve_ = ol.isDef(options.curve) ? this.curve_ = options.curve !== undefined ? options.curve : false;
/** @type {boolean} */ (options.curve) : false;
/** /**
* @private * @private
* @type {boolean} * @type {boolean}
*/ */
this.multiCurve_ = ol.isDef(options.multiCurve) ? this.multiCurve_ = options.multiCurve !== undefined ?
/** @type {boolean} */ (options.multiCurve) : true; options.multiCurve : true;
/** /**
* @private * @private
* @type {boolean} * @type {boolean}
*/ */
this.multiSurface_ = ol.isDef(options.multiSurface) ? this.multiSurface_ = options.multiSurface !== undefined ?
/** @type {boolean} */ (options.multiSurface) : true; /** @type {boolean} */ (options.multiSurface) : true;
/** /**
@@ -787,11 +785,11 @@ ol.format.GML3.prototype.RING_NODE_FACTORY_ =
var parentNode = context.node; var parentNode = context.node;
goog.asserts.assert(goog.isObject(context), 'context should be an Object'); goog.asserts.assert(goog.isObject(context), 'context should be an Object');
var exteriorWritten = context['exteriorWritten']; var exteriorWritten = context['exteriorWritten'];
if (!ol.isDef(exteriorWritten)) { if (exteriorWritten === undefined) {
context['exteriorWritten'] = true; context['exteriorWritten'] = true;
} }
return ol.xml.createElementNS(parentNode.namespaceURI, return ol.xml.createElementNS(parentNode.namespaceURI,
ol.isDef(exteriorWritten) ? 'interior' : 'exterior'); exteriorWritten !== undefined ? 'interior' : 'exterior');
}; };

View File

@@ -89,8 +89,8 @@ ol.format.KML = function(opt_options) {
* @private * @private
* @type {boolean} * @type {boolean}
*/ */
this.extractStyles_ = ol.isDef(options.extractStyles) ? this.extractStyles_ = options.extractStyles !== undefined ?
/** @type {boolean} */ (options.extractStyles) : true; options.extractStyles : true;
/** /**
* @private * @private
@@ -441,7 +441,7 @@ ol.format.KML.readVec2_ = function(node) {
*/ */
ol.format.KML.readScale_ = function(node) { ol.format.KML.readScale_ = function(node) {
var number = ol.format.XSD.readDecimal(node); var number = ol.format.XSD.readDecimal(node);
if (ol.isDef(number)) { if (number !== undefined) {
return Math.sqrt(number); return Math.sqrt(number);
} else { } else {
return undefined; return undefined;
@@ -517,7 +517,7 @@ ol.format.KML.IconStyleParser_ = function(node, objectStack) {
(IconObject['x']); (IconObject['x']);
var y = /** @type {number|undefined} */ var y = /** @type {number|undefined} */
(IconObject['y']); (IconObject['y']);
if (ol.isDef(x) && ol.isDef(y)) { if (x !== undefined && y !== undefined) {
offset = [x, y]; offset = [x, y];
} }
@@ -526,14 +526,14 @@ ol.format.KML.IconStyleParser_ = function(node, objectStack) {
(IconObject['w']); (IconObject['w']);
var h = /** @type {number|undefined} */ var h = /** @type {number|undefined} */
(IconObject['h']); (IconObject['h']);
if (ol.isDef(w) && ol.isDef(h)) { if (w !== undefined && h !== undefined) {
size = [w, h]; size = [w, h];
} }
var rotation; var rotation;
var heading = /** @type {number} */ var heading = /** @type {number} */
(object['heading']); (object['heading']);
if (ol.isDef(heading)) { if (heading !== undefined) {
rotation = goog.math.toRadians(heading); rotation = goog.math.toRadians(heading);
} }
@@ -648,12 +648,12 @@ ol.format.KML.PolyStyleParser_ = function(node, objectStack) {
}); });
styleObject['fillStyle'] = fillStyle; styleObject['fillStyle'] = fillStyle;
var fill = /** @type {boolean|undefined} */ (object['fill']); var fill = /** @type {boolean|undefined} */ (object['fill']);
if (ol.isDef(fill)) { if (fill !== undefined) {
styleObject['fill'] = fill; styleObject['fill'] = fill;
} }
var outline = var outline =
/** @type {boolean|undefined} */ (object['outline']); /** @type {boolean|undefined} */ (object['outline']);
if (ol.isDef(outline)) { if (outline !== undefined) {
styleObject['outline'] = outline; styleObject['outline'] = outline;
} }
}; };
@@ -1018,7 +1018,7 @@ ol.format.KML.readStyle_ = function(node, objectStack) {
styleObject, 'fillStyle', ol.format.KML.DEFAULT_FILL_STYLE_)); styleObject, 'fillStyle', ol.format.KML.DEFAULT_FILL_STYLE_));
var fill = /** @type {boolean|undefined} */ var fill = /** @type {boolean|undefined} */
(styleObject['fill']); (styleObject['fill']);
if (ol.isDef(fill) && !fill) { if (fill !== undefined && !fill) {
fillStyle = null; fillStyle = null;
} }
var imageStyle = /** @type {ol.style.Image} */ (goog.object.get( 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_)); styleObject, 'strokeStyle', ol.format.KML.DEFAULT_STROKE_STYLE_));
var outline = /** @type {boolean|undefined} */ var outline = /** @type {boolean|undefined} */
(styleObject['outline']); (styleObject['outline']);
if (ol.isDef(outline) && !outline) { if (outline !== undefined && !outline) {
strokeStyle = null; strokeStyle = null;
} }
return [new ol.style.Style({ return [new ol.style.Style({
@@ -1061,7 +1061,7 @@ ol.format.KML.setCommonGeometryProperties_ = function(multiGeometry,
geometry = geometries[i]; geometry = geometries[i];
extrudes[i] = geometry.get('extrude'); extrudes[i] = geometry.get('extrude');
altitudeModes[i] = geometry.get('altitudeMode'); altitudeModes[i] = geometry.get('altitudeMode');
hasExtrude = hasExtrude || ol.isDef(extrudes[i]); hasExtrude = hasExtrude || extrudes[i] !== undefined;
hasAltitudeMode = hasAltitudeMode || altitudeModes[i]; hasAltitudeMode = hasAltitudeMode || altitudeModes[i];
} }
if (hasExtrude) { if (hasExtrude) {

View File

@@ -451,7 +451,7 @@ ol.format.WFS.writeUpdate_ = function(node, feature, objectStack) {
var values = []; var values = [];
for (var i = 0, ii = keys.length; i < ii; i++) { for (var i = 0, ii = keys.length; i < ii; i++) {
var value = feature.get(keys[i]); var value = feature.get(keys[i]);
if (ol.isDef(value)) { if (value !== undefined) {
values.push({name: keys[i], value: value}); values.push({name: keys[i], value: value});
} }
} }
@@ -499,10 +499,10 @@ ol.format.WFS.writeNative_ = function(node, nativeElement, objectStack) {
if (nativeElement.vendorId) { if (nativeElement.vendorId) {
node.setAttribute('vendorId', nativeElement.vendorId); node.setAttribute('vendorId', nativeElement.vendorId);
} }
if (ol.isDef(nativeElement.safeToIgnore)) { if (nativeElement.safeToIgnore !== undefined) {
node.setAttribute('safeToIgnore', nativeElement.safeToIgnore); node.setAttribute('safeToIgnore', nativeElement.safeToIgnore);
} }
if (ol.isDef(nativeElement.value)) { if (nativeElement.value !== undefined) {
ol.format.XSD.writeStringTextNode(node, nativeElement.value); ol.format.XSD.writeStringTextNode(node, nativeElement.value);
} }
}; };
@@ -640,16 +640,16 @@ ol.format.WFS.prototype.writeGetFeature = function(options) {
if (options.outputFormat) { if (options.outputFormat) {
node.setAttribute('outputFormat', options.outputFormat); node.setAttribute('outputFormat', options.outputFormat);
} }
if (ol.isDef(options.maxFeatures)) { if (options.maxFeatures !== undefined) {
node.setAttribute('maxFeatures', options.maxFeatures); node.setAttribute('maxFeatures', options.maxFeatures);
} }
if (options.resultType) { if (options.resultType) {
node.setAttribute('resultType', options.resultType); node.setAttribute('resultType', options.resultType);
} }
if (ol.isDef(options.startIndex)) { if (options.startIndex !== undefined) {
node.setAttribute('startIndex', options.startIndex); node.setAttribute('startIndex', options.startIndex);
} }
if (ol.isDef(options.count)) { if (options.count !== undefined) {
node.setAttribute('count', options.count); node.setAttribute('count', options.count);
} }
} }

View File

@@ -38,8 +38,8 @@ ol.format.WKT = function(opt_options) {
* @type {boolean} * @type {boolean}
* @private * @private
*/ */
this.splitCollection_ = ol.isDef(options.splitCollection) ? this.splitCollection_ = options.splitCollection !== undefined ?
/** @type {boolean} */ (options.splitCollection) : false; options.splitCollection : false;
}; };
goog.inherits(ol.format.WKT, ol.format.TextFeature); goog.inherits(ol.format.WKT, ol.format.TextFeature);
@@ -427,7 +427,7 @@ ol.format.WKT.Lexer.prototype.isAlpha_ = function(c) {
* @private * @private
*/ */
ol.format.WKT.Lexer.prototype.isNumeric_ = function(c, opt_decimal) { 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; return c >= '0' && c <= '9' || c == '.' && !decimal;
}; };

View File

@@ -154,8 +154,8 @@ ol.format.WMSCapabilities.readEXGeographicBoundingBox_ =
(geographicBoundingBox['eastBoundLongitude']); (geographicBoundingBox['eastBoundLongitude']);
var northBoundLatitude = /** @type {number|undefined} */ var northBoundLatitude = /** @type {number|undefined} */
(geographicBoundingBox['northBoundLatitude']); (geographicBoundingBox['northBoundLatitude']);
if (!ol.isDef(westBoundLongitude) || !ol.isDef(southBoundLatitude) || if (westBoundLongitude === undefined || southBoundLatitude === undefined ||
!ol.isDef(eastBoundLongitude) || !ol.isDef(northBoundLatitude)) { eastBoundLongitude === undefined || northBoundLatitude === undefined) {
return undefined; return undefined;
} }
return /** @type {ol.Extent} */ ([ return /** @type {ol.Extent} */ ([
@@ -303,30 +303,30 @@ ol.format.WMSCapabilities.readLayer_ = function(node, objectStack) {
} }
var queryable = var queryable =
ol.format.XSD.readBooleanString(node.getAttribute('queryable')); ol.format.XSD.readBooleanString(node.getAttribute('queryable'));
if (!ol.isDef(queryable)) { if (queryable === undefined) {
queryable = parentLayerObject['queryable']; queryable = parentLayerObject['queryable'];
} }
layerObject['queryable'] = ol.isDef(queryable) ? queryable : false; layerObject['queryable'] = queryable !== undefined ? queryable : false;
var cascaded = ol.format.XSD.readNonNegativeIntegerString( var cascaded = ol.format.XSD.readNonNegativeIntegerString(
node.getAttribute('cascaded')); node.getAttribute('cascaded'));
if (!ol.isDef(cascaded)) { if (cascaded === undefined) {
cascaded = parentLayerObject['cascaded']; cascaded = parentLayerObject['cascaded'];
} }
layerObject['cascaded'] = cascaded; layerObject['cascaded'] = cascaded;
var opaque = ol.format.XSD.readBooleanString(node.getAttribute('opaque')); var opaque = ol.format.XSD.readBooleanString(node.getAttribute('opaque'));
if (!ol.isDef(opaque)) { if (opaque === undefined) {
opaque = parentLayerObject['opaque']; opaque = parentLayerObject['opaque'];
} }
layerObject['opaque'] = ol.isDef(opaque) ? opaque : false; layerObject['opaque'] = opaque !== undefined ? opaque : false;
var noSubsets = var noSubsets =
ol.format.XSD.readBooleanString(node.getAttribute('noSubsets')); ol.format.XSD.readBooleanString(node.getAttribute('noSubsets'));
if (!ol.isDef(noSubsets)) { if (noSubsets === undefined) {
noSubsets = parentLayerObject['noSubsets']; noSubsets = parentLayerObject['noSubsets'];
} }
layerObject['noSubsets'] = ol.isDef(noSubsets) ? noSubsets : false; layerObject['noSubsets'] = noSubsets !== undefined ? noSubsets : false;
var fixedWidth = var fixedWidth =
ol.format.XSD.readDecimalString(node.getAttribute('fixedWidth')); ol.format.XSD.readDecimalString(node.getAttribute('fixedWidth'));

View File

@@ -30,7 +30,7 @@ ol.format.XSD.readBoolean = function(node) {
ol.format.XSD.readBooleanString = function(string) { ol.format.XSD.readBooleanString = function(string) {
var m = /^\s*(true|1)|(false|0)\s*$/.exec(string); var m = /^\s*(true|1)|(false|0)\s*$/.exec(string);
if (m) { if (m) {
return ol.isDef(m[1]) || false; return m[1] !== undefined || false;
} else { } else {
return undefined; return undefined;
} }
@@ -57,7 +57,7 @@ ol.format.XSD.readDateTime = function(node) {
if (m[7] != 'Z') { if (m[7] != 'Z') {
var sign = m[8] == '-' ? -1 : 1; var sign = m[8] == '-' ? -1 : 1;
dateTime += sign * 60 * parseInt(m[9], 10); dateTime += sign * 60 * parseInt(m[9], 10);
if (ol.isDef(m[10])) { if (m[10] !== undefined) {
dateTime += sign * 60 * 60 * parseInt(m[10], 10); dateTime += sign * 60 * 60 * parseInt(m[10], 10);
} }
} }

View File

@@ -44,7 +44,7 @@ ol.geom.flat.orient.linearRingIsClockwise =
*/ */
ol.geom.flat.orient.linearRingsAreOriented = ol.geom.flat.orient.linearRingsAreOriented =
function(flatCoordinates, offset, ends, stride, opt_right) { 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; var i, ii;
for (i = 0, ii = ends.length; i < ii; ++i) { for (i = 0, ii = ends.length; i < ii; ++i) {
var end = ends[i]; var end = ends[i];
@@ -106,7 +106,7 @@ ol.geom.flat.orient.linearRingssAreOriented =
*/ */
ol.geom.flat.orient.orientLinearRings = ol.geom.flat.orient.orientLinearRings =
function(flatCoordinates, offset, ends, stride, opt_right) { 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; var i, ii;
for (i = 0, ii = ends.length; i < ii; ++i) { for (i = 0, ii = ends.length; i < ii; ++i) {
var end = ends[i]; var end = ends[i];

View File

@@ -149,8 +149,7 @@ ol.geom.LineString.prototype.getCoordinateAtM = function(m, opt_extrapolate) {
this.layout != ol.geom.GeometryLayout.XYZM) { this.layout != ol.geom.GeometryLayout.XYZM) {
return null; return null;
} }
var extrapolate = ol.isDef(opt_extrapolate) ? var extrapolate = opt_extrapolate !== undefined ? opt_extrapolate : false;
/** @type {boolean} */ (opt_extrapolate) : false;
return ol.geom.flat.lineStringCoordinateAtM(this.flatCoordinates, 0, return ol.geom.flat.lineStringCoordinateAtM(this.flatCoordinates, 0,
this.flatCoordinates.length, this.stride, m, extrapolate); this.flatCoordinates.length, this.stride, m, extrapolate);
}; };

View File

@@ -136,10 +136,8 @@ ol.geom.MultiLineString.prototype.getCoordinateAtM =
this.flatCoordinates.length === 0) { this.flatCoordinates.length === 0) {
return null; return null;
} }
var extrapolate = ol.isDef(opt_extrapolate) ? var extrapolate = opt_extrapolate !== undefined ? opt_extrapolate : false;
/** @type {boolean} */ (opt_extrapolate) : false; var interpolate = opt_interpolate !== undefined ? opt_interpolate : false;
var interpolate = ol.isDef(opt_interpolate) ?
/** @type {boolean} */ (opt_interpolate) : false;
return ol.geom.flat.lineStringsCoordinateAtM(this.flatCoordinates, 0, return ol.geom.flat.lineStringsCoordinateAtM(this.flatCoordinates, 0,
this.ends_, this.stride, m, extrapolate, interpolate); this.ends_, this.stride, m, extrapolate, interpolate);
}; };

View File

@@ -183,7 +183,7 @@ ol.geom.MultiPolygon.prototype.getArea = function() {
*/ */
ol.geom.MultiPolygon.prototype.getCoordinates = function(opt_right) { ol.geom.MultiPolygon.prototype.getCoordinates = function(opt_right) {
var flatCoordinates; var flatCoordinates;
if (ol.isDef(opt_right)) { if (opt_right !== undefined) {
flatCoordinates = this.getOrientedFlatCoordinates().slice(); flatCoordinates = this.getOrientedFlatCoordinates().slice();
ol.geom.flat.orient.orientLinearRingss( ol.geom.flat.orient.orientLinearRingss(
flatCoordinates, 0, this.endss_, this.stride, opt_right); flatCoordinates, 0, this.endss_, this.stride, opt_right);

View File

@@ -170,7 +170,7 @@ ol.geom.Polygon.prototype.getArea = function() {
*/ */
ol.geom.Polygon.prototype.getCoordinates = function(opt_right) { ol.geom.Polygon.prototype.getCoordinates = function(opt_right) {
var flatCoordinates; var flatCoordinates;
if (ol.isDef(opt_right)) { if (opt_right !== undefined) {
flatCoordinates = this.getOrientedFlatCoordinates().slice(); flatCoordinates = this.getOrientedFlatCoordinates().slice();
ol.geom.flat.orient.orientLinearRings( ol.geom.flat.orient.orientLinearRings(
flatCoordinates, 0, this.ends_, this.stride, opt_right); flatCoordinates, 0, this.ends_, this.stride, opt_right);

View File

@@ -90,17 +90,17 @@ ol.interaction.DragRotateAndZoom.handleDragEvent_ = function(mapBrowserEvent) {
var magnitude = delta.magnitude(); var magnitude = delta.magnitude();
var view = map.getView(); var view = map.getView();
map.render(); map.render();
if (ol.isDef(this.lastAngle_)) { if (this.lastAngle_ !== undefined) {
var angleDelta = theta - this.lastAngle_; var angleDelta = theta - this.lastAngle_;
ol.interaction.Interaction.rotateWithoutConstraints( ol.interaction.Interaction.rotateWithoutConstraints(
map, view, view.getRotation() - angleDelta); map, view, view.getRotation() - angleDelta);
} }
this.lastAngle_ = theta; this.lastAngle_ = theta;
if (ol.isDef(this.lastMagnitude_)) { if (this.lastMagnitude_ !== undefined) {
var resolution = this.lastMagnitude_ * (view.getResolution() / magnitude); var resolution = this.lastMagnitude_ * (view.getResolution() / magnitude);
ol.interaction.Interaction.zoomWithoutConstraints(map, view, resolution); ol.interaction.Interaction.zoomWithoutConstraints(map, view, resolution);
} }
if (ol.isDef(this.lastMagnitude_)) { if (this.lastMagnitude_ !== undefined) {
this.lastScaleDelta_ = this.lastMagnitude_ / magnitude; this.lastScaleDelta_ = this.lastMagnitude_ / magnitude;
} }
this.lastMagnitude_ = magnitude; this.lastMagnitude_ = magnitude;

View File

@@ -69,7 +69,7 @@ ol.interaction.DragRotate.handleDragEvent_ = function(mapBrowserEvent) {
var offset = mapBrowserEvent.pixel; var offset = mapBrowserEvent.pixel;
var theta = var theta =
Math.atan2(size[1] / 2 - offset[1], offset[0] - size[0] / 2); 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 delta = theta - this.lastAngle_;
var view = map.getView(); var view = map.getView();
var rotation = view.getRotation(); var rotation = view.getRotation();

View File

@@ -150,7 +150,7 @@ ol.interaction.Interaction.rotateWithoutConstraints =
if (goog.isDefAndNotNull(rotation)) { if (goog.isDefAndNotNull(rotation)) {
var currentRotation = view.getRotation(); var currentRotation = view.getRotation();
var currentCenter = view.getCenter(); var currentCenter = view.getCenter();
if (ol.isDef(currentRotation) && currentCenter && if (currentRotation !== undefined && currentCenter &&
opt_duration && opt_duration > 0) { opt_duration && opt_duration > 0) {
map.beforeRender(ol.animation.rotate({ map.beforeRender(ol.animation.rotate({
rotation: currentRotation, rotation: currentRotation,
@@ -221,7 +221,7 @@ ol.interaction.Interaction.zoomWithoutConstraints =
if (goog.isDefAndNotNull(resolution)) { if (goog.isDefAndNotNull(resolution)) {
var currentResolution = view.getResolution(); var currentResolution = view.getResolution();
var currentCenter = view.getCenter(); var currentCenter = view.getCenter();
if (ol.isDef(currentResolution) && currentCenter && if (currentResolution !== undefined && currentCenter &&
opt_duration && opt_duration > 0) { opt_duration && opt_duration > 0) {
map.beforeRender(ol.animation.zoom({ map.beforeRender(ol.animation.zoom({
resolution: /** @type {number} */ (currentResolution), resolution: /** @type {number} */ (currentResolution),

View File

@@ -48,13 +48,13 @@ ol.interaction.defaults = function(opt_options) {
var kinetic = new ol.Kinetic(-0.005, 0.05, 100); var kinetic = new ol.Kinetic(-0.005, 0.05, 100);
var altShiftDragRotate = ol.isDef(options.altShiftDragRotate) ? var altShiftDragRotate = options.altShiftDragRotate !== undefined ?
options.altShiftDragRotate : true; options.altShiftDragRotate : true;
if (altShiftDragRotate) { if (altShiftDragRotate) {
interactions.push(new ol.interaction.DragRotate()); interactions.push(new ol.interaction.DragRotate());
} }
var doubleClickZoom = ol.isDef(options.doubleClickZoom) ? var doubleClickZoom = options.doubleClickZoom !== undefined ?
options.doubleClickZoom : true; options.doubleClickZoom : true;
if (doubleClickZoom) { if (doubleClickZoom) {
interactions.push(new ol.interaction.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) { if (dragPan) {
interactions.push(new ol.interaction.DragPan({ interactions.push(new ol.interaction.DragPan({
kinetic: kinetic kinetic: kinetic
})); }));
} }
var pinchRotate = ol.isDef(options.pinchRotate) ? options.pinchRotate : var pinchRotate = options.pinchRotate !== undefined ? options.pinchRotate :
true; true;
if (pinchRotate) { if (pinchRotate) {
interactions.push(new ol.interaction.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) { if (pinchZoom) {
interactions.push(new ol.interaction.PinchZoom({ interactions.push(new ol.interaction.PinchZoom({
duration: options.zoomDuration duration: options.zoomDuration
})); }));
} }
var keyboard = ol.isDef(options.keyboard) ? options.keyboard : true; var keyboard = options.keyboard !== undefined ? options.keyboard : true;
if (keyboard) { if (keyboard) {
interactions.push(new ol.interaction.KeyboardPan()); interactions.push(new ol.interaction.KeyboardPan());
interactions.push(new ol.interaction.KeyboardZoom({ 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; options.mouseWheelZoom : true;
if (mouseWheelZoom) { if (mouseWheelZoom) {
interactions.push(new ol.interaction.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; options.shiftDragZoom : true;
if (shiftDragZoom) { if (shiftDragZoom) {
interactions.push(new ol.interaction.DragZoom()); interactions.push(new ol.interaction.DragZoom());

View File

@@ -35,14 +35,14 @@ ol.interaction.KeyboardPan = function(opt_options) {
handleEvent: ol.interaction.KeyboardPan.handleEvent handleEvent: ol.interaction.KeyboardPan.handleEvent
}); });
var options = ol.isDef(opt_options) ? opt_options : {}; var options = opt_options || {};
/** /**
* @private * @private
* @type {ol.events.ConditionType} * @type {ol.events.ConditionType}
*/ */
this.condition_ = ol.isDef(options.condition) ? this.condition_ = options.condition !== undefined ?
/** @type {ol.events.ConditionType} */ (options.condition) : options.condition :
goog.functions.and(ol.events.condition.noModifierKeys, goog.functions.and(ol.events.condition.noModifierKeys,
ol.events.condition.targetNotEditable); ol.events.condition.targetNotEditable);
@@ -50,15 +50,14 @@ ol.interaction.KeyboardPan = function(opt_options) {
* @private * @private
* @type {number} * @type {number}
*/ */
this.duration_ = ol.isDef(options.duration) ? this.duration_ = options.duration !== undefined ? options.duration : 100;
/** @type {number} */ (options.duration) : 100;
/** /**
* @private * @private
* @type {number} * @type {number}
*/ */
this.pixelDelta_ = ol.isDef(options.pixelDelta) ? this.pixelDelta_ = options.pixelDelta !== undefined ?
/** @type {number} */ (options.pixelDelta) : 128; options.pixelDelta : 128;
}; };
goog.inherits(ol.interaction.KeyboardPan, ol.interaction.Interaction); goog.inherits(ol.interaction.KeyboardPan, ol.interaction.Interaction);

View File

@@ -162,8 +162,8 @@ ol.interaction.Modify = function(options) {
* @type {number} * @type {number}
* @private * @private
*/ */
this.pixelTolerance_ = ol.isDef(options.pixelTolerance) ? this.pixelTolerance_ = options.pixelTolerance !== undefined ?
/** @type {number} */ (options.pixelTolerance) : 10; options.pixelTolerance : 10;
/** /**
* @type {boolean} * @type {boolean}
@@ -823,9 +823,9 @@ ol.interaction.Modify.prototype.insertVertex_ = function(segmentData, vertex) {
this.setGeometryCoordinates_(geometry, coordinates); this.setGeometryCoordinates_(geometry, coordinates);
var rTree = this.rBush_; 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); 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); this.updateSegmentIndices_(geometry, /** @type {number} */ (index), depth, 1);
var newSegmentData = /** @type {ol.interaction.SegmentDataType} */ ({ var newSegmentData = /** @type {ol.interaction.SegmentDataType} */ ({
segment: [segment[0], vertex], segment: [segment[0], vertex],
@@ -884,13 +884,13 @@ ol.interaction.Modify.prototype.removeVertex_ = function() {
segmentsByFeature[uid] = [left, right, index]; segmentsByFeature[uid] = [left, right, index];
} }
newSegment = segmentsByFeature[uid]; newSegment = segmentsByFeature[uid];
if (ol.isDef(left)) { if (left !== undefined) {
newSegment[0] = left; newSegment[0] = left;
} }
if (ol.isDef(right)) { if (right !== undefined) {
newSegment[1] = right; newSegment[1] = right;
} }
if (ol.isDef(newSegment[0]) && ol.isDef(newSegment[1])) { if (newSegment[0] !== undefined && newSegment[1] !== undefined) {
component = coordinates; component = coordinates;
deleted = false; deleted = false;
newIndex = index - 1; newIndex = index - 1;

View File

@@ -25,7 +25,7 @@ ol.interaction.MouseWheelZoom = function(opt_options) {
handleEvent: ol.interaction.MouseWheelZoom.handleEvent handleEvent: ol.interaction.MouseWheelZoom.handleEvent
}); });
var options = ol.isDef(opt_options) ? opt_options : {}; var options = opt_options || {};
/** /**
* @private * @private
@@ -37,15 +37,13 @@ ol.interaction.MouseWheelZoom = function(opt_options) {
* @private * @private
* @type {number} * @type {number}
*/ */
this.duration_ = ol.isDef(options.duration) ? this.duration_ = options.duration !== undefined ? options.duration : 250;
/** @type {number} */ (options.duration) : 250;
/** /**
* @private * @private
* @type {boolean} * @type {boolean}
*/ */
this.useAnchor_ = ol.isDef(options.useAnchor) ? this.useAnchor_ = options.useAnchor !== undefined ? options.useAnchor : true;
/** @type {boolean} */ (options.useAnchor) : true;
/** /**
* @private * @private
@@ -92,7 +90,7 @@ ol.interaction.MouseWheelZoom.handleEvent = function(mapBrowserEvent) {
this.delta_ += mouseWheelEvent.deltaY; this.delta_ += mouseWheelEvent.deltaY;
if (!ol.isDef(this.startTime_)) { if (this.startTime_ === undefined) {
this.startTime_ = goog.now(); this.startTime_ = goog.now();
} }

View File

@@ -29,7 +29,7 @@ ol.interaction.PinchRotate = function(opt_options) {
handleUpEvent: ol.interaction.PinchRotate.handleUpEvent_ handleUpEvent: ol.interaction.PinchRotate.handleUpEvent_
}); });
var options = ol.isDef(opt_options) ? opt_options : {}; var options = opt_options || {};
/** /**
* @private * @private
@@ -59,15 +59,13 @@ ol.interaction.PinchRotate = function(opt_options) {
* @private * @private
* @type {number} * @type {number}
*/ */
this.threshold_ = ol.isDef(options.threshold) ? this.threshold_ = options.threshold !== undefined ? options.threshold : 0.3;
/** @type {number} */ (options.threshold) : 0.3;
/** /**
* @private * @private
* @type {number} * @type {number}
*/ */
this.duration_ = ol.isDef(options.duration) ? this.duration_ = options.duration !== undefined ? options.duration : 250;
/** @type {number} */ (options.duration) : 250;
}; };
goog.inherits(ol.interaction.PinchRotate, ol.interaction.Pointer); goog.inherits(ol.interaction.PinchRotate, ol.interaction.Pointer);
@@ -91,7 +89,7 @@ ol.interaction.PinchRotate.handleDragEvent_ = function(mapBrowserEvent) {
touch1.clientY - touch0.clientY, touch1.clientY - touch0.clientY,
touch1.clientX - touch0.clientX); touch1.clientX - touch0.clientX);
if (ol.isDef(this.lastAngle_)) { if (this.lastAngle_ !== undefined) {
var delta = angle - this.lastAngle_; var delta = angle - this.lastAngle_;
this.rotationDelta_ += delta; this.rotationDelta_ += delta;
if (!this.rotating_ && if (!this.rotating_ &&

View File

@@ -41,8 +41,7 @@ ol.interaction.PinchZoom = function(opt_options) {
* @private * @private
* @type {number} * @type {number}
*/ */
this.duration_ = ol.isDef(options.duration) ? this.duration_ = options.duration !== undefined ? options.duration : 400;
/** @type {number} */ (options.duration) : 400;
/** /**
* @private * @private
@@ -78,7 +77,7 @@ ol.interaction.PinchZoom.handleDragEvent_ = function(mapBrowserEvent) {
// distance between touches // distance between touches
var distance = Math.sqrt(dx * dx + dy * dy); var distance = Math.sqrt(dx * dx + dy * dy);
if (ol.isDef(this.lastDistance_)) { if (this.lastDistance_ !== undefined) {
scaleDelta = this.lastDistance_ / distance; scaleDelta = this.lastDistance_ / distance;
} }
this.lastDistance_ = distance; this.lastDistance_ = distance;

View File

@@ -115,8 +115,8 @@ ol.interaction.Snap = function(opt_options) {
* @type {number} * @type {number}
* @private * @private
*/ */
this.pixelTolerance_ = ol.isDef(options.pixelTolerance) ? this.pixelTolerance_ = options.pixelTolerance !== undefined ?
/** @type {number} */ (options.pixelTolerance) : 10; options.pixelTolerance : 10;
/** /**
* @type {function(ol.interaction.Snap.SegmentDataType, ol.interaction.Snap.SegmentDataType): number} * @type {function(ol.interaction.Snap.SegmentDataType, ol.interaction.Snap.SegmentDataType): number}
@@ -160,8 +160,7 @@ goog.inherits(ol.interaction.Snap, ol.interaction.Pointer);
* @api * @api
*/ */
ol.interaction.Snap.prototype.addFeature = function(feature, opt_listen) { ol.interaction.Snap.prototype.addFeature = function(feature, opt_listen) {
var listen = ol.isDef(opt_listen) ? var listen = opt_listen !== undefined ? opt_listen : true;
/** @type {boolean} */ (opt_listen) : true;
var geometry = feature.getGeometry(); var geometry = feature.getGeometry();
var segmentWriter = this.SEGMENT_WRITERS_[geometry.getType()]; var segmentWriter = this.SEGMENT_WRITERS_[geometry.getType()];
if (segmentWriter) { if (segmentWriter) {
@@ -288,8 +287,7 @@ ol.interaction.Snap.prototype.handleGeometryModify_ = function(feature, evt) {
* @api * @api
*/ */
ol.interaction.Snap.prototype.removeFeature = function(feature, opt_unlisten) { ol.interaction.Snap.prototype.removeFeature = function(feature, opt_unlisten) {
var unlisten = ol.isDef(opt_unlisten) ? var unlisten = opt_unlisten !== undefined ? opt_unlisten : true;
/** @type {boolean} */ (opt_unlisten) : true;
var feature_uid = goog.getUid(feature); var feature_uid = goog.getUid(feature);
var extent = this.indexedFeaturesExtents_[feature_uid]; var extent = this.indexedFeaturesExtents_[feature_uid];
if (extent) { if (extent) {

View File

@@ -59,8 +59,7 @@ ol.layer.Heatmap = function(opt_options) {
* @private * @private
* @type {number} * @type {number}
*/ */
this.shadow_ = ol.isDef(options.shadow) ? this.shadow_ = options.shadow !== undefined ? options.shadow : 250;
/** @type {number} */ (options.shadow) : 250;
/** /**
* @private * @private
@@ -81,10 +80,10 @@ ol.layer.Heatmap = function(opt_options) {
this.setGradient(options.gradient ? this.setGradient(options.gradient ?
options.gradient : ol.layer.Heatmap.DEFAULT_GRADIENT); options.gradient : ol.layer.Heatmap.DEFAULT_GRADIENT);
this.setBlur(ol.isDef(options.blur) ? this.setBlur(options.blur !== undefined ?
/** @type {number} */ (options.blur) : 15); /** @type {number} */ (options.blur) : 15);
this.setRadius(ol.isDef(options.radius) ? this.setRadius(options.radius !== undefined ?
/** @type {number} */ (options.radius) : 8); /** @type {number} */ (options.radius) : 8);
goog.events.listen(this, [ goog.events.listen(this, [
@@ -112,8 +111,8 @@ ol.layer.Heatmap = function(opt_options) {
goog.asserts.assert(this.circleImage_ !== undefined, goog.asserts.assert(this.circleImage_ !== undefined,
'this.circleImage_ should be defined'); 'this.circleImage_ should be defined');
var weight = weightFunction(feature); var weight = weightFunction(feature);
var opacity = ol.isDef(weight) ? var opacity = weight !== undefined ?
goog.math.clamp(/** @type {number} */ (weight), 0, 1) : 1; goog.math.clamp(weight, 0, 1) : 1;
// cast to 8 bits // cast to 8 bits
var index = (255 * opacity) | 0; var index = (255 * opacity) | 0;
var style = this.styleCache_[index]; var style = this.styleCache_[index];

View File

@@ -109,8 +109,7 @@ ol.layer.Layer.prototype.getLayerStatesArray = function(opt_states) {
*/ */
ol.layer.Layer.prototype.getSource = function() { ol.layer.Layer.prototype.getSource = function() {
var source = this.get(ol.layer.LayerProperty.SOURCE); var source = this.get(ol.layer.LayerProperty.SOURCE);
return ol.isDef(source) ? return /** @type {ol.source.Source} */ (source) || null;
/** @type {ol.source.Source} */ (source) : null;
}; };

View File

@@ -68,23 +68,23 @@ ol.layer.Base = function(options) {
*/ */
var properties = goog.object.clone(options); var properties = goog.object.clone(options);
properties[ol.layer.LayerProperty.BRIGHTNESS] = properties[ol.layer.LayerProperty.BRIGHTNESS] =
ol.isDef(options.brightness) ? options.brightness : 0; options.brightness !== undefined ? options.brightness : 0;
properties[ol.layer.LayerProperty.CONTRAST] = properties[ol.layer.LayerProperty.CONTRAST] =
ol.isDef(options.contrast) ? options.contrast : 1; options.contrast !== undefined ? options.contrast : 1;
properties[ol.layer.LayerProperty.HUE] = properties[ol.layer.LayerProperty.HUE] =
ol.isDef(options.hue) ? options.hue : 0; options.hue !== undefined ? options.hue : 0;
properties[ol.layer.LayerProperty.OPACITY] = properties[ol.layer.LayerProperty.OPACITY] =
ol.isDef(options.opacity) ? options.opacity : 1; options.opacity !== undefined ? options.opacity : 1;
properties[ol.layer.LayerProperty.SATURATION] = properties[ol.layer.LayerProperty.SATURATION] =
ol.isDef(options.saturation) ? options.saturation : 1; options.saturation !== undefined ? options.saturation : 1;
properties[ol.layer.LayerProperty.VISIBLE] = properties[ol.layer.LayerProperty.VISIBLE] =
ol.isDef(options.visible) ? options.visible : true; options.visible !== undefined ? options.visible : true;
properties[ol.layer.LayerProperty.Z_INDEX] = 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] = 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] = properties[ol.layer.LayerProperty.MIN_RESOLUTION] =
ol.isDef(options.minResolution) ? options.minResolution : 0; options.minResolution !== undefined ? options.minResolution : 0;
this.setProperties(properties); this.setProperties(properties);
}; };

View File

@@ -38,10 +38,9 @@ ol.layer.Tile = function(opt_options) {
delete baseOptions.useInterimTilesOnError; delete baseOptions.useInterimTilesOnError;
goog.base(this, /** @type {olx.layer.LayerOptions} */ (baseOptions)); goog.base(this, /** @type {olx.layer.LayerOptions} */ (baseOptions));
this.setPreload(ol.isDef(options.preload) ? this.setPreload(options.preload !== undefined ? options.preload : 0);
/** @type {number} */ (options.preload) : 0); this.setUseInterimTilesOnError(options.useInterimTilesOnError !== undefined ?
this.setUseInterimTilesOnError(ol.isDef(options.useInterimTilesOnError) ? options.useInterimTilesOnError : true);
/** @type {boolean} */ (options.useInterimTilesOnError) : true);
}; };
goog.inherits(ol.layer.Tile, ol.layer.Layer); goog.inherits(ol.layer.Tile, ol.layer.Layer);

View File

@@ -51,8 +51,8 @@ ol.layer.Vector = function(opt_options) {
* @type {number} * @type {number}
* @private * @private
*/ */
this.renderBuffer_ = ol.isDef(options.renderBuffer) ? this.renderBuffer_ = options.renderBuffer !== undefined ?
/** @type {number} */ (options.renderBuffer) : 100; options.renderBuffer : 100;
/** /**
* User provided style. * User provided style.
@@ -74,15 +74,15 @@ ol.layer.Vector = function(opt_options) {
* @type {boolean} * @type {boolean}
* @private * @private
*/ */
this.updateWhileAnimating_ = ol.isDef(options.updateWhileAnimating) ? this.updateWhileAnimating_ = options.updateWhileAnimating !== undefined ?
/** @type {boolean} */ (options.updateWhileAnimating) : false; options.updateWhileAnimating : false;
/** /**
* @type {boolean} * @type {boolean}
* @private * @private
*/ */
this.updateWhileInteracting_ = ol.isDef(options.updateWhileInteracting) ? this.updateWhileInteracting_ = options.updateWhileInteracting !== undefined ?
/** @type {boolean} */ (options.updateWhileInteracting) : false; options.updateWhileInteracting : false;
}; };
goog.inherits(ol.layer.Vector, ol.layer.Layer); goog.inherits(ol.layer.Vector, ol.layer.Layer);
@@ -180,11 +180,7 @@ ol.layer.Vector.prototype.setRenderOrder = function(renderOrder) {
* @api stable * @api stable
*/ */
ol.layer.Vector.prototype.setStyle = function(style) { ol.layer.Vector.prototype.setStyle = function(style) {
this.style_ = ol.isDef(style) ? this.style_ = style !== undefined ? style : ol.style.defaultStyleFunction;
/**
* @type {ol.style.Style|Array.<ol.style.Style>|ol.style.StyleFunction|null}
*/
(style) : ol.style.defaultStyleFunction;
this.styleFunction_ = goog.isNull(style) ? this.styleFunction_ = goog.isNull(style) ?
undefined : ol.style.createStyleFunction(this.style_); undefined : ol.style.createStyleFunction(this.style_);
this.changed(); this.changed();

View File

@@ -240,13 +240,3 @@ ol.WEBGL_EXTENSIONS; // value is set in `ol.has`
ol.inherits = ol.inherits =
goog.inherits; goog.inherits;
// note that the newline above is necessary to satisfy the linter // 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;
};

View File

@@ -169,7 +169,7 @@ ol.pointer.TouchSource.prototype.resetClickCountHandler_ = function() {
* @private * @private
*/ */
ol.pointer.TouchSource.prototype.cancelResetClickCount_ = function() { ol.pointer.TouchSource.prototype.cancelResetClickCount_ = function() {
if (ol.isDef(this.resetId_)) { if (this.resetId_ !== undefined) {
goog.global.clearTimeout(this.resetId_); goog.global.clearTimeout(this.resetId_);
} }
}; };

View File

@@ -140,7 +140,7 @@ ol.renderer.Map.prototype.forEachFeatureAtCoordinate =
* @return {?} Callback result. * @return {?} Callback result.
*/ */
function forEachFeatureAtCoordinate(feature) { 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(); var key = goog.getUid(feature).toString();
if (!(key in features)) { if (!(key in features)) {
features[key] = true; features[key] = true;
@@ -242,7 +242,7 @@ ol.renderer.Map.prototype.hasFeatureAtCoordinate =
var hasFeature = this.forEachFeatureAtCoordinate( var hasFeature = this.forEachFeatureAtCoordinate(
coordinate, frameState, goog.functions.TRUE, this, layerFilter, thisArg); coordinate, frameState, goog.functions.TRUE, this, layerFilter, thisArg);
return ol.isDef(hasFeature); return hasFeature !== undefined;
}; };