Merge pull request #507 from twpayne/asserts
Clean up use of goog.asserts
This commit is contained in:
@@ -74,7 +74,7 @@ ol.array.linearFindNearest = function(arr, target, direction) {
|
||||
}
|
||||
// We should never get here, but the compiler complains
|
||||
// if it finds a path for which no number is returned.
|
||||
goog.asserts.assert(false);
|
||||
goog.asserts.fail();
|
||||
return n - 1;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -226,7 +226,7 @@ ol.control.ScaleLine.prototype.updateElement_ = function(frameState) {
|
||||
pointResolution /= 1609.3472;
|
||||
}
|
||||
} else {
|
||||
goog.asserts.assert(false);
|
||||
goog.asserts.fail();
|
||||
}
|
||||
|
||||
var i = 3 * Math.floor(
|
||||
|
||||
@@ -77,7 +77,7 @@ ol.dom.transformElement2D = function(element, transform, opt_precision) {
|
||||
ol.dom.setTransform(element, 'matrix(' + value2D + ')');
|
||||
} else if (ol.dom.BrowserFeature.CAN_USE_MATRIX_FILTER) {
|
||||
// http://msdn.microsoft.com/en-us/library/ms533014%28VS.85,loband%29.aspx
|
||||
goog.asserts.assert(false); // FIXME
|
||||
goog.asserts.fail(); // FIXME
|
||||
} else {
|
||||
// FIXME check this code!
|
||||
var style = element.style;
|
||||
|
||||
@@ -47,7 +47,7 @@ ol.interaction.DblClickZoom.prototype.handleMapBrowserEvent =
|
||||
-this.delta_ : this.delta_;
|
||||
// FIXME works for View2D only
|
||||
var view = map.getView();
|
||||
goog.asserts.assert(view instanceof ol.View2D);
|
||||
goog.asserts.assertInstanceof(view, ol.View2D);
|
||||
view.zoomByDelta(map, delta, anchor,
|
||||
ol.interaction.DBLCLICKZOOM_ANIMATION_DURATION);
|
||||
mapBrowserEvent.preventDefault();
|
||||
|
||||
@@ -99,24 +99,24 @@ ol.interaction.Drag.prototype.handleMapBrowserEvent =
|
||||
var view = map.getView();
|
||||
var browserEvent = mapBrowserEvent.browserEvent;
|
||||
if (mapBrowserEvent.type == ol.MapBrowserEvent.EventType.DOWN) {
|
||||
goog.asserts.assert(browserEvent instanceof goog.events.BrowserEvent);
|
||||
goog.asserts.assertInstanceof(browserEvent, goog.events.BrowserEvent);
|
||||
this.handleDown(mapBrowserEvent);
|
||||
}
|
||||
if (this.dragging_) {
|
||||
if (mapBrowserEvent.type == ol.MapBrowserEvent.EventType.DRAG) {
|
||||
goog.asserts.assert(browserEvent instanceof goog.events.BrowserEvent);
|
||||
goog.asserts.assertInstanceof(browserEvent, goog.events.BrowserEvent);
|
||||
this.deltaX = browserEvent.clientX - this.startX;
|
||||
this.deltaY = browserEvent.clientY - this.startY;
|
||||
this.handleDrag(mapBrowserEvent);
|
||||
} else if (mapBrowserEvent.type == ol.MapBrowserEvent.EventType.DRAGEND) {
|
||||
goog.asserts.assert(browserEvent instanceof goog.events.BrowserEvent);
|
||||
goog.asserts.assertInstanceof(browserEvent, goog.events.BrowserEvent);
|
||||
this.deltaX = browserEvent.clientX - this.startX;
|
||||
this.deltaY = browserEvent.clientY - this.startY;
|
||||
this.handleDragEnd(mapBrowserEvent);
|
||||
this.dragging_ = false;
|
||||
}
|
||||
} else if (mapBrowserEvent.type == ol.MapBrowserEvent.EventType.DRAGSTART) {
|
||||
goog.asserts.assert(browserEvent instanceof goog.events.BrowserEvent);
|
||||
goog.asserts.assertInstanceof(browserEvent, goog.events.BrowserEvent);
|
||||
this.startX = browserEvent.clientX;
|
||||
this.startY = browserEvent.clientY;
|
||||
this.deltaX = 0;
|
||||
|
||||
@@ -58,7 +58,7 @@ ol.interaction.DragPan.prototype.handleDrag = function(mapBrowserEvent) {
|
||||
var map = mapBrowserEvent.map;
|
||||
// FIXME works for View2D only
|
||||
var view = map.getView();
|
||||
goog.asserts.assert(view instanceof ol.View2D);
|
||||
goog.asserts.assertInstanceof(view, ol.View2D);
|
||||
var resolution = view.getResolution();
|
||||
var rotation = view.getRotation();
|
||||
var newCenter = [-resolution * this.deltaX, resolution * this.deltaY];
|
||||
@@ -124,7 +124,7 @@ ol.interaction.DragPan.prototype.handleDown = function(mapBrowserEvent) {
|
||||
var map = mapBrowserEvent.map;
|
||||
// FIXME works for View2D only
|
||||
var view = map.getView();
|
||||
goog.asserts.assert(view instanceof ol.View2D);
|
||||
goog.asserts.assertInstanceof(view, ol.View2D);
|
||||
goog.asserts.assert(!goog.isNull(mapBrowserEvent.frameState));
|
||||
if (!goog.isNull(this.kineticPreRenderFn_) &&
|
||||
map.removePreRenderFunction(this.kineticPreRenderFn_)) {
|
||||
|
||||
@@ -56,7 +56,7 @@ ol.interaction.DragRotateAndZoom.prototype.handleDrag =
|
||||
var magnitude = delta.magnitude();
|
||||
// FIXME works for View2D only
|
||||
var view = map.getView();
|
||||
goog.asserts.assert(view instanceof ol.View2D);
|
||||
goog.asserts.assertInstanceof(view, ol.View2D);
|
||||
map.requestRenderFrame();
|
||||
// FIXME the calls to map.rotate and map.zoomToResolution should use
|
||||
// map.withFrozenRendering but an assertion fails :-(
|
||||
|
||||
@@ -52,7 +52,7 @@ ol.interaction.DragRotate.prototype.handleDrag = function(mapBrowserEvent) {
|
||||
var delta = theta - this.lastAngle_;
|
||||
var view = map.getView();
|
||||
// FIXME supports View2D only
|
||||
goog.asserts.assert(view instanceof ol.View2D);
|
||||
goog.asserts.assertInstanceof(view, ol.View2D);
|
||||
map.requestRenderFrame();
|
||||
view.rotateWithoutConstraints(map, view.getRotation() - delta);
|
||||
}
|
||||
@@ -68,7 +68,7 @@ ol.interaction.DragRotate.prototype.handleDragEnd = function(mapBrowserEvent) {
|
||||
var map = mapBrowserEvent.map;
|
||||
// FIXME supports View2D only
|
||||
var view = map.getView();
|
||||
goog.asserts.assert(view instanceof ol.View2D);
|
||||
goog.asserts.assertInstanceof(view, ol.View2D);
|
||||
view.rotate(map, view.getRotation(), undefined,
|
||||
ol.interaction.DRAGROTATE_ANIMATION_DURATION);
|
||||
view.setHint(ol.ViewHint.INTERACTING, -1);
|
||||
@@ -85,7 +85,7 @@ ol.interaction.DragRotate.prototype.handleDragStart =
|
||||
var map = mapBrowserEvent.map;
|
||||
// FIXME supports View2D only
|
||||
var view = map.getView();
|
||||
goog.asserts.assert(view instanceof ol.View2D);
|
||||
goog.asserts.assertInstanceof(view, ol.View2D);
|
||||
map.requestRenderFrame();
|
||||
this.lastAngle_ = undefined;
|
||||
view.setHint(ol.ViewHint.INTERACTING, 1);
|
||||
|
||||
@@ -69,7 +69,7 @@ ol.interaction.DragZoom.prototype.handleDragEnd =
|
||||
map.withFrozenRendering(function() {
|
||||
// FIXME works for View2D only
|
||||
var view = map.getView();
|
||||
goog.asserts.assert(view instanceof ol.View2D);
|
||||
goog.asserts.assertInstanceof(view, ol.View2D);
|
||||
var mapSize = /** @type {ol.Size} */ (map.getSize());
|
||||
view.fitExtent(extent, mapSize);
|
||||
// FIXME we should preserve rotation
|
||||
|
||||
@@ -54,7 +54,7 @@ ol.interaction.KeyboardPan.prototype.handleMapBrowserEvent =
|
||||
var map = mapBrowserEvent.map;
|
||||
// FIXME works for View2D only
|
||||
var view = map.getView();
|
||||
goog.asserts.assert(view instanceof ol.View2D);
|
||||
goog.asserts.assertInstanceof(view, ol.View2D);
|
||||
var resolution = view.getResolution();
|
||||
var rotation = view.getRotation();
|
||||
var mapUnitsDelta = resolution * this.delta_;
|
||||
|
||||
@@ -51,7 +51,7 @@ ol.interaction.KeyboardZoom.prototype.handleMapBrowserEvent =
|
||||
map.requestRenderFrame();
|
||||
// FIXME works for View2D only
|
||||
var view = map.getView();
|
||||
goog.asserts.assert(view instanceof ol.View2D);
|
||||
goog.asserts.assertInstanceof(view, ol.View2D);
|
||||
view.zoomByDelta(map, delta, undefined,
|
||||
ol.interaction.KEYBOARD_ZOOM_DURATION);
|
||||
keyEvent.preventDefault();
|
||||
|
||||
@@ -77,7 +77,7 @@ ol.interaction.MouseWheelZoom.prototype.handleMapBrowserEvent =
|
||||
var map = mapBrowserEvent.map;
|
||||
var mouseWheelEvent = /** @type {goog.events.MouseWheelEvent} */
|
||||
(mapBrowserEvent.browserEvent);
|
||||
goog.asserts.assert(mouseWheelEvent instanceof goog.events.MouseWheelEvent);
|
||||
goog.asserts.assertInstanceof(mouseWheelEvent, goog.events.MouseWheelEvent);
|
||||
|
||||
this.lastAnchor_ = mapBrowserEvent.getCoordinate();
|
||||
this.delta_ += mouseWheelEvent.deltaY / 3;
|
||||
@@ -109,7 +109,7 @@ ol.interaction.MouseWheelZoom.prototype.doZoom_ = function(map) {
|
||||
|
||||
// FIXME works for View2D only
|
||||
var view = map.getView();
|
||||
goog.asserts.assert(view instanceof ol.View2D);
|
||||
goog.asserts.assertInstanceof(view, ol.View2D);
|
||||
|
||||
map.requestRenderFrame();
|
||||
view.zoomByDelta(map, -delta, this.lastAnchor_,
|
||||
|
||||
@@ -913,7 +913,7 @@ ol.Map.createOptionsInternal = function(options) {
|
||||
if (goog.isArray(options.layers)) {
|
||||
layers = new ol.Collection(goog.array.clone(options.layers));
|
||||
} else {
|
||||
goog.asserts.assert(options.layers instanceof ol.Collection);
|
||||
goog.asserts.assertInstanceof(options.layers, ol.Collection);
|
||||
layers = options.layers;
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -374,7 +374,7 @@ ol.projection.createProjection = function(projection, defaultCode) {
|
||||
} else if (goog.isString(projection)) {
|
||||
return ol.projection.get(projection);
|
||||
} else {
|
||||
goog.asserts.assert(projection instanceof ol.Projection);
|
||||
goog.asserts.assertInstanceof(projection, ol.Projection);
|
||||
return projection;
|
||||
}
|
||||
};
|
||||
@@ -610,7 +610,7 @@ ol.projection.getTransformFromProjections =
|
||||
ol.projection.identityTransform = function(input, opt_output, opt_dimension) {
|
||||
if (goog.isDef(opt_output) && input !== opt_output) {
|
||||
// TODO: consider making this a warning instead
|
||||
goog.asserts.assert(false, 'This should not be used internally.');
|
||||
goog.asserts.fail('This should not be used internally.');
|
||||
for (var i = 0, ii = input.length; i < ii; ++i) {
|
||||
opt_output[i] = input[i];
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ ol.renderer.canvas.Map.prototype.createLayerRenderer = function(layer) {
|
||||
} else if (layer instanceof ol.layer.Vector) {
|
||||
return new ol.renderer.canvas.VectorLayer(this, layer);
|
||||
} else {
|
||||
goog.asserts.assert(false);
|
||||
goog.asserts.fail();
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -313,7 +313,7 @@ ol.renderer.webgl.Map.prototype.createLayerRenderer = function(layer) {
|
||||
} else if (layer instanceof ol.layer.ImageLayer) {
|
||||
layerRenderer = new ol.renderer.webgl.ImageLayer(this, layer);
|
||||
} else {
|
||||
goog.asserts.assert(false);
|
||||
goog.asserts.fail();
|
||||
}
|
||||
return layerRenderer;
|
||||
};
|
||||
|
||||
@@ -235,7 +235,7 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, layer) {
|
||||
goog.asserts.assert(urls.length > 0);
|
||||
break;
|
||||
default:
|
||||
goog.asserts.assert(false);
|
||||
goog.asserts.fail();
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user