Inline goog.isDef() property checks

This commit is contained in:
Tim Schaub
2015-09-27 10:21:50 -06:00
parent 7659e47e07
commit b36d697585
27 changed files with 58 additions and 58 deletions

View File

@@ -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);
}

View File

@@ -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;

View File

@@ -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 {

View File

@@ -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.<ol.RendererType>}
*/
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 {

View File

@@ -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);
}

View File

@@ -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;
}

View File

@@ -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);

View File

@@ -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(

View File

@@ -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);
}

View File

@@ -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)) {

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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)) {

View File

@@ -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 {

View File

@@ -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];
}

View File

@@ -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)) {

View File

@@ -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];

View File

@@ -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);
}

View File

@@ -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;

View File

@@ -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.<string, Array.<ol.TileRange>>} */

View File

@@ -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);
}

View File

@@ -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"

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -64,7 +64,7 @@ ol.tilegrid.TileGrid = function(options) {
* @type {Array.<ol.Coordinate>}
*/
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.<number|ol.Size>}
*/
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) {

View File

@@ -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);