Merge branch 'master' of github.com:openlayers/ol3 into wms-improvements

Conflicts:
	src/ol/source/tiledwmssource.js
	test/spec/ol/tileurlfunction.test.js
This commit is contained in:
ahocevar
2013-03-05 00:55:52 +01:00
49 changed files with 647 additions and 248 deletions

View File

@@ -10,6 +10,8 @@
@exportObjectLiteralProperty ol.MapOptions.mouseWheelZoomDelta number|undefined
@exportObjectLiteralProperty ol.MapOptions.renderer ol.RendererHint|undefined
@exportObjectLiteralProperty ol.MapOptions.renderers Array.<ol.RendererHint>|undefined
@exportObjectLiteralProperty ol.MapOptions.scaleLineControl boolean|undefined
@exportObjectLiteralProperty ol.MapOptions.scaleLineUnits ol.control.ScaleLineUnits|undefined
@exportObjectLiteralProperty ol.MapOptions.shiftDragZoom boolean|undefined
@exportObjectLiteralProperty ol.MapOptions.target Element|string
@exportObjectLiteralProperty ol.MapOptions.touchPan boolean|undefined
@@ -58,6 +60,12 @@
@exportObjectLiteralProperty ol.control.AttributionOptions.map ol.Map|undefined
@exportObjectLiteralProperty ol.control.AttributionOptions.target Element|undefined
@exportObjectLiteral ol.control.ScaleLineOptions
@exportObjectLiteralProperty ol.control.ScaleLineOptions.map ol.Map|undefined
@exportObjectLiteralProperty ol.control.ScaleLineOptions.minWidth number|undefined
@exportObjectLiteralProperty ol.control.ScaleLineOptions.target Element|undefined
@exportObjectLiteralProperty ol.control.ScaleLineOptions.units ol.control.ScaleLineUnits|undefined
@exportObjectLiteral ol.control.MousePositionOptions
@exportObjectLiteralProperty ol.control.MousePositionOptions.coordinateFormat ol.CoordinateFormatType|undefined
@exportObjectLiteralProperty ol.control.MousePositionOptions.map ol.Map|undefined
@@ -88,7 +96,7 @@
@exportObjectLiteral ol.source.BingMapsOptions
@exportObjectLiteralProperty ol.source.BingMapsOptions.culture string|undefined
@exportObjectLiteralProperty ol.source.BingMapsOptions.key string
@exportObjectLiteralProperty ol.source.BingMapsOptions.style ol.BingMapsStyle
@exportObjectLiteralProperty ol.source.BingMapsOptions.style string
@exportObjectLiteral ol.source.DebugTileSourceOptions
@exportObjectLiteralProperty ol.source.DebugTileSourceOptions.extent ol.Extent|undefined
@@ -125,6 +133,7 @@
@exportObjectLiteralProperty ol.source.TiledWMSOptions.crossOrigin null|string|undefined
@exportObjectLiteralProperty ol.source.TiledWMSOptions.extent ol.Extent|undefined
@exportObjectLiteralProperty ol.source.TiledWMSOptions.tileGrid ol.tilegrid.TileGrid|undefined
@exportObjectLiteralProperty ol.source.TiledWMSOptions.transparent boolean|undefined
@exportObjectLiteralProperty ol.source.TiledWMSOptions.maxZoom number|undefined
@exportObjectLiteralProperty ol.source.TiledWMSOptions.projection ol.Projection|undefined
@exportObjectLiteralProperty ol.source.TiledWMSOptions.url string|undefined

View File

@@ -0,0 +1,9 @@
@exportClass ol.control.ScaleLine ol.control.ScaleLineOptions
@exportProperty ol.control.ScaleLine.prototype.setMap
@exportSymbol ol.control.ScaleLineUnits
@exportProperty ol.control.ScaleLineUnits.DEGREES
@exportProperty ol.control.ScaleLineUnits.IMPERIAL
@exportProperty ol.control.ScaleLineUnits.NAUTICAL
@exportProperty ol.control.ScaleLineUnits.METRIC
@exportProperty ol.control.ScaleLineUnits.US

View File

