Reduce the use of goog.*
This commit is contained in:
@@ -171,5 +171,5 @@ ol.featureloader.xhr = function(url, format) {
|
||||
*/
|
||||
function(features) {
|
||||
this.addFeatures(features);
|
||||
}, goog.nullFunction);
|
||||
}, ol.nullFunction);
|
||||
};
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
goog.provide('ol.format.MVT');
|
||||
|
||||
goog.require('goog.array');
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.ext.pbf');
|
||||
@@ -37,7 +36,7 @@ ol.format.MVT = function(opt_options) {
|
||||
|
||||
goog.base(this);
|
||||
|
||||
var options = goog.isDef(opt_options) ? opt_options : {};
|
||||
var options = opt_options ? opt_options : {};
|
||||
|
||||
/**
|
||||
* @type {ol.proj.Projection}
|
||||
@@ -53,27 +52,27 @@ ol.format.MVT = function(opt_options) {
|
||||
* function(ol.geom.GeometryType,Array.<number>,
|
||||
* (Array.<number>|Array.<Array.<number>>),Object.<string, *>)}
|
||||
*/
|
||||
this.featureClass_ = goog.isDef(options.featureClass) ?
|
||||
this.featureClass_ = options.featureClass ?
|
||||
options.featureClass : ol.render.Feature;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {string}
|
||||
*/
|
||||
this.geometryName_ = goog.isDef(options.geometryName) ?
|
||||
this.geometryName_ = options.geometryName ?
|
||||
options.geometryName : 'geometry';
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {string}
|
||||
*/
|
||||
this.layerName_ = goog.isDef(options.layerName) ? options.layerName : 'layer';
|
||||
this.layerName_ = options.layerName ? options.layerName : 'layer';
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {Array.<string>}
|
||||
*/
|
||||
this.layers_ = goog.isDef(options.layers) ? options.layers : null;
|
||||
this.layers_ = options.layers ? options.layers : null;
|
||||
|
||||
this.rightHandedPolygons = true;
|
||||
|
||||
@@ -104,7 +103,7 @@ ol.format.MVT.prototype.readFeature_ = function(
|
||||
var geometry = ol.format.Feature.transformWithOptions(
|
||||
ol.format.MVT.readGeometry_(rawFeature), false,
|
||||
this.adaptOptions(opt_options));
|
||||
if (!goog.isNull(geometry)) {
|
||||
if (geometry) {
|
||||
goog.asserts.assertInstanceof(geometry, ol.geom.Geometry);
|
||||
values[this.geometryName_] = geometry;
|
||||
}
|
||||
@@ -176,7 +175,7 @@ ol.format.MVT.prototype.readFeatures = function(source, opt_options) {
|
||||
var featureClass = this.featureClass_;
|
||||
var layer, feature;
|
||||
for (var name in tile.layers) {
|
||||
if (!goog.isNull(layers) && !goog.array.contains(layers, name)) {
|
||||
if (layers && layers.indexOf(name) == -1) {
|
||||
continue;
|
||||
}
|
||||
layer = tile.layers[name];
|
||||
|
||||
@@ -27,7 +27,7 @@ ol.layer.VectorTileProperty = {
|
||||
* @api
|
||||
*/
|
||||
ol.layer.VectorTile = function(opt_options) {
|
||||
var options = goog.isDef(opt_options) ? opt_options : {};
|
||||
var options = opt_options ? opt_options : {};
|
||||
|
||||
var baseOptions = goog.object.clone(options);
|
||||
|
||||
@@ -35,8 +35,8 @@ ol.layer.VectorTile = function(opt_options) {
|
||||
delete baseOptions.useInterimTilesOnError;
|
||||
goog.base(this, /** @type {olx.layer.VectorOptions} */ (baseOptions));
|
||||
|
||||
this.setPreload(goog.isDef(options.preload) ? options.preload : 0);
|
||||
this.setUseInterimTilesOnError(goog.isDef(options.useInterimTilesOnError) ?
|
||||
this.setPreload(options.preload ? options.preload : 0);
|
||||
this.setUseInterimTilesOnError(options.useInterimTilesOnError ?
|
||||
options.useInterimTilesOnError : true);
|
||||
|
||||
};
|
||||
|
||||
@@ -1884,7 +1884,7 @@ ol.render.canvas.ReplayGroup = function(
|
||||
* @private
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.rightHandedPolygons_ = goog.isDef(opt_rightHandedPolygons) ?
|
||||
this.rightHandedPolygons_ = opt_rightHandedPolygons ?
|
||||
opt_rightHandedPolygons : false;
|
||||
|
||||
};
|
||||
|
||||
@@ -143,7 +143,7 @@ ol.render.Feature.prototype.getStride = goog.functions.constant(2);
|
||||
/**
|
||||
* @return {undefined}
|
||||
*/
|
||||
ol.render.Feature.prototype.getStyleFunction = goog.nullFunction;
|
||||
ol.render.Feature.prototype.getStyleFunction = ol.nullFunction;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
goog.provide('ol.renderer.canvas.VectorTileLayer');
|
||||
|
||||
goog.require('goog.array');
|
||||
goog.require('goog.asserts');
|
||||
goog.require('goog.events');
|
||||
goog.require('goog.object');
|
||||
goog.require('goog.vec.Mat4');
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.TileRange');
|
||||
@@ -163,7 +161,7 @@ ol.renderer.canvas.VectorTileLayer.prototype.createReplayGroup = function(tile,
|
||||
layer, pixelRatio) {
|
||||
var revision = layer.getRevision();
|
||||
var renderOrder = layer.getRenderOrder();
|
||||
if (!goog.isDef(renderOrder)) {
|
||||
if (renderOrder === undefined) {
|
||||
renderOrder = null;
|
||||
}
|
||||
|
||||
@@ -207,13 +205,13 @@ ol.renderer.canvas.VectorTileLayer.prototype.createReplayGroup = function(tile,
|
||||
*/
|
||||
function renderFeature(feature) {
|
||||
var styles;
|
||||
if (goog.isDef(feature.getStyleFunction())) {
|
||||
if (feature.getStyleFunction()) {
|
||||
goog.asserts.assertInstanceof(feature, ol.Feature, 'Got an ol.Feature');
|
||||
styles = feature.getStyleFunction().call(feature, resolution);
|
||||
} else if (goog.isDef(layer.getStyleFunction())) {
|
||||
} else if (layer.getStyleFunction()) {
|
||||
styles = layer.getStyleFunction()(feature, resolution);
|
||||
}
|
||||
if (goog.isDefAndNotNull(styles)) {
|
||||
if (styles) {
|
||||
var dirty = this.renderFeature(feature, squaredTolerance, styles,
|
||||
replayGroup);
|
||||
this.dirty_ = this.dirty_ || dirty;
|
||||
@@ -222,11 +220,10 @@ ol.renderer.canvas.VectorTileLayer.prototype.createReplayGroup = function(tile,
|
||||
}
|
||||
|
||||
var features = tile.getFeatures();
|
||||
if (!goog.isNull(renderOrder) &&
|
||||
renderOrder !== replayState.renderedRenderOrder) {
|
||||
goog.array.sort(features, renderOrder);
|
||||
if (renderOrder && renderOrder !== replayState.renderedRenderOrder) {
|
||||
features.sort(renderOrder);
|
||||
}
|
||||
goog.array.forEach(features, renderFeature, this);
|
||||
features.forEach(renderFeature, this);
|
||||
|
||||
replayGroup.finish();
|
||||
|
||||
@@ -286,7 +283,7 @@ ol.renderer.canvas.VectorTileLayer.prototype.forEachFeatureAtCoordinate =
|
||||
* @return {?} Callback result.
|
||||
*/
|
||||
function(feature) {
|
||||
goog.asserts.assert(goog.isDef(feature), 'received a feature');
|
||||
goog.asserts.assert(feature, 'received a feature');
|
||||
var key = goog.getUid(feature).toString();
|
||||
if (!(key in features)) {
|
||||
features[key] = true;
|
||||
@@ -336,7 +333,7 @@ ol.renderer.canvas.VectorTileLayer.prototype.prepareFrame =
|
||||
}
|
||||
|
||||
var extent = frameState.extent;
|
||||
if (goog.isDef(layerState.extent)) {
|
||||
if (layerState.extent) {
|
||||
extent = ol.extent.getIntersection(extent, layerState.extent);
|
||||
}
|
||||
if (ol.extent.isEmpty(extent)) {
|
||||
@@ -394,7 +391,7 @@ ol.renderer.canvas.VectorTileLayer.prototype.prepareFrame =
|
||||
if (!fullyLoaded) {
|
||||
childTileRange = tileGrid.getTileCoordChildTileRange(
|
||||
tile.tileCoord, tmpTileRange, tmpExtent);
|
||||
if (!goog.isNull(childTileRange)) {
|
||||
if (childTileRange) {
|
||||
findLoadedTiles(z + 1, childTileRange);
|
||||
}
|
||||
}
|
||||
@@ -405,8 +402,8 @@ ol.renderer.canvas.VectorTileLayer.prototype.prepareFrame =
|
||||
this.dirty_ = false;
|
||||
|
||||
/** @type {Array.<number>} */
|
||||
var zs = goog.array.map(goog.object.getKeys(tilesToDrawByZ), Number);
|
||||
goog.array.sort(zs);
|
||||
var zs = Object.keys(tilesToDrawByZ).map(Number);
|
||||
zs.sort();
|
||||
var replayables = [];
|
||||
var i, ii, currentZ, tileCoordKey, tilesToDraw;
|
||||
for (i = 0, ii = zs.length; i < ii; ++i) {
|
||||
@@ -436,7 +433,7 @@ ol.renderer.canvas.VectorTileLayer.prototype.prepareFrame =
|
||||
*/
|
||||
ol.renderer.canvas.VectorTileLayer.prototype.renderFeature =
|
||||
function(feature, squaredTolerance, styles, replayGroup) {
|
||||
if (!goog.isDefAndNotNull(styles)) {
|
||||
if (!styles) {
|
||||
return false;
|
||||
}
|
||||
var i, ii, loading = false;
|
||||
|
||||
@@ -34,7 +34,7 @@ ol.source.TileImage = function(options) {
|
||||
state: options.state !== undefined ?
|
||||
/** @type {ol.source.State} */ (options.state) : undefined,
|
||||
tileGrid: options.tileGrid,
|
||||
tileLoadFunction: goog.isDef(options.tileLoadFunction) ?
|
||||
tileLoadFunction: options.tileLoadFunction ?
|
||||
options.tileLoadFunction : ol.source.TileImage.defaultTileLoadFunction,
|
||||
tilePixelRatio: options.tilePixelRatio,
|
||||
tileUrlFunction: options.tileUrlFunction,
|
||||
|
||||
@@ -47,7 +47,7 @@ ol.source.UrlTile = function(options) {
|
||||
logo: options.logo,
|
||||
opaque: options.opaque,
|
||||
projection: options.projection,
|
||||
state: goog.isDef(options.state) ?
|
||||
state: options.state ?
|
||||
/** @type {ol.source.State} */ (options.state) : undefined,
|
||||
tileGrid: options.tileGrid,
|
||||
tilePixelRatio: options.tilePixelRatio,
|
||||
|
||||
@@ -35,10 +35,10 @@ ol.source.VectorTile = function(options) {
|
||||
logo: options.logo,
|
||||
opaque: options.opaque,
|
||||
projection: options.projection,
|
||||
state: goog.isDef(options.state) ?
|
||||
state: options.state ?
|
||||
/** @type {ol.source.State} */ (options.state) : undefined,
|
||||
tileGrid: options.tileGrid,
|
||||
tileLoadFunction: goog.isDef(options.tileLoadFunction) ?
|
||||
tileLoadFunction: options.tileLoadFunction ?
|
||||
options.tileLoadFunction : ol.source.VectorTile.defaultTileLoadFunction,
|
||||
tileUrlFunction: options.tileUrlFunction,
|
||||
tilePixelRatio: options.tilePixelRatio,
|
||||
@@ -51,15 +51,14 @@ ol.source.VectorTile = function(options) {
|
||||
* @private
|
||||
* @type {ol.format.Feature}
|
||||
*/
|
||||
this.format_ = goog.isDef(options.format) ? options.format : null;
|
||||
this.format_ = options.format ? options.format : null;
|
||||
|
||||
/**
|
||||
* @protected
|
||||
* @type {function(new: ol.VectorTile, ol.TileCoord, ol.TileState, string,
|
||||
* ol.format.Feature, ol.TileLoadFunctionType)}
|
||||
*/
|
||||
this.tileClass = goog.isDef(options.tileClass) ?
|
||||
options.tileClass : ol.VectorTile;
|
||||
this.tileClass = options.tileClass ? options.tileClass : ol.VectorTile;
|
||||
|
||||
};
|
||||
goog.inherits(ol.source.VectorTile, ol.source.UrlTile);
|
||||
@@ -78,12 +77,12 @@ ol.source.VectorTile.prototype.getTile =
|
||||
var tileCoord = [z, x, y];
|
||||
var urlTileCoord = this.getTileCoordForTileUrlFunction(
|
||||
tileCoord, projection);
|
||||
var tileUrl = goog.isNull(urlTileCoord) ? undefined :
|
||||
this.tileUrlFunction(urlTileCoord, pixelRatio, projection);
|
||||
var tileUrl = urlTileCoord ?
|
||||
this.tileUrlFunction(urlTileCoord, pixelRatio, projection) : undefined;
|
||||
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.format_,
|
||||
this.tileLoadFunction);
|
||||
goog.events.listen(tile, goog.events.EventType.CHANGE,
|
||||
|
||||
Reference in New Issue
Block a user