Refactor to a more convenient internal API
This commit is contained in:
@@ -2,7 +2,7 @@ goog.provide('ol.RendererType');
|
||||
goog.provide('ol.renderer.Map');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.matrix');
|
||||
goog.require('ol.transform');
|
||||
goog.require('ol');
|
||||
goog.require('ol.Disposable');
|
||||
goog.require('ol.events');
|
||||
@@ -65,17 +65,19 @@ ol.inherits(ol.renderer.Map, ol.Disposable);
|
||||
*/
|
||||
ol.renderer.Map.prototype.calculateMatrices2D = function(frameState) {
|
||||
var viewState = frameState.viewState;
|
||||
var coordinateToPixelMatrix = frameState.coordinateToPixelMatrix;
|
||||
goog.asserts.assert(coordinateToPixelMatrix,
|
||||
'frameState has a coordinateToPixelMatrix');
|
||||
ol.matrix.makeTransform(coordinateToPixelMatrix,
|
||||
frameState.size[0] / 2, frameState.size[1] / 2,
|
||||
1 / viewState.resolution, -1 / viewState.resolution,
|
||||
-viewState.rotation,
|
||||
var coordinateToPixelTransform = frameState.coordinateToPixelTransform;
|
||||
var pixelToCoordinateTransform = frameState.pixelToCoordinateTransform;
|
||||
goog.asserts.assert(coordinateToPixelTransform,
|
||||
'frameState has a coordinateToPixelTransform');
|
||||
ol.transform.translate(ol.transform.reset(coordinateToPixelTransform),
|
||||
frameState.size[0] / 2, frameState.size[1] / 2);
|
||||
ol.transform.scale(coordinateToPixelTransform,
|
||||
1 / viewState.resolution, -1 / viewState.resolution);
|
||||
ol.transform.rotate(coordinateToPixelTransform, -viewState.rotation);
|
||||
ol.transform.translate(coordinateToPixelTransform,
|
||||
-viewState.center[0], -viewState.center[1]);
|
||||
var inverted = ol.matrix.invert(
|
||||
coordinateToPixelMatrix, frameState.pixelToCoordinateMatrix);
|
||||
goog.asserts.assert(inverted, 'matrix could be inverted');
|
||||
ol.transform.invert(
|
||||
ol.transform.setFromArray(pixelToCoordinateTransform, coordinateToPixelTransform));
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user