@@ -0,0 +1,277 @@
goog.provide('ol.control.ScaleLine');
goog.provide('ol.control.ScaleLineUnits');
goog.require('goog.dom');
goog.require('goog.style');
goog.require('ol.FrameState');
goog.require('ol.MapEvent');
goog.require('ol.MapEventType');
goog.require('ol.ProjectionUnits');
goog.require('ol.TransformFunction');
goog.require('ol.control.Control');
goog.require('ol.projection');
goog.require('ol.sphere.NORMAL');
/**
* @enum {string}
*/
ol.control.ScaleLineUnits = {
DEGREES: 'degrees',
IMPERIAL: 'imperial',
NAUTICAL: 'nautical',
METRIC: 'metric',
US: 'us'
};
/**
* @constructor
* @extends {ol.control.Control}
* @param {ol.control.ScaleLineOptions=} opt_options Options.
*/
ol.control.ScaleLine = function(opt_options) {
var options = opt_options || {};
/**
* @private
* @type {Element}
*/
this.innerElement_ = goog.dom.createDom(goog.dom.TagName.DIV, {
'class': 'ol-scale-line-inner'
});
/**
* @private
* @type {Element}
*/
this.element_ = goog.dom.createDom(goog.dom.TagName.DIV, {
'class': 'ol-scale-line ol-unselectable'
}, this.innerElement_);
/**
* @private
* @type {number}
*/
this.minWidth_ = goog.isDef(options.minWidth) ? options.minWidth : 64;
/**
* @private
* @type {ol.control.ScaleLineUnits}
*/
this.units_ = goog.isDef(options.units) ?
options.units : ol.control.ScaleLineUnits.METRIC;
/**
* @private
* @type {Array.<?number>}
*/
this.listenerKeys_ = null;
/**
* @private
* @type {boolean}
*/
this.renderedVisible_ = false;
/**
* @private
* @type {number|undefined}
*/
this.renderedWidth_;
/**
* @private
* @type {string}
*/
this.renderedHTML_ = '';
/**
* @private
* @type {?ol.TransformFunction}
*/
this.toEPSG4326_ = null;
goog.base(this, {
element: this.element_,
map: options.map,
target: options.target
});
};
goog.inherits(ol.control.ScaleLine, ol.control.Control);
/**
* @const
* @type {Array.<number>}
*/
ol.control.ScaleLine.LEADING_DIGITS = [1, 2, 5];
/**
* @param {ol.MapEvent} mapEvent Map event.
*/
ol.control.ScaleLine.prototype.handleMapPostrender = function(mapEvent) {
var frameState = mapEvent.frameState;
this.updateElement_(mapEvent.frameState);
};
/**
* @inheritDoc
*/
ol.control.ScaleLine.prototype.setMap = function(map) {
if (!goog.isNull(this.listenerKeys_)) {
goog.array.forEach(this.listenerKeys_, goog.events.unlistenByKey);
this.listenerKeys_ = null;
}
goog.base(this, 'setMap', map);
if (!goog.isNull(map)) {
this.listenerKeys_ = [
goog.events.listen(map, ol.MapEventType.POSTRENDER,
this.handleMapPostrender, false, this)
];
}
};
/**
* @param {?ol.FrameState} frameState Frame state.
* @private
*/
ol.control.ScaleLine.prototype.updateElement_ = function(frameState) {
if (goog.isNull(frameState)) {
if (this.renderedVisible_) {
goog.style.showElement(this.element_, false);
this.renderedVisible_ = false;
}
return;
}
var view2DState = frameState.view2DState;
var center = view2DState.center;
var projection = view2DState.projection;
var pointResolution =
projection.getPointResolution(view2DState.resolution, center);
var projectionUnits = projection.getUnits();
var cosLatitude;
if (projectionUnits == ol.ProjectionUnits.DEGREES &&
(this.units_ == ol.control.ScaleLineUnits.METRIC ||
this.units_ == ol.control.ScaleLineUnits.IMPERIAL)) {
// Convert pointResolution from degrees to meters
this.toEPSG4326_ = null;
cosLatitude = Math.cos(goog.math.toRadians(center.y));
pointResolution *= Math.PI * cosLatitude * ol.sphere.NORMAL.radius / 180;
} else if (projectionUnits == ol.ProjectionUnits.METERS &&
this.units_ == ol.control.ScaleLineUnits.DEGREES) {
// Convert pointResolution from meters to degrees
if (goog.isNull(this.toEPSG4326_)) {
this.toEPSG4326_ = ol.projection.getTransform(
projection, ol.projection.getFromCode('EPSG:4326'));
}
var vertex = [center.x, center.y];
vertex = this.toEPSG4326_(vertex, vertex, 2);
cosLatitude = Math.cos(goog.math.toRadians(vertex[1]));
pointResolution *= 180 / (Math.PI * cosLatitude * ol.sphere.NORMAL.radius);
} else {
this.toEPSG4326_ = null;
goog.asserts.assert(
((this.units_ == ol.control.ScaleLineUnits.METRIC ||
this.units_ == ol.control.ScaleLineUnits.IMPERIAL) &&
projectionUnits == ol.ProjectionUnits.METERS) ||
(this.units_ == ol.control.ScaleLineUnits.DEGREES &&
projectionUnits == ol.ProjectionUnits.DEGREES));
}
var nominalCount = this.minWidth_ * pointResolution;
var suffix = '';
if (this.units_ == ol.control.ScaleLineUnits.DEGREES) {
if (nominalCount < 1 / 60) {
suffix = '\u2033'; // seconds
pointResolution *= 3600;
} else if (nominalCount < 1) {
suffix = '\u2032'; // minutes
pointResolution *= 60;
} else {
suffix = '\u00b0'; // degrees
}
} else if (this.units_ == ol.control.ScaleLineUnits.IMPERIAL) {
if (nominalCount < 0.9144) {
suffix = 'in';
pointResolution /= 0.0254;
} else if (nominalCount < 1609.344) {
suffix = 'ft';
pointResolution /= 0.3048;
} else {
suffix = 'mi';
pointResolution /= 1609.344;
}
} else if (this.units_ == ol.control.ScaleLineUnits.NAUTICAL) {
pointResolution /= 1852;
suffix = 'nm';
} else if (this.units_ == ol.control.ScaleLineUnits.METRIC) {
if (nominalCount < 1) {
suffix = 'mm';
pointResolution *= 1000;
} else if (nominalCount < 1000) {
suffix = 'm';
} else {
suffix = 'km';
pointResolution /= 1000;
}
} else if (this.units_ == ol.control.ScaleLineUnits.US) {
if (nominalCount < 0.9144) {
suffix = 'in';
pointResolution *= 39.37;
} else if (nominalCount < 1609.344) {
suffix = 'ft';
pointResolution /= 0.30480061;
} else {
suffix = 'mi';
pointResolution /= 1609.3472;
}
} else {
goog.asserts.assert(false);
}
var i = 3 * Math.floor(
Math.log(this.minWidth_ * pointResolution) / Math.log(10));
var count, width;
while (true) {
count = ol.control.ScaleLine.LEADING_DIGITS[i % 3] *
Math.pow(10, Math.floor(i / 3));
width = Math.round(count / pointResolution);
if (width >= this.minWidth_) {
break;
}
++i;
}
var html = count + suffix;
if (this.renderedHTML_ != html) {
this.innerElement_.innerHTML = html;
this.renderedHTML_ = html;
}
if (this.renderedWidth_ != width) {
this.innerElement_.style.width = width + 'px';
this.renderedWidth_ = width;
}
if (!this.renderedVisible_) {
goog.style.showElement(this.element_, true);
this.renderedVisible_ = true;
}
};

