Remove use of goog.vec.*
This commit is contained in:
@@ -7383,7 +7383,7 @@ olx.view.FitOptions.prototype.maxZoom;
|
||||
/**
|
||||
* @typedef {{animate: boolean,
|
||||
* attributions: Object.<string, ol.Attribution>,
|
||||
* coordinateToPixelMatrix: ol.vec.Mat4.Number,
|
||||
* coordinateToPixelMatrix: ol.Matrix,
|
||||
* extent: (null|ol.Extent),
|
||||
* focus: ol.Coordinate,
|
||||
* index: number,
|
||||
@@ -7391,7 +7391,7 @@ olx.view.FitOptions.prototype.maxZoom;
|
||||
* layerStatesArray: Array.<ol.LayerState>,
|
||||
* logos: Object.<string, (string|Element)>,
|
||||
* pixelRatio: number,
|
||||
* pixelToCoordinateMatrix: ol.vec.Mat4.Number,
|
||||
* pixelToCoordinateMatrix: ol.Matrix,
|
||||
* postRenderFunctions: Array.<ol.PostRenderFunction>,
|
||||
* size: ol.Size,
|
||||
* skippedFeatureUids: Object.<string, boolean>,
|
||||
|
||||
@@ -2,8 +2,8 @@ goog.provide('ol.dom');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('goog.userAgent');
|
||||
goog.require('goog.vec.Mat4');
|
||||
goog.require('ol');
|
||||
goog.require('ol.vec.Mat4');
|
||||
|
||||
|
||||
/**
|
||||
@@ -127,7 +127,7 @@ ol.dom.setTransform = function(element, value) {
|
||||
|
||||
/**
|
||||
* @param {!Element} element Element.
|
||||
* @param {goog.vec.Mat4.Number} transform Matrix.
|
||||
* @param {ol.Matrix} transform Matrix.
|
||||
* @param {number=} opt_precision Precision.
|
||||
*/
|
||||
ol.dom.transformElement2D = function(element, transform, opt_precision) {
|
||||
@@ -136,45 +136,35 @@ ol.dom.transformElement2D = function(element, transform, opt_precision) {
|
||||
var i;
|
||||
if (ol.dom.canUseCssTransform3D()) {
|
||||
var value3D;
|
||||
|
||||
var transform3D = ol.vec.Mat4.fromMatrix(transform);
|
||||
if (opt_precision !== undefined) {
|
||||
/** @type {Array.<string>} */
|
||||
var strings3D = new Array(16);
|
||||
for (i = 0; i < 16; ++i) {
|
||||
strings3D[i] = transform[i].toFixed(opt_precision);
|
||||
strings3D[i] = transform3D[i].toFixed(opt_precision);
|
||||
}
|
||||
value3D = strings3D.join(',');
|
||||
} else {
|
||||
value3D = transform.join(',');
|
||||
value3D = transform3D.join(',');
|
||||
}
|
||||
ol.dom.setTransform(element, 'matrix3d(' + value3D + ')');
|
||||
} else if (ol.dom.canUseCssTransform()) {
|
||||
/** @type {Array.<number>} */
|
||||
var transform2D = [
|
||||
goog.vec.Mat4.getElement(transform, 0, 0),
|
||||
goog.vec.Mat4.getElement(transform, 1, 0),
|
||||
goog.vec.Mat4.getElement(transform, 0, 1),
|
||||
goog.vec.Mat4.getElement(transform, 1, 1),
|
||||
goog.vec.Mat4.getElement(transform, 0, 3),
|
||||
goog.vec.Mat4.getElement(transform, 1, 3)
|
||||
];
|
||||
/** @type {string} */
|
||||
var value2D;
|
||||
if (opt_precision !== undefined) {
|
||||
/** @type {Array.<string>} */
|
||||
var strings2D = new Array(6);
|
||||
for (i = 0; i < 6; ++i) {
|
||||
strings2D[i] = transform2D[i].toFixed(opt_precision);
|
||||
strings2D[i] = transform[i].toFixed(opt_precision);
|
||||
}
|
||||
value2D = strings2D.join(',');
|
||||
} else {
|
||||
value2D = transform2D.join(',');
|
||||
value2D = transform.join(',');
|
||||
}
|
||||
ol.dom.setTransform(element, 'matrix(' + value2D + ')');
|
||||
} else {
|
||||
element.style.left =
|
||||
Math.round(goog.vec.Mat4.getElement(transform, 0, 3)) + 'px';
|
||||
element.style.top =
|
||||
Math.round(goog.vec.Mat4.getElement(transform, 1, 3)) + 'px';
|
||||
element.style.left = Math.round(transform[4]) + 'px';
|
||||
element.style.top = Math.round(transform[5]) + 'px';
|
||||
|
||||
// TODO: Add scaling here. This isn't quite as simple as multiplying
|
||||
// width/height, because that only changes the container size, not the
|
||||
|
||||
@@ -1,32 +1,24 @@
|
||||
goog.provide('ol.geom.flat.transform');
|
||||
|
||||
goog.require('goog.vec.Mat4');
|
||||
|
||||
|
||||
/**
|
||||
* @param {Array.<number>} flatCoordinates Flat coordinates.
|
||||
* @param {number} offset Offset.
|
||||
* @param {number} end End.
|
||||
* @param {number} stride Stride.
|
||||
* @param {goog.vec.Mat4.Number} transform Transform.
|
||||
* @param {ol.Matrix} transform Transform.
|
||||
* @param {Array.<number>=} opt_dest Destination.
|
||||
* @return {Array.<number>} Transformed coordinates.
|
||||
*/
|
||||
ol.geom.flat.transform.transform2D = function(flatCoordinates, offset, end, stride, transform, opt_dest) {
|
||||
var m00 = goog.vec.Mat4.getElement(transform, 0, 0);
|
||||
var m10 = goog.vec.Mat4.getElement(transform, 1, 0);
|
||||
var m01 = goog.vec.Mat4.getElement(transform, 0, 1);
|
||||
var m11 = goog.vec.Mat4.getElement(transform, 1, 1);
|
||||
var m03 = goog.vec.Mat4.getElement(transform, 0, 3);
|
||||
var m13 = goog.vec.Mat4.getElement(transform, 1, 3);
|
||||
var dest = opt_dest ? opt_dest : [];
|
||||
var i = 0;
|
||||
var j;
|
||||
for (j = offset; j < end; j += stride) {
|
||||
var x = flatCoordinates[j];
|
||||
var y = flatCoordinates[j + 1];
|
||||
dest[i++] = m00 * x + m01 * y + m03;
|
||||
dest[i++] = m10 * x + m11 * y + m13;
|
||||
dest[i++] = transform[0] * x + transform[2] * y + transform[4];
|
||||
dest[i++] = transform[1] * x + transform[3] * y + transform[5];
|
||||
}
|
||||
if (opt_dest && dest.length != i) {
|
||||
dest.length = i;
|
||||
|
||||
@@ -294,7 +294,7 @@ ol.geom.SimpleGeometry.prototype.translate = function(deltaX, deltaY) {
|
||||
|
||||
/**
|
||||
* @param {ol.geom.SimpleGeometry} simpleGeometry Simple geometry.
|
||||
* @param {goog.vec.Mat4.Number} transform Transform.
|
||||
* @param {ol.Matrix} transform Transform.
|
||||
* @param {Array.<number>=} opt_dest Destination.
|
||||
* @return {Array.<number>} Transformed flat coordinates.
|
||||
*/
|
||||
|
||||
@@ -7,7 +7,6 @@ goog.provide('ol.MapProperty');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('goog.async.nextTick');
|
||||
goog.require('goog.vec.Mat4');
|
||||
goog.require('ol.Collection');
|
||||
goog.require('ol.CollectionEventType');
|
||||
goog.require('ol.MapBrowserEvent');
|
||||
@@ -34,6 +33,7 @@ goog.require('ol.has');
|
||||
goog.require('ol.interaction');
|
||||
goog.require('ol.layer.Base');
|
||||
goog.require('ol.layer.Group');
|
||||
goog.require('ol.matrix');
|
||||
goog.require('ol.object');
|
||||
goog.require('ol.proj');
|
||||
goog.require('ol.proj.common');
|
||||
@@ -43,7 +43,6 @@ goog.require('ol.renderer.dom.Map');
|
||||
goog.require('ol.renderer.webgl.Map');
|
||||
goog.require('ol.size');
|
||||
goog.require('ol.structs.PriorityQueue');
|
||||
goog.require('ol.vec.Mat4');
|
||||
|
||||
|
||||
/**
|
||||
@@ -203,15 +202,15 @@ ol.Map = function(options) {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {goog.vec.Mat4.Number}
|
||||
* @type {ol.Matrix}
|
||||
*/
|
||||
this.coordinateToPixelMatrix_ = goog.vec.Mat4.createNumber();
|
||||
this.coordinateToPixelMatrix_ = ol.matrix.create();
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {goog.vec.Mat4.Number}
|
||||
* @type {ol.Matrix}
|
||||
*/
|
||||
this.pixelToCoordinateMatrix_ = goog.vec.Mat4.createNumber();
|
||||
this.pixelToCoordinateMatrix_ = ol.matrix.create();
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -765,7 +764,7 @@ ol.Map.prototype.getCoordinateFromPixel = function(pixel) {
|
||||
return null;
|
||||
} else {
|
||||
var vec2 = pixel.slice();
|
||||
return ol.vec.Mat4.multVec2(frameState.pixelToCoordinateMatrix, vec2, vec2);
|
||||
return ol.matrix.multVec2(frameState.pixelToCoordinateMatrix, vec2, vec2);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -854,7 +853,7 @@ ol.Map.prototype.getPixelFromCoordinate = function(coordinate) {
|
||||
return null;
|
||||
} else {
|
||||
var vec2 = coordinate.slice(0, 2);
|
||||
return ol.vec.Mat4.multVec2(frameState.coordinateToPixelMatrix, vec2, vec2);
|
||||
return ol.matrix.multVec2(frameState.coordinateToPixelMatrix, vec2, vec2);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
247
src/ol/matrix.js
Normal file
247
src/ol/matrix.js
Normal file
@@ -0,0 +1,247 @@
|
||||
goog.provide('ol.matrix');
|
||||
|
||||
/**
|
||||
* Collection of matrix transformation functions. The element order is
|
||||
* compatible with the [SVGMatrix interface](https://developer.mozilla.org/en-US/docs/Web/API/SVGMatrix):
|
||||
* ```
|
||||
* [ a c e ]
|
||||
* [ b d f ]
|
||||
* [ 0 0 1 ]
|
||||
* ```
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Create an identity matrix.
|
||||
* @return {!ol.Matrix} Identity matrix.
|
||||
*/
|
||||
ol.matrix.create = function() {
|
||||
return [1, 0, 0, 1, 0, 0];
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Check if two matrices are equal.
|
||||
* @param {!ol.Matrix} mat1 Matrix 1.
|
||||
* @param {!ol.Matrix} mat2 Matrix 2.
|
||||
* @return {boolean} Matrix 1 and Matrix 2 are equal.
|
||||
*/
|
||||
ol.matrix.equals = function(mat1, mat2) {
|
||||
return mat1[0] == mat2[0] &&
|
||||
mat1[1] == mat2[1] &&
|
||||
mat1[2] == mat2[2] &&
|
||||
mat1[3] == mat2[3] &&
|
||||
mat1[4] == mat2[4] &&
|
||||
mat1[5] == mat2[5];
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Resets the given matrix to an identity matrix.
|
||||
* @param {!ol.Matrix} mat Matrix.
|
||||
* @return {!ol.Matrix} Matrix.
|
||||
*/
|
||||
ol.matrix.makeIdentity = function(mat) {
|
||||
return ol.matrix.setTransform(mat, 1, 0, 0, 1, 0, 0);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Multiply two matrices with each other.
|
||||
* @param {!ol.Matrix} mat1 Matrix 1.
|
||||
* @param {!ol.Matrix} mat2 Matrix 2.
|
||||
* @param {ol.Matrix=} opt_mat Optional matrix for the result.
|
||||
* @return {!ol.Matrix} Result matrix.
|
||||
*/
|
||||
ol.matrix.multiply = function(mat1, mat2, opt_mat) {
|
||||
var mat = opt_mat ? opt_mat : ol.matrix.create();
|
||||
ol.matrix.setTransform(mat, mat1[0], mat1[1], mat1[2], mat1[3], mat1[4], mat1[5]);
|
||||
return ol.matrix.transform(mat, mat2[0], mat2[1], mat2[2], mat2[3], mat2[4], mat2[5]);
|
||||
};
|
||||
|
||||
/**
|
||||
* Set the transform for a given matrix.
|
||||
* @param {!ol.Matrix} mat Matrix.
|
||||
* @param {number} a The a component of the matrix.
|
||||
* @param {number} b The b component of the matrix.
|
||||
* @param {number} c The c component of the matrix.
|
||||
* @param {number} d The d component of the matrix.
|
||||
* @param {number} e The e component of the matrix.
|
||||
* @param {number} f The f component of the matrix.
|
||||
* @return {!ol.Matrix} Matrix with transform applied.
|
||||
*/
|
||||
ol.matrix.setTransform = function(mat, a, b, c, d, e, f) {
|
||||
mat[0] = a;
|
||||
mat[1] = b;
|
||||
mat[2] = c;
|
||||
mat[3] = d;
|
||||
mat[4] = e;
|
||||
mat[5] = f;
|
||||
return mat;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Set transform on one matrix from another matrix.
|
||||
* @param {!ol.Matrix} mat1 Matrix to set transform to.
|
||||
* @param {!ol.Matrix} mat2 Matrix to set transform from.
|
||||
* @return {!ol.Matrix} mat1 with transform from mat2 applied.
|
||||
*/
|
||||
ol.matrix.setFromArray = function(mat1, mat2) {
|
||||
mat1[0] = mat2[0];
|
||||
mat1[1] = mat2[1];
|
||||
mat1[2] = mat2[2];
|
||||
mat1[3] = mat2[3];
|
||||
mat1[4] = mat2[4];
|
||||
mat1[5] = mat2[5];
|
||||
return mat1;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Rotates the given matrix.
|
||||
* @param {!ol.Matrix} mat Matrix.
|
||||
* @param {number} rotation Angle in radians.
|
||||
* @return {!ol.Matrix} Rotated matrix.
|
||||
*/
|
||||
ol.matrix.rotate = function(mat, rotation) {
|
||||
var cos = Math.cos(rotation);
|
||||
var sin = Math.sin(rotation);
|
||||
return ol.matrix.transform(mat, cos, sin, -sin, cos, 0, 0);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Multiplies the given matrix with new matrix values.
|
||||
* @see {@link ol.Matrix#multiply}.
|
||||
*
|
||||
* @param {!ol.Matrix} mat Matrix.
|
||||
* @param {number} a The a component of the matrix.
|
||||
* @param {number} b The b component of the matrix.
|
||||
* @param {number} c The c component of the matrix.
|
||||
* @param {number} d The d component of the matrix.
|
||||
* @param {number} e The e component of the matrix.
|
||||
* @param {number} f The f component of the matrix.
|
||||
* @return {!ol.Matrix} Transformed matrix.
|
||||
*/
|
||||
ol.matrix.transform = function(mat, a, b, c, d, e, f) {
|
||||
var matA = mat[0];
|
||||
var matB = mat[1];
|
||||
var matC = mat[2];
|
||||
var matD = mat[3];
|
||||
var matE = mat[4];
|
||||
var matF = mat[5];
|
||||
|
||||
mat[0] = matA * a + matC * b;
|
||||
mat[1] = matB * a + matD * b;
|
||||
mat[2] = matA * c + matC * d;
|
||||
mat[3] = matB * c + matD * d;
|
||||
mat[4] = matA * e + matC * f + matE;
|
||||
mat[5] = matB * e + matD * f + matF;
|
||||
|
||||
return mat;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {!ol.Matrix} mat Matrix.
|
||||
* @param {number} translateX1 Translate X1.
|
||||
* @param {number} translateY1 Translate Y1.
|
||||
* @param {number} scaleX Scale X.
|
||||
* @param {number} scaleY Scale Y.
|
||||
* @param {number} rotation Rotation.
|
||||
* @param {number} translateX2 Translate X2.
|
||||
* @param {number} translateY2 Translate Y2.
|
||||
* @return {!ol.Matrix} Matrix.
|
||||
*/
|
||||
ol.matrix.makeTransform = function(mat, translateX1, translateY1,
|
||||
scaleX, scaleY, rotation, translateX2, translateY2) {
|
||||
ol.matrix.makeIdentity(mat);
|
||||
if (translateX1 !== 0 || translateY1 !== 0) {
|
||||
ol.matrix.translate(mat, translateX1, translateY1);
|
||||
}
|
||||
if (scaleX != 1 || scaleY != 1) {
|
||||
ol.matrix.scale(mat, scaleX, scaleY);
|
||||
}
|
||||
if (rotation !== 0) {
|
||||
ol.matrix.rotate(mat, rotation);
|
||||
}
|
||||
if (translateX2 !== 0 || translateY2 !== 0) {
|
||||
ol.matrix.translate(mat, translateX2, translateY2);
|
||||
}
|
||||
return mat;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Transforms the given vector with the given matrix storing the resulting,
|
||||
* transformed vector into resultVec.
|
||||
*
|
||||
* @param {ol.Matrix} mat The matrix supplying the transformation.
|
||||
* @param {Array.<number>} vec The 2 element vector to transform.
|
||||
* @param {Array.<number>} resultVec The 2 element vector to receive the results
|
||||
* (may be vec).
|
||||
* @return {Array.<number>} return resultVec so that operations can be
|
||||
* chained together.
|
||||
*/
|
||||
ol.matrix.multVec2 = function(mat, vec, resultVec) {
|
||||
var x = vec[0], y = vec[1];
|
||||
resultVec[0] = mat[0] * x + mat[2] * y + mat[4];
|
||||
resultVec[1] = mat[1] * x + mat[3] * y + mat[5];
|
||||
return resultVec;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Scales the given matrix.
|
||||
* @param {!ol.Matrix} mat Matrix.
|
||||
* @param {number} sx Scale factor x.
|
||||
* @param {number} sy Scale factor y.
|
||||
* @return {!ol.Matrix} The scaled matrix.
|
||||
*/
|
||||
ol.matrix.scale = function(mat, sx, sy) {
|
||||
return ol.matrix.transform(mat, sx, 0, 0, sy, 0, 0);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Translate the given matrix.
|
||||
* @param {!ol.Matrix} mat Matrix.
|
||||
* @param {number} tx Translation x.
|
||||
* @param {number} ty Translation y.
|
||||
* @return {!ol.Matrix} The translated matrix.
|
||||
*/
|
||||
ol.matrix.translate = function(mat, tx, ty) {
|
||||
return ol.matrix.transform(mat, 1, 0, 0, 1, tx, ty);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Invert the given matrix.
|
||||
* @param {!ol.Matrix} mat Matrix.
|
||||
* @param {ol.Matrix=} opt_mat Optional matrix for the result.
|
||||
* @return {!ol.Matrix} Inverse of the matrix.
|
||||
*/
|
||||
ol.matrix.invert = function(mat, opt_mat) {
|
||||
var result = opt_mat ? opt_mat : ol.matrix.create();
|
||||
var det = ol.matrix.determinant(mat);
|
||||
goog.asserts.assert(det !== 0, 'Matrix cannot be inverted.');
|
||||
|
||||
result[0] = mat[3] / det;
|
||||
result[1] = -mat[1] / det;
|
||||
result[2] = -mat[2] / det;
|
||||
result[3] = mat[0] / det;
|
||||
result[4] = (mat[2] * mat[5] - mat[3] * mat[4]) / det;
|
||||
result[5] = -(mat[0] * mat[5] - mat[1] * mat[4]) / det;
|
||||
return result;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Returns the determinant of the given matrix.
|
||||
* @param {!ol.Matrix} mat Matrix.
|
||||
* @return {number} Determinant.
|
||||
*/
|
||||
ol.matrix.determinant = function(mat) {
|
||||
return mat[0] * mat[3] - mat[1] * mat[2];
|
||||
};
|
||||
@@ -1,8 +1,7 @@
|
||||
goog.provide('ol.render');
|
||||
|
||||
goog.require('goog.vec.Mat4');
|
||||
goog.require('ol.matrix');
|
||||
goog.require('ol.render.canvas.Immediate');
|
||||
goog.require('ol.vec.Mat4');
|
||||
|
||||
|
||||
/**
|
||||
@@ -37,7 +36,7 @@ ol.render.toContext = function(context, opt_options) {
|
||||
canvas.style.height = size[1] + 'px';
|
||||
}
|
||||
var extent = [0, 0, canvas.width, canvas.height];
|
||||
var transform = ol.vec.Mat4.makeTransform2D(goog.vec.Mat4.createNumber(),
|
||||
var transform = ol.matrix.makeTransform(ol.matrix.create(),
|
||||
0, 0, pixelRatio, pixelRatio, 0, 0, 0);
|
||||
return new ol.render.canvas.Immediate(context, pixelRatio, extent, transform,
|
||||
0);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
goog.provide('ol.render.canvas.Immediate');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('goog.vec.Mat4');
|
||||
goog.require('ol.matrix');
|
||||
goog.require('ol.array');
|
||||
goog.require('ol.color');
|
||||
goog.require('ol.colorlike');
|
||||
@@ -15,7 +15,6 @@ goog.require('ol.geom.flat.transform');
|
||||
goog.require('ol.has');
|
||||
goog.require('ol.render.VectorContext');
|
||||
goog.require('ol.render.canvas');
|
||||
goog.require('ol.vec.Mat4');
|
||||
|
||||
|
||||
/**
|
||||
@@ -32,7 +31,7 @@ goog.require('ol.vec.Mat4');
|
||||
* @param {CanvasRenderingContext2D} context Context.
|
||||
* @param {number} pixelRatio Pixel ratio.
|
||||
* @param {ol.Extent} extent Extent.
|
||||
* @param {goog.vec.Mat4.Number} transform Transform.
|
||||
* @param {ol.Matrix} transform Transform.
|
||||
* @param {number} viewRotation View rotation.
|
||||
* @struct
|
||||
*/
|
||||
@@ -59,7 +58,7 @@ ol.render.canvas.Immediate = function(context, pixelRatio, extent, transform, vi
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {goog.vec.Mat4.Number}
|
||||
* @type {ol.Matrix}
|
||||
*/
|
||||
this.transform_ = transform;
|
||||
|
||||
@@ -227,9 +226,9 @@ ol.render.canvas.Immediate = function(context, pixelRatio, extent, transform, vi
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {!goog.vec.Mat4.Number}
|
||||
* @type {ol.Matrix}
|
||||
*/
|
||||
this.tmpLocalTransform_ = goog.vec.Mat4.createNumber();
|
||||
this.tmpLocalTransform_ = ol.matrix.create();
|
||||
|
||||
};
|
||||
ol.inherits(ol.render.canvas.Immediate, ol.render.VectorContext);
|
||||
@@ -273,16 +272,10 @@ ol.render.canvas.Immediate.prototype.drawImages_ = function(flatCoordinates, off
|
||||
if (rotation !== 0 || this.imageScale_ != 1) {
|
||||
var centerX = x + this.imageAnchorX_;
|
||||
var centerY = y + this.imageAnchorY_;
|
||||
ol.vec.Mat4.makeTransform2D(localTransform,
|
||||
ol.matrix.makeTransform(localTransform,
|
||||
centerX, centerY, this.imageScale_, this.imageScale_,
|
||||
rotation, -centerX, -centerY);
|
||||
context.setTransform(
|
||||
goog.vec.Mat4.getElement(localTransform, 0, 0),
|
||||
goog.vec.Mat4.getElement(localTransform, 1, 0),
|
||||
goog.vec.Mat4.getElement(localTransform, 0, 1),
|
||||
goog.vec.Mat4.getElement(localTransform, 1, 1),
|
||||
goog.vec.Mat4.getElement(localTransform, 0, 3),
|
||||
goog.vec.Mat4.getElement(localTransform, 1, 3));
|
||||
context.setTransform.apply(context, localTransform);
|
||||
}
|
||||
context.drawImage(this.image_, this.imageOriginX_, this.imageOriginY_,
|
||||
this.imageWidth_, this.imageHeight_, x, y,
|
||||
@@ -326,15 +319,9 @@ ol.render.canvas.Immediate.prototype.drawText_ = function(flatCoordinates, offse
|
||||
var x = pixelCoordinates[offset] + this.textOffsetX_;
|
||||
var y = pixelCoordinates[offset + 1] + this.textOffsetY_;
|
||||
if (this.textRotation_ !== 0 || this.textScale_ != 1) {
|
||||
var localTransform = ol.vec.Mat4.makeTransform2D(this.tmpLocalTransform_,
|
||||
var localTransform = ol.matrix.makeTransform(this.tmpLocalTransform_,
|
||||
x, y, this.textScale_, this.textScale_, this.textRotation_, -x, -y);
|
||||
context.setTransform(
|
||||
goog.vec.Mat4.getElement(localTransform, 0, 0),
|
||||
goog.vec.Mat4.getElement(localTransform, 1, 0),
|
||||
goog.vec.Mat4.getElement(localTransform, 0, 1),
|
||||
goog.vec.Mat4.getElement(localTransform, 1, 1),
|
||||
goog.vec.Mat4.getElement(localTransform, 0, 3),
|
||||
goog.vec.Mat4.getElement(localTransform, 1, 3));
|
||||
context.setTransform.apply(context, localTransform);
|
||||
}
|
||||
if (this.textStrokeState_) {
|
||||
context.strokeText(this.text_, x, y);
|
||||
|
||||
@@ -9,7 +9,7 @@ goog.provide('ol.render.canvas.ReplayGroup');
|
||||
goog.provide('ol.render.canvas.TextReplay');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('goog.vec.Mat4');
|
||||
goog.require('ol.matrix');
|
||||
goog.require('ol');
|
||||
goog.require('ol.array');
|
||||
goog.require('ol.color');
|
||||
@@ -24,7 +24,6 @@ goog.require('ol.object');
|
||||
goog.require('ol.render.IReplayGroup');
|
||||
goog.require('ol.render.VectorContext');
|
||||
goog.require('ol.render.canvas');
|
||||
goog.require('ol.vec.Mat4');
|
||||
|
||||
|
||||
/**
|
||||
@@ -117,9 +116,9 @@ ol.render.canvas.Replay = function(tolerance, maxExtent, resolution) {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {goog.vec.Mat4.Number}
|
||||
* @type {ol.Matrix}
|
||||
*/
|
||||
this.renderedTransform_ = goog.vec.Mat4.createNumber();
|
||||
this.renderedTransform_ = ol.matrix.create();
|
||||
|
||||
/**
|
||||
* @protected
|
||||
@@ -135,15 +134,15 @@ ol.render.canvas.Replay = function(tolerance, maxExtent, resolution) {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {!goog.vec.Mat4.Number}
|
||||
* @type {ol.Matrix}
|
||||
*/
|
||||
this.tmpLocalTransform_ = goog.vec.Mat4.createNumber();
|
||||
this.tmpLocalTransform_ = ol.matrix.create();
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {!goog.vec.Mat4.Number}
|
||||
* @type {ol.Matrix}
|
||||
*/
|
||||
this.tmpLocalTransformInv_ = goog.vec.Mat4.createNumber();
|
||||
this.tmpLocalTransformInv_ = ol.matrix.create();
|
||||
};
|
||||
ol.inherits(ol.render.canvas.Replay, ol.render.VectorContext);
|
||||
|
||||
@@ -223,7 +222,7 @@ ol.render.canvas.Replay.prototype.beginGeometry = function(geometry, feature) {
|
||||
* @private
|
||||
* @param {CanvasRenderingContext2D} context Context.
|
||||
* @param {number} pixelRatio Pixel ratio.
|
||||
* @param {goog.vec.Mat4.Number} transform Transform.
|
||||
* @param {ol.Matrix} transform Transform.
|
||||
* @param {number} viewRotation View rotation.
|
||||
* @param {Object.<string, boolean>} skippedFeaturesHash Ids of features
|
||||
* to skip.
|
||||
@@ -240,13 +239,13 @@ ol.render.canvas.Replay.prototype.replay_ = function(
|
||||
instructions, featureCallback, opt_hitExtent) {
|
||||
/** @type {Array.<number>} */
|
||||
var pixelCoordinates;
|
||||
if (ol.vec.Mat4.equals2D(transform, this.renderedTransform_)) {
|
||||
if (ol.matrix.equals(transform, this.renderedTransform_)) {
|
||||
pixelCoordinates = this.pixelCoordinates_;
|
||||
} else {
|
||||
pixelCoordinates = ol.geom.flat.transform.transform2D(
|
||||
this.coordinates, 0, this.coordinates.length, 2,
|
||||
transform, this.pixelCoordinates_);
|
||||
goog.vec.Mat4.setFromArray(this.renderedTransform_, transform);
|
||||
ol.matrix.setFromArray(this.renderedTransform_, transform);
|
||||
goog.asserts.assert(pixelCoordinates === this.pixelCoordinates_,
|
||||
'pixelCoordinates should be the same as this.pixelCoordinates_');
|
||||
}
|
||||
@@ -332,16 +331,10 @@ ol.render.canvas.Replay.prototype.replay_ = function(
|
||||
if (scale != 1 || rotation !== 0) {
|
||||
var centerX = x + anchorX;
|
||||
var centerY = y + anchorY;
|
||||
ol.vec.Mat4.makeTransform2D(
|
||||
ol.matrix.makeTransform(
|
||||
localTransform, centerX, centerY, scale, scale,
|
||||
rotation, -centerX, -centerY);
|
||||
context.transform(
|
||||
goog.vec.Mat4.getElement(localTransform, 0, 0),
|
||||
goog.vec.Mat4.getElement(localTransform, 1, 0),
|
||||
goog.vec.Mat4.getElement(localTransform, 0, 1),
|
||||
goog.vec.Mat4.getElement(localTransform, 1, 1),
|
||||
goog.vec.Mat4.getElement(localTransform, 0, 3),
|
||||
goog.vec.Mat4.getElement(localTransform, 1, 3));
|
||||
context.transform.apply(context, localTransform);
|
||||
}
|
||||
var alpha = context.globalAlpha;
|
||||
if (opacity != 1) {
|
||||
@@ -358,14 +351,8 @@ ol.render.canvas.Replay.prototype.replay_ = function(
|
||||
context.globalAlpha = alpha;
|
||||
}
|
||||
if (scale != 1 || rotation !== 0) {
|
||||
goog.vec.Mat4.invert(localTransform, localTransformInv);
|
||||
context.transform(
|
||||
goog.vec.Mat4.getElement(localTransformInv, 0, 0),
|
||||
goog.vec.Mat4.getElement(localTransformInv, 1, 0),
|
||||
goog.vec.Mat4.getElement(localTransformInv, 0, 1),
|
||||
goog.vec.Mat4.getElement(localTransformInv, 1, 1),
|
||||
goog.vec.Mat4.getElement(localTransformInv, 0, 3),
|
||||
goog.vec.Mat4.getElement(localTransformInv, 1, 3));
|
||||
ol.matrix.invert(localTransform, localTransformInv);
|
||||
context.transform.apply(context, localTransformInv);
|
||||
}
|
||||
}
|
||||
++i;
|
||||
@@ -402,15 +389,9 @@ ol.render.canvas.Replay.prototype.replay_ = function(
|
||||
x = pixelCoordinates[d] + offsetX;
|
||||
y = pixelCoordinates[d + 1] + offsetY;
|
||||
if (scale != 1 || rotation !== 0) {
|
||||
ol.vec.Mat4.makeTransform2D(
|
||||
ol.matrix.makeTransform(
|
||||
localTransform, x, y, scale, scale, rotation, -x, -y);
|
||||
context.transform(
|
||||
goog.vec.Mat4.getElement(localTransform, 0, 0),
|
||||
goog.vec.Mat4.getElement(localTransform, 1, 0),
|
||||
goog.vec.Mat4.getElement(localTransform, 0, 1),
|
||||
goog.vec.Mat4.getElement(localTransform, 1, 1),
|
||||
goog.vec.Mat4.getElement(localTransform, 0, 3),
|
||||
goog.vec.Mat4.getElement(localTransform, 1, 3));
|
||||
context.transform.apply(context, localTransform);
|
||||
}
|
||||
|
||||
// Support multiple lines separated by \n
|
||||
@@ -441,14 +422,8 @@ ol.render.canvas.Replay.prototype.replay_ = function(
|
||||
}
|
||||
|
||||
if (scale != 1 || rotation !== 0) {
|
||||
goog.vec.Mat4.invert(localTransform, localTransformInv);
|
||||
context.transform(
|
||||
goog.vec.Mat4.getElement(localTransformInv, 0, 0),
|
||||
goog.vec.Mat4.getElement(localTransformInv, 1, 0),
|
||||
goog.vec.Mat4.getElement(localTransformInv, 0, 1),
|
||||
goog.vec.Mat4.getElement(localTransformInv, 1, 1),
|
||||
goog.vec.Mat4.getElement(localTransformInv, 0, 3),
|
||||
goog.vec.Mat4.getElement(localTransformInv, 1, 3));
|
||||
ol.matrix.invert(localTransform, localTransformInv);
|
||||
context.transform.apply(context, localTransformInv);
|
||||
}
|
||||
}
|
||||
++i;
|
||||
@@ -565,7 +540,7 @@ ol.render.canvas.Replay.prototype.replay_ = function(
|
||||
/**
|
||||
* @param {CanvasRenderingContext2D} context Context.
|
||||
* @param {number} pixelRatio Pixel ratio.
|
||||
* @param {goog.vec.Mat4.Number} transform Transform.
|
||||
* @param {ol.Matrix} transform Transform.
|
||||
* @param {number} viewRotation View rotation.
|
||||
* @param {Object.<string, boolean>} skippedFeaturesHash Ids of features
|
||||
* to skip.
|
||||
@@ -580,7 +555,7 @@ ol.render.canvas.Replay.prototype.replay = function(
|
||||
|
||||
/**
|
||||
* @param {CanvasRenderingContext2D} context Context.
|
||||
* @param {goog.vec.Mat4.Number} transform Transform.
|
||||
* @param {ol.Matrix} transform Transform.
|
||||
* @param {number} viewRotation View rotation.
|
||||
* @param {Object.<string, boolean>} skippedFeaturesHash Ids of features
|
||||
* to skip.
|
||||
@@ -1883,9 +1858,9 @@ ol.render.canvas.ReplayGroup = function(
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {!goog.vec.Mat4.Number}
|
||||
* @type {ol.Matrix}
|
||||
*/
|
||||
this.hitDetectionTransform_ = goog.vec.Mat4.createNumber();
|
||||
this.hitDetectionTransform_ = ol.matrix.create();
|
||||
|
||||
};
|
||||
|
||||
@@ -1920,7 +1895,7 @@ ol.render.canvas.ReplayGroup.prototype.forEachFeatureAtCoordinate = function(
|
||||
coordinate, resolution, rotation, skippedFeaturesHash, callback) {
|
||||
|
||||
var transform = this.hitDetectionTransform_;
|
||||
ol.vec.Mat4.makeTransform2D(transform, 0.5, 0.5,
|
||||
ol.matrix.makeTransform(transform, 0.5, 0.5,
|
||||
1 / resolution, -1 / resolution, -rotation,
|
||||
-coordinate[0], -coordinate[1]);
|
||||
|
||||
@@ -1991,7 +1966,7 @@ ol.render.canvas.ReplayGroup.prototype.isEmpty = function() {
|
||||
/**
|
||||
* @param {CanvasRenderingContext2D} context Context.
|
||||
* @param {number} pixelRatio Pixel ratio.
|
||||
* @param {goog.vec.Mat4.Number} transform Transform.
|
||||
* @param {ol.Matrix} transform Transform.
|
||||
* @param {number} viewRotation View rotation.
|
||||
* @param {Object.<string, boolean>} skippedFeaturesHash Ids of features
|
||||
* to skip.
|
||||
@@ -2044,7 +2019,7 @@ ol.render.canvas.ReplayGroup.prototype.replay = function(context, pixelRatio,
|
||||
/**
|
||||
* @private
|
||||
* @param {CanvasRenderingContext2D} context Context.
|
||||
* @param {goog.vec.Mat4.Number} transform Transform.
|
||||
* @param {ol.Matrix} transform Transform.
|
||||
* @param {number} viewRotation View rotation.
|
||||
* @param {Object.<string, boolean>} skippedFeaturesHash Ids of features
|
||||
* to skip.
|
||||
|
||||
@@ -2,7 +2,7 @@ goog.provide('ol.render.webgl.ImageReplay');
|
||||
goog.provide('ol.render.webgl.ReplayGroup');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('goog.vec.Mat4');
|
||||
goog.require('ol.matrix');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.object');
|
||||
goog.require('ol.render.IReplayGroup');
|
||||
@@ -116,16 +116,16 @@ ol.render.webgl.ImageReplay = function(tolerance, maxExtent) {
|
||||
this.opacity_ = undefined;
|
||||
|
||||
/**
|
||||
* @type {!goog.vec.Mat4.Number}
|
||||
* @type {ol.Matrix}
|
||||
* @private
|
||||
*/
|
||||
this.offsetRotateMatrix_ = goog.vec.Mat4.createNumberIdentity();
|
||||
this.offsetRotateMatrix_ = ol.matrix.create();
|
||||
|
||||
/**
|
||||
* @type {!goog.vec.Mat4.Number}
|
||||
* @type {ol.Matrix}
|
||||
* @private
|
||||
*/
|
||||
this.offsetScaleMatrix_ = goog.vec.Mat4.createNumberIdentity();
|
||||
this.offsetScaleMatrix_ = ol.matrix.create();
|
||||
|
||||
/**
|
||||
* @type {number|undefined}
|
||||
@@ -140,10 +140,10 @@ ol.render.webgl.ImageReplay = function(tolerance, maxExtent) {
|
||||
this.originY_ = undefined;
|
||||
|
||||
/**
|
||||
* @type {!goog.vec.Mat4.Number}
|
||||
* @type {ol.Matrix}
|
||||
* @private
|
||||
*/
|
||||
this.projectionMatrix_ = goog.vec.Mat4.createNumberIdentity();
|
||||
this.projectionMatrix_ = ol.matrix.create();
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -553,7 +553,7 @@ ol.render.webgl.ImageReplay.prototype.replay = function(context,
|
||||
|
||||
// set the "uniform" values
|
||||
var projectionMatrix = this.projectionMatrix_;
|
||||
ol.vec.Mat4.makeTransform2D(projectionMatrix,
|
||||
ol.matrix.makeTransform(projectionMatrix,
|
||||
0.0, 0.0,
|
||||
2 / (resolution * size[0]),
|
||||
2 / (resolution * size[1]),
|
||||
@@ -561,18 +561,18 @@ ol.render.webgl.ImageReplay.prototype.replay = function(context,
|
||||
-(center[0] - this.origin_[0]), -(center[1] - this.origin_[1]));
|
||||
|
||||
var offsetScaleMatrix = this.offsetScaleMatrix_;
|
||||
goog.vec.Mat4.makeScale(offsetScaleMatrix, 2 / size[0], 2 / size[1], 1);
|
||||
ol.matrix.makeIdentity(offsetScaleMatrix);
|
||||
ol.matrix.scale(offsetScaleMatrix, 2 / size[0], 2 / size[1]);
|
||||
|
||||
var offsetRotateMatrix = this.offsetRotateMatrix_;
|
||||
goog.vec.Mat4.makeIdentity(offsetRotateMatrix);
|
||||
ol.matrix.makeIdentity(offsetRotateMatrix);
|
||||
if (rotation !== 0) {
|
||||
goog.vec.Mat4.rotateZ(offsetRotateMatrix, -rotation);
|
||||
ol.matrix.rotate(offsetRotateMatrix, -rotation);
|
||||
}
|
||||
|
||||
gl.uniformMatrix4fv(locations.u_projectionMatrix, false, projectionMatrix);
|
||||
gl.uniformMatrix4fv(locations.u_offsetScaleMatrix, false, offsetScaleMatrix);
|
||||
gl.uniformMatrix4fv(locations.u_offsetRotateMatrix, false,
|
||||
offsetRotateMatrix);
|
||||
gl.uniformMatrix4fv(locations.u_projectionMatrix, false, ol.vec.Mat4.fromMatrix(projectionMatrix));
|
||||
gl.uniformMatrix4fv(locations.u_offsetScaleMatrix, false, ol.vec.Mat4.fromMatrix(offsetScaleMatrix));
|
||||
gl.uniformMatrix4fv(locations.u_offsetRotateMatrix, false, ol.vec.Mat4.fromMatrix(offsetRotateMatrix));
|
||||
gl.uniform1f(locations.u_opacity, opacity);
|
||||
|
||||
// draw!
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
goog.provide('ol.renderer.canvas.ImageLayer');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('goog.vec.Mat4');
|
||||
goog.require('ol.matrix');
|
||||
goog.require('ol.functions');
|
||||
goog.require('ol.ImageBase');
|
||||
goog.require('ol.ViewHint');
|
||||
@@ -11,7 +11,6 @@ goog.require('ol.layer.Image');
|
||||
goog.require('ol.proj');
|
||||
goog.require('ol.renderer.canvas.Layer');
|
||||
goog.require('ol.source.ImageVector');
|
||||
goog.require('ol.vec.Mat4');
|
||||
|
||||
|
||||
/**
|
||||
@@ -31,13 +30,13 @@ ol.renderer.canvas.ImageLayer = function(imageLayer) {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {!goog.vec.Mat4.Number}
|
||||
* @type {ol.Matrix}
|
||||
*/
|
||||
this.imageTransform_ = goog.vec.Mat4.createNumber();
|
||||
this.imageTransform_ = ol.matrix.create();
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {?goog.vec.Mat4.Number}
|
||||
* @type {?ol.Matrix}
|
||||
*/
|
||||
this.imageTransformInv_ = null;
|
||||
|
||||
@@ -84,7 +83,7 @@ ol.renderer.canvas.ImageLayer.prototype.forEachLayerAtPixel = function(pixel, fr
|
||||
// for ImageVector sources use the original hit-detection logic,
|
||||
// so that for example also transparent polygons are detected
|
||||
var coordinate = pixel.slice();
|
||||
ol.vec.Mat4.multVec2(
|
||||
ol.matrix.multVec2(
|
||||
frameState.pixelToCoordinateMatrix, coordinate, coordinate);
|
||||
var hasFeature = this.forEachFeatureAtCoordinate(
|
||||
coordinate, frameState, ol.functions.TRUE, this);
|
||||
@@ -97,8 +96,8 @@ ol.renderer.canvas.ImageLayer.prototype.forEachLayerAtPixel = function(pixel, fr
|
||||
} else {
|
||||
// for all other image sources directly check the image
|
||||
if (!this.imageTransformInv_) {
|
||||
this.imageTransformInv_ = goog.vec.Mat4.createNumber();
|
||||
goog.vec.Mat4.invert(this.imageTransform_, this.imageTransformInv_);
|
||||
this.imageTransformInv_ = ol.matrix.create();
|
||||
ol.matrix.invert(this.imageTransform_, this.imageTransformInv_);
|
||||
}
|
||||
|
||||
var pixelOnCanvas =
|
||||
@@ -190,7 +189,7 @@ ol.renderer.canvas.ImageLayer.prototype.prepareFrame = function(frameState, laye
|
||||
var imagePixelRatio = image.getPixelRatio();
|
||||
var scale = pixelRatio * imageResolution /
|
||||
(viewResolution * imagePixelRatio);
|
||||
ol.vec.Mat4.makeTransform2D(this.imageTransform_,
|
||||
ol.matrix.makeTransform(this.imageTransform_,
|
||||
pixelRatio * frameState.size[0] / 2,
|
||||
pixelRatio * frameState.size[1] / 2,
|
||||
scale, scale,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
goog.provide('ol.renderer.canvas.Layer');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('goog.vec.Mat4');
|
||||
goog.require('ol.matrix');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.layer.Layer');
|
||||
goog.require('ol.render.Event');
|
||||
@@ -9,7 +9,6 @@ goog.require('ol.render.EventType');
|
||||
goog.require('ol.render.canvas');
|
||||
goog.require('ol.render.canvas.Immediate');
|
||||
goog.require('ol.renderer.Layer');
|
||||
goog.require('ol.vec.Mat4');
|
||||
|
||||
|
||||
/**
|
||||
@@ -23,9 +22,9 @@ ol.renderer.canvas.Layer = function(layer) {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {!goog.vec.Mat4.Number}
|
||||
* @type {ol.Matrix}
|
||||
*/
|
||||
this.transform_ = goog.vec.Mat4.createNumber();
|
||||
this.transform_ = ol.matrix.create();
|
||||
|
||||
};
|
||||
ol.inherits(ol.renderer.canvas.Layer, ol.renderer.Layer);
|
||||
@@ -58,13 +57,13 @@ ol.renderer.canvas.Layer.prototype.composeFrame = function(frameState, layerStat
|
||||
var bottomRight = ol.extent.getBottomRight(extent);
|
||||
var bottomLeft = ol.extent.getBottomLeft(extent);
|
||||
|
||||
ol.vec.Mat4.multVec2(frameState.coordinateToPixelMatrix,
|
||||
ol.matrix.multVec2(frameState.coordinateToPixelMatrix,
|
||||
topLeft, topLeft);
|
||||
ol.vec.Mat4.multVec2(frameState.coordinateToPixelMatrix,
|
||||
ol.matrix.multVec2(frameState.coordinateToPixelMatrix,
|
||||
topRight, topRight);
|
||||
ol.vec.Mat4.multVec2(frameState.coordinateToPixelMatrix,
|
||||
ol.matrix.multVec2(frameState.coordinateToPixelMatrix,
|
||||
bottomRight, bottomRight);
|
||||
ol.vec.Mat4.multVec2(frameState.coordinateToPixelMatrix,
|
||||
ol.matrix.multVec2(frameState.coordinateToPixelMatrix,
|
||||
bottomLeft, bottomLeft);
|
||||
|
||||
context.save();
|
||||
@@ -87,10 +86,10 @@ ol.renderer.canvas.Layer.prototype.composeFrame = function(frameState, layerStat
|
||||
|
||||
// for performance reasons, context.setTransform is only used
|
||||
// when the view is rotated. see http://jsperf.com/canvas-transform
|
||||
var dx = goog.vec.Mat4.getElement(imageTransform, 0, 3);
|
||||
var dy = goog.vec.Mat4.getElement(imageTransform, 1, 3);
|
||||
var dw = image.width * goog.vec.Mat4.getElement(imageTransform, 0, 0);
|
||||
var dh = image.height * goog.vec.Mat4.getElement(imageTransform, 1, 1);
|
||||
var dx = imageTransform[4];
|
||||
var dy = imageTransform[5];
|
||||
var dw = image.width * imageTransform[0];
|
||||
var dh = image.height * imageTransform[3];
|
||||
context.drawImage(image, 0, 0, +image.width, +image.height,
|
||||
Math.round(dx), Math.round(dy), Math.round(dw), Math.round(dh));
|
||||
context.globalAlpha = alpha;
|
||||
@@ -109,7 +108,7 @@ ol.renderer.canvas.Layer.prototype.composeFrame = function(frameState, layerStat
|
||||
* @param {ol.render.EventType} type Event type.
|
||||
* @param {CanvasRenderingContext2D} context Context.
|
||||
* @param {olx.FrameState} frameState Frame state.
|
||||
* @param {goog.vec.Mat4.Number=} opt_transform Transform.
|
||||
* @param {ol.Matrix=} opt_transform Transform.
|
||||
* @private
|
||||
*/
|
||||
ol.renderer.canvas.Layer.prototype.dispatchComposeEvent_ = function(type, context, frameState, opt_transform) {
|
||||
@@ -135,7 +134,7 @@ ol.renderer.canvas.Layer.prototype.dispatchComposeEvent_ = function(type, contex
|
||||
/**
|
||||
* @param {CanvasRenderingContext2D} context Context.
|
||||
* @param {olx.FrameState} frameState Frame state.
|
||||
* @param {goog.vec.Mat4.Number=} opt_transform Transform.
|
||||
* @param {ol.Matrix=} opt_transform Transform.
|
||||
* @protected
|
||||
*/
|
||||
ol.renderer.canvas.Layer.prototype.dispatchPostComposeEvent = function(context, frameState, opt_transform) {
|
||||
@@ -147,7 +146,7 @@ ol.renderer.canvas.Layer.prototype.dispatchPostComposeEvent = function(context,
|
||||
/**
|
||||
* @param {CanvasRenderingContext2D} context Context.
|
||||
* @param {olx.FrameState} frameState Frame state.
|
||||
* @param {goog.vec.Mat4.Number=} opt_transform Transform.
|
||||
* @param {ol.Matrix=} opt_transform Transform.
|
||||
* @protected
|
||||
*/
|
||||
ol.renderer.canvas.Layer.prototype.dispatchPreComposeEvent = function(context, frameState, opt_transform) {
|
||||
@@ -159,7 +158,7 @@ ol.renderer.canvas.Layer.prototype.dispatchPreComposeEvent = function(context, f
|
||||
/**
|
||||
* @param {CanvasRenderingContext2D} context Context.
|
||||
* @param {olx.FrameState} frameState Frame state.
|
||||
* @param {goog.vec.Mat4.Number=} opt_transform Transform.
|
||||
* @param {ol.Matrix=} opt_transform Transform.
|
||||
* @protected
|
||||
*/
|
||||
ol.renderer.canvas.Layer.prototype.dispatchRenderEvent = function(context, frameState, opt_transform) {
|
||||
@@ -175,7 +174,7 @@ ol.renderer.canvas.Layer.prototype.getImage = goog.abstractMethod;
|
||||
|
||||
|
||||
/**
|
||||
* @return {!goog.vec.Mat4.Number} Image transform.
|
||||
* @return {!ol.Matrix} Image transform.
|
||||
*/
|
||||
ol.renderer.canvas.Layer.prototype.getImageTransform = goog.abstractMethod;
|
||||
|
||||
@@ -184,12 +183,12 @@ ol.renderer.canvas.Layer.prototype.getImageTransform = goog.abstractMethod;
|
||||
* @param {olx.FrameState} frameState Frame state.
|
||||
* @param {number} offsetX Offset on the x-axis in view coordinates.
|
||||
* @protected
|
||||
* @return {!goog.vec.Mat4.Number} Transform.
|
||||
* @return {!ol.Matrix} Transform.
|
||||
*/
|
||||
ol.renderer.canvas.Layer.prototype.getTransform = function(frameState, offsetX) {
|
||||
var viewState = frameState.viewState;
|
||||
var pixelRatio = frameState.pixelRatio;
|
||||
return ol.vec.Mat4.makeTransform2D(this.transform_,
|
||||
return ol.matrix.makeTransform(this.transform_,
|
||||
pixelRatio * frameState.size[0] / 2,
|
||||
pixelRatio * frameState.size[1] / 2,
|
||||
pixelRatio / viewState.resolution,
|
||||
@@ -210,13 +209,13 @@ ol.renderer.canvas.Layer.prototype.prepareFrame = goog.abstractMethod;
|
||||
|
||||
/**
|
||||
* @param {ol.Pixel} pixelOnMap Pixel.
|
||||
* @param {goog.vec.Mat4.Number} imageTransformInv The transformation matrix
|
||||
* @param {ol.Matrix} imageTransformInv The transformation matrix
|
||||
* to convert from a map pixel to a canvas pixel.
|
||||
* @return {ol.Pixel} The pixel.
|
||||
* @protected
|
||||
*/
|
||||
ol.renderer.canvas.Layer.prototype.getPixelOnCanvas = function(pixelOnMap, imageTransformInv) {
|
||||
var pixelOnCanvas = [0, 0];
|
||||
ol.vec.Mat4.multVec2(imageTransformInv, pixelOnMap, pixelOnCanvas);
|
||||
ol.matrix.multVec2(imageTransformInv, pixelOnMap, pixelOnCanvas);
|
||||
return pixelOnCanvas;
|
||||
};
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
goog.provide('ol.renderer.canvas.Map');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('goog.vec.Mat4');
|
||||
goog.require('ol.matrix');
|
||||
goog.require('ol');
|
||||
goog.require('ol.RendererType');
|
||||
goog.require('ol.array');
|
||||
@@ -25,7 +25,6 @@ goog.require('ol.renderer.canvas.TileLayer');
|
||||
goog.require('ol.renderer.canvas.VectorLayer');
|
||||
goog.require('ol.renderer.canvas.VectorTileLayer');
|
||||
goog.require('ol.source.State');
|
||||
goog.require('ol.vec.Mat4');
|
||||
|
||||
|
||||
/**
|
||||
@@ -63,9 +62,9 @@ ol.renderer.canvas.Map = function(container, map) {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {!goog.vec.Mat4.Number}
|
||||
* @type {ol.Matrix}
|
||||
*/
|
||||
this.transform_ = goog.vec.Mat4.createNumber();
|
||||
this.transform_ = ol.matrix.create();
|
||||
|
||||
};
|
||||
ol.inherits(ol.renderer.canvas.Map, ol.renderer.Map);
|
||||
@@ -118,13 +117,13 @@ ol.renderer.canvas.Map.prototype.dispatchComposeEvent_ = function(type, frameSta
|
||||
/**
|
||||
* @param {olx.FrameState} frameState Frame state.
|
||||
* @protected
|
||||
* @return {!goog.vec.Mat4.Number} Transform.
|
||||
* @return {!ol.Matrix} Transform.
|
||||
*/
|
||||
ol.renderer.canvas.Map.prototype.getTransform = function(frameState) {
|
||||
var pixelRatio = frameState.pixelRatio;
|
||||
var viewState = frameState.viewState;
|
||||
var resolution = viewState.resolution;
|
||||
return ol.vec.Mat4.makeTransform2D(this.transform_,
|
||||
return ol.matrix.makeTransform(this.transform_,
|
||||
this.canvas_.width / 2, this.canvas_.height / 2,
|
||||
pixelRatio / resolution, -pixelRatio / resolution,
|
||||
-viewState.rotation,
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
goog.provide('ol.renderer.canvas.TileLayer');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('goog.vec.Mat4');
|
||||
goog.require('ol.matrix');
|
||||
goog.require('ol.TileRange');
|
||||
goog.require('ol.TileState');
|
||||
goog.require('ol.array');
|
||||
@@ -13,7 +13,6 @@ goog.require('ol.render.EventType');
|
||||
goog.require('ol.renderer.canvas.Layer');
|
||||
goog.require('ol.size');
|
||||
goog.require('ol.source.Tile');
|
||||
goog.require('ol.vec.Mat4');
|
||||
|
||||
|
||||
/**
|
||||
@@ -51,9 +50,9 @@ ol.renderer.canvas.TileLayer = function(tileLayer) {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {!goog.vec.Mat4.Number}
|
||||
* @type {ol.Matrix}
|
||||
*/
|
||||
this.imageTransform_ = goog.vec.Mat4.createNumber();
|
||||
this.imageTransform_ = ol.matrix.create();
|
||||
|
||||
/**
|
||||
* @protected
|
||||
@@ -327,7 +326,7 @@ ol.renderer.canvas.TileLayer.prototype.renderTileImages = function(context, fram
|
||||
if (hasRenderListeners) {
|
||||
var dX = drawOffsetX - offsetX / drawScale + offsetX;
|
||||
var dY = drawOffsetY - offsetY / drawScale + offsetY;
|
||||
var imageTransform = ol.vec.Mat4.makeTransform2D(this.imageTransform_,
|
||||
var imageTransform = ol.matrix.makeTransform(this.imageTransform_,
|
||||
drawSize / 2 - dX, drawSize / 2 - dY, pixelScale, -pixelScale,
|
||||
-rotation, -center[0] + dX / pixelScale, -center[1] - dY / pixelScale);
|
||||
this.dispatchRenderEvent(renderContext, frameState, imageTransform);
|
||||
|
||||
@@ -2,7 +2,7 @@ goog.provide('ol.renderer.canvas.VectorTileLayer');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.events');
|
||||
goog.require('goog.vec.Mat4');
|
||||
goog.require('ol.matrix');
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.VectorTile');
|
||||
goog.require('ol.array');
|
||||
@@ -17,7 +17,6 @@ goog.require('ol.renderer.canvas.TileLayer');
|
||||
goog.require('ol.renderer.vector');
|
||||
goog.require('ol.size');
|
||||
goog.require('ol.source.VectorTile');
|
||||
goog.require('ol.vec.Mat4');
|
||||
|
||||
|
||||
/**
|
||||
@@ -57,9 +56,9 @@ ol.renderer.canvas.VectorTileLayer = function(layer) {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {!goog.vec.Mat4.Number}
|
||||
* @type {ol.Matrix}
|
||||
*/
|
||||
this.tmpTransform_ = goog.vec.Mat4.createNumber();
|
||||
this.tmpTransform_ = ol.matrix.create();
|
||||
|
||||
// Use lower resolution for pure vector rendering. Closest resolution otherwise.
|
||||
this.zDirection =
|
||||
@@ -148,7 +147,7 @@ ol.renderer.canvas.VectorTileLayer.prototype.renderTileReplays_ = function(
|
||||
|
||||
if (pixelSpace) {
|
||||
origin = ol.extent.getTopLeft(tileExtent);
|
||||
tileTransform = ol.vec.Mat4.makeTransform2D(this.tmpTransform_,
|
||||
tileTransform = ol.matrix.makeTransform(this.tmpTransform_,
|
||||
offsetX, offsetY,
|
||||
pixelScale * tilePixelResolution,
|
||||
pixelScale * tilePixelResolution,
|
||||
@@ -428,14 +427,14 @@ ol.renderer.canvas.VectorTileLayer.prototype.renderTileImage_ = function(
|
||||
tile.getTileCoord(), this.tmpExtent);
|
||||
var tileTransform;
|
||||
if (pixelSpace) {
|
||||
tileTransform = ol.vec.Mat4.makeTransform2D(this.tmpTransform_,
|
||||
tileTransform = ol.matrix.makeTransform(this.tmpTransform_,
|
||||
0, 0,
|
||||
pixelScale * tilePixelResolution, pixelScale * tilePixelResolution,
|
||||
0,
|
||||
-tileSize[0] * tilePixelRatio / 2, -tileSize[1] * tilePixelRatio / 2);
|
||||
} else {
|
||||
var tileCenter = ol.extent.getCenter(tileExtent);
|
||||
tileTransform = ol.vec.Mat4.makeTransform2D(this.tmpTransform_,
|
||||
tileTransform = ol.matrix.makeTransform(this.tmpTransform_,
|
||||
0, 0,
|
||||
pixelScale, -pixelScale,
|
||||
0,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
goog.provide('ol.renderer.dom.ImageLayer');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('goog.vec.Mat4');
|
||||
goog.require('ol.matrix');
|
||||
goog.require('ol.ImageBase');
|
||||
goog.require('ol.ViewHint');
|
||||
goog.require('ol.dom');
|
||||
@@ -9,7 +9,6 @@ goog.require('ol.extent');
|
||||
goog.require('ol.layer.Image');
|
||||
goog.require('ol.proj');
|
||||
goog.require('ol.renderer.dom.Layer');
|
||||
goog.require('ol.vec.Mat4');
|
||||
|
||||
|
||||
/**
|
||||
@@ -32,9 +31,9 @@ ol.renderer.dom.ImageLayer = function(imageLayer) {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {goog.vec.Mat4.Number}
|
||||
* @type {ol.Matrix}
|
||||
*/
|
||||
this.transform_ = goog.vec.Mat4.createNumberIdentity();
|
||||
this.transform_ = ol.matrix.create();
|
||||
|
||||
};
|
||||
ol.inherits(ol.renderer.dom.ImageLayer, ol.renderer.dom.Layer);
|
||||
@@ -118,8 +117,8 @@ ol.renderer.dom.ImageLayer.prototype.prepareFrame = function(frameState, layerSt
|
||||
if (image) {
|
||||
var imageExtent = image.getExtent();
|
||||
var imageResolution = image.getResolution();
|
||||
var transform = goog.vec.Mat4.createNumber();
|
||||
ol.vec.Mat4.makeTransform2D(transform,
|
||||
var transform = ol.matrix.create();
|
||||
ol.matrix.makeTransform(transform,
|
||||
frameState.size[0] / 2, frameState.size[1] / 2,
|
||||
imageResolution / viewResolution, imageResolution / viewResolution,
|
||||
viewRotation,
|
||||
@@ -146,12 +145,12 @@ ol.renderer.dom.ImageLayer.prototype.prepareFrame = function(frameState, layerSt
|
||||
|
||||
|
||||
/**
|
||||
* @param {goog.vec.Mat4.Number} transform Transform.
|
||||
* @param {ol.Matrix} transform Transform.
|
||||
* @private
|
||||
*/
|
||||
ol.renderer.dom.ImageLayer.prototype.setTransform_ = function(transform) {
|
||||
if (!ol.vec.Mat4.equals2D(transform, this.transform_)) {
|
||||
if (!ol.matrix.equals(transform, this.transform_)) {
|
||||
ol.dom.transformElement2D(this.target, transform, 6);
|
||||
goog.vec.Mat4.setFromArray(this.transform_, transform);
|
||||
ol.matrix.setFromArray(this.transform_, transform);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -4,7 +4,7 @@ goog.require('goog.asserts');
|
||||
goog.require('ol.events');
|
||||
goog.require('ol.events.Event');
|
||||
goog.require('ol.events.EventType');
|
||||
goog.require('goog.vec.Mat4');
|
||||
goog.require('ol.matrix');
|
||||
goog.require('ol');
|
||||
goog.require('ol.RendererType');
|
||||
goog.require('ol.array');
|
||||
@@ -23,7 +23,6 @@ goog.require('ol.renderer.dom.Layer');
|
||||
goog.require('ol.renderer.dom.TileLayer');
|
||||
goog.require('ol.renderer.dom.VectorLayer');
|
||||
goog.require('ol.source.State');
|
||||
goog.require('ol.vec.Mat4');
|
||||
|
||||
|
||||
/**
|
||||
@@ -50,9 +49,9 @@ ol.renderer.dom.Map = function(container, map) {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {!goog.vec.Mat4.Number}
|
||||
* @type {ol.Matrix}
|
||||
*/
|
||||
this.transform_ = goog.vec.Mat4.createNumber();
|
||||
this.transform_ = ol.matrix.create();
|
||||
|
||||
/**
|
||||
* @type {!Element}
|
||||
@@ -124,7 +123,7 @@ ol.renderer.dom.Map.prototype.dispatchComposeEvent_ = function(type, frameState)
|
||||
var context = this.context_;
|
||||
var canvas = context.canvas;
|
||||
|
||||
ol.vec.Mat4.makeTransform2D(this.transform_,
|
||||
ol.matrix.makeTransform(this.transform_,
|
||||
canvas.width / 2,
|
||||
canvas.height / 2,
|
||||
pixelRatio / viewState.resolution,
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
goog.provide('ol.renderer.dom.TileLayer');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('goog.vec.Mat4');
|
||||
goog.require('ol.matrix');
|
||||
goog.require('ol');
|
||||
goog.require('ol.TileRange');
|
||||
goog.require('ol.TileState');
|
||||
@@ -16,7 +16,6 @@ goog.require('ol.layer.Tile');
|
||||
goog.require('ol.renderer.dom.Layer');
|
||||
goog.require('ol.size');
|
||||
goog.require('ol.tilegrid.TileGrid');
|
||||
goog.require('ol.vec.Mat4');
|
||||
|
||||
|
||||
/**
|
||||
@@ -200,7 +199,7 @@ ol.renderer.dom.TileLayer.prototype.prepareFrame = function(frameState, layerSta
|
||||
tileLayerZKeys.sort(ol.array.numberSafeCompareFunction);
|
||||
|
||||
var i, ii, j, origin, resolution;
|
||||
var transform = goog.vec.Mat4.createNumber();
|
||||
var transform = ol.matrix.create();
|
||||
for (i = 0, ii = tileLayerZKeys.length; i < ii; ++i) {
|
||||
tileLayerZKey = tileLayerZKeys[i];
|
||||
tileLayerZ = this.tileLayerZs_[tileLayerZKey];
|
||||
@@ -211,7 +210,7 @@ ol.renderer.dom.TileLayer.prototype.prepareFrame = function(frameState, layerSta
|
||||
}
|
||||
resolution = tileLayerZ.getResolution();
|
||||
origin = tileLayerZ.getOrigin();
|
||||
ol.vec.Mat4.makeTransform2D(transform,
|
||||
ol.matrix.makeTransform(transform,
|
||||
frameState.size[0] / 2, frameState.size[1] / 2,
|
||||
resolution / viewState.resolution,
|
||||
resolution / viewState.resolution,
|
||||
@@ -314,9 +313,9 @@ ol.renderer.dom.TileLayerZ_ = function(tileGrid, tileCoordOrigin) {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {goog.vec.Mat4.Number}
|
||||
* @type {ol.Matrix}
|
||||
*/
|
||||
this.transform_ = goog.vec.Mat4.createNumberIdentity();
|
||||
this.transform_ = ol.matrix.create();
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -437,11 +436,11 @@ ol.renderer.dom.TileLayerZ_.prototype.removeTilesOutsideExtent = function(extent
|
||||
|
||||
|
||||
/**
|
||||
* @param {goog.vec.Mat4.Number} transform Transform.
|
||||
* @param {ol.Matrix} transform Transform.
|
||||
*/
|
||||
ol.renderer.dom.TileLayerZ_.prototype.setTransform = function(transform) {
|
||||
if (!ol.vec.Mat4.equals2D(transform, this.transform_)) {
|
||||
if (!ol.matrix.equals(transform, this.transform_)) {
|
||||
ol.dom.transformElement2D(this.target, transform, 6);
|
||||
goog.vec.Mat4.setFromArray(this.transform_, transform);
|
||||
ol.matrix.setFromArray(this.transform_, transform);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -2,7 +2,7 @@ goog.provide('ol.renderer.dom.VectorLayer');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.events');
|
||||
goog.require('goog.vec.Mat4');
|
||||
goog.require('ol.matrix');
|
||||
goog.require('ol.ViewHint');
|
||||
goog.require('ol.dom');
|
||||
goog.require('ol.extent');
|
||||
@@ -13,7 +13,6 @@ goog.require('ol.render.canvas.Immediate');
|
||||
goog.require('ol.render.canvas.ReplayGroup');
|
||||
goog.require('ol.renderer.dom.Layer');
|
||||
goog.require('ol.renderer.vector');
|
||||
goog.require('ol.vec.Mat4');
|
||||
|
||||
|
||||
/**
|
||||
@@ -76,15 +75,15 @@ ol.renderer.dom.VectorLayer = function(vectorLayer) {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {goog.vec.Mat4.Number}
|
||||
* @type {ol.Matrix}
|
||||
*/
|
||||
this.transform_ = goog.vec.Mat4.createNumber();
|
||||
this.transform_ = ol.matrix.create();
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {goog.vec.Mat4.Number}
|
||||
* @type {ol.Matrix}
|
||||
*/
|
||||
this.elementTransform_ = goog.vec.Mat4.createNumber();
|
||||
this.elementTransform_ = ol.matrix.create();
|
||||
|
||||
};
|
||||
ol.inherits(ol.renderer.dom.VectorLayer, ol.renderer.dom.Layer);
|
||||
@@ -120,7 +119,7 @@ ol.renderer.dom.VectorLayer.prototype.composeFrame = function(frameState, layerS
|
||||
var imageWidth = viewWidth * pixelRatio;
|
||||
var imageHeight = viewHeight * pixelRatio;
|
||||
|
||||
var transform = ol.vec.Mat4.makeTransform2D(this.transform_,
|
||||
var transform = ol.matrix.makeTransform(this.transform_,
|
||||
pixelRatio * viewWidth / 2,
|
||||
pixelRatio * viewHeight / 2,
|
||||
pixelRatio / viewResolution,
|
||||
@@ -134,7 +133,7 @@ ol.renderer.dom.VectorLayer.prototype.composeFrame = function(frameState, layerS
|
||||
context.canvas.width = imageWidth;
|
||||
context.canvas.height = imageHeight;
|
||||
|
||||
var elementTransform = ol.vec.Mat4.makeTransform2D(this.elementTransform_,
|
||||
var elementTransform = ol.matrix.makeTransform(this.elementTransform_,
|
||||
0, 0,
|
||||
1 / pixelRatio, 1 / pixelRatio,
|
||||
0,
|
||||
@@ -162,7 +161,7 @@ ol.renderer.dom.VectorLayer.prototype.composeFrame = function(frameState, layerS
|
||||
/**
|
||||
* @param {ol.render.EventType} type Event type.
|
||||
* @param {olx.FrameState} frameState Frame state.
|
||||
* @param {goog.vec.Mat4.Number} transform Transform.
|
||||
* @param {ol.Matrix} transform Transform.
|
||||
* @private
|
||||
*/
|
||||
ol.renderer.dom.VectorLayer.prototype.dispatchEvent_ = function(type, frameState, transform) {
|
||||
|
||||
@@ -10,10 +10,9 @@ goog.require('ol.Observable');
|
||||
goog.require('ol.TileRange');
|
||||
goog.require('ol.TileState');
|
||||
goog.require('ol.layer.Layer');
|
||||
goog.require('ol.source.Source');
|
||||
goog.require('ol.matrix');
|
||||
goog.require('ol.source.State');
|
||||
goog.require('ol.source.Tile');
|
||||
goog.require('ol.vec.Mat4');
|
||||
|
||||
|
||||
/**
|
||||
@@ -59,7 +58,7 @@ ol.renderer.Layer.prototype.forEachFeatureAtCoordinate = ol.nullFunction;
|
||||
*/
|
||||
ol.renderer.Layer.prototype.forEachLayerAtPixel = function(pixel, frameState, callback, thisArg) {
|
||||
var coordinate = pixel.slice();
|
||||
ol.vec.Mat4.multVec2(
|
||||
ol.matrix.multVec2(
|
||||
frameState.pixelToCoordinateMatrix, coordinate, coordinate);
|
||||
|
||||
var hasFeature = this.forEachFeatureAtCoordinate(
|
||||
|
||||
@@ -2,7 +2,7 @@ goog.provide('ol.RendererType');
|
||||
goog.provide('ol.renderer.Map');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('goog.vec.Mat4');
|
||||
goog.require('ol.matrix');
|
||||
goog.require('ol');
|
||||
goog.require('ol.Disposable');
|
||||
goog.require('ol.events');
|
||||
@@ -12,7 +12,6 @@ goog.require('ol.functions');
|
||||
goog.require('ol.layer.Layer');
|
||||
goog.require('ol.renderer.Layer');
|
||||
goog.require('ol.style.IconImageCache');
|
||||
goog.require('ol.vec.Mat4');
|
||||
|
||||
|
||||
/**
|
||||
@@ -69,12 +68,12 @@ ol.renderer.Map.prototype.calculateMatrices2D = function(frameState) {
|
||||
var coordinateToPixelMatrix = frameState.coordinateToPixelMatrix;
|
||||
goog.asserts.assert(coordinateToPixelMatrix,
|
||||
'frameState has a coordinateToPixelMatrix');
|
||||
ol.vec.Mat4.makeTransform2D(coordinateToPixelMatrix,
|
||||
ol.matrix.makeTransform(coordinateToPixelMatrix,
|
||||
frameState.size[0] / 2, frameState.size[1] / 2,
|
||||
1 / viewState.resolution, -1 / viewState.resolution,
|
||||
-viewState.rotation,
|
||||
-viewState.center[0], -viewState.center[1]);
|
||||
var inverted = goog.vec.Mat4.invert(
|
||||
var inverted = ol.matrix.invert(
|
||||
coordinateToPixelMatrix, frameState.pixelToCoordinateMatrix);
|
||||
goog.asserts.assert(inverted, 'matrix could be inverted');
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
goog.provide('ol.renderer.webgl.ImageLayer');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('goog.vec.Mat4');
|
||||
goog.require('ol.matrix');
|
||||
goog.require('goog.webgl');
|
||||
goog.require('ol.ImageBase');
|
||||
goog.require('ol.ViewHint');
|
||||
@@ -12,7 +12,6 @@ goog.require('ol.layer.Image');
|
||||
goog.require('ol.proj');
|
||||
goog.require('ol.renderer.webgl.Layer');
|
||||
goog.require('ol.source.ImageVector');
|
||||
goog.require('ol.vec.Mat4');
|
||||
goog.require('ol.webgl.Context');
|
||||
|
||||
|
||||
@@ -41,7 +40,7 @@ ol.renderer.webgl.ImageLayer = function(mapRenderer, imageLayer) {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {?goog.vec.Mat4.Number}
|
||||
* @type {?ol.Matrix}
|
||||
*/
|
||||
this.hitTransformationMatrix_ = null;
|
||||
|
||||
@@ -165,9 +164,9 @@ ol.renderer.webgl.ImageLayer.prototype.prepareFrame = function(frameState, layer
|
||||
|
||||
// Translate and scale to flip the Y coord.
|
||||
var texCoordMatrix = this.texCoordMatrix;
|
||||
goog.vec.Mat4.makeIdentity(texCoordMatrix);
|
||||
goog.vec.Mat4.scale(texCoordMatrix, 1, -1, 1);
|
||||
goog.vec.Mat4.translate(texCoordMatrix, 0, -1, 0);
|
||||
ol.matrix.makeIdentity(texCoordMatrix);
|
||||
ol.matrix.scale(texCoordMatrix, 1, -1);
|
||||
ol.matrix.translate(texCoordMatrix, 0, -1);
|
||||
|
||||
this.image_ = image;
|
||||
this.texture = texture;
|
||||
@@ -197,20 +196,18 @@ ol.renderer.webgl.ImageLayer.prototype.updateProjectionMatrix_ = function(canvas
|
||||
var canvasExtentHeight = canvasHeight * viewResolution;
|
||||
|
||||
var projectionMatrix = this.projectionMatrix;
|
||||
goog.vec.Mat4.makeIdentity(projectionMatrix);
|
||||
goog.vec.Mat4.scale(projectionMatrix,
|
||||
ol.matrix.makeIdentity(projectionMatrix);
|
||||
ol.matrix.scale(projectionMatrix,
|
||||
pixelRatio * 2 / canvasExtentWidth,
|
||||
pixelRatio * 2 / canvasExtentHeight, 1);
|
||||
goog.vec.Mat4.rotateZ(projectionMatrix, -viewRotation);
|
||||
goog.vec.Mat4.translate(projectionMatrix,
|
||||
pixelRatio * 2 / canvasExtentHeight);
|
||||
ol.matrix.rotate(projectionMatrix, -viewRotation);
|
||||
ol.matrix.translate(projectionMatrix,
|
||||
imageExtent[0] - viewCenter[0],
|
||||
imageExtent[1] - viewCenter[1],
|
||||
0);
|
||||
goog.vec.Mat4.scale(projectionMatrix,
|
||||
imageExtent[1] - viewCenter[1]);
|
||||
ol.matrix.scale(projectionMatrix,
|
||||
(imageExtent[2] - imageExtent[0]) / 2,
|
||||
(imageExtent[3] - imageExtent[1]) / 2,
|
||||
1);
|
||||
goog.vec.Mat4.translate(projectionMatrix, 1, 1, 0);
|
||||
(imageExtent[3] - imageExtent[1]) / 2);
|
||||
ol.matrix.translate(projectionMatrix, 1, 1);
|
||||
|
||||
};
|
||||
|
||||
@@ -237,7 +234,7 @@ ol.renderer.webgl.ImageLayer.prototype.forEachLayerAtPixel = function(pixel, fra
|
||||
// for ImageVector sources use the original hit-detection logic,
|
||||
// so that for example also transparent polygons are detected
|
||||
var coordinate = pixel.slice();
|
||||
ol.vec.Mat4.multVec2(
|
||||
ol.matrix.multVec2(
|
||||
frameState.pixelToCoordinateMatrix, coordinate, coordinate);
|
||||
var hasFeature = this.forEachFeatureAtCoordinate(
|
||||
coordinate, frameState, ol.functions.TRUE, this);
|
||||
@@ -257,7 +254,7 @@ ol.renderer.webgl.ImageLayer.prototype.forEachLayerAtPixel = function(pixel, fra
|
||||
}
|
||||
|
||||
var pixelOnFrameBuffer = [0, 0];
|
||||
ol.vec.Mat4.multVec2(
|
||||
ol.matrix.multVec2(
|
||||
this.hitTransformationMatrix_, pixel, pixelOnFrameBuffer);
|
||||
|
||||
if (pixelOnFrameBuffer[0] < 0 || pixelOnFrameBuffer[0] > imageSize[0] ||
|
||||
@@ -289,36 +286,34 @@ ol.renderer.webgl.ImageLayer.prototype.forEachLayerAtPixel = function(pixel, fra
|
||||
* pixel on the map.
|
||||
* @param {ol.Size} mapSize The map size.
|
||||
* @param {ol.Size} imageSize The image size.
|
||||
* @return {goog.vec.Mat4.Number} The transformation matrix.
|
||||
* @return {ol.Matrix} The transformation matrix.
|
||||
* @private
|
||||
*/
|
||||
ol.renderer.webgl.ImageLayer.prototype.getHitTransformationMatrix_ = function(mapSize, imageSize) {
|
||||
// the first matrix takes a map pixel, flips the y-axis and scales to
|
||||
// a range between -1 ... 1
|
||||
var mapCoordMatrix = goog.vec.Mat4.createNumber();
|
||||
goog.vec.Mat4.makeIdentity(mapCoordMatrix);
|
||||
goog.vec.Mat4.translate(mapCoordMatrix, -1, -1, 0);
|
||||
goog.vec.Mat4.scale(mapCoordMatrix, 2 / mapSize[0], 2 / mapSize[1], 1);
|
||||
goog.vec.Mat4.translate(mapCoordMatrix, 0, mapSize[1], 0);
|
||||
goog.vec.Mat4.scale(mapCoordMatrix, 1, -1, 1);
|
||||
var mapCoordMatrix = ol.matrix.create();
|
||||
ol.matrix.translate(mapCoordMatrix, -1, -1);
|
||||
ol.matrix.scale(mapCoordMatrix, 2 / mapSize[0], 2 / mapSize[1]);
|
||||
ol.matrix.translate(mapCoordMatrix, 0, mapSize[1]);
|
||||
ol.matrix.scale(mapCoordMatrix, 1, -1);
|
||||
|
||||
// the second matrix is the inverse of the projection matrix used in the
|
||||
// shader for drawing
|
||||
var projectionMatrixInv = goog.vec.Mat4.createNumber();
|
||||
goog.vec.Mat4.invert(this.projectionMatrix, projectionMatrixInv);
|
||||
var projectionMatrixInv = ol.matrix.create();
|
||||
ol.matrix.invert(this.projectionMatrix, projectionMatrixInv);
|
||||
|
||||
// the third matrix scales to the image dimensions and flips the y-axis again
|
||||
var imageCoordMatrix = goog.vec.Mat4.createNumber();
|
||||
goog.vec.Mat4.makeIdentity(imageCoordMatrix);
|
||||
goog.vec.Mat4.translate(imageCoordMatrix, 0, imageSize[1], 0);
|
||||
goog.vec.Mat4.scale(imageCoordMatrix, 1, -1, 1);
|
||||
goog.vec.Mat4.scale(imageCoordMatrix, imageSize[0] / 2, imageSize[1] / 2, 1);
|
||||
goog.vec.Mat4.translate(imageCoordMatrix, 1, 1, 0);
|
||||
var imageCoordMatrix = ol.matrix.create();
|
||||
ol.matrix.translate(imageCoordMatrix, 0, imageSize[1]);
|
||||
ol.matrix.scale(imageCoordMatrix, 1, -1);
|
||||
ol.matrix.scale(imageCoordMatrix, imageSize[0] / 2, imageSize[1] / 2);
|
||||
ol.matrix.translate(imageCoordMatrix, 1, 1);
|
||||
|
||||
var transformMatrix = goog.vec.Mat4.createNumber();
|
||||
goog.vec.Mat4.multMat(
|
||||
var transformMatrix = ol.matrix.create();
|
||||
ol.matrix.multiply(
|
||||
imageCoordMatrix, projectionMatrixInv, transformMatrix);
|
||||
goog.vec.Mat4.multMat(
|
||||
ol.matrix.multiply(
|
||||
transformMatrix, mapCoordMatrix, transformMatrix);
|
||||
|
||||
return transformMatrix;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
goog.provide('ol.renderer.webgl.Layer');
|
||||
|
||||
goog.require('goog.vec.Mat4');
|
||||
goog.require('goog.webgl');
|
||||
goog.require('ol.layer.Layer');
|
||||
goog.require('ol.matrix');
|
||||
goog.require('ol.render.Event');
|
||||
goog.require('ol.render.EventType');
|
||||
goog.require('ol.render.webgl.Immediate');
|
||||
@@ -11,6 +11,7 @@ goog.require('ol.renderer.webgl.map.shader.Default');
|
||||
goog.require('ol.renderer.webgl.map.shader.Default.Locations');
|
||||
goog.require('ol.renderer.webgl.map.shader.DefaultFragment');
|
||||
goog.require('ol.renderer.webgl.map.shader.DefaultVertex');
|
||||
goog.require('ol.vec.Mat4');
|
||||
goog.require('ol.webgl.Buffer');
|
||||
goog.require('ol.webgl.Context');
|
||||
|
||||
@@ -62,15 +63,15 @@ ol.renderer.webgl.Layer = function(mapRenderer, layer) {
|
||||
|
||||
/**
|
||||
* @protected
|
||||
* @type {!goog.vec.Mat4.Number}
|
||||
* @type {ol.Matrix}
|
||||
*/
|
||||
this.texCoordMatrix = goog.vec.Mat4.createNumber();
|
||||
this.texCoordMatrix = ol.matrix.create();
|
||||
|
||||
/**
|
||||
* @protected
|
||||
* @type {!goog.vec.Mat4.Number}
|
||||
* @type {ol.Matrix}
|
||||
*/
|
||||
this.projectionMatrix = goog.vec.Mat4.createNumberIdentity();
|
||||
this.projectionMatrix = ol.matrix.create();
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -167,10 +168,10 @@ ol.renderer.webgl.Layer.prototype.composeFrame = function(frameState, layerState
|
||||
gl.uniform1i(locations.u_texture, 0);
|
||||
}
|
||||
|
||||
gl.uniformMatrix4fv(
|
||||
locations.u_texCoordMatrix, false, this.getTexCoordMatrix());
|
||||
gl.uniformMatrix4fv(locations.u_texCoordMatrix, false,
|
||||
ol.vec.Mat4.fromMatrix(this.getTexCoordMatrix()));
|
||||
gl.uniformMatrix4fv(locations.u_projectionMatrix, false,
|
||||
this.getProjectionMatrix());
|
||||
ol.vec.Mat4.fromMatrix(this.getProjectionMatrix()));
|
||||
gl.uniform1f(locations.u_opacity, layerState.opacity);
|
||||
gl.bindTexture(goog.webgl.TEXTURE_2D, this.getTexture());
|
||||
gl.drawArrays(goog.webgl.TRIANGLE_STRIP, 0, 4);
|
||||
@@ -208,7 +209,7 @@ ol.renderer.webgl.Layer.prototype.dispatchComposeEvent_ = function(type, context
|
||||
|
||||
|
||||
/**
|
||||
* @return {!goog.vec.Mat4.Number} Matrix.
|
||||
* @return {!ol.Matrix} Matrix.
|
||||
*/
|
||||
ol.renderer.webgl.Layer.prototype.getTexCoordMatrix = function() {
|
||||
return this.texCoordMatrix;
|
||||
@@ -224,7 +225,7 @@ ol.renderer.webgl.Layer.prototype.getTexture = function() {
|
||||
|
||||
|
||||
/**
|
||||
* @return {!goog.vec.Mat4.Number} Matrix.
|
||||
* @return {!ol.Matrix} Matrix.
|
||||
*/
|
||||
ol.renderer.webgl.Layer.prototype.getProjectionMatrix = function() {
|
||||
return this.projectionMatrix;
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
goog.provide('ol.renderer.webgl.TileLayer');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('goog.vec.Mat4');
|
||||
goog.require('goog.vec.Vec4');
|
||||
goog.require('ol.matrix');
|
||||
goog.require('goog.webgl');
|
||||
goog.require('ol.TileRange');
|
||||
goog.require('ol.TileState');
|
||||
@@ -18,7 +17,6 @@ goog.require('ol.renderer.webgl.tilelayer.shader.Fragment');
|
||||
goog.require('ol.renderer.webgl.tilelayer.shader.Locations');
|
||||
goog.require('ol.renderer.webgl.tilelayer.shader.Vertex');
|
||||
goog.require('ol.size');
|
||||
goog.require('ol.vec.Mat4');
|
||||
goog.require('ol.webgl.Buffer');
|
||||
|
||||
|
||||
@@ -294,22 +292,21 @@ ol.renderer.webgl.TileLayer.prototype.prepareFrame = function(frameState, layerS
|
||||
/** @type {Array.<number>} */
|
||||
var zs = Object.keys(tilesToDrawByZ).map(Number);
|
||||
zs.sort(ol.array.numberSafeCompareFunction);
|
||||
var u_tileOffset = goog.vec.Vec4.createFloat32();
|
||||
var i, ii, sx, sy, tileKey, tilesToDraw, tx, ty;
|
||||
var u_tileOffset = new Float32Array(4);
|
||||
var i, ii, tileKey, tilesToDraw;
|
||||
for (i = 0, ii = zs.length; i < ii; ++i) {
|
||||
tilesToDraw = tilesToDrawByZ[zs[i]];
|
||||
for (tileKey in tilesToDraw) {
|
||||
tile = tilesToDraw[tileKey];
|
||||
tileExtent = tileGrid.getTileCoordExtent(tile.tileCoord, tmpExtent);
|
||||
sx = 2 * (tileExtent[2] - tileExtent[0]) /
|
||||
u_tileOffset[0] = 2 * (tileExtent[2] - tileExtent[0]) /
|
||||
framebufferExtentDimension;
|
||||
sy = 2 * (tileExtent[3] - tileExtent[1]) /
|
||||
u_tileOffset[1] = 2 * (tileExtent[3] - tileExtent[1]) /
|
||||
framebufferExtentDimension;
|
||||
tx = 2 * (tileExtent[0] - framebufferExtent[0]) /
|
||||
u_tileOffset[2] = 2 * (tileExtent[0] - framebufferExtent[0]) /
|
||||
framebufferExtentDimension - 1;
|
||||
ty = 2 * (tileExtent[1] - framebufferExtent[1]) /
|
||||
u_tileOffset[3] = 2 * (tileExtent[1] - framebufferExtent[1]) /
|
||||
framebufferExtentDimension - 1;
|
||||
goog.vec.Vec4.setFromValues(u_tileOffset, sx, sy, tx, ty);
|
||||
gl.uniform4fv(this.locations_.u_tileOffset, u_tileOffset);
|
||||
mapRenderer.bindTileTexture(tile, tilePixelSize,
|
||||
tileGutter * pixelRatio, goog.webgl.LINEAR, goog.webgl.LINEAR);
|
||||
@@ -354,26 +351,21 @@ ol.renderer.webgl.TileLayer.prototype.prepareFrame = function(frameState, layerS
|
||||
this.updateLogos(frameState, tileSource);
|
||||
|
||||
var texCoordMatrix = this.texCoordMatrix;
|
||||
goog.vec.Mat4.makeIdentity(texCoordMatrix);
|
||||
goog.vec.Mat4.translate(texCoordMatrix,
|
||||
ol.matrix.makeIdentity(texCoordMatrix);
|
||||
ol.matrix.translate(texCoordMatrix,
|
||||
(center[0] - framebufferExtent[0]) /
|
||||
(framebufferExtent[2] - framebufferExtent[0]),
|
||||
(center[1] - framebufferExtent[1]) /
|
||||
(framebufferExtent[3] - framebufferExtent[1]),
|
||||
0);
|
||||
(framebufferExtent[3] - framebufferExtent[1]));
|
||||
if (viewState.rotation !== 0) {
|
||||
goog.vec.Mat4.rotateZ(texCoordMatrix, viewState.rotation);
|
||||
ol.matrix.rotate(texCoordMatrix, viewState.rotation);
|
||||
}
|
||||
goog.vec.Mat4.scale(texCoordMatrix,
|
||||
ol.matrix.scale(texCoordMatrix,
|
||||
frameState.size[0] * viewState.resolution /
|
||||
(framebufferExtent[2] - framebufferExtent[0]),
|
||||
frameState.size[1] * viewState.resolution /
|
||||
(framebufferExtent[3] - framebufferExtent[1]),
|
||||
1);
|
||||
goog.vec.Mat4.translate(texCoordMatrix,
|
||||
-0.5,
|
||||
-0.5,
|
||||
0);
|
||||
(framebufferExtent[3] - framebufferExtent[1]));
|
||||
ol.matrix.translate(texCoordMatrix, -0.5, -0.5);
|
||||
|
||||
return true;
|
||||
};
|
||||
@@ -392,7 +384,7 @@ ol.renderer.webgl.TileLayer.prototype.forEachLayerAtPixel = function(pixel, fram
|
||||
(frameState.size[1] - pixel[1]) / frameState.size[1]];
|
||||
|
||||
var pixelOnFrameBufferScaled = [0, 0];
|
||||
ol.vec.Mat4.multVec2(
|
||||
ol.matrix.multVec2(
|
||||
this.texCoordMatrix, pixelOnMapScaled, pixelOnFrameBufferScaled);
|
||||
var pixelOnFrameBuffer = [
|
||||
pixelOnFrameBufferScaled[0] * this.framebufferDimension,
|
||||
|
||||
@@ -5,10 +5,10 @@ goog.require('ol.events');
|
||||
goog.require('ol.ViewHint');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.layer.Vector');
|
||||
goog.require('ol.matrix');
|
||||
goog.require('ol.render.webgl.ReplayGroup');
|
||||
goog.require('ol.renderer.vector');
|
||||
goog.require('ol.renderer.webgl.Layer');
|
||||
goog.require('ol.vec.Mat4');
|
||||
|
||||
|
||||
/**
|
||||
@@ -155,7 +155,7 @@ ol.renderer.webgl.VectorLayer.prototype.hasFeatureAtCoordinate = function(coordi
|
||||
*/
|
||||
ol.renderer.webgl.VectorLayer.prototype.forEachLayerAtPixel = function(pixel, frameState, callback, thisArg) {
|
||||
var coordinate = pixel.slice();
|
||||
ol.vec.Mat4.multVec2(
|
||||
ol.matrix.multVec2(
|
||||
frameState.pixelToCoordinateMatrix, coordinate, coordinate);
|
||||
var hasFeature = this.hasFeatureAtCoordinate(coordinate, frameState);
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ goog.provide('ol.source.ImageVector');
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.events');
|
||||
goog.require('ol.events.EventType');
|
||||
goog.require('goog.vec.Mat4');
|
||||
goog.require('ol.matrix');
|
||||
goog.require('ol.dom');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.render.canvas.ReplayGroup');
|
||||
@@ -11,7 +11,6 @@ goog.require('ol.renderer.vector');
|
||||
goog.require('ol.source.ImageCanvas');
|
||||
goog.require('ol.source.Vector');
|
||||
goog.require('ol.style.Style');
|
||||
goog.require('ol.vec.Mat4');
|
||||
|
||||
|
||||
/**
|
||||
@@ -41,9 +40,9 @@ ol.source.ImageVector = function(options) {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {!goog.vec.Mat4.Number}
|
||||
* @type {ol.Matrix}
|
||||
*/
|
||||
this.transform_ = goog.vec.Mat4.createNumber();
|
||||
this.transform_ = ol.matrix.create();
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -212,11 +211,11 @@ ol.source.ImageVector.prototype.getStyleFunction = function() {
|
||||
* @param {number} resolution Resolution.
|
||||
* @param {number} pixelRatio Pixel ratio.
|
||||
* @param {ol.Size} size Size.
|
||||
* @return {!goog.vec.Mat4.Number} Transform.
|
||||
* @return {!ol.Matrix} Transform.
|
||||
* @private
|
||||
*/
|
||||
ol.source.ImageVector.prototype.getTransform_ = function(center, resolution, pixelRatio, size) {
|
||||
return ol.vec.Mat4.makeTransform2D(this.transform_,
|
||||
return ol.matrix.makeTransform(this.transform_,
|
||||
size[0] / 2, size[1] / 2,
|
||||
pixelRatio / resolution, -pixelRatio / resolution,
|
||||
0,
|
||||
|
||||
@@ -4,7 +4,7 @@ goog.provide('ol.source.RasterEvent');
|
||||
goog.provide('ol.source.RasterEventType');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('goog.vec.Mat4');
|
||||
goog.require('ol.matrix');
|
||||
goog.require('ol.ImageCanvas');
|
||||
goog.require('ol.TileQueue');
|
||||
goog.require('ol.dom');
|
||||
@@ -120,7 +120,7 @@ ol.source.Raster = function(options) {
|
||||
this.frameState_ = {
|
||||
animate: false,
|
||||
attributions: {},
|
||||
coordinateToPixelMatrix: goog.vec.Mat4.createNumber(),
|
||||
coordinateToPixelMatrix: ol.matrix.create(),
|
||||
extent: null,
|
||||
focus: null,
|
||||
index: 0,
|
||||
@@ -128,7 +128,7 @@ ol.source.Raster = function(options) {
|
||||
layerStatesArray: layerStatesArray,
|
||||
logos: {},
|
||||
pixelRatio: 1,
|
||||
pixelToCoordinateMatrix: goog.vec.Mat4.createNumber(),
|
||||
pixelToCoordinateMatrix: ol.matrix.create(),
|
||||
postRenderFunctions: [],
|
||||
size: [0, 0],
|
||||
skippedFeatureUids: {},
|
||||
|
||||
@@ -329,6 +329,14 @@ ol.LRUCacheEntry;
|
||||
ol.MapOptionsInternal;
|
||||
|
||||
|
||||
/**
|
||||
* An array representing a matrix for use in {@link ol.matrix}. The array has
|
||||
* 6 elements, and the element order is `[a, b, c, d, e, f]`.
|
||||
* @typedef {Array.<number>}
|
||||
*/
|
||||
ol.Matrix;
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {{depth: (Array.<number>|undefined),
|
||||
* feature: ol.Feature,
|
||||
|
||||
@@ -1,90 +1,23 @@
|
||||
goog.provide('ol.vec.Mat4');
|
||||
goog.provide('ol.vec.Mat4.Number');
|
||||
|
||||
goog.require('goog.vec.Mat4');
|
||||
|
||||
|
||||
/**
|
||||
* A alias for the goog.vec.Number type.
|
||||
* @typedef {goog.vec.Number}
|
||||
* @type {Array.<number>}
|
||||
*/
|
||||
ol.vec.Mat4.Number;
|
||||
ol.vec.Mat4.tmpMatrix_ = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
|
||||
|
||||
|
||||
/**
|
||||
* @param {!goog.vec.Mat4.Number} mat Matrix.
|
||||
* @param {number} translateX1 Translate X1.
|
||||
* @param {number} translateY1 Translate Y1.
|
||||
* @param {number} scaleX Scale X.
|
||||
* @param {number} scaleY Scale Y.
|
||||
* @param {number} rotation Rotation.
|
||||
* @param {number} translateX2 Translate X2.
|
||||
* @param {number} translateY2 Translate Y2.
|
||||
* @return {!goog.vec.Mat4.Number} Matrix.
|
||||
* @param {ol.Matrix} mat Transformation matrix.
|
||||
* @return {Array.<number>} 2D transformation matrix as flattened 4x4 matrix.
|
||||
*/
|
||||
ol.vec.Mat4.makeTransform2D = function(mat, translateX1, translateY1,
|
||||
scaleX, scaleY, rotation, translateX2, translateY2) {
|
||||
goog.vec.Mat4.makeIdentity(mat);
|
||||
if (translateX1 !== 0 || translateY1 !== 0) {
|
||||
goog.vec.Mat4.translate(mat, translateX1, translateY1, 0);
|
||||
}
|
||||
if (scaleX != 1 || scaleY != 1) {
|
||||
goog.vec.Mat4.scale(mat, scaleX, scaleY, 1);
|
||||
}
|
||||
if (rotation !== 0) {
|
||||
goog.vec.Mat4.rotateZ(mat, rotation);
|
||||
}
|
||||
if (translateX2 !== 0 || translateY2 !== 0) {
|
||||
goog.vec.Mat4.translate(mat, translateX2, translateY2, 0);
|
||||
}
|
||||
return mat;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if mat1 and mat2 represent the same 2D transformation.
|
||||
* @param {goog.vec.Mat4.Number} mat1 Matrix 1.
|
||||
* @param {goog.vec.Mat4.Number} mat2 Matrix 2.
|
||||
* @return {boolean} Equal 2D.
|
||||
*/
|
||||
ol.vec.Mat4.equals2D = function(mat1, mat2) {
|
||||
return (
|
||||
goog.vec.Mat4.getElement(mat1, 0, 0) ==
|
||||
goog.vec.Mat4.getElement(mat2, 0, 0) &&
|
||||
goog.vec.Mat4.getElement(mat1, 1, 0) ==
|
||||
goog.vec.Mat4.getElement(mat2, 1, 0) &&
|
||||
goog.vec.Mat4.getElement(mat1, 0, 1) ==
|
||||
goog.vec.Mat4.getElement(mat2, 0, 1) &&
|
||||
goog.vec.Mat4.getElement(mat1, 1, 1) ==
|
||||
goog.vec.Mat4.getElement(mat2, 1, 1) &&
|
||||
goog.vec.Mat4.getElement(mat1, 0, 3) ==
|
||||
goog.vec.Mat4.getElement(mat2, 0, 3) &&
|
||||
goog.vec.Mat4.getElement(mat1, 1, 3) ==
|
||||
goog.vec.Mat4.getElement(mat2, 1, 3));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Transforms the given vector with the given matrix storing the resulting,
|
||||
* transformed vector into resultVec. The input vector is multiplied against the
|
||||
* upper 2x4 matrix omitting the projective component.
|
||||
*
|
||||
* @param {goog.vec.Mat4.Number} mat The matrix supplying the transformation.
|
||||
* @param {Array.<number>} vec The 3 element vector to transform.
|
||||
* @param {Array.<number>} resultVec The 3 element vector to receive the results
|
||||
* (may be vec).
|
||||
* @return {Array.<number>} return resultVec so that operations can be
|
||||
* chained together.
|
||||
*/
|
||||
ol.vec.Mat4.multVec2 = function(mat, vec, resultVec) {
|
||||
var m00 = goog.vec.Mat4.getElement(mat, 0, 0);
|
||||
var m10 = goog.vec.Mat4.getElement(mat, 1, 0);
|
||||
var m01 = goog.vec.Mat4.getElement(mat, 0, 1);
|
||||
var m11 = goog.vec.Mat4.getElement(mat, 1, 1);
|
||||
var m03 = goog.vec.Mat4.getElement(mat, 0, 3);
|
||||
var m13 = goog.vec.Mat4.getElement(mat, 1, 3);
|
||||
var x = vec[0], y = vec[1];
|
||||
resultVec[0] = m00 * x + m01 * y + m03;
|
||||
resultVec[1] = m10 * x + m11 * y + m13;
|
||||
return resultVec;
|
||||
ol.vec.Mat4.fromMatrix = function(mat) {
|
||||
var mat4 = ol.vec.Mat4.tmpMatrix_;
|
||||
mat4[0] = mat[0];
|
||||
mat4[1] = mat[1];
|
||||
mat4[4] = mat[2];
|
||||
mat4[5] = mat[3];
|
||||
mat4[12] = mat[4];
|
||||
mat4[13] = mat[5];
|
||||
return mat4;
|
||||
};
|
||||
|
||||
@@ -147,8 +147,8 @@ describe('ol.dom', function() {
|
||||
|
||||
describe('ol.dom.transformElement2D', function() {
|
||||
var element = null;
|
||||
var transform = goog.vec.Mat4.createNumber();
|
||||
var transformFloat = goog.vec.Mat4.createNumber();
|
||||
var transform = ol.matrix.create();
|
||||
var transformFloat = ol.matrix.create();
|
||||
transformFloat[0] = 0.12345;
|
||||
beforeEach(function() {
|
||||
element = document.createElement('div');
|
||||
@@ -564,5 +564,5 @@ describe('ol.dom', function() {
|
||||
});
|
||||
|
||||
goog.require('goog.userAgent');
|
||||
goog.require('goog.vec.Mat4');
|
||||
goog.require('ol.matrix');
|
||||
goog.require('ol.dom');
|
||||
|
||||
@@ -864,7 +864,6 @@ describe('ol.extent', function() {
|
||||
});
|
||||
|
||||
|
||||
goog.require('goog.vec.Mat4');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.extent.Corner');
|
||||
goog.require('ol.extent.Relationship');
|
||||
|
||||
@@ -23,9 +23,11 @@ describe('ol.geom.flat.transform', function() {
|
||||
[-82.128838, 26.693342, 0],
|
||||
[-82.102127, 26.585724, 0]]]
|
||||
]).transform('EPSG:4326', 'EPSG:3857');
|
||||
var transform = [0.0004088332670837288, 0, 0, 0, 0,
|
||||
-0.0004088332670837288, 0, 0, 0, 0, 1, 0, 4480.991370439071,
|
||||
1529.5752568707105, 0, 1];
|
||||
var transform = [
|
||||
0.0004088332670837288, 0,
|
||||
0, -0.0004088332670837288,
|
||||
4480.991370439071, 1529.5752568707105
|
||||
];
|
||||
var pixelCoordinates = ol.geom.transformSimpleGeometry2D(
|
||||
multiPolygonGeometry, transform, []);
|
||||
expect(pixelCoordinates[0]).to.roughlyEqual(806.6035275946265, 1e-9);
|
||||
|
||||
@@ -22,16 +22,16 @@ describe('ol.render', function() {
|
||||
[0, 0, size[0] * pixelRatio, size[1] * pixelRatio]);
|
||||
expect(canvas.style.width).to.be(size[0] + 'px');
|
||||
expect(canvas.style.height).to.be(size[1] + 'px');
|
||||
var transform = ol.vec.Mat4.makeTransform2D(goog.vec.Mat4.createNumber(),
|
||||
var transform = ol.matrix.makeTransform(ol.matrix.create(),
|
||||
0, 0, pixelRatio, pixelRatio, 0, 0, 0);
|
||||
expect(ol.vec.Mat4.equals2D(render.transform_, transform)).to.be.ok();
|
||||
expect(ol.matrix.equals(render.transform_, transform)).to.be.ok();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
goog.require('goog.vec.Mat4');
|
||||
goog.require('ol.matrix');
|
||||
goog.require('ol.render');
|
||||
goog.require('ol.render.canvas.Immediate');
|
||||
goog.require('ol.vec.Mat4');
|
||||
|
||||
@@ -198,10 +198,9 @@ describe('ol.render.canvas.Immediate', function() {
|
||||
};
|
||||
|
||||
var transform = [
|
||||
0.0004088332670837288, 0, 0, 0,
|
||||
0, -0.0004088332670837288, 0, 0,
|
||||
0, 0, 1, 0,
|
||||
4480.991370439071, 1529.5752568707105, 0, 1
|
||||
0.0004088332670837288, 0,
|
||||
0, -0.0004088332670837288,
|
||||
4480.991370439071, 1529.5752568707105
|
||||
];
|
||||
|
||||
var extent = [
|
||||
|
||||
@@ -23,11 +23,11 @@ describe('ol.renderer.canvas.Layer', function() {
|
||||
},
|
||||
size: [10, 10],
|
||||
pixelRatio: 1,
|
||||
coordinateToPixelMatrix: goog.vec.Mat4.createNumber(),
|
||||
pixelToCoordinateMatrix: goog.vec.Mat4.createNumber()
|
||||
coordinateToPixelMatrix: ol.matrix.create(),
|
||||
pixelToCoordinateMatrix: ol.matrix.create()
|
||||
};
|
||||
renderer.getImageTransform = function() {
|
||||
return goog.vec.Mat4.createNumberIdentity();
|
||||
return ol.matrix.create();
|
||||
};
|
||||
ol.renderer.Map.prototype.calculateMatrices2D(frameState);
|
||||
var layerState = layer.getLayerState();
|
||||
@@ -62,7 +62,7 @@ describe('ol.renderer.canvas.Layer', function() {
|
||||
|
||||
|
||||
goog.require('ol.render.canvas');
|
||||
goog.require('goog.vec.Mat4');
|
||||
goog.require('ol.matrix');
|
||||
goog.require('ol.layer.Image');
|
||||
goog.require('ol.renderer.Map');
|
||||
goog.require('ol.renderer.canvas.Layer');
|
||||
|
||||
@@ -49,39 +49,32 @@ describe('ol.renderer.webgl.ImageLayer', function() {
|
||||
pixelRatio, viewCenter, viewResolution, viewRotation, imageExtent);
|
||||
var matrix = renderer.getProjectionMatrix();
|
||||
|
||||
var input;
|
||||
var output = goog.vec.Vec4.createNumber();
|
||||
var output = ol.matrix.create();
|
||||
|
||||
input = goog.vec.Vec4.createFromValues(-1, -1, 0, 1);
|
||||
goog.vec.Mat4.multVec4(matrix, input, output);
|
||||
ol.matrix.multVec2(matrix, [-1, -1], output);
|
||||
expect(output[0]).to.eql(-6);
|
||||
expect(output[1]).to.eql(-6);
|
||||
|
||||
input = goog.vec.Vec4.createFromValues(1, -1, 0, 1);
|
||||
goog.vec.Mat4.multVec4(matrix, input, output);
|
||||
ol.matrix.multVec2(matrix, [1, -1], output);
|
||||
expect(output[0]).to.eql(2);
|
||||
expect(output[1]).to.eql(-6);
|
||||
|
||||
input = goog.vec.Vec4.createFromValues(-1, 1, 0, 1);
|
||||
goog.vec.Mat4.multVec4(matrix, input, output);
|
||||
ol.matrix.multVec2(matrix, [-1, 1], output);
|
||||
expect(output[0]).to.eql(-6);
|
||||
expect(output[1]).to.eql(6);
|
||||
|
||||
input = goog.vec.Vec4.createFromValues(1, 1, 0, 1);
|
||||
goog.vec.Mat4.multVec4(matrix, input, output);
|
||||
ol.matrix.multVec2(matrix, [1, 1], output);
|
||||
expect(output[0]).to.eql(2);
|
||||
expect(output[1]).to.eql(6);
|
||||
|
||||
input = goog.vec.Vec4.createFromValues(0, 0, 0, 1);
|
||||
goog.vec.Mat4.multVec4(matrix, input, output);
|
||||
ol.matrix.multVec2(matrix, [0, 0], output);
|
||||
expect(output[0]).to.eql(-2);
|
||||
expect(output[1]).to.eql(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
goog.require('goog.vec.Mat4');
|
||||
goog.require('goog.vec.Vec4');
|
||||
goog.require('ol.matrix');
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.proj.common');
|
||||
goog.require('ol.layer.Image');
|
||||
|
||||
Reference in New Issue
Block a user