Add message to assertions.
This commit is contained in:
@@ -233,8 +233,10 @@ ol.render.webgl.ImageReplay.prototype.getDeleteResourcesFunction =
|
|||||||
// be used by other ImageReplay instances (for other layers). And
|
// be used by other ImageReplay instances (for other layers). And
|
||||||
// they will be deleted when disposing of the ol.webgl.Context
|
// they will be deleted when disposing of the ol.webgl.Context
|
||||||
// object.
|
// object.
|
||||||
goog.asserts.assert(!goog.isNull(this.verticesBuffer_));
|
goog.asserts.assert(!goog.isNull(this.verticesBuffer_),
|
||||||
goog.asserts.assert(!goog.isNull(this.indicesBuffer_));
|
'verticesBuffer must not be null');
|
||||||
|
goog.asserts.assert(!goog.isNull(this.indicesBuffer_),
|
||||||
|
'indicesBuffer must not be null');
|
||||||
var verticesBuffer = this.verticesBuffer_;
|
var verticesBuffer = this.verticesBuffer_;
|
||||||
var indicesBuffer = this.indicesBuffer_;
|
var indicesBuffer = this.indicesBuffer_;
|
||||||
var textures = this.textures_;
|
var textures = this.textures_;
|
||||||
@@ -272,18 +274,19 @@ ol.render.webgl.ImageReplay.prototype.drawAsync = goog.abstractMethod;
|
|||||||
*/
|
*/
|
||||||
ol.render.webgl.ImageReplay.prototype.drawCoordinates_ =
|
ol.render.webgl.ImageReplay.prototype.drawCoordinates_ =
|
||||||
function(flatCoordinates, offset, end, stride) {
|
function(flatCoordinates, offset, end, stride) {
|
||||||
goog.asserts.assert(goog.isDef(this.anchorX_));
|
goog.asserts.assert(goog.isDef(this.anchorX_), 'anchorX is defined');
|
||||||
goog.asserts.assert(goog.isDef(this.anchorY_));
|
goog.asserts.assert(goog.isDef(this.anchorY_), 'anchorY is defined');
|
||||||
goog.asserts.assert(goog.isDef(this.height_));
|
goog.asserts.assert(goog.isDef(this.height_), 'height is defined');
|
||||||
goog.asserts.assert(goog.isDef(this.imageHeight_));
|
goog.asserts.assert(goog.isDef(this.imageHeight_), 'imageHeight is defined');
|
||||||
goog.asserts.assert(goog.isDef(this.imageWidth_));
|
goog.asserts.assert(goog.isDef(this.imageWidth_), 'imageWidth is defined');
|
||||||
goog.asserts.assert(goog.isDef(this.opacity_));
|
goog.asserts.assert(goog.isDef(this.opacity_), 'opacity is defined');
|
||||||
goog.asserts.assert(goog.isDef(this.originX_));
|
goog.asserts.assert(goog.isDef(this.originX_), 'originX is defined');
|
||||||
goog.asserts.assert(goog.isDef(this.originY_));
|
goog.asserts.assert(goog.isDef(this.originY_), 'originY is defined');
|
||||||
goog.asserts.assert(goog.isDef(this.rotateWithView_));
|
goog.asserts.assert(goog.isDef(this.rotateWithView_),
|
||||||
goog.asserts.assert(goog.isDef(this.rotation_));
|
'rotateWithView is defined');
|
||||||
goog.asserts.assert(goog.isDef(this.scale_));
|
goog.asserts.assert(goog.isDef(this.rotation_), 'rotation is defined');
|
||||||
goog.asserts.assert(goog.isDef(this.width_));
|
goog.asserts.assert(goog.isDef(this.scale_), 'scale is defined');
|
||||||
|
goog.asserts.assert(goog.isDef(this.width_), 'width is defined');
|
||||||
var anchorX = this.anchorX_;
|
var anchorX = this.anchorX_;
|
||||||
var anchorY = this.anchorY_;
|
var anchorY = this.anchorY_;
|
||||||
var height = this.height_;
|
var height = this.height_;
|
||||||
@@ -464,10 +467,12 @@ ol.render.webgl.ImageReplay.prototype.finish = function(context) {
|
|||||||
var gl = context.getGL();
|
var gl = context.getGL();
|
||||||
|
|
||||||
this.groupIndices_.push(this.indices_.length);
|
this.groupIndices_.push(this.indices_.length);
|
||||||
goog.asserts.assert(this.images_.length === this.groupIndices_.length);
|
goog.asserts.assert(this.images_.length === this.groupIndices_.length,
|
||||||
|
'number of images and groupIndices match');
|
||||||
this.hitDetectionGroupIndices_.push(this.indices_.length);
|
this.hitDetectionGroupIndices_.push(this.indices_.length);
|
||||||
goog.asserts.assert(this.hitDetectionImages_.length ===
|
goog.asserts.assert(this.hitDetectionImages_.length ===
|
||||||
this.hitDetectionGroupIndices_.length);
|
this.hitDetectionGroupIndices_.length,
|
||||||
|
'number of hitDetectionImages and hitDetectionGroupIndices match');
|
||||||
|
|
||||||
// create, bind, and populate the vertices buffer
|
// create, bind, and populate the vertices buffer
|
||||||
this.verticesBuffer_ = new ol.webgl.Buffer(this.vertices_);
|
this.verticesBuffer_ = new ol.webgl.Buffer(this.vertices_);
|
||||||
@@ -488,12 +493,14 @@ ol.render.webgl.ImageReplay.prototype.finish = function(context) {
|
|||||||
var texturePerImage = {};
|
var texturePerImage = {};
|
||||||
|
|
||||||
this.createTextures_(this.textures_, this.images_, texturePerImage, gl);
|
this.createTextures_(this.textures_, this.images_, texturePerImage, gl);
|
||||||
goog.asserts.assert(this.textures_.length === this.groupIndices_.length);
|
goog.asserts.assert(this.textures_.length === this.groupIndices_.length,
|
||||||
|
'number of textures and groupIndices match');
|
||||||
|
|
||||||
this.createTextures_(this.hitDetectionTextures_, this.hitDetectionImages_,
|
this.createTextures_(this.hitDetectionTextures_, this.hitDetectionImages_,
|
||||||
texturePerImage, gl);
|
texturePerImage, gl);
|
||||||
goog.asserts.assert(this.hitDetectionTextures_.length ===
|
goog.asserts.assert(this.hitDetectionTextures_.length ===
|
||||||
this.hitDetectionGroupIndices_.length);
|
this.hitDetectionGroupIndices_.length,
|
||||||
|
'number of hitDetectionTextures and hitDetectionGroupIndices match');
|
||||||
|
|
||||||
this.anchorX_ = undefined;
|
this.anchorX_ = undefined;
|
||||||
this.anchorY_ = undefined;
|
this.anchorY_ = undefined;
|
||||||
@@ -524,7 +531,8 @@ ol.render.webgl.ImageReplay.prototype.finish = function(context) {
|
|||||||
*/
|
*/
|
||||||
ol.render.webgl.ImageReplay.prototype.createTextures_ =
|
ol.render.webgl.ImageReplay.prototype.createTextures_ =
|
||||||
function(textures, images, texturePerImage, gl) {
|
function(textures, images, texturePerImage, gl) {
|
||||||
goog.asserts.assert(textures.length === 0);
|
goog.asserts.assert(textures.length === 0,
|
||||||
|
'upon creation, textures is empty');
|
||||||
|
|
||||||
var texture, image, uid, i;
|
var texture, image, uid, i;
|
||||||
var ii = images.length;
|
var ii = images.length;
|
||||||
@@ -571,11 +579,13 @@ ol.render.webgl.ImageReplay.prototype.replay = function(context,
|
|||||||
var gl = context.getGL();
|
var gl = context.getGL();
|
||||||
|
|
||||||
// bind the vertices buffer
|
// bind the vertices buffer
|
||||||
goog.asserts.assert(!goog.isNull(this.verticesBuffer_));
|
goog.asserts.assert(!goog.isNull(this.verticesBuffer_),
|
||||||
|
'verticesBuffer must not be null');
|
||||||
context.bindBuffer(goog.webgl.ARRAY_BUFFER, this.verticesBuffer_);
|
context.bindBuffer(goog.webgl.ARRAY_BUFFER, this.verticesBuffer_);
|
||||||
|
|
||||||
// bind the indices buffer
|
// bind the indices buffer
|
||||||
goog.asserts.assert(!goog.isNull(this.indicesBuffer_));
|
goog.asserts.assert(!goog.isNull(this.indicesBuffer_),
|
||||||
|
'indecesBuffer must not be null');
|
||||||
context.bindBuffer(goog.webgl.ELEMENT_ARRAY_BUFFER, this.indicesBuffer_);
|
context.bindBuffer(goog.webgl.ELEMENT_ARRAY_BUFFER, this.indicesBuffer_);
|
||||||
|
|
||||||
var useColor = brightness || contrast != 1 || hue || saturation != 1;
|
var useColor = brightness || contrast != 1 || hue || saturation != 1;
|
||||||
@@ -699,7 +709,8 @@ ol.render.webgl.ImageReplay.prototype.replay = function(context,
|
|||||||
*/
|
*/
|
||||||
ol.render.webgl.ImageReplay.prototype.drawReplay_ =
|
ol.render.webgl.ImageReplay.prototype.drawReplay_ =
|
||||||
function(gl, context, skippedFeaturesHash, textures, groupIndices) {
|
function(gl, context, skippedFeaturesHash, textures, groupIndices) {
|
||||||
goog.asserts.assert(textures.length === groupIndices.length);
|
goog.asserts.assert(textures.length === groupIndices.length,
|
||||||
|
'number of textures and groupIndeces match');
|
||||||
var elementType = context.hasOESElementIndexUint ?
|
var elementType = context.hasOESElementIndexUint ?
|
||||||
goog.webgl.UNSIGNED_INT : goog.webgl.UNSIGNED_SHORT;
|
goog.webgl.UNSIGNED_INT : goog.webgl.UNSIGNED_SHORT;
|
||||||
var elementSize = context.hasOESElementIndexUint ? 4 : 2;
|
var elementSize = context.hasOESElementIndexUint ? 4 : 2;
|
||||||
@@ -873,7 +884,8 @@ ol.render.webgl.ImageReplay.prototype.drawHitDetectionReplayOneByOne_ =
|
|||||||
function(gl, context, skippedFeaturesHash, featureCallback,
|
function(gl, context, skippedFeaturesHash, featureCallback,
|
||||||
opt_hitExtent) {
|
opt_hitExtent) {
|
||||||
goog.asserts.assert(this.hitDetectionTextures_.length ===
|
goog.asserts.assert(this.hitDetectionTextures_.length ===
|
||||||
this.hitDetectionGroupIndices_.length);
|
this.hitDetectionGroupIndices_.length,
|
||||||
|
'number of hitDetectionTextures and hitDetectionGroupIndices match');
|
||||||
var elementType = context.hasOESElementIndexUint ?
|
var elementType = context.hasOESElementIndexUint ?
|
||||||
goog.webgl.UNSIGNED_INT : goog.webgl.UNSIGNED_SHORT;
|
goog.webgl.UNSIGNED_INT : goog.webgl.UNSIGNED_SHORT;
|
||||||
var elementSize = context.hasOESElementIndexUint ? 4 : 2;
|
var elementSize = context.hasOESElementIndexUint ? 4 : 2;
|
||||||
@@ -923,27 +935,31 @@ ol.render.webgl.ImageReplay.prototype.setFillStrokeStyle = goog.abstractMethod;
|
|||||||
*/
|
*/
|
||||||
ol.render.webgl.ImageReplay.prototype.setImageStyle = function(imageStyle) {
|
ol.render.webgl.ImageReplay.prototype.setImageStyle = function(imageStyle) {
|
||||||
var anchor = imageStyle.getAnchor();
|
var anchor = imageStyle.getAnchor();
|
||||||
goog.asserts.assert(!goog.isNull(anchor));
|
goog.asserts.assert(!goog.isNull(anchor), 'imageStyle anchor is not null');
|
||||||
var image = imageStyle.getImage(1);
|
var image = imageStyle.getImage(1);
|
||||||
goog.asserts.assert(!goog.isNull(image));
|
goog.asserts.assert(!goog.isNull(image), 'imageStyle image is not null');
|
||||||
var imageSize = imageStyle.getImageSize();
|
var imageSize = imageStyle.getImageSize();
|
||||||
goog.asserts.assert(!goog.isNull(imageSize));
|
goog.asserts.assert(!goog.isNull(imageSize),
|
||||||
|
'imageStyle imageSize is not null');
|
||||||
var hitDetectionImage = imageStyle.getHitDetectionImage(1);
|
var hitDetectionImage = imageStyle.getHitDetectionImage(1);
|
||||||
goog.asserts.assert(!goog.isNull(hitDetectionImage));
|
goog.asserts.assert(!goog.isNull(hitDetectionImage),
|
||||||
|
'imageStyle hitDetectionImage is not null');
|
||||||
var hitDetectionImageSize = imageStyle.getHitDetectionImageSize();
|
var hitDetectionImageSize = imageStyle.getHitDetectionImageSize();
|
||||||
goog.asserts.assert(!goog.isNull(hitDetectionImageSize));
|
goog.asserts.assert(!goog.isNull(hitDetectionImageSize),
|
||||||
|
'imageStyle hitDetectionImageSize is not null');
|
||||||
var opacity = imageStyle.getOpacity();
|
var opacity = imageStyle.getOpacity();
|
||||||
goog.asserts.assert(goog.isDef(opacity));
|
goog.asserts.assert(goog.isDef(opacity), 'imageStyle opacity is defined');
|
||||||
var origin = imageStyle.getOrigin();
|
var origin = imageStyle.getOrigin();
|
||||||
goog.asserts.assert(!goog.isNull(origin));
|
goog.asserts.assert(!goog.isNull(origin), 'imageStyle origin is not null');
|
||||||
var rotateWithView = imageStyle.getRotateWithView();
|
var rotateWithView = imageStyle.getRotateWithView();
|
||||||
goog.asserts.assert(goog.isDef(rotateWithView));
|
goog.asserts.assert(goog.isDef(rotateWithView),
|
||||||
|
'imageStyle rotateWithView is defined');
|
||||||
var rotation = imageStyle.getRotation();
|
var rotation = imageStyle.getRotation();
|
||||||
goog.asserts.assert(goog.isDef(rotation));
|
goog.asserts.assert(goog.isDef(rotation), 'imageStyle rotation is defined');
|
||||||
var size = imageStyle.getSize();
|
var size = imageStyle.getSize();
|
||||||
goog.asserts.assert(!goog.isNull(size));
|
goog.asserts.assert(!goog.isNull(size), 'imageStyle size is not null');
|
||||||
var scale = imageStyle.getScale();
|
var scale = imageStyle.getScale();
|
||||||
goog.asserts.assert(goog.isDef(scale));
|
goog.asserts.assert(goog.isDef(scale), 'imageStyle scale is defined');
|
||||||
|
|
||||||
var currentImage;
|
var currentImage;
|
||||||
if (this.images_.length === 0) {
|
if (this.images_.length === 0) {
|
||||||
@@ -952,7 +968,8 @@ ol.render.webgl.ImageReplay.prototype.setImageStyle = function(imageStyle) {
|
|||||||
currentImage = this.images_[this.images_.length - 1];
|
currentImage = this.images_[this.images_.length - 1];
|
||||||
if (goog.getUid(currentImage) != goog.getUid(image)) {
|
if (goog.getUid(currentImage) != goog.getUid(image)) {
|
||||||
this.groupIndices_.push(this.indices_.length);
|
this.groupIndices_.push(this.indices_.length);
|
||||||
goog.asserts.assert(this.groupIndices_.length === this.images_.length);
|
goog.asserts.assert(this.groupIndices_.length === this.images_.length,
|
||||||
|
'number of groupIndices and images match');
|
||||||
this.images_.push(image);
|
this.images_.push(image);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -965,7 +982,8 @@ ol.render.webgl.ImageReplay.prototype.setImageStyle = function(imageStyle) {
|
|||||||
if (goog.getUid(currentImage) != goog.getUid(hitDetectionImage)) {
|
if (goog.getUid(currentImage) != goog.getUid(hitDetectionImage)) {
|
||||||
this.hitDetectionGroupIndices_.push(this.indices_.length);
|
this.hitDetectionGroupIndices_.push(this.indices_.length);
|
||||||
goog.asserts.assert(this.hitDetectionGroupIndices_.length ===
|
goog.asserts.assert(this.hitDetectionGroupIndices_.length ===
|
||||||
this.hitDetectionImages_.length);
|
this.hitDetectionImages_.length,
|
||||||
|
'number of hitDetectionGroupIndices and hitDetectionImages match');
|
||||||
this.hitDetectionImages_.push(hitDetectionImage);
|
this.hitDetectionImages_.push(hitDetectionImage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1066,7 +1084,8 @@ ol.render.webgl.ReplayGroup.prototype.getReplay =
|
|||||||
var replay = this.replays_[replayType];
|
var replay = this.replays_[replayType];
|
||||||
if (!goog.isDef(replay)) {
|
if (!goog.isDef(replay)) {
|
||||||
var constructor = ol.render.webgl.BATCH_CONSTRUCTORS_[replayType];
|
var constructor = ol.render.webgl.BATCH_CONSTRUCTORS_[replayType];
|
||||||
goog.asserts.assert(goog.isDef(constructor));
|
goog.asserts.assert(goog.isDef(constructor),
|
||||||
|
'a constructor could be found in ol.render.webgl.BATCH_CONSTRUCTORS_');
|
||||||
replay = new constructor(this.tolerance_, this.maxExtent_);
|
replay = new constructor(this.tolerance_, this.maxExtent_);
|
||||||
this.replays_[replayType] = replay;
|
this.replays_[replayType] = replay;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -156,7 +156,8 @@ ol.renderer.canvas.ImageLayer.prototype.prepareFrame =
|
|||||||
|
|
||||||
var image;
|
var image;
|
||||||
var imageLayer = this.getLayer();
|
var imageLayer = this.getLayer();
|
||||||
goog.asserts.assertInstanceof(imageLayer, ol.layer.Image);
|
goog.asserts.assertInstanceof(imageLayer, ol.layer.Image,
|
||||||
|
'layer is an instance of ol.layer.Image');
|
||||||
var imageSource = imageLayer.getSource();
|
var imageSource = imageLayer.getSource();
|
||||||
|
|
||||||
var hints = frameState.viewHints;
|
var hints = frameState.viewHints;
|
||||||
@@ -172,7 +173,8 @@ ol.renderer.canvas.ImageLayer.prototype.prepareFrame =
|
|||||||
var projection = viewState.projection;
|
var projection = viewState.projection;
|
||||||
var sourceProjection = imageSource.getProjection();
|
var sourceProjection = imageSource.getProjection();
|
||||||
if (!goog.isNull(sourceProjection)) {
|
if (!goog.isNull(sourceProjection)) {
|
||||||
goog.asserts.assert(ol.proj.equivalent(projection, sourceProjection));
|
goog.asserts.assert(ol.proj.equivalent(projection, sourceProjection),
|
||||||
|
'projection and sourceProjection are equivalent');
|
||||||
projection = sourceProjection;
|
projection = sourceProjection;
|
||||||
}
|
}
|
||||||
image = imageSource.getImage(
|
image = imageSource.getImage(
|
||||||
|
|||||||
@@ -50,7 +50,8 @@ ol.renderer.canvas.Layer.prototype.composeFrame =
|
|||||||
var extent = layerState.extent;
|
var extent = layerState.extent;
|
||||||
var clipped = goog.isDef(extent);
|
var clipped = goog.isDef(extent);
|
||||||
if (clipped) {
|
if (clipped) {
|
||||||
goog.asserts.assert(goog.isDef(extent));
|
goog.asserts.assert(goog.isDef(extent),
|
||||||
|
'layerState extent is defined');
|
||||||
var pixelRatio = frameState.pixelRatio;
|
var pixelRatio = frameState.pixelRatio;
|
||||||
var topLeft = ol.extent.getTopLeft(extent);
|
var topLeft = ol.extent.getTopLeft(extent);
|
||||||
var topRight = ol.extent.getTopRight(extent);
|
var topRight = ol.extent.getTopRight(extent);
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ ol.renderer.canvas.Map.prototype.createLayerRenderer = function(layer) {
|
|||||||
} else if (ol.ENABLE_VECTOR && layer instanceof ol.layer.Vector) {
|
} else if (ol.ENABLE_VECTOR && layer instanceof ol.layer.Vector) {
|
||||||
return new ol.renderer.canvas.VectorLayer(layer);
|
return new ol.renderer.canvas.VectorLayer(layer);
|
||||||
} else {
|
} else {
|
||||||
goog.asserts.fail();
|
goog.asserts.fail('unexpected layer configuration');
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -138,7 +138,8 @@ ol.renderer.canvas.Map.prototype.dispatchComposeEvent_ =
|
|||||||
*/
|
*/
|
||||||
ol.renderer.canvas.Map.prototype.getCanvasLayerRenderer = function(layer) {
|
ol.renderer.canvas.Map.prototype.getCanvasLayerRenderer = function(layer) {
|
||||||
var layerRenderer = this.getLayerRenderer(layer);
|
var layerRenderer = this.getLayerRenderer(layer);
|
||||||
goog.asserts.assertInstanceof(layerRenderer, ol.renderer.canvas.Layer);
|
goog.asserts.assertInstanceof(layerRenderer, ol.renderer.canvas.Layer,
|
||||||
|
'layerRenderer is an instance of ol.renderer.canvas.Layer');
|
||||||
return /** @type {ol.renderer.canvas.Layer} */ (layerRenderer);
|
return /** @type {ol.renderer.canvas.Layer} */ (layerRenderer);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -185,7 +186,8 @@ ol.renderer.canvas.Map.prototype.renderFrame = function(frameState) {
|
|||||||
layerState = layerStatesArray[i];
|
layerState = layerStatesArray[i];
|
||||||
layer = layerState.layer;
|
layer = layerState.layer;
|
||||||
layerRenderer = this.getLayerRenderer(layer);
|
layerRenderer = this.getLayerRenderer(layer);
|
||||||
goog.asserts.assertInstanceof(layerRenderer, ol.renderer.canvas.Layer);
|
goog.asserts.assertInstanceof(layerRenderer, ol.renderer.canvas.Layer,
|
||||||
|
'layerRenderer is an instance of ol.renderer.canvas.Layer');
|
||||||
if (!ol.layer.Layer.visibleAtResolution(layerState, viewResolution) ||
|
if (!ol.layer.Layer.visibleAtResolution(layerState, viewResolution) ||
|
||||||
layerState.sourceState != ol.source.State.READY) {
|
layerState.sourceState != ol.source.State.READY) {
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -182,7 +182,8 @@ ol.renderer.canvas.TileLayer.prototype.prepareFrame =
|
|||||||
var projection = viewState.projection;
|
var projection = viewState.projection;
|
||||||
|
|
||||||
var tileLayer = this.getLayer();
|
var tileLayer = this.getLayer();
|
||||||
goog.asserts.assertInstanceof(tileLayer, ol.layer.Tile);
|
goog.asserts.assertInstanceof(tileLayer, ol.layer.Tile,
|
||||||
|
'layer is an instance of ol.layer.Tile');
|
||||||
var tileSource = tileLayer.getSource();
|
var tileSource = tileLayer.getSource();
|
||||||
var tileGrid = tileSource.getTileGridForProjection(projection);
|
var tileGrid = tileSource.getTileGridForProjection(projection);
|
||||||
var tileGutter = tileSource.getGutter();
|
var tileGutter = tileSource.getGutter();
|
||||||
@@ -218,9 +219,12 @@ ol.renderer.canvas.TileLayer.prototype.prepareFrame =
|
|||||||
|
|
||||||
var canvas, context;
|
var canvas, context;
|
||||||
if (goog.isNull(this.canvas_)) {
|
if (goog.isNull(this.canvas_)) {
|
||||||
goog.asserts.assert(goog.isNull(this.canvasSize_));
|
goog.asserts.assert(goog.isNull(this.canvasSize_),
|
||||||
goog.asserts.assert(goog.isNull(this.context_));
|
'canvasSize is null (because canvas is null)');
|
||||||
goog.asserts.assert(goog.isNull(this.renderedCanvasTileRange_));
|
goog.asserts.assert(goog.isNull(this.context_),
|
||||||
|
'context is null (because canvas is null)');
|
||||||
|
goog.asserts.assert(goog.isNull(this.renderedCanvasTileRange_),
|
||||||
|
'renderedCanvasTileRange is null (because canvas is null)');
|
||||||
context = ol.dom.createCanvasContext2D(canvasWidth, canvasHeight);
|
context = ol.dom.createCanvasContext2D(canvasWidth, canvasHeight);
|
||||||
this.canvas_ = context.canvas;
|
this.canvas_ = context.canvas;
|
||||||
this.canvasSize_ = [canvasWidth, canvasHeight];
|
this.canvasSize_ = [canvasWidth, canvasHeight];
|
||||||
@@ -228,8 +232,10 @@ ol.renderer.canvas.TileLayer.prototype.prepareFrame =
|
|||||||
this.canvasTooBig_ =
|
this.canvasTooBig_ =
|
||||||
!ol.renderer.canvas.Layer.testCanvasSize(this.canvasSize_);
|
!ol.renderer.canvas.Layer.testCanvasSize(this.canvasSize_);
|
||||||
} else {
|
} else {
|
||||||
goog.asserts.assert(!goog.isNull(this.canvasSize_));
|
goog.asserts.assert(!goog.isNull(this.canvasSize_),
|
||||||
goog.asserts.assert(!goog.isNull(this.context_));
|
'non-null canvasSize (because canvas is not null)');
|
||||||
|
goog.asserts.assert(!goog.isNull(this.context_),
|
||||||
|
'non-null context (because canvas is not null)');
|
||||||
canvas = this.canvas_;
|
canvas = this.canvas_;
|
||||||
context = this.context_;
|
context = this.context_;
|
||||||
if (this.canvasSize_[0] < canvasWidth ||
|
if (this.canvasSize_[0] < canvasWidth ||
|
||||||
@@ -277,7 +283,8 @@ ol.renderer.canvas.TileLayer.prototype.prepareFrame =
|
|||||||
canvasTileRangeWidth = canvasTileRange.getWidth();
|
canvasTileRangeWidth = canvasTileRange.getWidth();
|
||||||
}
|
}
|
||||||
|
|
||||||
goog.asserts.assert(canvasTileRange.containsTileRange(tileRange));
|
goog.asserts.assert(canvasTileRange.containsTileRange(tileRange),
|
||||||
|
'tileRange is contained in canvasTileRange');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {Object.<number, Object.<string, ol.Tile>>}
|
* @type {Object.<number, Object.<string, ol.Tile>>}
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ ol.renderer.canvas.VectorLayer.prototype.forEachFeatureAtCoordinate =
|
|||||||
* @return {?} Callback result.
|
* @return {?} Callback result.
|
||||||
*/
|
*/
|
||||||
function(feature) {
|
function(feature) {
|
||||||
goog.asserts.assert(goog.isDef(feature));
|
goog.asserts.assert(goog.isDef(feature), '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;
|
||||||
@@ -161,7 +161,8 @@ ol.renderer.canvas.VectorLayer.prototype.prepareFrame =
|
|||||||
function(frameState, layerState) {
|
function(frameState, layerState) {
|
||||||
|
|
||||||
var vectorLayer = /** @type {ol.layer.Vector} */ (this.getLayer());
|
var vectorLayer = /** @type {ol.layer.Vector} */ (this.getLayer());
|
||||||
goog.asserts.assertInstanceof(vectorLayer, ol.layer.Vector);
|
goog.asserts.assertInstanceof(vectorLayer, ol.layer.Vector,
|
||||||
|
'layer is an instance of ol.layer.Vector');
|
||||||
var vectorSource = vectorLayer.getSource();
|
var vectorSource = vectorLayer.getSource();
|
||||||
|
|
||||||
this.updateAttributions(
|
this.updateAttributions(
|
||||||
|
|||||||
@@ -87,7 +87,8 @@ ol.renderer.dom.ImageLayer.prototype.prepareFrame =
|
|||||||
|
|
||||||
var image = this.image_;
|
var image = this.image_;
|
||||||
var imageLayer = this.getLayer();
|
var imageLayer = this.getLayer();
|
||||||
goog.asserts.assertInstanceof(imageLayer, ol.layer.Image);
|
goog.asserts.assertInstanceof(imageLayer, ol.layer.Image,
|
||||||
|
'layer is an instance of ol.layer.Image');
|
||||||
var imageSource = imageLayer.getSource();
|
var imageSource = imageLayer.getSource();
|
||||||
|
|
||||||
var hints = frameState.viewHints;
|
var hints = frameState.viewHints;
|
||||||
@@ -103,7 +104,8 @@ ol.renderer.dom.ImageLayer.prototype.prepareFrame =
|
|||||||
var projection = viewState.projection;
|
var projection = viewState.projection;
|
||||||
var sourceProjection = imageSource.getProjection();
|
var sourceProjection = imageSource.getProjection();
|
||||||
if (!goog.isNull(sourceProjection)) {
|
if (!goog.isNull(sourceProjection)) {
|
||||||
goog.asserts.assert(ol.proj.equivalent(projection, sourceProjection));
|
goog.asserts.assert(ol.proj.equivalent(projection, sourceProjection),
|
||||||
|
'projection and sourceProjection are equivalent');
|
||||||
projection = sourceProjection;
|
projection = sourceProjection;
|
||||||
}
|
}
|
||||||
var image_ = imageSource.getImage(renderedExtent, viewResolution,
|
var image_ = imageSource.getImage(renderedExtent, viewResolution,
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ ol.renderer.dom.Map.prototype.createLayerRenderer = function(layer) {
|
|||||||
ol.ENABLE_VECTOR && layer instanceof ol.layer.Vector) {
|
ol.ENABLE_VECTOR && layer instanceof ol.layer.Vector) {
|
||||||
layerRenderer = new ol.renderer.dom.VectorLayer(layer);
|
layerRenderer = new ol.renderer.dom.VectorLayer(layer);
|
||||||
} else {
|
} else {
|
||||||
goog.asserts.fail();
|
goog.asserts.fail('unexpected layer configuration');
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return layerRenderer;
|
return layerRenderer;
|
||||||
@@ -238,7 +238,8 @@ ol.renderer.dom.Map.prototype.renderFrame = function(frameState) {
|
|||||||
layer = layerState.layer;
|
layer = layerState.layer;
|
||||||
layerRenderer = /** @type {ol.renderer.dom.Layer} */ (
|
layerRenderer = /** @type {ol.renderer.dom.Layer} */ (
|
||||||
this.getLayerRenderer(layer));
|
this.getLayerRenderer(layer));
|
||||||
goog.asserts.assertInstanceof(layerRenderer, ol.renderer.dom.Layer);
|
goog.asserts.assertInstanceof(layerRenderer, ol.renderer.dom.Layer,
|
||||||
|
'renderer is an instance of ol.renderer.dom.Layer');
|
||||||
addChild.call(this, layerRenderer.getTarget(), i);
|
addChild.call(this, layerRenderer.getTarget(), i);
|
||||||
if (layerState.sourceState == ol.source.State.READY) {
|
if (layerState.sourceState == ol.source.State.READY) {
|
||||||
if (layerRenderer.prepareFrame(frameState, layerState)) {
|
if (layerRenderer.prepareFrame(frameState, layerState)) {
|
||||||
@@ -254,7 +255,8 @@ ol.renderer.dom.Map.prototype.renderFrame = function(frameState) {
|
|||||||
for (layerKey in this.getLayerRenderers()) {
|
for (layerKey in this.getLayerRenderers()) {
|
||||||
if (!(layerKey in layerStates)) {
|
if (!(layerKey in layerStates)) {
|
||||||
layerRenderer = this.getLayerRendererByKey(layerKey);
|
layerRenderer = this.getLayerRendererByKey(layerKey);
|
||||||
goog.asserts.assertInstanceof(layerRenderer, ol.renderer.dom.Layer);
|
goog.asserts.assertInstanceof(layerRenderer, ol.renderer.dom.Layer,
|
||||||
|
'renderer is an instance of ol.renderer.dom.Layer');
|
||||||
goog.dom.removeNode(layerRenderer.getTarget());
|
goog.dom.removeNode(layerRenderer.getTarget());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -101,7 +101,8 @@ ol.renderer.dom.TileLayer.prototype.prepareFrame =
|
|||||||
var projection = viewState.projection;
|
var projection = viewState.projection;
|
||||||
|
|
||||||
var tileLayer = this.getLayer();
|
var tileLayer = this.getLayer();
|
||||||
goog.asserts.assertInstanceof(tileLayer, ol.layer.Tile);
|
goog.asserts.assertInstanceof(tileLayer, ol.layer.Tile,
|
||||||
|
'layer is an instance of ol.layer.Tile');
|
||||||
var tileSource = tileLayer.getSource();
|
var tileSource = tileLayer.getSource();
|
||||||
var tileGrid = tileSource.getTileGridForProjection(projection);
|
var tileGrid = tileSource.getTileGridForProjection(projection);
|
||||||
var tileGutter = tileSource.getGutter();
|
var tileGutter = tileSource.getGutter();
|
||||||
@@ -353,7 +354,8 @@ ol.renderer.dom.TileLayerZ_.prototype.addTile = function(tile, tileGutter) {
|
|||||||
var tileCoordZ = tileCoord[0];
|
var tileCoordZ = tileCoord[0];
|
||||||
var tileCoordX = tileCoord[1];
|
var tileCoordX = tileCoord[1];
|
||||||
var tileCoordY = tileCoord[2];
|
var tileCoordY = tileCoord[2];
|
||||||
goog.asserts.assert(tileCoordZ == this.tileCoordOrigin_[0]);
|
goog.asserts.assert(tileCoordZ == this.tileCoordOrigin_[0],
|
||||||
|
'tileCoordZ matches z of tileCoordOrigin');
|
||||||
var tileCoordKey = ol.tilecoord.toString(tileCoord);
|
var tileCoordKey = ol.tilecoord.toString(tileCoord);
|
||||||
if (tileCoordKey in this.tiles_) {
|
if (tileCoordKey in this.tiles_) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -99,7 +99,8 @@ ol.renderer.dom.VectorLayer.prototype.composeFrame =
|
|||||||
function(frameState, layerState) {
|
function(frameState, layerState) {
|
||||||
|
|
||||||
var vectorLayer = /** @type {ol.layer.Vector} */ (this.getLayer());
|
var vectorLayer = /** @type {ol.layer.Vector} */ (this.getLayer());
|
||||||
goog.asserts.assertInstanceof(vectorLayer, ol.layer.Vector);
|
goog.asserts.assertInstanceof(vectorLayer, ol.layer.Vector,
|
||||||
|
'layer is an instance of ol.layer.Vector');
|
||||||
|
|
||||||
var viewState = frameState.viewState;
|
var viewState = frameState.viewState;
|
||||||
var viewCenter = viewState.center;
|
var viewCenter = viewState.center;
|
||||||
@@ -192,7 +193,7 @@ ol.renderer.dom.VectorLayer.prototype.forEachFeatureAtCoordinate =
|
|||||||
* @return {?} Callback result.
|
* @return {?} Callback result.
|
||||||
*/
|
*/
|
||||||
function(feature) {
|
function(feature) {
|
||||||
goog.asserts.assert(goog.isDef(feature));
|
goog.asserts.assert(goog.isDef(feature), '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;
|
||||||
@@ -221,7 +222,8 @@ ol.renderer.dom.VectorLayer.prototype.prepareFrame =
|
|||||||
function(frameState, layerState) {
|
function(frameState, layerState) {
|
||||||
|
|
||||||
var vectorLayer = /** @type {ol.layer.Vector} */ (this.getLayer());
|
var vectorLayer = /** @type {ol.layer.Vector} */ (this.getLayer());
|
||||||
goog.asserts.assertInstanceof(vectorLayer, ol.layer.Vector);
|
goog.asserts.assertInstanceof(vectorLayer, ol.layer.Vector,
|
||||||
|
'layer is an instance of ol.layer.Vector');
|
||||||
var vectorSource = vectorLayer.getSource();
|
var vectorSource = vectorLayer.getSource();
|
||||||
|
|
||||||
this.updateAttributions(
|
this.updateAttributions(
|
||||||
|
|||||||
@@ -149,14 +149,16 @@ ol.renderer.Layer.prototype.loadImage = function(image) {
|
|||||||
// the image is either "idle" or "loading", register the change
|
// the image is either "idle" or "loading", register the change
|
||||||
// listener (a noop if the listener was already registered)
|
// listener (a noop if the listener was already registered)
|
||||||
goog.asserts.assert(imageState == ol.ImageState.IDLE ||
|
goog.asserts.assert(imageState == ol.ImageState.IDLE ||
|
||||||
imageState == ol.ImageState.LOADING);
|
imageState == ol.ImageState.LOADING,
|
||||||
|
'imageState is "idle" or "loading"');
|
||||||
goog.events.listen(image, goog.events.EventType.CHANGE,
|
goog.events.listen(image, goog.events.EventType.CHANGE,
|
||||||
this.handleImageChange_, false, this);
|
this.handleImageChange_, false, this);
|
||||||
}
|
}
|
||||||
if (imageState == ol.ImageState.IDLE) {
|
if (imageState == ol.ImageState.IDLE) {
|
||||||
image.load();
|
image.load();
|
||||||
imageState = image.getState();
|
imageState = image.getState();
|
||||||
goog.asserts.assert(imageState == ol.ImageState.LOADING);
|
goog.asserts.assert(imageState == ol.ImageState.LOADING,
|
||||||
|
'imageState is "loading"');
|
||||||
}
|
}
|
||||||
return imageState == ol.ImageState.LOADED;
|
return imageState == ol.ImageState.LOADED;
|
||||||
};
|
};
|
||||||
@@ -225,8 +227,8 @@ ol.renderer.Layer.prototype.updateLogos = function(frameState, source) {
|
|||||||
if (goog.isString(logo)) {
|
if (goog.isString(logo)) {
|
||||||
frameState.logos[logo] = '';
|
frameState.logos[logo] = '';
|
||||||
} else if (goog.isObject(logo)) {
|
} else if (goog.isObject(logo)) {
|
||||||
goog.asserts.assertString(logo.href);
|
goog.asserts.assertString(logo.href, 'logo.href is a string');
|
||||||
goog.asserts.assertString(logo.src);
|
goog.asserts.assertString(logo.src, 'logo.src is a string');
|
||||||
frameState.logos[logo.src] = logo.href;
|
frameState.logos[logo.src] = logo.href;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,7 +75,8 @@ goog.inherits(ol.renderer.Map, goog.Disposable);
|
|||||||
ol.renderer.Map.prototype.calculateMatrices2D = function(frameState) {
|
ol.renderer.Map.prototype.calculateMatrices2D = function(frameState) {
|
||||||
var viewState = frameState.viewState;
|
var viewState = frameState.viewState;
|
||||||
var coordinateToPixelMatrix = frameState.coordinateToPixelMatrix;
|
var coordinateToPixelMatrix = frameState.coordinateToPixelMatrix;
|
||||||
goog.asserts.assert(!goog.isNull(coordinateToPixelMatrix));
|
goog.asserts.assert(!goog.isNull(coordinateToPixelMatrix),
|
||||||
|
'frameState has non-null coordinateToPixelMatrix');
|
||||||
ol.vec.Mat4.makeTransform2D(coordinateToPixelMatrix,
|
ol.vec.Mat4.makeTransform2D(coordinateToPixelMatrix,
|
||||||
frameState.size[0] / 2, frameState.size[1] / 2,
|
frameState.size[0] / 2, frameState.size[1] / 2,
|
||||||
1 / viewState.resolution, -1 / viewState.resolution,
|
1 / viewState.resolution, -1 / viewState.resolution,
|
||||||
@@ -83,7 +84,7 @@ ol.renderer.Map.prototype.calculateMatrices2D = function(frameState) {
|
|||||||
-viewState.center[0], -viewState.center[1]);
|
-viewState.center[0], -viewState.center[1]);
|
||||||
var inverted = goog.vec.Mat4.invert(
|
var inverted = goog.vec.Mat4.invert(
|
||||||
coordinateToPixelMatrix, frameState.pixelToCoordinateMatrix);
|
coordinateToPixelMatrix, frameState.pixelToCoordinateMatrix);
|
||||||
goog.asserts.assert(inverted);
|
goog.asserts.assert(inverted, 'matrix could be inverted');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -145,7 +146,7 @@ ol.renderer.Map.prototype.forEachFeatureAtCoordinate =
|
|||||||
* @return {?} Callback result.
|
* @return {?} Callback result.
|
||||||
*/
|
*/
|
||||||
function(feature) {
|
function(feature) {
|
||||||
goog.asserts.assert(goog.isDef(feature));
|
goog.asserts.assert(goog.isDef(feature), '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;
|
||||||
@@ -277,7 +278,8 @@ ol.renderer.Map.prototype.getLayerRenderer = function(layer) {
|
|||||||
* @return {ol.renderer.Layer} Layer renderer.
|
* @return {ol.renderer.Layer} Layer renderer.
|
||||||
*/
|
*/
|
||||||
ol.renderer.Map.prototype.getLayerRendererByKey = function(layerKey) {
|
ol.renderer.Map.prototype.getLayerRendererByKey = function(layerKey) {
|
||||||
goog.asserts.assert(layerKey in this.layerRenderers_);
|
goog.asserts.assert(layerKey in this.layerRenderers_,
|
||||||
|
'given layerKey (%s) exists in layerRenderers', layerKey);
|
||||||
return this.layerRenderers_[layerKey];
|
return this.layerRenderers_[layerKey];
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -320,11 +322,13 @@ ol.renderer.Map.prototype.handleLayerRendererChange_ = function() {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.renderer.Map.prototype.removeLayerRendererByKey_ = function(layerKey) {
|
ol.renderer.Map.prototype.removeLayerRendererByKey_ = function(layerKey) {
|
||||||
goog.asserts.assert(layerKey in this.layerRenderers_);
|
goog.asserts.assert(layerKey in this.layerRenderers_,
|
||||||
|
'given layerKey (%s) exists in layerRenderers', layerKey);
|
||||||
var layerRenderer = this.layerRenderers_[layerKey];
|
var layerRenderer = this.layerRenderers_[layerKey];
|
||||||
delete this.layerRenderers_[layerKey];
|
delete this.layerRenderers_[layerKey];
|
||||||
|
|
||||||
goog.asserts.assert(layerKey in this.layerRendererListeners_);
|
goog.asserts.assert(layerKey in this.layerRendererListeners_,
|
||||||
|
'given layerKey (%s) exists in layerRendererListeners', layerKey);
|
||||||
goog.events.unlistenByKey(this.layerRendererListeners_[layerKey]);
|
goog.events.unlistenByKey(this.layerRendererListeners_[layerKey]);
|
||||||
delete this.layerRendererListeners_[layerKey];
|
delete this.layerRendererListeners_[layerKey];
|
||||||
|
|
||||||
|
|||||||
@@ -110,7 +110,8 @@ ol.renderer.webgl.ImageLayer.prototype.prepareFrame =
|
|||||||
var image = this.image_;
|
var image = this.image_;
|
||||||
var texture = this.texture;
|
var texture = this.texture;
|
||||||
var imageLayer = this.getLayer();
|
var imageLayer = this.getLayer();
|
||||||
goog.asserts.assertInstanceof(imageLayer, ol.layer.Image);
|
goog.asserts.assertInstanceof(imageLayer, ol.layer.Image,
|
||||||
|
'layer is an instance of ol.layer.Image');
|
||||||
var imageSource = imageLayer.getSource();
|
var imageSource = imageLayer.getSource();
|
||||||
|
|
||||||
var hints = frameState.viewHints;
|
var hints = frameState.viewHints;
|
||||||
@@ -125,7 +126,8 @@ ol.renderer.webgl.ImageLayer.prototype.prepareFrame =
|
|||||||
var projection = viewState.projection;
|
var projection = viewState.projection;
|
||||||
var sourceProjection = imageSource.getProjection();
|
var sourceProjection = imageSource.getProjection();
|
||||||
if (!goog.isNull(sourceProjection)) {
|
if (!goog.isNull(sourceProjection)) {
|
||||||
goog.asserts.assert(ol.proj.equivalent(projection, sourceProjection));
|
goog.asserts.assert(ol.proj.equivalent(projection, sourceProjection),
|
||||||
|
'projection and sourceProjection are equivalent');
|
||||||
projection = sourceProjection;
|
projection = sourceProjection;
|
||||||
}
|
}
|
||||||
var image_ = imageSource.getImage(renderedExtent, viewResolution,
|
var image_ = imageSource.getImage(renderedExtent, viewResolution,
|
||||||
@@ -153,7 +155,7 @@ ol.renderer.webgl.ImageLayer.prototype.prepareFrame =
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!goog.isNull(image)) {
|
if (!goog.isNull(image)) {
|
||||||
goog.asserts.assert(!goog.isNull(texture));
|
goog.asserts.assert(!goog.isNull(texture), 'texture is not null');
|
||||||
|
|
||||||
var canvas = this.mapRenderer.getContext().getCanvas();
|
var canvas = this.mapRenderer.getContext().getCanvas();
|
||||||
|
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ ol.renderer.webgl.Map = function(container, map) {
|
|||||||
preserveDrawingBuffer: false,
|
preserveDrawingBuffer: false,
|
||||||
stencil: true
|
stencil: true
|
||||||
});
|
});
|
||||||
goog.asserts.assert(!goog.isNull(this.gl_));
|
goog.asserts.assert(!goog.isNull(this.gl_), 'got a WebGLRenderingContext');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
@@ -190,7 +190,8 @@ ol.renderer.webgl.Map.prototype.bindTileTexture =
|
|||||||
var tileKey = tile.getKey();
|
var tileKey = tile.getKey();
|
||||||
if (this.textureCache_.containsKey(tileKey)) {
|
if (this.textureCache_.containsKey(tileKey)) {
|
||||||
var textureCacheEntry = this.textureCache_.get(tileKey);
|
var textureCacheEntry = this.textureCache_.get(tileKey);
|
||||||
goog.asserts.assert(!goog.isNull(textureCacheEntry));
|
goog.asserts.assert(!goog.isNull(textureCacheEntry),
|
||||||
|
'a texture cache entry exists for key %s', tileKey);
|
||||||
gl.bindTexture(goog.webgl.TEXTURE_2D, textureCacheEntry.texture);
|
gl.bindTexture(goog.webgl.TEXTURE_2D, textureCacheEntry.texture);
|
||||||
if (textureCacheEntry.magFilter != magFilter) {
|
if (textureCacheEntry.magFilter != magFilter) {
|
||||||
gl.texParameteri(
|
gl.texParameteri(
|
||||||
@@ -253,7 +254,7 @@ ol.renderer.webgl.Map.prototype.createLayerRenderer = function(layer) {
|
|||||||
} else if (ol.ENABLE_VECTOR && layer instanceof ol.layer.Vector) {
|
} else if (ol.ENABLE_VECTOR && layer instanceof ol.layer.Vector) {
|
||||||
return new ol.renderer.webgl.VectorLayer(this, layer);
|
return new ol.renderer.webgl.VectorLayer(this, layer);
|
||||||
} else {
|
} else {
|
||||||
goog.asserts.fail();
|
goog.asserts.fail('unexpected layer configuration');
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -397,7 +398,8 @@ ol.renderer.webgl.Map.prototype.handleWebGLContextLost = function(event) {
|
|||||||
* @param {Object.<string, ol.renderer.Layer>} object Object.
|
* @param {Object.<string, ol.renderer.Layer>} object Object.
|
||||||
*/
|
*/
|
||||||
function(layerRenderer, key, object) {
|
function(layerRenderer, key, object) {
|
||||||
goog.asserts.assertInstanceof(layerRenderer, ol.renderer.webgl.Layer);
|
goog.asserts.assertInstanceof(layerRenderer, ol.renderer.webgl.Layer,
|
||||||
|
'renderer is an instance of ol.renderer.webgl.Layer');
|
||||||
var webGLLayerRenderer = /** @type {ol.renderer.webgl.Layer} */
|
var webGLLayerRenderer = /** @type {ol.renderer.webgl.Layer} */
|
||||||
(layerRenderer);
|
(layerRenderer);
|
||||||
webGLLayerRenderer.handleWebGLContextLost();
|
webGLLayerRenderer.handleWebGLContextLost();
|
||||||
@@ -482,7 +484,8 @@ ol.renderer.webgl.Map.prototype.renderFrame = function(frameState) {
|
|||||||
if (ol.layer.Layer.visibleAtResolution(layerState, viewResolution) &&
|
if (ol.layer.Layer.visibleAtResolution(layerState, viewResolution) &&
|
||||||
layerState.sourceState == ol.source.State.READY) {
|
layerState.sourceState == ol.source.State.READY) {
|
||||||
layerRenderer = this.getLayerRenderer(layerState.layer);
|
layerRenderer = this.getLayerRenderer(layerState.layer);
|
||||||
goog.asserts.assertInstanceof(layerRenderer, ol.renderer.webgl.Layer);
|
goog.asserts.assertInstanceof(layerRenderer, ol.renderer.webgl.Layer,
|
||||||
|
'renderer is an instance of ol.renderer.webgl.Layer');
|
||||||
if (layerRenderer.prepareFrame(frameState, layerState, context)) {
|
if (layerRenderer.prepareFrame(frameState, layerState, context)) {
|
||||||
layerStatesToDraw.push(layerState);
|
layerStatesToDraw.push(layerState);
|
||||||
}
|
}
|
||||||
@@ -508,7 +511,8 @@ ol.renderer.webgl.Map.prototype.renderFrame = function(frameState) {
|
|||||||
for (i = 0, ii = layerStatesToDraw.length; i < ii; ++i) {
|
for (i = 0, ii = layerStatesToDraw.length; i < ii; ++i) {
|
||||||
layerState = layerStatesToDraw[i];
|
layerState = layerStatesToDraw[i];
|
||||||
layerRenderer = this.getLayerRenderer(layerState.layer);
|
layerRenderer = this.getLayerRenderer(layerState.layer);
|
||||||
goog.asserts.assertInstanceof(layerRenderer, ol.renderer.webgl.Layer);
|
goog.asserts.assertInstanceof(layerRenderer, ol.renderer.webgl.Layer,
|
||||||
|
'renderer is an instance of ol.renderer.webgl.Layer');
|
||||||
layerRenderer.composeFrame(frameState, layerState, context);
|
layerRenderer.composeFrame(frameState, layerState, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -569,7 +573,7 @@ ol.renderer.webgl.Map.prototype.forEachFeatureAtCoordinate =
|
|||||||
* @return {?} Callback result.
|
* @return {?} Callback result.
|
||||||
*/
|
*/
|
||||||
function(feature) {
|
function(feature) {
|
||||||
goog.asserts.assert(goog.isDef(feature));
|
goog.asserts.assert(goog.isDef(feature), '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;
|
||||||
|
|||||||
@@ -151,7 +151,8 @@ ol.renderer.webgl.TileLayer.prototype.prepareFrame =
|
|||||||
var projection = viewState.projection;
|
var projection = viewState.projection;
|
||||||
|
|
||||||
var tileLayer = this.getLayer();
|
var tileLayer = this.getLayer();
|
||||||
goog.asserts.assertInstanceof(tileLayer, ol.layer.Tile);
|
goog.asserts.assertInstanceof(tileLayer, ol.layer.Tile,
|
||||||
|
'layer is an instance of ol.layer.Tile');
|
||||||
var tileSource = tileLayer.getSource();
|
var tileSource = tileLayer.getSource();
|
||||||
var tileGrid = tileSource.getTileGridForProjection(projection);
|
var tileGrid = tileSource.getTileGridForProjection(projection);
|
||||||
var z = tileGrid.getZForResolution(viewState.resolution);
|
var z = tileGrid.getZForResolution(viewState.resolution);
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ ol.renderer.webgl.VectorLayer.prototype.forEachFeatureAtCoordinate =
|
|||||||
* @return {?} Callback result.
|
* @return {?} Callback result.
|
||||||
*/
|
*/
|
||||||
function(feature) {
|
function(feature) {
|
||||||
goog.asserts.assert(goog.isDef(feature));
|
goog.asserts.assert(goog.isDef(feature), '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;
|
||||||
@@ -194,7 +194,8 @@ ol.renderer.webgl.VectorLayer.prototype.prepareFrame =
|
|||||||
function(frameState, layerState, context) {
|
function(frameState, layerState, context) {
|
||||||
|
|
||||||
var vectorLayer = /** @type {ol.layer.Vector} */ (this.getLayer());
|
var vectorLayer = /** @type {ol.layer.Vector} */ (this.getLayer());
|
||||||
goog.asserts.assertInstanceof(vectorLayer, ol.layer.Vector);
|
goog.asserts.assertInstanceof(vectorLayer, ol.layer.Vector,
|
||||||
|
'layer is an instance of ol.layer.Vector');
|
||||||
var vectorSource = vectorLayer.getSource();
|
var vectorSource = vectorLayer.getSource();
|
||||||
|
|
||||||
this.updateAttributions(
|
this.updateAttributions(
|
||||||
|
|||||||
@@ -98,7 +98,8 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse =
|
|||||||
}
|
}
|
||||||
//var copyright = response.copyright; // FIXME do we need to display this?
|
//var copyright = response.copyright; // FIXME do we need to display this?
|
||||||
var resource = response.resourceSets[0].resources[0];
|
var resource = response.resourceSets[0].resources[0];
|
||||||
goog.asserts.assert(resource.imageWidth == resource.imageHeight);
|
goog.asserts.assert(resource.imageWidth == resource.imageHeight,
|
||||||
|
'resource has imageWidth equal to imageHeight, i.e. is square');
|
||||||
var maxZoom = this.maxZoom_ == -1 ? resource.zoomMax : this.maxZoom_;
|
var maxZoom = this.maxZoom_ == -1 ? resource.zoomMax : this.maxZoom_;
|
||||||
|
|
||||||
var sourceProjection = this.getProjection();
|
var sourceProjection = this.getProjection();
|
||||||
@@ -129,7 +130,8 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse =
|
|||||||
*/
|
*/
|
||||||
function(tileCoord, pixelRatio, projection) {
|
function(tileCoord, pixelRatio, projection) {
|
||||||
goog.asserts.assert(ol.proj.equivalent(
|
goog.asserts.assert(ol.proj.equivalent(
|
||||||
projection, sourceProjection));
|
projection, sourceProjection),
|
||||||
|
'projections are equivalent');
|
||||||
if (goog.isNull(tileCoord)) {
|
if (goog.isNull(tileCoord)) {
|
||||||
return undefined;
|
return undefined;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -117,13 +117,14 @@ ol.source.Cluster.prototype.cluster_ = function() {
|
|||||||
var feature = features[i];
|
var feature = features[i];
|
||||||
if (!goog.object.containsKey(clustered, goog.getUid(feature).toString())) {
|
if (!goog.object.containsKey(clustered, goog.getUid(feature).toString())) {
|
||||||
var geometry = feature.getGeometry();
|
var geometry = feature.getGeometry();
|
||||||
goog.asserts.assert(geometry instanceof ol.geom.Point);
|
goog.asserts.assert(geometry instanceof ol.geom.Point,
|
||||||
|
'feature geometry is a ol.geom.Point instance');
|
||||||
var coordinates = geometry.getCoordinates();
|
var coordinates = geometry.getCoordinates();
|
||||||
ol.extent.createOrUpdateFromCoordinate(coordinates, extent);
|
ol.extent.createOrUpdateFromCoordinate(coordinates, extent);
|
||||||
ol.extent.buffer(extent, mapDistance, extent);
|
ol.extent.buffer(extent, mapDistance, extent);
|
||||||
|
|
||||||
var neighbors = this.source_.getFeaturesInExtent(extent);
|
var neighbors = this.source_.getFeaturesInExtent(extent);
|
||||||
goog.asserts.assert(neighbors.length >= 1);
|
goog.asserts.assert(neighbors.length >= 1, 'at least one neighbor found');
|
||||||
neighbors = goog.array.filter(neighbors, function(neighbor) {
|
neighbors = goog.array.filter(neighbors, function(neighbor) {
|
||||||
var uid = goog.getUid(neighbor).toString();
|
var uid = goog.getUid(neighbor).toString();
|
||||||
if (!goog.object.containsKey(clustered, uid)) {
|
if (!goog.object.containsKey(clustered, uid)) {
|
||||||
@@ -137,7 +138,8 @@ ol.source.Cluster.prototype.cluster_ = function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
goog.asserts.assert(
|
goog.asserts.assert(
|
||||||
goog.object.getCount(clustered) == this.source_.getFeatures().length);
|
goog.object.getCount(clustered) == this.source_.getFeatures().length,
|
||||||
|
'number of clustered equals number of features in the source');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -151,7 +153,8 @@ ol.source.Cluster.prototype.createCluster_ = function(features) {
|
|||||||
var centroid = [0, 0];
|
var centroid = [0, 0];
|
||||||
for (var i = 0; i < length; i++) {
|
for (var i = 0; i < length; i++) {
|
||||||
var geometry = features[i].getGeometry();
|
var geometry = features[i].getGeometry();
|
||||||
goog.asserts.assert(geometry instanceof ol.geom.Point);
|
goog.asserts.assert(geometry instanceof ol.geom.Point,
|
||||||
|
'feature geometry is a ol.geom.Point instance');
|
||||||
var coordinates = geometry.getCoordinates();
|
var coordinates = geometry.getCoordinates();
|
||||||
ol.coordinate.add(centroid, coordinates);
|
ol.coordinate.add(centroid, coordinates);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,7 +75,8 @@ ol.source.FormatVector.prototype.loadFeaturesFromURL =
|
|||||||
*/
|
*/
|
||||||
function(event) {
|
function(event) {
|
||||||
var xhrIo = event.target;
|
var xhrIo = event.target;
|
||||||
goog.asserts.assertInstanceof(xhrIo, goog.net.XhrIo);
|
goog.asserts.assertInstanceof(xhrIo, goog.net.XhrIo,
|
||||||
|
'event.target/xhrIo is an instance of goog.net.XhrIo');
|
||||||
if (xhrIo.isSuccess()) {
|
if (xhrIo.isSuccess()) {
|
||||||
var type = this.format.getType();
|
var type = this.format.getType();
|
||||||
/** @type {ArrayBuffer|Document|Node|Object|string|undefined} */
|
/** @type {ArrayBuffer|Document|Node|Object|string|undefined} */
|
||||||
@@ -83,7 +84,8 @@ ol.source.FormatVector.prototype.loadFeaturesFromURL =
|
|||||||
if (type == ol.format.FormatType.BINARY &&
|
if (type == ol.format.FormatType.BINARY &&
|
||||||
ol.has.ARRAY_BUFFER) {
|
ol.has.ARRAY_BUFFER) {
|
||||||
source = xhrIo.getResponse();
|
source = xhrIo.getResponse();
|
||||||
goog.asserts.assertInstanceof(source, ArrayBuffer);
|
goog.asserts.assertInstanceof(source, ArrayBuffer,
|
||||||
|
'source is an instance of ArrayBuffer');
|
||||||
} else if (type == ol.format.FormatType.JSON) {
|
} else if (type == ol.format.FormatType.JSON) {
|
||||||
source = xhrIo.getResponseText();
|
source = xhrIo.getResponseText();
|
||||||
} else if (type == ol.format.FormatType.TEXT) {
|
} else if (type == ol.format.FormatType.TEXT) {
|
||||||
@@ -96,13 +98,13 @@ ol.source.FormatVector.prototype.loadFeaturesFromURL =
|
|||||||
source = ol.xml.parse(xhrIo.getResponseText());
|
source = ol.xml.parse(xhrIo.getResponseText());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
goog.asserts.fail();
|
goog.asserts.fail('unexpected format type');
|
||||||
}
|
}
|
||||||
if (goog.isDefAndNotNull(source)) {
|
if (goog.isDefAndNotNull(source)) {
|
||||||
success.call(thisArg, this.readFeatures(source));
|
success.call(thisArg, this.readFeatures(source));
|
||||||
} else {
|
} else {
|
||||||
this.setState(ol.source.State.ERROR);
|
this.setState(ol.source.State.ERROR);
|
||||||
goog.asserts.fail();
|
goog.asserts.fail('undefined or null source');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
error.call(thisArg);
|
error.call(thisArg);
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ ol.source.Image = function(options) {
|
|||||||
goog.array.isSorted(this.resolutions_,
|
goog.array.isSorted(this.resolutions_,
|
||||||
function(a, b) {
|
function(a, b) {
|
||||||
return b - a;
|
return b - a;
|
||||||
}, true));
|
}, true), 'resolutions must be null or sorted in descending order');
|
||||||
|
|
||||||
};
|
};
|
||||||
goog.inherits(ol.source.Image, ol.source.Source);
|
goog.inherits(ol.source.Image, ol.source.Source);
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ ol.source.ImageVector.prototype.forEachFeatureAtCoordinate = function(
|
|||||||
* @return {?} Callback result.
|
* @return {?} Callback result.
|
||||||
*/
|
*/
|
||||||
function(feature) {
|
function(feature) {
|
||||||
goog.asserts.assert(goog.isDef(feature));
|
goog.asserts.assert(goog.isDef(feature), 'passed 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;
|
||||||
|
|||||||
@@ -139,7 +139,8 @@ ol.source.ImageWMS.GETFEATUREINFO_IMAGE_SIZE_ = [101, 101];
|
|||||||
ol.source.ImageWMS.prototype.getGetFeatureInfoUrl =
|
ol.source.ImageWMS.prototype.getGetFeatureInfoUrl =
|
||||||
function(coordinate, resolution, projection, params) {
|
function(coordinate, resolution, projection, params) {
|
||||||
|
|
||||||
goog.asserts.assert(!('VERSION' in params));
|
goog.asserts.assert(!('VERSION' in params),
|
||||||
|
'key VERSION is not allowed in params');
|
||||||
|
|
||||||
if (!goog.isDef(this.url_)) {
|
if (!goog.isDef(this.url_)) {
|
||||||
return undefined;
|
return undefined;
|
||||||
@@ -279,7 +280,7 @@ ol.source.ImageWMS.prototype.getImageLoadFunction = function() {
|
|||||||
ol.source.ImageWMS.prototype.getRequestUrl_ =
|
ol.source.ImageWMS.prototype.getRequestUrl_ =
|
||||||
function(extent, size, pixelRatio, projection, params) {
|
function(extent, size, pixelRatio, projection, params) {
|
||||||
|
|
||||||
goog.asserts.assert(goog.isDef(this.url_));
|
goog.asserts.assert(goog.isDef(this.url_), 'url is defined');
|
||||||
|
|
||||||
params[this.v13_ ? 'CRS' : 'SRS'] = projection.getCode();
|
params[this.v13_ ? 'CRS' : 'SRS'] = projection.getCode();
|
||||||
|
|
||||||
@@ -303,7 +304,7 @@ ol.source.ImageWMS.prototype.getRequestUrl_ =
|
|||||||
params['DPI'] = 90 * pixelRatio;
|
params['DPI'] = 90 * pixelRatio;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
goog.asserts.fail();
|
goog.asserts.fail('unknown serverType configured');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,8 @@ goog.require('ol.source.XYZ');
|
|||||||
ol.source.MapQuest = function(opt_options) {
|
ol.source.MapQuest = function(opt_options) {
|
||||||
|
|
||||||
var options = goog.isDef(opt_options) ? opt_options : {};
|
var options = goog.isDef(opt_options) ? opt_options : {};
|
||||||
goog.asserts.assert(options.layer in ol.source.MapQuestConfig);
|
goog.asserts.assert(options.layer in ol.source.MapQuestConfig,
|
||||||
|
'known layer configured');
|
||||||
|
|
||||||
var layerConfig = ol.source.MapQuestConfig[options.layer];
|
var layerConfig = ol.source.MapQuestConfig[options.layer];
|
||||||
|
|
||||||
|
|||||||
@@ -91,10 +91,12 @@ ol.source.Stamen = function(options) {
|
|||||||
|
|
||||||
var i = options.layer.indexOf('-');
|
var i = options.layer.indexOf('-');
|
||||||
var provider = i == -1 ? options.layer : options.layer.slice(0, i);
|
var provider = i == -1 ? options.layer : options.layer.slice(0, i);
|
||||||
goog.asserts.assert(provider in ol.source.StamenProviderConfig);
|
goog.asserts.assert(provider in ol.source.StamenProviderConfig,
|
||||||
|
'known provider configured');
|
||||||
var providerConfig = ol.source.StamenProviderConfig[provider];
|
var providerConfig = ol.source.StamenProviderConfig[provider];
|
||||||
|
|
||||||
goog.asserts.assert(options.layer in ol.source.StamenLayerConfig);
|
goog.asserts.assert(options.layer in ol.source.StamenLayerConfig,
|
||||||
|
'known layer configured');
|
||||||
var layerConfig = ol.source.StamenLayerConfig[options.layer];
|
var layerConfig = ol.source.StamenLayerConfig[options.layer];
|
||||||
|
|
||||||
var root = ol.IS_HTTPS ? 'https://stamen-tiles-{a-d}.a.ssl.fastly.net/' :
|
var root = ol.IS_HTTPS ? 'https://stamen-tiles-{a-d}.a.ssl.fastly.net/' :
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ ol.source.TileImage.prototype.getTile =
|
|||||||
if (this.tileCache.containsKey(tileCoordKey)) {
|
if (this.tileCache.containsKey(tileCoordKey)) {
|
||||||
return /** @type {!ol.Tile} */ (this.tileCache.get(tileCoordKey));
|
return /** @type {!ol.Tile} */ (this.tileCache.get(tileCoordKey));
|
||||||
} else {
|
} else {
|
||||||
goog.asserts.assert(projection);
|
goog.asserts.assert(projection, 'argument projection is truthy');
|
||||||
var tileCoord = [z, x, y];
|
var tileCoord = [z, x, y];
|
||||||
var urlTileCoord = this.getWrapXTileCoord(tileCoord, projection);
|
var urlTileCoord = this.getWrapXTileCoord(tileCoord, projection);
|
||||||
var tileUrl = goog.isNull(urlTileCoord) ? undefined :
|
var tileUrl = goog.isNull(urlTileCoord) ? undefined :
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ ol.source.TileJSON.prototype.handleTileJSONResponse = function(tileJSON) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (goog.isDef(tileJSON.scheme)) {
|
if (goog.isDef(tileJSON.scheme)) {
|
||||||
goog.asserts.assert(tileJSON.scheme == 'xyz');
|
goog.asserts.assert(tileJSON.scheme == 'xyz', 'tileJSON-scheme is "xyz"');
|
||||||
}
|
}
|
||||||
var minZoom = tileJSON.minzoom || 0;
|
var minZoom = tileJSON.minzoom || 0;
|
||||||
var maxZoom = tileJSON.maxzoom || 22;
|
var maxZoom = tileJSON.maxzoom || 22;
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ ol.source.TileUTFGrid.prototype.handleTileJSONResponse = function(tileJSON) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (goog.isDef(tileJSON.scheme)) {
|
if (goog.isDef(tileJSON.scheme)) {
|
||||||
goog.asserts.assert(tileJSON.scheme == 'xyz');
|
goog.asserts.assert(tileJSON.scheme == 'xyz', 'tileJSON-scheme is "xyz"');
|
||||||
}
|
}
|
||||||
var minZoom = tileJSON.minzoom || 0;
|
var minZoom = tileJSON.minzoom || 0;
|
||||||
var maxZoom = tileJSON.maxzoom || 22;
|
var maxZoom = tileJSON.maxzoom || 22;
|
||||||
@@ -175,7 +175,7 @@ ol.source.TileUTFGrid.prototype.getTile =
|
|||||||
if (this.tileCache.containsKey(tileCoordKey)) {
|
if (this.tileCache.containsKey(tileCoordKey)) {
|
||||||
return /** @type {!ol.Tile} */ (this.tileCache.get(tileCoordKey));
|
return /** @type {!ol.Tile} */ (this.tileCache.get(tileCoordKey));
|
||||||
} else {
|
} else {
|
||||||
goog.asserts.assert(projection);
|
goog.asserts.assert(projection, 'argument projection is truthy');
|
||||||
var tileCoord = [z, x, y];
|
var tileCoord = [z, x, y];
|
||||||
var tileUrl = this.tileUrlFunction_(tileCoord, pixelRatio, projection);
|
var tileUrl = this.tileUrlFunction_(tileCoord, pixelRatio, projection);
|
||||||
var tile = new ol.source.TileUTFGridTile_(
|
var tile = new ol.source.TileUTFGridTile_(
|
||||||
|
|||||||
@@ -121,7 +121,8 @@ ol.source.TileVector.prototype.forEachFeatureAtCoordinateAndResolution =
|
|||||||
for (i = 0, ii = features.length; i < ii; ++i) {
|
for (i = 0, ii = features.length; i < ii; ++i) {
|
||||||
var feature = features[i];
|
var feature = features[i];
|
||||||
var geometry = feature.getGeometry();
|
var geometry = feature.getGeometry();
|
||||||
goog.asserts.assert(goog.isDefAndNotNull(geometry));
|
goog.asserts.assert(goog.isDefAndNotNull(geometry),
|
||||||
|
'feature geometry is defined and not null');
|
||||||
if (geometry.containsCoordinate(coordinate)) {
|
if (geometry.containsCoordinate(coordinate)) {
|
||||||
var result = callback.call(opt_this, feature);
|
var result = callback.call(opt_this, feature);
|
||||||
if (result) {
|
if (result) {
|
||||||
|
|||||||
@@ -129,7 +129,8 @@ goog.inherits(ol.source.TileWMS, ol.source.TileImage);
|
|||||||
ol.source.TileWMS.prototype.getGetFeatureInfoUrl =
|
ol.source.TileWMS.prototype.getGetFeatureInfoUrl =
|
||||||
function(coordinate, resolution, projection, params) {
|
function(coordinate, resolution, projection, params) {
|
||||||
|
|
||||||
goog.asserts.assert(!('VERSION' in params));
|
goog.asserts.assert(!('VERSION' in params),
|
||||||
|
'key VERSION is not allowed in params');
|
||||||
|
|
||||||
var projectionObj = ol.proj.get(projection);
|
var projectionObj = ol.proj.get(projection);
|
||||||
|
|
||||||
@@ -248,7 +249,7 @@ ol.source.TileWMS.prototype.getRequestUrl_ =
|
|||||||
params['DPI'] = 90 * pixelRatio;
|
params['DPI'] = 90 * pixelRatio;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
goog.asserts.fail();
|
goog.asserts.fail('unknown serverType configured');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -158,7 +158,8 @@ ol.source.Vector.prototype.addFeatureInternal = function(feature) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.source.Vector.prototype.setupChangeEvents_ = function(featureKey, feature) {
|
ol.source.Vector.prototype.setupChangeEvents_ = function(featureKey, feature) {
|
||||||
goog.asserts.assert(!(featureKey in this.featureChangeKeys_));
|
goog.asserts.assert(!(featureKey in this.featureChangeKeys_),
|
||||||
|
'key (%s) not yet registered in featurChangeKey', featureKey);
|
||||||
this.featureChangeKeys_[featureKey] = [
|
this.featureChangeKeys_[featureKey] = [
|
||||||
goog.events.listen(feature,
|
goog.events.listen(feature,
|
||||||
goog.events.EventType.CHANGE,
|
goog.events.EventType.CHANGE,
|
||||||
@@ -251,9 +252,12 @@ ol.source.Vector.prototype.clear = function(opt_fast) {
|
|||||||
var rmFeatureInternal = this.removeFeatureInternal;
|
var rmFeatureInternal = this.removeFeatureInternal;
|
||||||
this.rBush_.forEach(rmFeatureInternal, this);
|
this.rBush_.forEach(rmFeatureInternal, this);
|
||||||
goog.object.forEach(this.nullGeometryFeatures_, rmFeatureInternal, this);
|
goog.object.forEach(this.nullGeometryFeatures_, rmFeatureInternal, this);
|
||||||
goog.asserts.assert(goog.object.isEmpty(this.featureChangeKeys_));
|
goog.asserts.assert(goog.object.isEmpty(this.featureChangeKeys_),
|
||||||
goog.asserts.assert(goog.object.isEmpty(this.idIndex_));
|
'featureChangeKeys is an empty object now');
|
||||||
goog.asserts.assert(goog.object.isEmpty(this.undefIdIndex_));
|
goog.asserts.assert(goog.object.isEmpty(this.idIndex_),
|
||||||
|
'idIndex is an empty object now');
|
||||||
|
goog.asserts.assert(goog.object.isEmpty(this.undefIdIndex_),
|
||||||
|
'undefIdIndex is an empty object now');
|
||||||
}
|
}
|
||||||
|
|
||||||
this.rBush_.clear();
|
this.rBush_.clear();
|
||||||
@@ -300,7 +304,8 @@ ol.source.Vector.prototype.forEachFeatureAtCoordinateDirect =
|
|||||||
var extent = [coordinate[0], coordinate[1], coordinate[0], coordinate[1]];
|
var extent = [coordinate[0], coordinate[1], coordinate[0], coordinate[1]];
|
||||||
return this.forEachFeatureInExtent(extent, function(feature) {
|
return this.forEachFeatureInExtent(extent, function(feature) {
|
||||||
var geometry = feature.getGeometry();
|
var geometry = feature.getGeometry();
|
||||||
goog.asserts.assert(goog.isDefAndNotNull(geometry));
|
goog.asserts.assert(goog.isDefAndNotNull(geometry),
|
||||||
|
'feature geometry is defined and not null');
|
||||||
if (geometry.containsCoordinate(coordinate)) {
|
if (geometry.containsCoordinate(coordinate)) {
|
||||||
return callback.call(opt_this, feature);
|
return callback.call(opt_this, feature);
|
||||||
} else {
|
} else {
|
||||||
@@ -375,7 +380,8 @@ ol.source.Vector.prototype.forEachFeatureIntersectingExtent =
|
|||||||
*/
|
*/
|
||||||
function(feature) {
|
function(feature) {
|
||||||
var geometry = feature.getGeometry();
|
var geometry = feature.getGeometry();
|
||||||
goog.asserts.assert(goog.isDefAndNotNull(geometry));
|
goog.asserts.assert(goog.isDefAndNotNull(geometry),
|
||||||
|
'feature geometry is defined and not null');
|
||||||
if (geometry.intersectsExtent(extent)) {
|
if (geometry.intersectsExtent(extent)) {
|
||||||
var result = callback.call(opt_this, feature);
|
var result = callback.call(opt_this, feature);
|
||||||
if (result) {
|
if (result) {
|
||||||
@@ -452,7 +458,8 @@ ol.source.Vector.prototype.getClosestFeatureToCoordinate =
|
|||||||
*/
|
*/
|
||||||
function(feature) {
|
function(feature) {
|
||||||
var geometry = feature.getGeometry();
|
var geometry = feature.getGeometry();
|
||||||
goog.asserts.assert(goog.isDefAndNotNull(geometry));
|
goog.asserts.assert(goog.isDefAndNotNull(geometry),
|
||||||
|
'feature geometry is defined and not null');
|
||||||
var previousMinSquaredDistance = minSquaredDistance;
|
var previousMinSquaredDistance = minSquaredDistance;
|
||||||
minSquaredDistance = geometry.closestPointXY(
|
minSquaredDistance = geometry.closestPointXY(
|
||||||
x, y, closestPoint, minSquaredDistance);
|
x, y, closestPoint, minSquaredDistance);
|
||||||
@@ -542,7 +549,8 @@ ol.source.Vector.prototype.handleFeatureChange_ = function(event) {
|
|||||||
'Expected feature to be removed from index');
|
'Expected feature to be removed from index');
|
||||||
this.undefIdIndex_[featureKey] = feature;
|
this.undefIdIndex_[featureKey] = feature;
|
||||||
} else {
|
} else {
|
||||||
goog.asserts.assert(this.undefIdIndex_[featureKey] === feature);
|
goog.asserts.assert(this.undefIdIndex_[featureKey] === feature,
|
||||||
|
'feature keyed under %s in undefIdKeys', featureKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.changed();
|
this.changed();
|
||||||
@@ -594,7 +602,8 @@ ol.source.Vector.prototype.removeFeature = function(feature) {
|
|||||||
*/
|
*/
|
||||||
ol.source.Vector.prototype.removeFeatureInternal = function(feature) {
|
ol.source.Vector.prototype.removeFeatureInternal = function(feature) {
|
||||||
var featureKey = goog.getUid(feature).toString();
|
var featureKey = goog.getUid(feature).toString();
|
||||||
goog.asserts.assert(featureKey in this.featureChangeKeys_);
|
goog.asserts.assert(featureKey in this.featureChangeKeys_,
|
||||||
|
'featureKey exists in featureChangeKeys');
|
||||||
goog.array.forEach(this.featureChangeKeys_[featureKey],
|
goog.array.forEach(this.featureChangeKeys_[featureKey],
|
||||||
goog.events.unlistenByKey);
|
goog.events.unlistenByKey);
|
||||||
delete this.featureChangeKeys_[featureKey];
|
delete this.featureChangeKeys_[featureKey];
|
||||||
|
|||||||
@@ -177,7 +177,8 @@ ol.source.WMTS = function(options) {
|
|||||||
* @return {ol.TileCoord} Tile coordinate.
|
* @return {ol.TileCoord} Tile coordinate.
|
||||||
*/
|
*/
|
||||||
function(tileCoord, projection, opt_tileCoord) {
|
function(tileCoord, projection, opt_tileCoord) {
|
||||||
goog.asserts.assert(!goog.isNull(tileGrid));
|
goog.asserts.assert(!goog.isNull(tileGrid),
|
||||||
|
'tileGrid must not be null');
|
||||||
if (tileGrid.getResolutions().length <= tileCoord[0]) {
|
if (tileGrid.getResolutions().length <= tileCoord[0]) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -328,15 +329,18 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) {
|
|||||||
/* jshint -W069 */
|
/* jshint -W069 */
|
||||||
|
|
||||||
// TODO: add support for TileMatrixLimits
|
// TODO: add support for TileMatrixLimits
|
||||||
goog.asserts.assert(!goog.isNull(config['layer']));
|
goog.asserts.assert(!goog.isNull(config['layer']),
|
||||||
|
'config "layer" must not be null');
|
||||||
|
|
||||||
var layers = wmtsCap['Contents']['Layer'];
|
var layers = wmtsCap['Contents']['Layer'];
|
||||||
var l = goog.array.find(layers, function(elt, index, array) {
|
var l = goog.array.find(layers, function(elt, index, array) {
|
||||||
return elt['Identifier'] == config['layer'];
|
return elt['Identifier'] == config['layer'];
|
||||||
});
|
});
|
||||||
goog.asserts.assert(!goog.isNull(l));
|
goog.asserts.assert(!goog.isNull(l),
|
||||||
|
'found a matching layer in Contents/Layer');
|
||||||
|
|
||||||
goog.asserts.assert(l['TileMatrixSetLink'].length > 0);
|
goog.asserts.assert(l['TileMatrixSetLink'].length > 0,
|
||||||
|
'layer has TileMatrixSetLink');
|
||||||
var idx, matrixSet, wrapX;
|
var idx, matrixSet, wrapX;
|
||||||
if (l['TileMatrixSetLink'].length > 1) {
|
if (l['TileMatrixSetLink'].length > 1) {
|
||||||
idx = goog.array.findIndex(l['TileMatrixSetLink'],
|
idx = goog.array.findIndex(l['TileMatrixSetLink'],
|
||||||
@@ -359,7 +363,8 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) {
|
|||||||
matrixSet = /** @type {string} */
|
matrixSet = /** @type {string} */
|
||||||
(l['TileMatrixSetLink'][idx]['TileMatrixSet']);
|
(l['TileMatrixSetLink'][idx]['TileMatrixSet']);
|
||||||
|
|
||||||
goog.asserts.assert(!goog.isNull(matrixSet));
|
goog.asserts.assert(!goog.isNull(matrixSet),
|
||||||
|
'TileMatrixSet must not be null');
|
||||||
|
|
||||||
var wgs84BoundingBox = l['WGS84BoundingBox'];
|
var wgs84BoundingBox = l['WGS84BoundingBox'];
|
||||||
if (goog.isDef(wgs84BoundingBox)) {
|
if (goog.isDef(wgs84BoundingBox)) {
|
||||||
@@ -390,11 +395,12 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) {
|
|||||||
var key = elt['Identifier'];
|
var key = elt['Identifier'];
|
||||||
var value = elt['default'];
|
var value = elt['default'];
|
||||||
if (goog.isDef(value)) {
|
if (goog.isDef(value)) {
|
||||||
goog.asserts.assert(goog.array.contains(elt['values'], value));
|
goog.asserts.assert(goog.array.contains(elt['values'], value),
|
||||||
|
'default value contained in values');
|
||||||
} else {
|
} else {
|
||||||
value = elt['values'][0];
|
value = elt['values'][0];
|
||||||
}
|
}
|
||||||
goog.asserts.assert(goog.isDef(value));
|
goog.asserts.assert(goog.isDef(value), 'value could be found');
|
||||||
dimensions[key] = value;
|
dimensions[key] = value;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -403,7 +409,8 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) {
|
|||||||
var matrixSetObj = goog.array.find(matrixSets, function(elt, index, array) {
|
var matrixSetObj = goog.array.find(matrixSets, function(elt, index, array) {
|
||||||
return elt['Identifier'] == matrixSet;
|
return elt['Identifier'] == matrixSet;
|
||||||
});
|
});
|
||||||
goog.asserts.assert(!goog.isNull(matrixSetObj));
|
goog.asserts.assert(!goog.isNull(matrixSetObj),
|
||||||
|
'found matrixSet in Contents/TileMatrixSet');
|
||||||
|
|
||||||
var tileGrid = ol.tilegrid.WMTS.createFromCapabilitiesMatrixSet(
|
var tileGrid = ol.tilegrid.WMTS.createFromCapabilitiesMatrixSet(
|
||||||
matrixSetObj);
|
matrixSetObj);
|
||||||
@@ -422,7 +429,9 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) {
|
|||||||
requestEncoding = goog.isDef(requestEncoding) ? requestEncoding : '';
|
requestEncoding = goog.isDef(requestEncoding) ? requestEncoding : '';
|
||||||
|
|
||||||
goog.asserts.assert(
|
goog.asserts.assert(
|
||||||
goog.array.contains(['REST', 'RESTful', 'KVP', ''], requestEncoding));
|
goog.array.contains(['REST', 'RESTful', 'KVP', ''], requestEncoding),
|
||||||
|
'requestEncoding (%s) is one of "REST", "RESTful", "KVP" or ""',
|
||||||
|
requestEncoding);
|
||||||
|
|
||||||
if (!wmtsCap['OperationsMetadata'].hasOwnProperty('GetTile') ||
|
if (!wmtsCap['OperationsMetadata'].hasOwnProperty('GetTile') ||
|
||||||
goog.string.startsWith(requestEncoding, 'REST')) {
|
goog.string.startsWith(requestEncoding, 'REST')) {
|
||||||
@@ -448,7 +457,7 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
goog.asserts.assert(urls.length > 0);
|
goog.asserts.assert(urls.length > 0, 'At least one URL found');
|
||||||
|
|
||||||
return {
|
return {
|
||||||
urls: urls,
|
urls: urls,
|
||||||
|
|||||||
@@ -47,32 +47,42 @@ ol.structs.LRUCache = function() {
|
|||||||
*/
|
*/
|
||||||
ol.structs.LRUCache.prototype.assertValid = function() {
|
ol.structs.LRUCache.prototype.assertValid = function() {
|
||||||
if (this.count_ === 0) {
|
if (this.count_ === 0) {
|
||||||
goog.asserts.assert(goog.object.isEmpty(this.entries_));
|
goog.asserts.assert(goog.object.isEmpty(this.entries_),
|
||||||
goog.asserts.assert(goog.isNull(this.oldest_));
|
'entries must be an empty object (count = 0)');
|
||||||
goog.asserts.assert(goog.isNull(this.newest_));
|
goog.asserts.assert(goog.isNull(this.oldest_),
|
||||||
|
'oldest must be null (count = 0)');
|
||||||
|
goog.asserts.assert(goog.isNull(this.newest_),
|
||||||
|
'newest must be null (count = 0)');
|
||||||
} else {
|
} else {
|
||||||
goog.asserts.assert(goog.object.getCount(this.entries_) == this.count_);
|
goog.asserts.assert(goog.object.getCount(this.entries_) == this.count_,
|
||||||
goog.asserts.assert(!goog.isNull(this.oldest_));
|
'number of entries matches count');
|
||||||
goog.asserts.assert(goog.isNull(this.oldest_.older));
|
goog.asserts.assert(!goog.isNull(this.oldest_),
|
||||||
goog.asserts.assert(!goog.isNull(this.newest_));
|
'we have an oldest entry');
|
||||||
goog.asserts.assert(goog.isNull(this.newest_.newer));
|
goog.asserts.assert(goog.isNull(this.oldest_.older),
|
||||||
|
'no entry is older than oldest');
|
||||||
|
goog.asserts.assert(!goog.isNull(this.newest_),
|
||||||
|
'we have a newest entry');
|
||||||
|
goog.asserts.assert(goog.isNull(this.newest_.newer),
|
||||||
|
'no entry is newer than newest');
|
||||||
var i, entry;
|
var i, entry;
|
||||||
var older = null;
|
var older = null;
|
||||||
i = 0;
|
i = 0;
|
||||||
for (entry = this.oldest_; !goog.isNull(entry); entry = entry.newer) {
|
for (entry = this.oldest_; !goog.isNull(entry); entry = entry.newer) {
|
||||||
goog.asserts.assert(entry.older === older);
|
goog.asserts.assert(entry.older === older,
|
||||||
|
'entry.older links to correct older');
|
||||||
older = entry;
|
older = entry;
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
goog.asserts.assert(i == this.count_);
|
goog.asserts.assert(i == this.count_, 'iterated correct amount of times');
|
||||||
var newer = null;
|
var newer = null;
|
||||||
i = 0;
|
i = 0;
|
||||||
for (entry = this.newest_; !goog.isNull(entry); entry = entry.older) {
|
for (entry = this.newest_; !goog.isNull(entry); entry = entry.older) {
|
||||||
goog.asserts.assert(entry.newer === newer);
|
goog.asserts.assert(entry.newer === newer,
|
||||||
|
'entry.newer links to correct newer');
|
||||||
newer = entry;
|
newer = entry;
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
goog.asserts.assert(i == this.count_);
|
goog.asserts.assert(i == this.count_, 'iterated correct amount of times');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -120,7 +130,7 @@ ol.structs.LRUCache.prototype.forEach = function(f, opt_this) {
|
|||||||
*/
|
*/
|
||||||
ol.structs.LRUCache.prototype.get = function(key) {
|
ol.structs.LRUCache.prototype.get = function(key) {
|
||||||
var entry = this.entries_[key];
|
var entry = this.entries_[key];
|
||||||
goog.asserts.assert(goog.isDef(entry));
|
goog.asserts.assert(goog.isDef(entry), 'an entry exists for key %s', key);
|
||||||
if (entry === this.newest_) {
|
if (entry === this.newest_) {
|
||||||
return entry.value_;
|
return entry.value_;
|
||||||
} else if (entry === this.oldest_) {
|
} else if (entry === this.oldest_) {
|
||||||
@@ -156,7 +166,7 @@ ol.structs.LRUCache.prototype.getKeys = function() {
|
|||||||
for (entry = this.newest_; !goog.isNull(entry); entry = entry.older) {
|
for (entry = this.newest_; !goog.isNull(entry); entry = entry.older) {
|
||||||
keys[i++] = entry.key_;
|
keys[i++] = entry.key_;
|
||||||
}
|
}
|
||||||
goog.asserts.assert(i == this.count_);
|
goog.asserts.assert(i == this.count_, 'iterated correct number of times');
|
||||||
return keys;
|
return keys;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -171,7 +181,7 @@ ol.structs.LRUCache.prototype.getValues = function() {
|
|||||||
for (entry = this.newest_; !goog.isNull(entry); entry = entry.older) {
|
for (entry = this.newest_; !goog.isNull(entry); entry = entry.older) {
|
||||||
values[i++] = entry.value_;
|
values[i++] = entry.value_;
|
||||||
}
|
}
|
||||||
goog.asserts.assert(i == this.count_);
|
goog.asserts.assert(i == this.count_, 'iterated correct number of times');
|
||||||
return values;
|
return values;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -180,7 +190,7 @@ ol.structs.LRUCache.prototype.getValues = function() {
|
|||||||
* @return {T} Last value.
|
* @return {T} Last value.
|
||||||
*/
|
*/
|
||||||
ol.structs.LRUCache.prototype.peekLast = function() {
|
ol.structs.LRUCache.prototype.peekLast = function() {
|
||||||
goog.asserts.assert(!goog.isNull(this.oldest_));
|
goog.asserts.assert(!goog.isNull(this.oldest_), 'oldest must not be null');
|
||||||
return this.oldest_.value_;
|
return this.oldest_.value_;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -189,7 +199,7 @@ ol.structs.LRUCache.prototype.peekLast = function() {
|
|||||||
* @return {string} Last key.
|
* @return {string} Last key.
|
||||||
*/
|
*/
|
||||||
ol.structs.LRUCache.prototype.peekLastKey = function() {
|
ol.structs.LRUCache.prototype.peekLastKey = function() {
|
||||||
goog.asserts.assert(!goog.isNull(this.oldest_));
|
goog.asserts.assert(!goog.isNull(this.oldest_), 'oldest must not be null');
|
||||||
return this.oldest_.key_;
|
return this.oldest_.key_;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -198,10 +208,11 @@ ol.structs.LRUCache.prototype.peekLastKey = function() {
|
|||||||
* @return {T} value Value.
|
* @return {T} value Value.
|
||||||
*/
|
*/
|
||||||
ol.structs.LRUCache.prototype.pop = function() {
|
ol.structs.LRUCache.prototype.pop = function() {
|
||||||
goog.asserts.assert(!goog.isNull(this.oldest_));
|
goog.asserts.assert(!goog.isNull(this.oldest_), 'oldest must not be null');
|
||||||
goog.asserts.assert(!goog.isNull(this.newest_));
|
goog.asserts.assert(!goog.isNull(this.newest_), 'newest must not be null');
|
||||||
var entry = this.oldest_;
|
var entry = this.oldest_;
|
||||||
goog.asserts.assert(entry.key_ in this.entries_);
|
goog.asserts.assert(entry.key_ in this.entries_,
|
||||||
|
'oldest is indexed in entries');
|
||||||
delete this.entries_[entry.key_];
|
delete this.entries_[entry.key_];
|
||||||
if (!goog.isNull(entry.newer)) {
|
if (!goog.isNull(entry.newer)) {
|
||||||
entry.newer.older = null;
|
entry.newer.older = null;
|
||||||
@@ -220,8 +231,10 @@ ol.structs.LRUCache.prototype.pop = function() {
|
|||||||
* @param {T} value Value.
|
* @param {T} value Value.
|
||||||
*/
|
*/
|
||||||
ol.structs.LRUCache.prototype.set = function(key, value) {
|
ol.structs.LRUCache.prototype.set = function(key, value) {
|
||||||
goog.asserts.assert(!(key in {}));
|
goog.asserts.assert(!(key in {}),
|
||||||
goog.asserts.assert(!(key in this.entries_));
|
'key is not a standard property of objects (e.g. "__proto__")');
|
||||||
|
goog.asserts.assert(!(key in this.entries_),
|
||||||
|
'key is not used already');
|
||||||
var entry = {
|
var entry = {
|
||||||
key_: key,
|
key_: key,
|
||||||
newer: null,
|
newer: null,
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ ol.structs.PriorityQueue.DROP = Infinity;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FIXME empty desciption for jsdoc
|
* FIXME empty description for jsdoc
|
||||||
*/
|
*/
|
||||||
ol.structs.PriorityQueue.prototype.assertValid = function() {
|
ol.structs.PriorityQueue.prototype.assertValid = function() {
|
||||||
var elements = this.elements_;
|
var elements = this.elements_;
|
||||||
@@ -73,8 +73,12 @@ ol.structs.PriorityQueue.prototype.assertValid = function() {
|
|||||||
var i, priority;
|
var i, priority;
|
||||||
for (i = 0; i < (n >> 1) - 1; ++i) {
|
for (i = 0; i < (n >> 1) - 1; ++i) {
|
||||||
priority = priorities[i];
|
priority = priorities[i];
|
||||||
goog.asserts.assert(priority <= priorities[this.getLeftChildIndex_(i)]);
|
goog.asserts.assert(priority <= priorities[this.getLeftChildIndex_(i)],
|
||||||
goog.asserts.assert(priority <= priorities[this.getRightChildIndex_(i)]);
|
'priority smaller than or equal to priority of left child (%s <= %s)',
|
||||||
|
priority, priorities[this.getLeftChildIndex_(i)]);
|
||||||
|
goog.asserts.assert(priority <= priorities[this.getRightChildIndex_(i)],
|
||||||
|
'priority smaller than or equal to priority of right child (%s <= %s)',
|
||||||
|
priority, priorities[this.getRightChildIndex_(i)]);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -95,7 +99,8 @@ ol.structs.PriorityQueue.prototype.clear = function() {
|
|||||||
*/
|
*/
|
||||||
ol.structs.PriorityQueue.prototype.dequeue = function() {
|
ol.structs.PriorityQueue.prototype.dequeue = function() {
|
||||||
var elements = this.elements_;
|
var elements = this.elements_;
|
||||||
goog.asserts.assert(elements.length > 0);
|
goog.asserts.assert(elements.length > 0,
|
||||||
|
'must have elements in order to be able to dequeue');
|
||||||
var priorities = this.priorities_;
|
var priorities = this.priorities_;
|
||||||
var element = elements[0];
|
var element = elements[0];
|
||||||
if (elements.length == 1) {
|
if (elements.length == 1) {
|
||||||
@@ -107,7 +112,8 @@ ol.structs.PriorityQueue.prototype.dequeue = function() {
|
|||||||
this.siftUp_(0);
|
this.siftUp_(0);
|
||||||
}
|
}
|
||||||
var elementKey = this.keyFunction_(element);
|
var elementKey = this.keyFunction_(element);
|
||||||
goog.asserts.assert(elementKey in this.queuedElements_);
|
goog.asserts.assert(elementKey in this.queuedElements_,
|
||||||
|
'key %s is not listed as queued', elementKey);
|
||||||
delete this.queuedElements_[elementKey];
|
delete this.queuedElements_[elementKey];
|
||||||
return element;
|
return element;
|
||||||
};
|
};
|
||||||
@@ -118,7 +124,8 @@ ol.structs.PriorityQueue.prototype.dequeue = function() {
|
|||||||
* @param {T} element Element.
|
* @param {T} element Element.
|
||||||
*/
|
*/
|
||||||
ol.structs.PriorityQueue.prototype.enqueue = function(element) {
|
ol.structs.PriorityQueue.prototype.enqueue = function(element) {
|
||||||
goog.asserts.assert(!(this.keyFunction_(element) in this.queuedElements_));
|
goog.asserts.assert(!(this.keyFunction_(element) in this.queuedElements_),
|
||||||
|
'key %s is already listed as queued', this.keyFunction_(element));
|
||||||
var priority = this.priorityFunction_(element);
|
var priority = this.priorityFunction_(element);
|
||||||
if (priority != ol.structs.PriorityQueue.DROP) {
|
if (priority != ol.structs.PriorityQueue.DROP) {
|
||||||
this.elements_.push(element);
|
this.elements_.push(element);
|
||||||
|
|||||||
@@ -61,7 +61,8 @@ ol.structs.RBush.prototype.insert = function(extent, value) {
|
|||||||
this.rbush_.insert(item);
|
this.rbush_.insert(item);
|
||||||
// remember the object that was added to the internal rbush
|
// remember the object that was added to the internal rbush
|
||||||
goog.asserts.assert(
|
goog.asserts.assert(
|
||||||
!goog.object.containsKey(this.items_, goog.getUid(value)));
|
!goog.object.containsKey(this.items_, goog.getUid(value)),
|
||||||
|
'uid (%s) of value (%s) already exists', goog.getUid(value), value);
|
||||||
this.items_[goog.getUid(value)] = item;
|
this.items_[goog.getUid(value)] = item;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -75,7 +76,9 @@ ol.structs.RBush.prototype.load = function(extents, values) {
|
|||||||
if (goog.DEBUG && this.readers_) {
|
if (goog.DEBUG && this.readers_) {
|
||||||
throw new Error('Can not insert values while reading');
|
throw new Error('Can not insert values while reading');
|
||||||
}
|
}
|
||||||
goog.asserts.assert(extents.length === values.length);
|
goog.asserts.assert(extents.length === values.length,
|
||||||
|
'extens and values must have same length (%s === %s)',
|
||||||
|
extents.length, values.length);
|
||||||
|
|
||||||
var items = new Array(values.length);
|
var items = new Array(values.length);
|
||||||
for (var i = 0, l = values.length; i < l; i++) {
|
for (var i = 0, l = values.length; i < l; i++) {
|
||||||
@@ -91,7 +94,8 @@ ol.structs.RBush.prototype.load = function(extents, values) {
|
|||||||
];
|
];
|
||||||
items[i] = item;
|
items[i] = item;
|
||||||
goog.asserts.assert(
|
goog.asserts.assert(
|
||||||
!goog.object.containsKey(this.items_, goog.getUid(value)));
|
!goog.object.containsKey(this.items_, goog.getUid(value)),
|
||||||
|
'uid (%s) of value (%s) already exists', goog.getUid(value), value);
|
||||||
this.items_[goog.getUid(value)] = item;
|
this.items_[goog.getUid(value)] = item;
|
||||||
}
|
}
|
||||||
this.rbush_.load(items);
|
this.rbush_.load(items);
|
||||||
@@ -108,7 +112,8 @@ ol.structs.RBush.prototype.remove = function(value) {
|
|||||||
throw new Error('Can not remove value while reading');
|
throw new Error('Can not remove value while reading');
|
||||||
}
|
}
|
||||||
var uid = goog.getUid(value);
|
var uid = goog.getUid(value);
|
||||||
goog.asserts.assert(goog.object.containsKey(this.items_, uid));
|
goog.asserts.assert(goog.object.containsKey(this.items_, uid),
|
||||||
|
'uid (%s) of value (%s) does not exist', uid, value);
|
||||||
|
|
||||||
// get the object in which the value was wrapped when adding to the
|
// get the object in which the value was wrapped when adding to the
|
||||||
// internal rbush. then use that object to do the removal.
|
// internal rbush. then use that object to do the removal.
|
||||||
@@ -125,7 +130,8 @@ ol.structs.RBush.prototype.remove = function(value) {
|
|||||||
*/
|
*/
|
||||||
ol.structs.RBush.prototype.update = function(extent, value) {
|
ol.structs.RBush.prototype.update = function(extent, value) {
|
||||||
var uid = goog.getUid(value);
|
var uid = goog.getUid(value);
|
||||||
goog.asserts.assert(goog.object.containsKey(this.items_, uid));
|
goog.asserts.assert(goog.object.containsKey(this.items_, uid),
|
||||||
|
'uid (%s) of value (%s) does not exist', uid, value);
|
||||||
|
|
||||||
var item = this.items_[uid];
|
var item = this.items_[uid];
|
||||||
if (!ol.extent.equals(item.slice(0, 4), extent)) {
|
if (!ol.extent.equals(item.slice(0, 4), extent)) {
|
||||||
|
|||||||
@@ -102,7 +102,8 @@ ol.style.AtlasManager.prototype.getInfo = function(id) {
|
|||||||
}
|
}
|
||||||
/** @type {?ol.style.AtlasInfo} */
|
/** @type {?ol.style.AtlasInfo} */
|
||||||
var hitInfo = this.getInfo_(this.hitAtlases_, id);
|
var hitInfo = this.getInfo_(this.hitAtlases_, id);
|
||||||
goog.asserts.assert(!goog.isNull(hitInfo));
|
goog.asserts.assert(!goog.isNull(hitInfo),
|
||||||
|
'hitInfo must not be null');
|
||||||
|
|
||||||
return this.mergeInfos_(info, hitInfo);
|
return this.mergeInfos_(info, hitInfo);
|
||||||
};
|
};
|
||||||
@@ -137,8 +138,10 @@ ol.style.AtlasManager.prototype.getInfo_ = function(atlases, id) {
|
|||||||
* entry, or `null` if the entry is not part of the atlases.
|
* entry, or `null` if the entry is not part of the atlases.
|
||||||
*/
|
*/
|
||||||
ol.style.AtlasManager.prototype.mergeInfos_ = function(info, hitInfo) {
|
ol.style.AtlasManager.prototype.mergeInfos_ = function(info, hitInfo) {
|
||||||
goog.asserts.assert(info.offsetX === hitInfo.offsetX);
|
goog.asserts.assert(info.offsetX === hitInfo.offsetX,
|
||||||
goog.asserts.assert(info.offsetY === hitInfo.offsetY);
|
'in order to merge, offsetX of info and hitInfo must be equal');
|
||||||
|
goog.asserts.assert(info.offsetY === hitInfo.offsetY,
|
||||||
|
'in order to merge, offsetY of info and hitInfo must be equal');
|
||||||
return /** @type {ol.style.AtlasManagerInfo} */ ({
|
return /** @type {ol.style.AtlasManagerInfo} */ ({
|
||||||
offsetX: info.offsetX,
|
offsetX: info.offsetX,
|
||||||
offsetY: info.offsetY,
|
offsetY: info.offsetY,
|
||||||
@@ -194,7 +197,8 @@ ol.style.AtlasManager.prototype.add =
|
|||||||
/** @type {?ol.style.AtlasInfo} */
|
/** @type {?ol.style.AtlasInfo} */
|
||||||
var hitInfo = this.add_(true,
|
var hitInfo = this.add_(true,
|
||||||
id, width, height, renderHitCallback, opt_this);
|
id, width, height, renderHitCallback, opt_this);
|
||||||
goog.asserts.assert(!goog.isNull(hitInfo));
|
goog.asserts.assert(!goog.isNull(hitInfo),
|
||||||
|
'hitInfo must not be null');
|
||||||
|
|
||||||
return this.mergeInfos_(info, hitInfo);
|
return this.mergeInfos_(info, hitInfo);
|
||||||
};
|
};
|
||||||
@@ -240,7 +244,7 @@ ol.style.AtlasManager.prototype.add_ =
|
|||||||
++ii;
|
++ii;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
goog.asserts.fail();
|
goog.asserts.fail('Failed to add to atlasmanager');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -103,7 +103,8 @@ ol.style.Icon = function(opt_options) {
|
|||||||
if ((!goog.isDef(src) || src.length === 0) && !goog.isNull(image)) {
|
if ((!goog.isDef(src) || src.length === 0) && !goog.isNull(image)) {
|
||||||
src = image.src;
|
src = image.src;
|
||||||
}
|
}
|
||||||
goog.asserts.assert(goog.isDef(src) && src.length > 0);
|
goog.asserts.assert(goog.isDef(src) && src.length > 0,
|
||||||
|
'must provide a defined and non-empty src');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {ol.style.ImageState}
|
* @type {ol.style.ImageState}
|
||||||
@@ -529,8 +530,10 @@ ol.style.IconImage_.prototype.getSrc = function() {
|
|||||||
*/
|
*/
|
||||||
ol.style.IconImage_.prototype.load = function() {
|
ol.style.IconImage_.prototype.load = function() {
|
||||||
if (this.imageState_ == ol.style.ImageState.IDLE) {
|
if (this.imageState_ == ol.style.ImageState.IDLE) {
|
||||||
goog.asserts.assert(goog.isDef(this.src_));
|
goog.asserts.assert(goog.isDef(this.src_),
|
||||||
goog.asserts.assert(goog.isNull(this.imageListenerKeys_));
|
'this.src_ must not be undefined');
|
||||||
|
goog.asserts.assert(goog.isNull(this.imageListenerKeys_),
|
||||||
|
'no listener keys existing');
|
||||||
this.imageState_ = ol.style.ImageState.LOADING;
|
this.imageState_ = ol.style.ImageState.LOADING;
|
||||||
this.imageListenerKeys_ = [
|
this.imageListenerKeys_ = [
|
||||||
goog.events.listenOnce(this.image_, goog.events.EventType.ERROR,
|
goog.events.listenOnce(this.image_, goog.events.EventType.ERROR,
|
||||||
@@ -553,7 +556,8 @@ ol.style.IconImage_.prototype.load = function() {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.style.IconImage_.prototype.unlistenImage_ = function() {
|
ol.style.IconImage_.prototype.unlistenImage_ = function() {
|
||||||
goog.asserts.assert(!goog.isNull(this.imageListenerKeys_));
|
goog.asserts.assert(!goog.isNull(this.imageListenerKeys_),
|
||||||
|
'we must have listeners registered');
|
||||||
goog.array.forEach(this.imageListenerKeys_, goog.events.unlistenByKey);
|
goog.array.forEach(this.imageListenerKeys_, goog.events.unlistenByKey);
|
||||||
this.imageListenerKeys_ = null;
|
this.imageListenerKeys_ = null;
|
||||||
};
|
};
|
||||||
@@ -593,7 +597,8 @@ goog.addSingletonGetter(ol.style.IconImageCache);
|
|||||||
* @return {string} Cache key.
|
* @return {string} Cache key.
|
||||||
*/
|
*/
|
||||||
ol.style.IconImageCache.getKey = function(src, crossOrigin) {
|
ol.style.IconImageCache.getKey = function(src, crossOrigin) {
|
||||||
goog.asserts.assert(goog.isDef(crossOrigin));
|
goog.asserts.assert(goog.isDef(crossOrigin),
|
||||||
|
'argument crossOrigin must be defined');
|
||||||
return crossOrigin + ':' + src;
|
return crossOrigin + ':' + src;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -28,8 +28,9 @@ goog.require('ol.style.Stroke');
|
|||||||
*/
|
*/
|
||||||
ol.style.RegularShape = function(options) {
|
ol.style.RegularShape = function(options) {
|
||||||
|
|
||||||
goog.asserts.assert(goog.isDef(options.radius) ||
|
goog.asserts.assert(
|
||||||
goog.isDef(options.radius1));
|
goog.isDef(options.radius) || goog.isDef(options.radius1),
|
||||||
|
'must provide either "radius" or "radius1"');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
|
|||||||
@@ -156,14 +156,16 @@ ol.style.Style.prototype.setGeometry = function(geometry) {
|
|||||||
this.geometryFunction_ = function(feature) {
|
this.geometryFunction_ = function(feature) {
|
||||||
var result = feature.get(geometry);
|
var result = feature.get(geometry);
|
||||||
if (goog.isDefAndNotNull(result)) {
|
if (goog.isDefAndNotNull(result)) {
|
||||||
goog.asserts.assertInstanceof(result, ol.geom.Geometry);
|
goog.asserts.assertInstanceof(result, ol.geom.Geometry,
|
||||||
|
'feature geometry must be an ol.geom.Geometry instance');
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
} else if (goog.isNull(geometry)) {
|
} else if (goog.isNull(geometry)) {
|
||||||
this.geometryFunction_ = ol.style.defaultGeometryFunction;
|
this.geometryFunction_ = ol.style.defaultGeometryFunction;
|
||||||
} else if (goog.isDef(geometry)) {
|
} else if (goog.isDef(geometry)) {
|
||||||
goog.asserts.assertInstanceof(geometry, ol.geom.Geometry);
|
goog.asserts.assertInstanceof(geometry, ol.geom.Geometry,
|
||||||
|
'geometry must be an ol.geom.Geometry instance');
|
||||||
this.geometryFunction_ = function() {
|
this.geometryFunction_ = function() {
|
||||||
return geometry;
|
return geometry;
|
||||||
};
|
};
|
||||||
@@ -218,7 +220,8 @@ ol.style.createStyleFunction = function(obj) {
|
|||||||
if (goog.isArray(obj)) {
|
if (goog.isArray(obj)) {
|
||||||
styles = obj;
|
styles = obj;
|
||||||
} else {
|
} else {
|
||||||
goog.asserts.assertInstanceof(obj, ol.style.Style);
|
goog.asserts.assertInstanceof(obj, ol.style.Style,
|
||||||
|
'obj geometry must be an ol.style.Style instance');
|
||||||
styles = [obj];
|
styles = [obj];
|
||||||
}
|
}
|
||||||
styleFunction = goog.functions.constant(styles);
|
styleFunction = goog.functions.constant(styles);
|
||||||
@@ -358,6 +361,7 @@ ol.style.GeometryFunction;
|
|||||||
* @return {ol.geom.Geometry|undefined} Geometry to render.
|
* @return {ol.geom.Geometry|undefined} Geometry to render.
|
||||||
*/
|
*/
|
||||||
ol.style.defaultGeometryFunction = function(feature) {
|
ol.style.defaultGeometryFunction = function(feature) {
|
||||||
goog.asserts.assert(!goog.isNull(feature));
|
goog.asserts.assert(!goog.isNull(feature),
|
||||||
|
'feature must not be null');
|
||||||
return feature.getGeometry();
|
return feature.getGeometry();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -60,7 +60,8 @@ ol.tilecoord.createFromQuadKey = function(quadKey) {
|
|||||||
*/
|
*/
|
||||||
ol.tilecoord.createFromString = function(str) {
|
ol.tilecoord.createFromString = function(str) {
|
||||||
var v = str.split('/');
|
var v = str.split('/');
|
||||||
goog.asserts.assert(v.length === 3);
|
goog.asserts.assert(v.length === 3,
|
||||||
|
'must provide a string in "z/x/y" format, got "%s"', str);
|
||||||
v = goog.array.map(v, function(e, i, a) {
|
v = goog.array.map(v, function(e, i, a) {
|
||||||
return parseInt(e, 10);
|
return parseInt(e, 10);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ ol.tilegrid.TileGrid = function(options) {
|
|||||||
this.resolutions_ = options.resolutions;
|
this.resolutions_ = options.resolutions;
|
||||||
goog.asserts.assert(goog.array.isSorted(this.resolutions_, function(a, b) {
|
goog.asserts.assert(goog.array.isSorted(this.resolutions_, function(a, b) {
|
||||||
return b - a;
|
return b - a;
|
||||||
}, true));
|
}, true), 'resolutions must be sorted in descending order');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @protected
|
* @protected
|
||||||
@@ -65,11 +65,13 @@ ol.tilegrid.TileGrid = function(options) {
|
|||||||
this.origins_ = null;
|
this.origins_ = null;
|
||||||
if (goog.isDef(options.origins)) {
|
if (goog.isDef(options.origins)) {
|
||||||
this.origins_ = options.origins;
|
this.origins_ = options.origins;
|
||||||
goog.asserts.assert(this.origins_.length == this.resolutions_.length);
|
goog.asserts.assert(this.origins_.length == this.resolutions_.length,
|
||||||
|
'number of origins and resolutions must be equal');
|
||||||
}
|
}
|
||||||
goog.asserts.assert(
|
goog.asserts.assert(
|
||||||
(goog.isNull(this.origin_) && !goog.isNull(this.origins_)) ||
|
(goog.isNull(this.origin_) && !goog.isNull(this.origins_)) ||
|
||||||
(!goog.isNull(this.origin_) && goog.isNull(this.origins_)));
|
(!goog.isNull(this.origin_) && goog.isNull(this.origins_)),
|
||||||
|
'either origin or origins must be configured, never both');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
@@ -78,7 +80,8 @@ ol.tilegrid.TileGrid = function(options) {
|
|||||||
this.tileSizes_ = null;
|
this.tileSizes_ = null;
|
||||||
if (goog.isDef(options.tileSizes)) {
|
if (goog.isDef(options.tileSizes)) {
|
||||||
this.tileSizes_ = options.tileSizes;
|
this.tileSizes_ = options.tileSizes;
|
||||||
goog.asserts.assert(this.tileSizes_.length == this.resolutions_.length);
|
goog.asserts.assert(this.tileSizes_.length == this.resolutions_.length,
|
||||||
|
'number of tileSizes and resolutions must be equal');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -90,7 +93,8 @@ ol.tilegrid.TileGrid = function(options) {
|
|||||||
goog.isNull(this.tileSizes_) ? ol.DEFAULT_TILE_SIZE : undefined;
|
goog.isNull(this.tileSizes_) ? ol.DEFAULT_TILE_SIZE : undefined;
|
||||||
goog.asserts.assert(
|
goog.asserts.assert(
|
||||||
(!goog.isDef(this.tileSize_) && !goog.isNull(this.tileSizes_)) ||
|
(!goog.isDef(this.tileSize_) && !goog.isNull(this.tileSizes_)) ||
|
||||||
(goog.isDef(this.tileSize_) && goog.isNull(this.tileSizes_)));
|
(goog.isDef(this.tileSize_) && goog.isNull(this.tileSizes_)),
|
||||||
|
'either tileSize or tileSizes must be configured, never both');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
@@ -99,7 +103,8 @@ ol.tilegrid.TileGrid = function(options) {
|
|||||||
this.widths_ = null;
|
this.widths_ = null;
|
||||||
if (goog.isDef(options.widths)) {
|
if (goog.isDef(options.widths)) {
|
||||||
this.widths_ = options.widths;
|
this.widths_ = options.widths;
|
||||||
goog.asserts.assert(this.widths_.length == this.resolutions_.length);
|
goog.asserts.assert(this.widths_.length == this.resolutions_.length,
|
||||||
|
'number of widths and resolutions must be equal');
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -175,8 +180,11 @@ ol.tilegrid.TileGrid.prototype.getOrigin = function(z) {
|
|||||||
if (!goog.isNull(this.origin_)) {
|
if (!goog.isNull(this.origin_)) {
|
||||||
return this.origin_;
|
return this.origin_;
|
||||||
} else {
|
} else {
|
||||||
goog.asserts.assert(!goog.isNull(this.origins_));
|
goog.asserts.assert(!goog.isNull(this.origins_),
|
||||||
goog.asserts.assert(this.minZoom <= z && z <= this.maxZoom);
|
'origins cannot be null if origin is null');
|
||||||
|
goog.asserts.assert(this.minZoom <= z && z <= this.maxZoom,
|
||||||
|
'given z is not in allowed range (%s <= %s <= %s)',
|
||||||
|
this.minZoom, z, this.maxZoom);
|
||||||
return this.origins_[z];
|
return this.origins_[z];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -188,7 +196,9 @@ ol.tilegrid.TileGrid.prototype.getOrigin = function(z) {
|
|||||||
* @api stable
|
* @api stable
|
||||||
*/
|
*/
|
||||||
ol.tilegrid.TileGrid.prototype.getResolution = function(z) {
|
ol.tilegrid.TileGrid.prototype.getResolution = function(z) {
|
||||||
goog.asserts.assert(this.minZoom <= z && z <= this.maxZoom);
|
goog.asserts.assert(this.minZoom <= z && z <= this.maxZoom,
|
||||||
|
'given z is not in allowed range (%s <= %s <= %s)',
|
||||||
|
this.minZoom, z, this.maxZoom);
|
||||||
return this.resolutions_[z];
|
return this.resolutions_[z];
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -378,7 +388,9 @@ ol.tilegrid.TileGrid.prototype.getTileCoordForCoordAndZ =
|
|||||||
*/
|
*/
|
||||||
ol.tilegrid.TileGrid.prototype.getTileCoordResolution = function(tileCoord) {
|
ol.tilegrid.TileGrid.prototype.getTileCoordResolution = function(tileCoord) {
|
||||||
goog.asserts.assert(
|
goog.asserts.assert(
|
||||||
this.minZoom <= tileCoord[0] && tileCoord[0] <= this.maxZoom);
|
this.minZoom <= tileCoord[0] && tileCoord[0] <= this.maxZoom,
|
||||||
|
'z of given tilecoord is not in allowed range (%s <= %s <= %s',
|
||||||
|
this.minZoom, tileCoord[0], this.maxZoom);
|
||||||
return this.resolutions_[tileCoord[0]];
|
return this.resolutions_[tileCoord[0]];
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -411,8 +423,11 @@ ol.tilegrid.TileGrid.prototype.getTileSize = function(z) {
|
|||||||
if (goog.isDef(this.tileSize_)) {
|
if (goog.isDef(this.tileSize_)) {
|
||||||
return this.tileSize_;
|
return this.tileSize_;
|
||||||
} else {
|
} else {
|
||||||
goog.asserts.assert(!goog.isNull(this.tileSizes_));
|
goog.asserts.assert(!goog.isNull(this.tileSizes_),
|
||||||
goog.asserts.assert(this.minZoom <= z && z <= this.maxZoom);
|
'tileSizes cannot be null if tileSize is null');
|
||||||
|
goog.asserts.assert(this.minZoom <= z && z <= this.maxZoom,
|
||||||
|
'z is not in allowed range (%s <= %s <= %s',
|
||||||
|
this.minZoom, z, this.maxZoom);
|
||||||
return this.tileSizes_[z];
|
return this.tileSizes_[z];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -425,7 +440,9 @@ ol.tilegrid.TileGrid.prototype.getTileSize = function(z) {
|
|||||||
*/
|
*/
|
||||||
ol.tilegrid.TileGrid.prototype.getWidth = function(z) {
|
ol.tilegrid.TileGrid.prototype.getWidth = function(z) {
|
||||||
if (!goog.isNull(this.widths_)) {
|
if (!goog.isNull(this.widths_)) {
|
||||||
goog.asserts.assert(this.minZoom <= z && z <= this.maxZoom);
|
goog.asserts.assert(this.minZoom <= z && z <= this.maxZoom,
|
||||||
|
'z is not in allowed range (%s <= %s <= %s',
|
||||||
|
this.minZoom, z, this.maxZoom);
|
||||||
return this.widths_[z];
|
return this.widths_[z];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -20,7 +20,9 @@ goog.require('ol.tilegrid.TileGrid');
|
|||||||
ol.tilegrid.WMTS = function(options) {
|
ol.tilegrid.WMTS = function(options) {
|
||||||
|
|
||||||
goog.asserts.assert(
|
goog.asserts.assert(
|
||||||
options.resolutions.length == options.matrixIds.length);
|
options.resolutions.length == options.matrixIds.length,
|
||||||
|
'options resolutions and matrixIds must have equal length (%s == %s)',
|
||||||
|
options.resolutions.length, options.matrixIds.length);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
@@ -47,7 +49,8 @@ goog.inherits(ol.tilegrid.WMTS, ol.tilegrid.TileGrid);
|
|||||||
* @return {string} MatrixId..
|
* @return {string} MatrixId..
|
||||||
*/
|
*/
|
||||||
ol.tilegrid.WMTS.prototype.getMatrixId = function(z) {
|
ol.tilegrid.WMTS.prototype.getMatrixId = function(z) {
|
||||||
goog.asserts.assert(0 <= z && z < this.matrixIds_.length);
|
goog.asserts.assert(0 <= z && z < this.matrixIds_.length,
|
||||||
|
'attempted to retrive matrixId for illegal z (%s)', z);
|
||||||
return this.matrixIds_[z];
|
return this.matrixIds_[z];
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -113,7 +116,9 @@ ol.tilegrid.WMTS.createFromCapabilitiesMatrixSet =
|
|||||||
metersPerUnit);
|
metersPerUnit);
|
||||||
var tileWidth = elt[tileWidthPropName];
|
var tileWidth = elt[tileWidthPropName];
|
||||||
var tileHeight = elt[tileHeightPropName];
|
var tileHeight = elt[tileHeightPropName];
|
||||||
goog.asserts.assert(tileWidth == tileHeight);
|
goog.asserts.assert(tileWidth == tileHeight,
|
||||||
|
'square tiles are assumed, tileWidth (%s) == tileHeight (%s)',
|
||||||
|
tileWidth, tileHeight);
|
||||||
tileSizes.push(tileWidth);
|
tileSizes.push(tileWidth);
|
||||||
widths.push(elt['MatrixWidth']);
|
widths.push(elt['MatrixWidth']);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -59,7 +59,8 @@ ol.TileRange.boundingTileRange = function(var_args) {
|
|||||||
tileCoordZ = tileCoord[0];
|
tileCoordZ = tileCoord[0];
|
||||||
tileCoordX = tileCoord[1];
|
tileCoordX = tileCoord[1];
|
||||||
tileCoordY = tileCoord[2];
|
tileCoordY = tileCoord[2];
|
||||||
goog.asserts.assert(tileCoordZ == tileCoord0Z);
|
goog.asserts.assert(tileCoordZ == tileCoord0Z,
|
||||||
|
'passed tilecoords all have the same Z-value');
|
||||||
tileRange.minX = Math.min(tileRange.minX, tileCoordX);
|
tileRange.minX = Math.min(tileRange.minX, tileCoordX);
|
||||||
tileRange.maxX = Math.max(tileRange.maxX, tileCoordX);
|
tileRange.maxX = Math.max(tileRange.maxX, tileCoordX);
|
||||||
tileRange.minY = Math.min(tileRange.minY, tileCoordY);
|
tileRange.minY = Math.min(tileRange.minY, tileCoordY);
|
||||||
|
|||||||
@@ -275,7 +275,8 @@ ol.View.prototype.getHints = function() {
|
|||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
ol.View.prototype.calculateExtent = function(size) {
|
ol.View.prototype.calculateExtent = function(size) {
|
||||||
goog.asserts.assert(this.isDef());
|
goog.asserts.assert(this.isDef(),
|
||||||
|
'the view was not defined (had no center and/or resolution)');
|
||||||
var center = this.getCenter();
|
var center = this.getCenter();
|
||||||
var resolution = this.getResolution();
|
var resolution = this.getResolution();
|
||||||
var minX = center[0] - resolution * size[0] / 2;
|
var minX = center[0] - resolution * size[0] / 2;
|
||||||
@@ -344,7 +345,9 @@ ol.View.prototype.getResolutionForValueFunction = function(opt_power) {
|
|||||||
function(value) {
|
function(value) {
|
||||||
var resolution = maxResolution / Math.pow(power, value * max);
|
var resolution = maxResolution / Math.pow(power, value * max);
|
||||||
goog.asserts.assert(resolution >= minResolution &&
|
goog.asserts.assert(resolution >= minResolution &&
|
||||||
resolution <= maxResolution);
|
resolution <= maxResolution,
|
||||||
|
'calculated resolution outside allowed bounds (%s <= %s <= %s)',
|
||||||
|
minResolution, resolution, maxResolution);
|
||||||
return resolution;
|
return resolution;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -383,7 +386,8 @@ ol.View.prototype.getValueForResolutionFunction = function(opt_power) {
|
|||||||
function(resolution) {
|
function(resolution) {
|
||||||
var value =
|
var value =
|
||||||
(Math.log(maxResolution / resolution) / Math.log(power)) / max;
|
(Math.log(maxResolution / resolution) / Math.log(power)) / max;
|
||||||
goog.asserts.assert(value >= 0 && value <= 1);
|
goog.asserts.assert(value >= 0 && value <= 1,
|
||||||
|
'calculated value (%s) ouside allowed range (0-1)', value);
|
||||||
return value;
|
return value;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -393,7 +397,8 @@ ol.View.prototype.getValueForResolutionFunction = function(opt_power) {
|
|||||||
* @return {olx.ViewState} View state.
|
* @return {olx.ViewState} View state.
|
||||||
*/
|
*/
|
||||||
ol.View.prototype.getState = function() {
|
ol.View.prototype.getState = function() {
|
||||||
goog.asserts.assert(this.isDef());
|
goog.asserts.assert(this.isDef(),
|
||||||
|
'the view was not defined (had no center and/or resolution)');
|
||||||
var center = /** @type {ol.Coordinate} */ (this.getCenter());
|
var center = /** @type {ol.Coordinate} */ (this.getCenter());
|
||||||
var projection = this.getProjection();
|
var projection = this.getProjection();
|
||||||
var resolution = /** @type {number} */ (this.getResolution());
|
var resolution = /** @type {number} */ (this.getResolution());
|
||||||
@@ -483,7 +488,7 @@ ol.View.prototype.fitGeometry = function(geometry, size, opt_options) {
|
|||||||
|
|
||||||
// calculate rotated extent
|
// calculate rotated extent
|
||||||
var rotation = this.getRotation();
|
var rotation = this.getRotation();
|
||||||
goog.asserts.assert(goog.isDef(rotation));
|
goog.asserts.assert(goog.isDef(rotation), 'rotation was not defined');
|
||||||
var cosAngle = Math.cos(-rotation);
|
var cosAngle = Math.cos(-rotation);
|
||||||
var sinAngle = Math.sin(-rotation);
|
var sinAngle = Math.sin(-rotation);
|
||||||
var minRotX = +Infinity;
|
var minRotX = +Infinity;
|
||||||
@@ -602,9 +607,11 @@ goog.exportProperty(
|
|||||||
* @return {number} New value.
|
* @return {number} New value.
|
||||||
*/
|
*/
|
||||||
ol.View.prototype.setHint = function(hint, delta) {
|
ol.View.prototype.setHint = function(hint, delta) {
|
||||||
goog.asserts.assert(0 <= hint && hint < this.hints_.length);
|
goog.asserts.assert(0 <= hint && hint < this.hints_.length,
|
||||||
|
'illegal hint (%s), must be between 0 and %s', hint, this.hints_.length);
|
||||||
this.hints_[hint] += delta;
|
this.hints_[hint] += delta;
|
||||||
goog.asserts.assert(this.hints_[hint] >= 0);
|
goog.asserts.assert(this.hints_[hint] >= 0,
|
||||||
|
'Hint at %s must be positive, was %s', hint, this.hints_[hint]);
|
||||||
return this.hints_[hint];
|
return this.hints_[hint];
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -764,7 +771,8 @@ ol.View.createRotationConstraint_ = function(options) {
|
|||||||
} else if (goog.isNumber(constrainRotation)) {
|
} else if (goog.isNumber(constrainRotation)) {
|
||||||
return ol.RotationConstraint.createSnapToN(constrainRotation);
|
return ol.RotationConstraint.createSnapToN(constrainRotation);
|
||||||
} else {
|
} else {
|
||||||
goog.asserts.fail();
|
goog.asserts.fail(
|
||||||
|
'illegal option for constrainRotation (%s)', constrainRotation);
|
||||||
return ol.RotationConstraint.none;
|
return ol.RotationConstraint.none;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -93,7 +93,8 @@ ol.webgl.Context = function(canvas, gl) {
|
|||||||
// use the OES_element_index_uint extension if available
|
// use the OES_element_index_uint extension if available
|
||||||
if (this.hasOESElementIndexUint) {
|
if (this.hasOESElementIndexUint) {
|
||||||
var ext = gl.getExtension('OES_element_index_uint');
|
var ext = gl.getExtension('OES_element_index_uint');
|
||||||
goog.asserts.assert(!goog.isNull(ext));
|
goog.asserts.assert(!goog.isNull(ext),
|
||||||
|
'Failed to get extension "OES_element_index_uint"');
|
||||||
}
|
}
|
||||||
|
|
||||||
goog.events.listen(this.canvas_, ol.webgl.WebGLContextEventType.LOST,
|
goog.events.listen(this.canvas_, ol.webgl.WebGLContextEventType.LOST,
|
||||||
@@ -122,7 +123,8 @@ ol.webgl.Context.prototype.bindBuffer = function(target, buf) {
|
|||||||
var buffer = gl.createBuffer();
|
var buffer = gl.createBuffer();
|
||||||
gl.bindBuffer(target, buffer);
|
gl.bindBuffer(target, buffer);
|
||||||
goog.asserts.assert(target == goog.webgl.ARRAY_BUFFER ||
|
goog.asserts.assert(target == goog.webgl.ARRAY_BUFFER ||
|
||||||
target == goog.webgl.ELEMENT_ARRAY_BUFFER);
|
target == goog.webgl.ELEMENT_ARRAY_BUFFER,
|
||||||
|
'target is supposed to be an ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER');
|
||||||
var /** @type {ArrayBufferView} */ arrayBuffer;
|
var /** @type {ArrayBufferView} */ arrayBuffer;
|
||||||
if (target == goog.webgl.ARRAY_BUFFER) {
|
if (target == goog.webgl.ARRAY_BUFFER) {
|
||||||
arrayBuffer = new Float32Array(arr);
|
arrayBuffer = new Float32Array(arr);
|
||||||
@@ -147,7 +149,8 @@ ol.webgl.Context.prototype.bindBuffer = function(target, buf) {
|
|||||||
ol.webgl.Context.prototype.deleteBuffer = function(buf) {
|
ol.webgl.Context.prototype.deleteBuffer = function(buf) {
|
||||||
var gl = this.getGL();
|
var gl = this.getGL();
|
||||||
var bufferKey = goog.getUid(buf);
|
var bufferKey = goog.getUid(buf);
|
||||||
goog.asserts.assert(bufferKey in this.bufferCache_);
|
goog.asserts.assert(bufferKey in this.bufferCache_,
|
||||||
|
'attempted to delete uncached buffer');
|
||||||
var bufferCacheEntry = this.bufferCache_[bufferKey];
|
var bufferCacheEntry = this.bufferCache_[bufferKey];
|
||||||
if (!gl.isContextLost()) {
|
if (!gl.isContextLost()) {
|
||||||
gl.deleteBuffer(bufferCacheEntry.buffer);
|
gl.deleteBuffer(bufferCacheEntry.buffer);
|
||||||
@@ -231,7 +234,8 @@ ol.webgl.Context.prototype.getShader = function(shaderObject) {
|
|||||||
}
|
}
|
||||||
goog.asserts.assert(
|
goog.asserts.assert(
|
||||||
gl.getShaderParameter(shader, goog.webgl.COMPILE_STATUS) ||
|
gl.getShaderParameter(shader, goog.webgl.COMPILE_STATUS) ||
|
||||||
gl.isContextLost());
|
gl.isContextLost(),
|
||||||
|
'illegal state, shader not compiled or context lost');
|
||||||
this.shaderCache_[shaderKey] = shader;
|
this.shaderCache_[shaderKey] = shader;
|
||||||
return shader;
|
return shader;
|
||||||
}
|
}
|
||||||
@@ -266,7 +270,8 @@ ol.webgl.Context.prototype.getProgram = function(
|
|||||||
}
|
}
|
||||||
goog.asserts.assert(
|
goog.asserts.assert(
|
||||||
gl.getProgramParameter(program, goog.webgl.LINK_STATUS) ||
|
gl.getProgramParameter(program, goog.webgl.LINK_STATUS) ||
|
||||||
gl.isContextLost());
|
gl.isContextLost(),
|
||||||
|
'illegal state, shader not linked or context lost');
|
||||||
this.programCache_[programKey] = program;
|
this.programCache_[programKey] = program;
|
||||||
return program;
|
return program;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -137,7 +137,8 @@ ol.xml.getLocalNameIE_ = function(node) {
|
|||||||
return localName;
|
return localName;
|
||||||
}
|
}
|
||||||
var baseName = node.baseName;
|
var baseName = node.baseName;
|
||||||
goog.asserts.assert(goog.isDefAndNotNull(baseName));
|
goog.asserts.assert(goog.isDefAndNotNull(baseName),
|
||||||
|
'Failed to get localName/baseName of node %s', node);
|
||||||
return baseName;
|
return baseName;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -362,10 +363,12 @@ ol.xml.makeArrayExtender = function(valueReader, opt_this) {
|
|||||||
function(node, objectStack) {
|
function(node, objectStack) {
|
||||||
var value = valueReader.call(opt_this, node, objectStack);
|
var value = valueReader.call(opt_this, node, objectStack);
|
||||||
if (goog.isDef(value)) {
|
if (goog.isDef(value)) {
|
||||||
goog.asserts.assert(goog.isArray(value));
|
goog.asserts.assert(goog.isArray(value),
|
||||||
|
'valueReader function is expected to return an array of values');
|
||||||
var array = /** @type {Array.<*>} */
|
var array = /** @type {Array.<*>} */
|
||||||
(objectStack[objectStack.length - 1]);
|
(objectStack[objectStack.length - 1]);
|
||||||
goog.asserts.assert(goog.isArray(array));
|
goog.asserts.assert(goog.isArray(array),
|
||||||
|
'objectStack is supposed to be an array of arrays');
|
||||||
goog.array.extend(array, value);
|
goog.array.extend(array, value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -389,7 +392,8 @@ ol.xml.makeArrayPusher = function(valueReader, opt_this) {
|
|||||||
node, objectStack);
|
node, objectStack);
|
||||||
if (goog.isDef(value)) {
|
if (goog.isDef(value)) {
|
||||||
var array = objectStack[objectStack.length - 1];
|
var array = objectStack[objectStack.length - 1];
|
||||||
goog.asserts.assert(goog.isArray(array));
|
goog.asserts.assert(goog.isArray(array),
|
||||||
|
'objectStack is supposed to be an array of arrays');
|
||||||
array.push(value);
|
array.push(value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -427,7 +431,8 @@ ol.xml.makeReplacer = function(valueReader, opt_this) {
|
|||||||
*/
|
*/
|
||||||
ol.xml.makeObjectPropertyPusher =
|
ol.xml.makeObjectPropertyPusher =
|
||||||
function(valueReader, opt_property, opt_this) {
|
function(valueReader, opt_property, opt_this) {
|
||||||
goog.asserts.assert(goog.isDef(valueReader));
|
goog.asserts.assert(goog.isDef(valueReader),
|
||||||
|
'undefined valueReader, expected function(this: T, Node, Array.<*>)');
|
||||||
return (
|
return (
|
||||||
/**
|
/**
|
||||||
* @param {Node} node Node.
|
* @param {Node} node Node.
|
||||||
@@ -441,7 +446,8 @@ ol.xml.makeObjectPropertyPusher =
|
|||||||
(objectStack[objectStack.length - 1]);
|
(objectStack[objectStack.length - 1]);
|
||||||
var property = goog.isDef(opt_property) ?
|
var property = goog.isDef(opt_property) ?
|
||||||
opt_property : node.localName;
|
opt_property : node.localName;
|
||||||
goog.asserts.assert(goog.isObject(object));
|
goog.asserts.assert(goog.isObject(object),
|
||||||
|
'entity from stack was not an object');
|
||||||
var array = goog.object.setIfUndefined(object, property, []);
|
var array = goog.object.setIfUndefined(object, property, []);
|
||||||
array.push(value);
|
array.push(value);
|
||||||
}
|
}
|
||||||
@@ -458,7 +464,8 @@ ol.xml.makeObjectPropertyPusher =
|
|||||||
*/
|
*/
|
||||||
ol.xml.makeObjectPropertySetter =
|
ol.xml.makeObjectPropertySetter =
|
||||||
function(valueReader, opt_property, opt_this) {
|
function(valueReader, opt_property, opt_this) {
|
||||||
goog.asserts.assert(goog.isDef(valueReader));
|
goog.asserts.assert(goog.isDef(valueReader),
|
||||||
|
'undefined valueReader, expected function(this: T, Node, Array.<*>)');
|
||||||
return (
|
return (
|
||||||
/**
|
/**
|
||||||
* @param {Node} node Node.
|
* @param {Node} node Node.
|
||||||
@@ -472,7 +479,8 @@ ol.xml.makeObjectPropertySetter =
|
|||||||
(objectStack[objectStack.length - 1]);
|
(objectStack[objectStack.length - 1]);
|
||||||
var property = goog.isDef(opt_property) ?
|
var property = goog.isDef(opt_property) ?
|
||||||
opt_property : node.localName;
|
opt_property : node.localName;
|
||||||
goog.asserts.assert(goog.isObject(object));
|
goog.asserts.assert(goog.isObject(object),
|
||||||
|
'entity from stack was not an object');
|
||||||
object[property] = value;
|
object[property] = value;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -507,10 +515,12 @@ ol.xml.makeChildAppender = function(nodeWriter, opt_this) {
|
|||||||
nodeWriter.call(goog.isDef(opt_this) ? opt_this : this,
|
nodeWriter.call(goog.isDef(opt_this) ? opt_this : this,
|
||||||
node, value, objectStack);
|
node, value, objectStack);
|
||||||
var parent = objectStack[objectStack.length - 1];
|
var parent = objectStack[objectStack.length - 1];
|
||||||
goog.asserts.assert(goog.isObject(parent));
|
goog.asserts.assert(goog.isObject(parent),
|
||||||
|
'entity from stack was not an object');
|
||||||
var parentNode = parent.node;
|
var parentNode = parent.node;
|
||||||
goog.asserts.assert(ol.xml.isNode(parentNode) ||
|
goog.asserts.assert(ol.xml.isNode(parentNode) ||
|
||||||
ol.xml.isDocument(parentNode));
|
ol.xml.isDocument(parentNode),
|
||||||
|
'expected parentNode %s to be a Node or a Document', parentNode);
|
||||||
parentNode.appendChild(node);
|
parentNode.appendChild(node);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -569,7 +579,8 @@ ol.xml.makeSimpleNodeFactory = function(opt_nodeName, opt_namespaceURI) {
|
|||||||
function(value, objectStack, opt_nodeName) {
|
function(value, objectStack, opt_nodeName) {
|
||||||
var context = objectStack[objectStack.length - 1];
|
var context = objectStack[objectStack.length - 1];
|
||||||
var node = context.node;
|
var node = context.node;
|
||||||
goog.asserts.assert(ol.xml.isNode(node) || ol.xml.isDocument(node));
|
goog.asserts.assert(ol.xml.isNode(node) || ol.xml.isDocument(node),
|
||||||
|
'expected node %s to be a Node or a Document', node);
|
||||||
var nodeName = fixedNodeName;
|
var nodeName = fixedNodeName;
|
||||||
if (!goog.isDef(nodeName)) {
|
if (!goog.isDef(nodeName)) {
|
||||||
nodeName = opt_nodeName;
|
nodeName = opt_nodeName;
|
||||||
@@ -578,7 +589,7 @@ ol.xml.makeSimpleNodeFactory = function(opt_nodeName, opt_namespaceURI) {
|
|||||||
if (!goog.isDef(opt_namespaceURI)) {
|
if (!goog.isDef(opt_namespaceURI)) {
|
||||||
namespaceURI = node.namespaceURI;
|
namespaceURI = node.namespaceURI;
|
||||||
}
|
}
|
||||||
goog.asserts.assert(goog.isDef(nodeName));
|
goog.asserts.assert(goog.isDef(nodeName), 'nodeName was undefined');
|
||||||
return ol.xml.createElementNS(namespaceURI, nodeName);
|
return ol.xml.createElementNS(namespaceURI, nodeName);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user