View File

@@ -45,6 +45,7 @@ goog.require('ol.View');
goog.require('ol.View2D');
goog.require('ol.control.Attribution');
goog.require('ol.control.Control');
goog.require('ol.control.ScaleLine');
goog.require('ol.control.Zoom');
goog.require('ol.interaction.DblClickZoom');
goog.require('ol.interaction.DragPan');
@@ -926,6 +927,16 @@ ol.Map.createControls_ = function(mapOptions) {
controls.push(new ol.control.Attribution({}));
}
var scaleLineControl = goog.isDef(mapOptions.scaleLineControl) ?
mapOptions.scaleLineControl : false;
if (scaleLineControl) {
var scaleLineUnits = goog.isDef(mapOptions.scaleLineUnits) ?
mapOptions.scaleLineUnits : undefined;
controls.push(new ol.control.ScaleLine({
units: scaleLineUnits
}));
}
var zoomControl = goog.isDef(mapOptions.zoomControl) ?
mapOptions.zoomControl : true;
if (zoomControl) {

View File

@@ -94,17 +94,19 @@ ol.parser.ogc.WMTSCapabilities_v1_0_0 = function() {
obj['matrixHeight'] = parseInt(this.getChildValue(node), 10);
},
'ResourceURL': function(node, obj) {
obj['resourceUrl'] = obj['resourceUrl'] || {};
var resourceType = node.getAttribute('resourceType');
var format = node.getAttribute('format');
var template = node.getAttribute('template');
if (!obj['resourceUrls']) {
obj['resourceUrls'] = [];
obj['resourceUrls'] = {};
}
var resourceUrl = obj['resourceUrl'][resourceType] = {
'format': node.getAttribute('format'),
'template': node.getAttribute('template'),
'resourceType': resourceType
};
obj['resourceUrls'].push(resourceUrl);
if (!obj['resourceUrls'][resourceType]) {
obj['resourceUrls'][resourceType] = {};
}
if (!obj['resourceUrls'][resourceType][format]) {
obj['resourceUrls'][resourceType][format] = [];
}
obj['resourceUrls'][resourceType][format].push(template);
},
'WSDL': function(node, obj) {
obj['wsdl'] = {};

View File

@@ -1,4 +1,3 @@
// FIXME don't redraw tiles if not needed
// FIXME find correct globalCompositeOperation
// FIXME optimize :-)
@@ -51,6 +50,12 @@ ol.renderer.canvas.TileLayer = function(mapRenderer, tileLayer) {
*/
this.transform_ = goog.vec.Mat4.createNumber();
/**
* @private
* @type {Array.<ol.Tile|undefined>}
*/
this.renderedTiles_ = null;
};
goog.inherits(ol.renderer.canvas.TileLayer, ol.renderer.canvas.Layer);
@@ -100,10 +105,11 @@ ol.renderer.canvas.TileLayer.prototype.renderFrame =
var tileResolution = tileGrid.getResolution(z);
var tileRange = tileGrid.getTileRangeForExtentAndResolution(
frameState.extent, tileResolution);
var tileRangeWidth = tileRange.getWidth();
var tileRangeHeight = tileRange.getHeight();
var canvasSize = new ol.Size(
tileSize.width * tileRange.getWidth(),
tileSize.height * tileRange.getHeight());
tileSize.width * tileRangeWidth, tileSize.height * tileRangeHeight);
var canvas, context;
if (goog.isNull(this.canvas_)) {
@@ -115,6 +121,7 @@ ol.renderer.canvas.TileLayer.prototype.renderFrame =
this.canvas_ = canvas;
this.canvasSize_ = canvasSize;
this.context_ = context;
this.renderedTiles_ = new Array(tileRangeWidth * tileRangeHeight);
} else {
canvas = this.canvas_;
context = this.context_;
@@ -122,11 +129,10 @@ ol.renderer.canvas.TileLayer.prototype.renderFrame =
canvas.width = canvasSize.width;
canvas.height = canvasSize.height;
this.canvasSize_ = canvasSize;
this.renderedTiles_ = new Array(tileRangeWidth * tileRangeHeight);
}
}
context.clearRect(0, 0, canvasSize.width, canvasSize.height);
/**
* @type {Object.<number, Object.<string, ol.Tile>>}
*/
@@ -173,9 +179,12 @@ ol.renderer.canvas.TileLayer.prototype.renderFrame =
/** @type {Array.<number>} */
var zs = goog.array.map(goog.object.getKeys(tilesToDrawByZ), Number);
goog.array.sort(zs);
var opaque = tileSource.getOpaque();
var origin = tileGrid.getTileCoordExtent(
new ol.TileCoord(z, tileRange.minX, tileRange.maxY)).getTopLeft();
var currentZ, i, scale, tileCoordKey, tileExtent, tilesToDraw;
var currentZ, i, index, scale, tileCoordKey, tileExtent, tilesToDraw;
var ix, iy, interimTileExtent, interimTileRange, maxX, maxY, minX, minY;
var height, width;
for (i = 0; i < zs.length; ++i) {
currentZ = zs[i];
tileSize = tileGrid.getTileSize(currentZ);
@@ -183,22 +192,44 @@ ol.renderer.canvas.TileLayer.prototype.renderFrame =
if (currentZ == z) {
for (tileCoordKey in tilesToDraw) {
tile = tilesToDraw[tileCoordKey];
context.drawImage(
tile.getImage(),
tileSize.width * (tile.tileCoord.x - tileRange.minX),
tileSize.height * (tileRange.maxY - tile.tileCoord.y));
tileCoord = tile.tileCoord;
index = (tileCoord.y - tileRange.minY) * tileRangeWidth +
(tileCoord.x - tileRange.minX);
if (this.renderedTiles_[index] != tile) {
x = tileSize.width * (tile.tileCoord.x - tileRange.minX);
y = tileSize.height * (tileRange.maxY - tile.tileCoord.y);
if (!opaque) {
context.clearRect(x, y, tileSize.width, tileSize.height);
}
context.drawImage(tile.getImage(), x, y);
this.renderedTiles_[index] = tile;
}
}
} else {
scale = tileGrid.getResolution(currentZ) / tileResolution;
for (tileCoordKey in tilesToDraw) {
tile = tilesToDraw[tileCoordKey];
tileExtent = tileGrid.getTileCoordExtent(tile.tileCoord);
context.drawImage(
tile.getImage(),
(tileExtent.minX - origin.x) / tileResolution,
(origin.y - tileExtent.maxY) / tileResolution,
scale * tileSize.width,
scale * tileSize.height);
x = (tileExtent.minX - origin.x) / tileResolution;
y = (origin.y - tileExtent.maxY) / tileResolution;
width = scale * tileSize.width;
height = scale * tileSize.height;
if (!opaque) {
context.clearRect(x, y, width, height);
}
context.drawImage(tile.getImage(), x, y, width, height);
interimTileRange =
tileGrid.getTileRangeForExtentAndZ(tileExtent, z);
minX = Math.max(interimTileRange.minX, tileRange.minX);
maxX = Math.min(interimTileRange.maxX, tileRange.maxX);
minY = Math.max(interimTileRange.minY, tileRange.minY);
maxY = Math.min(interimTileRange.maxY, tileRange.maxY);
for (ix = minX; ix <= maxX; ++ix) {
for (iy = minY; iy <= maxY; ++iy) {
this.renderedTiles_[(iy - tileRange.minY) * tileRangeWidth +
(ix - tileRange.minX)] = undefined;
}
}
}
}
}

