Add assert messages for all assertions up until ol.renderer.vector.
This commit is contained in:
@@ -167,7 +167,7 @@ ol.control.Attribution.prototype.getSourceAttributions = function(frameState) {
|
||||
/** @type {Object.<string, ol.Attribution>} */
|
||||
var hiddenAttributions = {};
|
||||
var projection = frameState.viewState.projection;
|
||||
goog.asserts.assert(!goog.isNull(projection));
|
||||
goog.asserts.assert(!goog.isNull(projection), 'projection cannot be null');
|
||||
for (i = 0, ii = layerStatesArray.length; i < ii; i++) {
|
||||
source = layerStatesArray[i].layer.getSource();
|
||||
if (goog.isNull(source)) {
|
||||
@@ -186,9 +186,10 @@ ol.control.Attribution.prototype.getSourceAttributions = function(frameState) {
|
||||
}
|
||||
tileRanges = frameState.usedTiles[sourceKey];
|
||||
if (goog.isDef(tileRanges)) {
|
||||
goog.asserts.assertInstanceof(source, ol.source.Tile);
|
||||
goog.asserts.assertInstanceof(source, ol.source.Tile,
|
||||
'source should be an ol.source.Tile');
|
||||
var tileGrid = source.getTileGridForProjection(projection);
|
||||
goog.asserts.assert(!goog.isNull(tileGrid));
|
||||
goog.asserts.assert(!goog.isNull(tileGrid), 'tileGrid cannot be null');
|
||||
intersectsTileRange = sourceAttribution.intersectsAnyTileRange(
|
||||
tileRanges, tileGrid, projection);
|
||||
} else {
|
||||
|
||||
@@ -123,9 +123,11 @@ ol.control.FullScreen.prototype.handleFullScreen_ = function() {
|
||||
goog.dom.fullscreen.exitFullScreen();
|
||||
} else {
|
||||
var target = map.getTarget();
|
||||
goog.asserts.assert(goog.isDefAndNotNull(target));
|
||||
goog.asserts.assert(goog.isDefAndNotNull(target),
|
||||
'target should be defined');
|
||||
var element = goog.dom.getElement(target);
|
||||
goog.asserts.assert(goog.isDefAndNotNull(element));
|
||||
goog.asserts.assert(goog.isDefAndNotNull(element),
|
||||
'element should be defined');
|
||||
if (this.keys_) {
|
||||
goog.dom.fullscreen.requestFullScreenWithKeys(element);
|
||||
} else {
|
||||
|
||||
@@ -247,17 +247,17 @@ ol.control.OverviewMap.prototype.validateExtent_ = function() {
|
||||
}
|
||||
|
||||
var mapSize = map.getSize();
|
||||
goog.asserts.assertArray(mapSize);
|
||||
goog.asserts.assertArray(mapSize, 'mapSize should be an array');
|
||||
|
||||
var view = map.getView();
|
||||
goog.asserts.assert(goog.isDef(view));
|
||||
goog.asserts.assert(goog.isDef(view), 'view should be defined');
|
||||
var extent = view.calculateExtent(mapSize);
|
||||
|
||||
var ovmapSize = ovmap.getSize();
|
||||
goog.asserts.assertArray(ovmapSize);
|
||||
goog.asserts.assertArray(ovmapSize, 'ovmapSize should be an array');
|
||||
|
||||
var ovview = ovmap.getView();
|
||||
goog.asserts.assert(goog.isDef(ovview));
|
||||
goog.asserts.assert(goog.isDef(ovview), 'ovview should be defined');
|
||||
var ovextent = ovview.calculateExtent(ovmapSize);
|
||||
|
||||
var topLeftPixel =
|
||||
@@ -296,17 +296,17 @@ ol.control.OverviewMap.prototype.resetExtent_ = function() {
|
||||
var ovmap = this.ovmap_;
|
||||
|
||||
var mapSize = map.getSize();
|
||||
goog.asserts.assertArray(mapSize);
|
||||
goog.asserts.assertArray(mapSize, 'mapSize should be an array');
|
||||
|
||||
var view = map.getView();
|
||||
goog.asserts.assert(goog.isDef(view));
|
||||
goog.asserts.assert(goog.isDef(view), 'view should be defined');
|
||||
var extent = view.calculateExtent(mapSize);
|
||||
|
||||
var ovmapSize = ovmap.getSize();
|
||||
goog.asserts.assertArray(ovmapSize);
|
||||
goog.asserts.assertArray(ovmapSize, 'ovmapSize should be an array');
|
||||
|
||||
var ovview = ovmap.getView();
|
||||
goog.asserts.assert(goog.isDef(ovview));
|
||||
goog.asserts.assert(goog.isDef(ovview), 'ovview should be defined');
|
||||
|
||||
// get how many times the current map overview could hold different
|
||||
// box sizes using the min and max ratio, pick the step in the middle used
|
||||
@@ -329,10 +329,10 @@ ol.control.OverviewMap.prototype.recenter_ = function() {
|
||||
var ovmap = this.ovmap_;
|
||||
|
||||
var view = map.getView();
|
||||
goog.asserts.assert(goog.isDef(view));
|
||||
goog.asserts.assert(goog.isDef(view), 'view should be defined');
|
||||
|
||||
var ovview = ovmap.getView();
|
||||
goog.asserts.assert(goog.isDef(ovview));
|
||||
goog.asserts.assert(goog.isDef(ovview), 'ovview should be defined');
|
||||
|
||||
ovview.setCenter(view.getCenter());
|
||||
};
|
||||
@@ -351,19 +351,19 @@ ol.control.OverviewMap.prototype.updateBox_ = function() {
|
||||
}
|
||||
|
||||
var mapSize = map.getSize();
|
||||
goog.asserts.assertArray(mapSize);
|
||||
goog.asserts.assertArray(mapSize, 'mapSize should be an array');
|
||||
|
||||
var view = map.getView();
|
||||
goog.asserts.assert(goog.isDef(view));
|
||||
goog.asserts.assert(goog.isDef(view), 'view should be defined');
|
||||
|
||||
var ovview = ovmap.getView();
|
||||
goog.asserts.assert(goog.isDef(ovview));
|
||||
goog.asserts.assert(goog.isDef(ovview), 'ovview should be defined');
|
||||
|
||||
var ovmapSize = ovmap.getSize();
|
||||
goog.asserts.assertArray(ovmapSize);
|
||||
goog.asserts.assertArray(ovmapSize, 'ovmapSize should be an array');
|
||||
|
||||
var rotation = view.getRotation();
|
||||
goog.asserts.assert(goog.isDef(rotation));
|
||||
goog.asserts.assert(goog.isDef(rotation), 'rotation should be defined');
|
||||
|
||||
var overlay = this.boxOverlay_;
|
||||
var box = this.boxOverlay_.getElement();
|
||||
@@ -398,7 +398,7 @@ ol.control.OverviewMap.prototype.calculateCoordinateRotate_ = function(
|
||||
|
||||
var map = this.getMap();
|
||||
var view = map.getView();
|
||||
goog.asserts.assert(goog.isDef(view));
|
||||
goog.asserts.assert(goog.isDef(view), 'view should be defined');
|
||||
|
||||
var currentCenter = view.getCenter();
|
||||
|
||||
|
||||
@@ -238,7 +238,8 @@ ol.control.ScaleLine.prototype.updateElement_ = function() {
|
||||
}
|
||||
cosLatitude = Math.cos(goog.math.toRadians(this.toEPSG4326_(center)[1]));
|
||||
var radius = ol.sphere.NORMAL.radius;
|
||||
goog.asserts.assert(goog.isDef(ol.proj.METERS_PER_UNIT[projectionUnits]));
|
||||
goog.asserts.assert(goog.isDef(ol.proj.METERS_PER_UNIT[projectionUnits]),
|
||||
'Meters per unit should be defined for the projection unit');
|
||||
radius /= ol.proj.METERS_PER_UNIT[projectionUnits];
|
||||
pointResolution *= 180 / (Math.PI * cosLatitude * radius);
|
||||
projectionUnits = ol.proj.Units.DEGREES;
|
||||
@@ -254,7 +255,8 @@ ol.control.ScaleLine.prototype.updateElement_ = function() {
|
||||
units == ol.control.ScaleLineUnits.NAUTICAL) &&
|
||||
projectionUnits == ol.proj.Units.METERS) ||
|
||||
(units == ol.control.ScaleLineUnits.DEGREES &&
|
||||
projectionUnits == ol.proj.Units.DEGREES));
|
||||
projectionUnits == ol.proj.Units.DEGREES),
|
||||
'Scale line units and projection units should match');
|
||||
|
||||
var nominalCount = this.minWidth_ * pointResolution;
|
||||
var suffix = '';
|
||||
@@ -304,7 +306,7 @@ ol.control.ScaleLine.prototype.updateElement_ = function() {
|
||||
pointResolution /= 1609.3472;
|
||||
}
|
||||
} else {
|
||||
goog.asserts.fail();
|
||||
goog.asserts.fail('Scale line element cannot be updated');
|
||||
}
|
||||
|
||||
var i = 3 * Math.floor(
|
||||
|
||||
@@ -178,7 +178,8 @@ ol.control.ZoomSlider.render = function(mapEvent) {
|
||||
if (goog.isNull(mapEvent.frameState)) {
|
||||
return;
|
||||
}
|
||||
goog.asserts.assert(goog.isDefAndNotNull(mapEvent.frameState.viewState));
|
||||
goog.asserts.assert(goog.isDefAndNotNull(mapEvent.frameState.viewState),
|
||||
'viewState should be defined');
|
||||
if (!this.sliderInitialized_) {
|
||||
this.initSlider_();
|
||||
}
|
||||
@@ -198,7 +199,8 @@ ol.control.ZoomSlider.prototype.handleContainerClick_ = function(browserEvent) {
|
||||
var map = this.getMap();
|
||||
var view = map.getView();
|
||||
var currentResolution = view.getResolution();
|
||||
goog.asserts.assert(goog.isDef(currentResolution));
|
||||
goog.asserts.assert(goog.isDef(currentResolution),
|
||||
'currentResolution should be defined');
|
||||
map.beforeRender(ol.animation.zoom({
|
||||
resolution: currentResolution,
|
||||
duration: ol.ZOOMSLIDER_ANIMATION_DURATION,
|
||||
@@ -244,7 +246,8 @@ ol.control.ZoomSlider.prototype.handleDraggerEnd_ = function(event) {
|
||||
var map = this.getMap();
|
||||
var view = map.getView();
|
||||
view.setHint(ol.ViewHint.INTERACTING, -1);
|
||||
goog.asserts.assert(goog.isDef(this.currentResolution_));
|
||||
goog.asserts.assert(goog.isDef(this.currentResolution_),
|
||||
'this.currentResolution_ should be defined');
|
||||
map.beforeRender(ol.animation.zoom({
|
||||
resolution: this.currentResolution_,
|
||||
duration: ol.ZOOMSLIDER_ANIMATION_DURATION,
|
||||
|
||||
@@ -81,6 +81,6 @@ ol.control.ZoomToExtent.prototype.handleZoomToExtent_ = function() {
|
||||
var extent = goog.isNull(this.extent_) ?
|
||||
view.getProjection().getExtent() : this.extent_;
|
||||
var size = map.getSize();
|
||||
goog.asserts.assert(goog.isDef(size));
|
||||
goog.asserts.assert(goog.isDef(size), 'size should be defined');
|
||||
view.fitExtent(extent, size);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user