View File

@@ -45,7 +45,7 @@ ol.renderer.webgl.ImageLayer = function(mapRenderer, imageLayer) {
* @private
* @type {!goog.vec.Mat4.Number}
*/
this.vertexCoordMatrix_ = goog.vec.Mat4.createNumber();
this.projectionMatrix_ = goog.vec.Mat4.createNumber();
};
goog.inherits(ol.renderer.webgl.ImageLayer, ol.renderer.webgl.Layer);
@@ -118,8 +118,8 @@ ol.renderer.webgl.ImageLayer.prototype.getTexture = function() {
/**
* @inheritDoc
*/
ol.renderer.webgl.ImageLayer.prototype.getVertexCoordMatrix = function() {
return this.vertexCoordMatrix_;
ol.renderer.webgl.ImageLayer.prototype.getProjectionMatrix = function() {
return this.projectionMatrix_;
};
@@ -188,7 +188,7 @@ ol.renderer.webgl.ImageLayer.prototype.renderFrame =
var canvas = this.getMapRenderer().getCanvas();
this.updateVertexCoordMatrix_(canvas.width, canvas.height,
this.updateProjectionMatrix_(canvas.width, canvas.height,
viewCenter, viewResolution, viewRotation, image.getExtent());
// Translate and scale to flip the Y coord.
@@ -214,24 +214,24 @@ ol.renderer.webgl.ImageLayer.prototype.renderFrame =
* @param {number} viewRotation View rotation.
* @param {ol.Extent} imageExtent Image extent.
*/
ol.renderer.webgl.ImageLayer.prototype.updateVertexCoordMatrix_ =
ol.renderer.webgl.ImageLayer.prototype.updateProjectionMatrix_ =
function(canvasWidth, canvasHeight, viewCenter,
viewResolution, viewRotation, imageExtent) {
var canvasExtentWidth = canvasWidth * viewResolution;
var canvasExtentHeight = canvasHeight * viewResolution;
var vertexCoordMatrix = this.vertexCoordMatrix_;
goog.vec.Mat4.makeIdentity(vertexCoordMatrix);
goog.vec.Mat4.scale(vertexCoordMatrix,
var projectionMatrix = this.projectionMatrix_;
goog.vec.Mat4.makeIdentity(projectionMatrix);
goog.vec.Mat4.scale(projectionMatrix,
2 / canvasExtentWidth, 2 / canvasExtentHeight, 1);
goog.vec.Mat4.rotateZ(vertexCoordMatrix, -viewRotation);
goog.vec.Mat4.translate(vertexCoordMatrix,
goog.vec.Mat4.rotateZ(projectionMatrix, -viewRotation);
goog.vec.Mat4.translate(projectionMatrix,
imageExtent.minX - viewCenter.x,
imageExtent.minY - viewCenter.y,
0);
goog.vec.Mat4.scale(vertexCoordMatrix,
goog.vec.Mat4.scale(projectionMatrix,
imageExtent.getWidth() / 2, imageExtent.getHeight() / 2, 1);
goog.vec.Mat4.translate(vertexCoordMatrix, 1, 1, 0);
goog.vec.Mat4.translate(projectionMatrix, 1, 1, 0);
};

View File

@@ -100,7 +100,7 @@ ol.renderer.webgl.Layer.prototype.getTexture = goog.abstractMethod;
/**
* @return {!goog.vec.Mat4.Number} Matrix.
*/
ol.renderer.webgl.Layer.prototype.getVertexCoordMatrix = goog.abstractMethod;
ol.renderer.webgl.Layer.prototype.getProjectionMatrix = goog.abstractMethod;
/**

View File

@@ -48,17 +48,17 @@ ol.renderer.webgl.map.shader.Fragment = function() {
goog.base(this, [
'precision mediump float;',
'',
'uniform mat4 uColorMatrix;',
'uniform float uOpacity;',
'uniform sampler2D uTexture;',
'uniform mat4 u_colorMatrix;',
'uniform float u_opacity;',
'uniform sampler2D u_texture;',
'',
'varying vec2 vTexCoord;',
'varying vec2 v_texCoord;',
'',
'void main(void) {',
'',
' vec4 texColor = texture2D(uTexture, vTexCoord);',
' vec4 color = uColorMatrix * vec4(texColor.rgb, 1.);',
' color.a = texColor.a * uOpacity;',
' vec4 texColor = texture2D(u_texture, v_texCoord);',
' vec4 color = u_colorMatrix * vec4(texColor.rgb, 1.);',
' color.a = texColor.a * u_opacity;',
'',
' gl_FragColor = color;',
'',
@@ -77,17 +77,17 @@ goog.addSingletonGetter(ol.renderer.webgl.map.shader.Fragment);
*/
ol.renderer.webgl.map.shader.Vertex = function() {
goog.base(this, [
'attribute vec2 aPosition;',
'attribute vec2 aTexCoord;',
'attribute vec2 a_position;',
'attribute vec2 a_texCoord;',
'',
'uniform mat4 uTexCoordMatrix;',
'uniform mat4 uVertexCoordMatrix;',
'uniform mat4 u_texCoordMatrix;',
'uniform mat4 u_projectionMatrix;',
'',
'varying vec2 vTexCoord;',
'varying vec2 v_texCoord;',
'',
'void main(void) {',
' gl_Position = uVertexCoordMatrix * vec4(aPosition, 0., 1.);',
' vTexCoord = (uTexCoordMatrix * vec4(aTexCoord, 0., 1.)).st;',
' gl_Position = u_projectionMatrix * vec4(a_position, 0., 1.);',
' v_texCoord = (u_texCoordMatrix * vec4(a_texCoord, 0., 1.)).st;',
'}'
].join('\n'));
};
@@ -157,13 +157,13 @@ ol.renderer.webgl.Map = function(container, map) {
/**
* @private
* @type {{aPosition: number,
* aTexCoord: number,
* uColorMatrix: WebGLUniformLocation,
* uOpacity: WebGLUniformLocation,
* uTexture: WebGLUniformLocation,
* uTexCoordMatrix: WebGLUniformLocation,
* uVertexCoordMatrix: WebGLUniformLocation}|null}
* @type {{a_position: number,
* a_texCoord: number,
* u_colorMatrix: WebGLUniformLocation,
* u_opacity: WebGLUniformLocation,
* u_texture: WebGLUniformLocation,
* u_texCoordMatrix: WebGLUniformLocation,
* u_projectionMatrix: WebGLUniformLocation}|null}
*/
this.locations_ = null;
@@ -522,13 +522,13 @@ ol.renderer.webgl.Map.prototype.renderFrame = function(frameState) {
gl.useProgram(program);
if (goog.isNull(this.locations_)) {
this.locations_ = {
aPosition: gl.getAttribLocation(program, 'aPosition'),
aTexCoord: gl.getAttribLocation(program, 'aTexCoord'),
uColorMatrix: gl.getUniformLocation(program, 'uColorMatrix'),
uTexCoordMatrix: gl.getUniformLocation(program, 'uTexCoordMatrix'),
uVertexCoordMatrix: gl.getUniformLocation(program, 'uVertexCoordMatrix'),
uOpacity: gl.getUniformLocation(program, 'uOpacity'),
uTexture: gl.getUniformLocation(program, 'uTexture')
a_position: gl.getAttribLocation(program, 'a_position'),
a_texCoord: gl.getAttribLocation(program, 'a_texCoord'),
u_colorMatrix: gl.getUniformLocation(program, 'u_colorMatrix'),
u_texCoordMatrix: gl.getUniformLocation(program, 'u_texCoordMatrix'),
u_projectionMatrix: gl.getUniformLocation(program, 'u_projectionMatrix'),
u_opacity: gl.getUniformLocation(program, 'u_opacity'),
u_texture: gl.getUniformLocation(program, 'u_texture')
};
}
@@ -546,13 +546,13 @@ ol.renderer.webgl.Map.prototype.renderFrame = function(frameState) {
gl.bindBuffer(goog.webgl.ARRAY_BUFFER, this.arrayBuffer_);
}
gl.enableVertexAttribArray(this.locations_.aPosition);
gl.enableVertexAttribArray(this.locations_.a_position);
gl.vertexAttribPointer(
this.locations_.aPosition, 2, goog.webgl.FLOAT, false, 16, 0);
gl.enableVertexAttribArray(this.locations_.aTexCoord);
this.locations_.a_position, 2, goog.webgl.FLOAT, false, 16, 0);
gl.enableVertexAttribArray(this.locations_.a_texCoord);
gl.vertexAttribPointer(
this.locations_.aTexCoord, 2, goog.webgl.FLOAT, false, 16, 8);
gl.uniform1i(this.locations_.uTexture, 0);
this.locations_.a_texCoord, 2, goog.webgl.FLOAT, false, 16, 8);
gl.uniform1i(this.locations_.u_texture, 0);
goog.array.forEach(frameState.layersArray, function(layer) {
var layerState = frameState.layerStates[goog.getUid(layer)];
@@ -561,14 +561,14 @@ ol.renderer.webgl.Map.prototype.renderFrame = function(frameState) {
}
var layerRenderer = this.getLayerRenderer(layer);
gl.uniformMatrix4fv(
this.locations_.uTexCoordMatrix, false,
this.locations_.u_texCoordMatrix, false,
layerRenderer.getTexCoordMatrix());
gl.uniformMatrix4fv(
this.locations_.uVertexCoordMatrix, false,
layerRenderer.getVertexCoordMatrix());
this.locations_.u_projectionMatrix, false,
layerRenderer.getProjectionMatrix());
gl.uniformMatrix4fv(
this.locations_.uColorMatrix, false, layerRenderer.getColorMatrix());
gl.uniform1f(this.locations_.uOpacity, layer.getOpacity());
this.locations_.u_colorMatrix, false, layerRenderer.getColorMatrix());
gl.uniform1f(this.locations_.u_opacity, layer.getOpacity());
gl.bindTexture(goog.webgl.TEXTURE_2D, layerRenderer.getTexture());
gl.drawArrays(goog.webgl.TRIANGLE_STRIP, 0, 4);
}, this);

View File

@@ -145,7 +145,7 @@ ol.renderer.webgl.TileLayer = function(mapRenderer, tileLayer) {
* @private
* @type {!goog.vec.Mat4.Number}
*/
this.vertexCoordMatrix_ = goog.vec.Mat4.createNumberIdentity();
this.projectionMatrix_ = goog.vec.Mat4.createNumberIdentity();
/**
* @private
@@ -246,8 +246,8 @@ ol.renderer.webgl.TileLayer.prototype.getTexture = function() {
/**
* @inheritDoc
*/
ol.renderer.webgl.TileLayer.prototype.getVertexCoordMatrix = function() {
return this.vertexCoordMatrix_;
ol.renderer.webgl.TileLayer.prototype.getProjectionMatrix = function() {
return this.projectionMatrix_;
};

View File

@@ -1,7 +1 @@
@exportSymbol ol.source.BingMaps
@exportSymbol ol.BingMapsStyle
@exportProperty ol.BingMapsStyle.AERIAL
@exportProperty ol.BingMapsStyle.AERIAL_WITH_LABELS
@exportProperty ol.BingMapsStyle.ROAD
@exportProperty ol.BingMapsStyle.ORDNANCE_SURVEY
@exportProperty ol.BingMapsStyle.COLLINS_BART

View File

@@ -1,4 +1,3 @@
goog.provide('ol.BingMapsStyle');
goog.provide('ol.source.BingMaps');
goog.require('goog.Uri');
@@ -15,18 +14,6 @@ goog.require('ol.source.ImageTileSource');
goog.require('ol.tilegrid.XYZ');
/**
* @enum {string}
*/
ol.BingMapsStyle = {
AERIAL: 'Aerial',
AERIAL_WITH_LABELS: 'AerialWithLabels',
ROAD: 'Road',
ORDNANCE_SURVEY: 'OrdnanceSurvey',
COLLINS_BART: 'CollinsBart'
};
/**
* @constructor
@@ -36,6 +23,7 @@ ol.BingMapsStyle = {
ol.source.BingMaps = function(bingMapsOptions) {
goog.base(this, {
opaque: true,
projection: ol.projection.getFromCode('EPSG:3857')
});

View File

@@ -90,6 +90,7 @@ ol.source.DebugTileSource = function(options) {
goog.base(this, {
extent: options.extent,
opaque: false,
projection: options.projection,
tileGrid: options.tileGrid
});

View File

@@ -17,6 +17,7 @@ goog.require('ol.tilegrid.TileGrid');
* @typedef {{attributions: (Array.<ol.Attribution>|undefined),
* crossOrigin: (null|string|undefined),
* extent: (ol.Extent|undefined),
* opaque: (boolean|undefined),
* projection: (ol.Projection|undefined),
* tileGrid: (ol.tilegrid.TileGrid|undefined),
* tileUrlFunction: (ol.TileUrlFunctionType|undefined)}}
@@ -35,6 +36,7 @@ ol.source.ImageTileSource = function(options) {
goog.base(this, {
attributions: options.attributions,
extent: options.extent,
opaque: options.opaque,
projection: options.projection,
tileGrid: options.tileGrid
});

View File

@@ -26,6 +26,7 @@ ol.source.MapQuestOSM = function() {
goog.base(this, {
attributions: attributions,
opaque: true,
maxZoom: 28,
url: 'http://otile{1-4}.mqcdn.com/tiles/1.0.0/osm/{z}/{x}/{y}.jpg'
});
@@ -54,6 +55,7 @@ ol.source.MapQuestOpenAerial = function() {
goog.base(this, {
attributions: attributions,
maxZoom: 18,
opaque: true,
url: 'http://oatile{1-4}.mqcdn.com/tiles/1.0.0/sat/{z}/{x}/{y}.jpg'
});

View File

@@ -18,6 +18,7 @@ ol.source.OpenStreetMap = function() {
goog.base(this, {
attributions: [attribution],
opaque: true,
maxZoom: 18,
url: 'http://{a-c}.tile.openstreetmap.org/{z}/{x}/{y}.png'
});

View File

@@ -85,6 +85,7 @@ ol.source.Stamen = function(stamenOptions) {
goog.base(this, {
attributions: [attribution],
maxZoom: config.maxZoom,
opaque: false,
url: 'http://{a-d}.tile.stamen.com/' + layer + '/{z}/{x}/{y}.' + config.type
});

View File

@@ -38,7 +38,8 @@ ol.source.TiledWMS = function(tiledWMSOptions) {
} else {
tileUrlFunction = ol.TileUrlFunction.nullTileUrlFunction;
}
var transparent = goog.isDef(tiledWMSOptions.transparent) ?
tiledWMSOptions.transparent : true;
var extent = tiledWMSOptions.extent;
var tileCoordTransform = function(tileCoord, tileGrid, projection) {
@@ -70,6 +71,7 @@ ol.source.TiledWMS = function(tiledWMSOptions) {
crossOrigin: tiledWMSOptions.crossOrigin,
extent: extent,
tileGrid: tiledWMSOptions.tileGrid,
opaque: !transparent,
projection: tiledWMSOptions.projection,
tileUrlFunction: ol.TileUrlFunction.withTileCoordTransform(
tileCoordTransform, tileUrlFunction)

View File

@@ -15,6 +15,7 @@ goog.require('ol.tilegrid.TileGrid');
/**
* @typedef {{attributions: (Array.<ol.Attribution>|undefined),
* extent: (ol.Extent|undefined),
* opaque: (boolean|undefined),
* projection: (ol.Projection|undefined),
* tileGrid: (ol.tilegrid.TileGrid|undefined)}}
*/
@@ -35,6 +36,13 @@ ol.source.TileSource = function(tileSourceOptions) {
projection: tileSourceOptions.projection
});
/**
* @private
* @type {boolean}
*/
this.opaque_ = goog.isDef(tileSourceOptions.opaque) ?
tileSourceOptions.opaque : false;
/**
* @protected
* @type {ol.tilegrid.TileGrid}
@@ -98,6 +106,14 @@ ol.source.TileSource.prototype.findLoadedTiles = function(loadedTilesByZ,
};
/**
* @return {boolean} Opaque.
*/
ol.source.TileSource.prototype.getOpaque = function() {
return this.opaque_;
};
/**
* @inheritDoc
*/