Create ol.Size around goog.math.Size
This commit is contained in:
@@ -15,7 +15,6 @@ goog.require('goog.events.MouseWheelHandler');
|
|||||||
goog.require('goog.events.MouseWheelHandler.EventType');
|
goog.require('goog.events.MouseWheelHandler.EventType');
|
||||||
goog.require('goog.fx.anim');
|
goog.require('goog.fx.anim');
|
||||||
goog.require('goog.fx.anim.Animated');
|
goog.require('goog.fx.anim.Animated');
|
||||||
goog.require('goog.math.Size');
|
|
||||||
goog.require('goog.object');
|
goog.require('goog.object');
|
||||||
goog.require('ol.Array');
|
goog.require('ol.Array');
|
||||||
goog.require('ol.Control');
|
goog.require('ol.Control');
|
||||||
@@ -24,6 +23,7 @@ goog.require('ol.Extent');
|
|||||||
goog.require('ol.LayerRenderer');
|
goog.require('ol.LayerRenderer');
|
||||||
goog.require('ol.Object');
|
goog.require('ol.Object');
|
||||||
goog.require('ol.Projection');
|
goog.require('ol.Projection');
|
||||||
|
goog.require('ol.Size');
|
||||||
goog.require('ol.TransformFunction');
|
goog.require('ol.TransformFunction');
|
||||||
|
|
||||||
|
|
||||||
@@ -372,11 +372,10 @@ ol.Map.prototype.getResolutionForExtent = function(extent) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {goog.math.Size|undefined} Size.
|
* @return {ol.Size|undefined} Size.
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.getSize = function() {
|
ol.Map.prototype.getSize = function() {
|
||||||
return /** @type {goog.math.Size|undefined} */ (
|
return /** @type {ol.Size|undefined} */ this.get(ol.MapProperty.SIZE);
|
||||||
this.get(ol.MapProperty.SIZE));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -573,8 +572,7 @@ ol.Map.prototype.handleUserProjectionChanged = function() {
|
|||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.handleViewportResize = function() {
|
ol.Map.prototype.handleViewportResize = function() {
|
||||||
var size = new goog.math.Size(
|
var size = new ol.Size(this.target_.clientWidth, this.target_.clientHeight);
|
||||||
this.target_.clientWidth, this.target_.clientHeight);
|
|
||||||
this.setSize(size);
|
this.setSize(size);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -725,11 +723,11 @@ ol.Map.prototype.setResolution = function(resolution) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {goog.math.Size} size Size.
|
* @param {ol.Size} size Size.
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.setSize = function(size) {
|
ol.Map.prototype.setSize = function(size) {
|
||||||
var currentSize = this.getSize();
|
var currentSize = this.getSize();
|
||||||
if (!goog.isDef(currentSize) || !goog.math.Size.equals(size, currentSize)) {
|
if (!goog.isDef(currentSize) || !currentSize.equals(size)) {
|
||||||
this.set(ol.MapProperty.SIZE, size);
|
this.set(ol.MapProperty.SIZE, size);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
goog.provide('ol.Rectangle');
|
goog.provide('ol.Rectangle');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
goog.require('goog.asserts');
|
||||||
goog.require('goog.math.Size');
|
|
||||||
goog.require('ol.Coordinate');
|
goog.require('ol.Coordinate');
|
||||||
|
goog.require('ol.Size');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -90,10 +90,10 @@ ol.Rectangle.prototype.getHeight = function() {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {goog.math.Size} Size.
|
* @return {ol.Size} Size.
|
||||||
*/
|
*/
|
||||||
ol.Rectangle.prototype.getSize = function() {
|
ol.Rectangle.prototype.getSize = function() {
|
||||||
return new goog.math.Size(this.getWidth(), this.getHeight());
|
return new ol.Size(this.getWidth(), this.getHeight());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
25
src/ol/size.js
Normal file
25
src/ol/size.js
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
goog.provide('ol.Size');
|
||||||
|
|
||||||
|
goog.require('goog.math.Size');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
* @extends {goog.math.Size}
|
||||||
|
* @param {number} width Width.
|
||||||
|
* @param {number} height Height.
|
||||||
|
*/
|
||||||
|
ol.Size = function(width, height) {
|
||||||
|
goog.base(this, width, height);
|
||||||
|
};
|
||||||
|
goog.inherits(ol.Size, goog.math.Size);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {ol.Size} size Size.
|
||||||
|
* @return {boolean} Equals.
|
||||||
|
*/
|
||||||
|
ol.Size.prototype.equals = function(size) {
|
||||||
|
return this.width == size.width && this.height == size.height;
|
||||||
|
};
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
goog.provide('ol.TileBounds');
|
goog.provide('ol.TileBounds');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
goog.require('goog.asserts');
|
||||||
goog.require('goog.math.Size');
|
|
||||||
goog.require('ol.Rectangle');
|
goog.require('ol.Rectangle');
|
||||||
goog.require('ol.TileCoord');
|
goog.require('ol.TileCoord');
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
goog.provide('ol.tilegrid.createOpenStreetMap');
|
goog.provide('ol.tilegrid.createOpenStreetMap');
|
||||||
|
|
||||||
goog.require('goog.math.Size');
|
|
||||||
goog.require('ol.Coordinate');
|
goog.require('ol.Coordinate');
|
||||||
goog.require('ol.Projection');
|
goog.require('ol.Projection');
|
||||||
|
goog.require('ol.Size');
|
||||||
goog.require('ol.TileGrid');
|
goog.require('ol.TileGrid');
|
||||||
|
|
||||||
|
|
||||||
@@ -21,7 +21,7 @@ ol.tilegrid.createOpenStreetMap = function(maxZoom) {
|
|||||||
var extent = ol.Projection.EPSG_3857_EXTENT;
|
var extent = ol.Projection.EPSG_3857_EXTENT;
|
||||||
var origin = new ol.Coordinate(
|
var origin = new ol.Coordinate(
|
||||||
-ol.Projection.EPSG_3857_HALF_SIZE, ol.Projection.EPSG_3857_HALF_SIZE);
|
-ol.Projection.EPSG_3857_HALF_SIZE, ol.Projection.EPSG_3857_HALF_SIZE);
|
||||||
var tileSize = new goog.math.Size(256, 256);
|
var tileSize = new ol.Size(256, 256);
|
||||||
|
|
||||||
return new ol.TileGrid(resolutions, extent, origin, tileSize);
|
return new ol.TileGrid(resolutions, extent, origin, tileSize);
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ goog.provide('ol.TileGrid');
|
|||||||
|
|
||||||
goog.require('goog.array');
|
goog.require('goog.array');
|
||||||
goog.require('goog.asserts');
|
goog.require('goog.asserts');
|
||||||
goog.require('goog.math.Size');
|
|
||||||
goog.require('ol.Coordinate');
|
goog.require('ol.Coordinate');
|
||||||
goog.require('ol.Extent');
|
goog.require('ol.Extent');
|
||||||
|
goog.require('ol.Size');
|
||||||
goog.require('ol.TileBounds');
|
goog.require('ol.TileBounds');
|
||||||
goog.require('ol.TileCoord');
|
goog.require('ol.TileCoord');
|
||||||
|
|
||||||
@@ -15,7 +15,7 @@ goog.require('ol.TileCoord');
|
|||||||
* @param {!Array.<number>} resolutions Resolutions.
|
* @param {!Array.<number>} resolutions Resolutions.
|
||||||
* @param {ol.Extent} extent Extent.
|
* @param {ol.Extent} extent Extent.
|
||||||
* @param {ol.Coordinate|!Array.<ol.Coordinate>} origin Origin.
|
* @param {ol.Coordinate|!Array.<ol.Coordinate>} origin Origin.
|
||||||
* @param {goog.math.Size=} opt_tileSize Tile size.
|
* @param {ol.Size=} opt_tileSize Tile size.
|
||||||
*/
|
*/
|
||||||
ol.TileGrid = function(resolutions, extent, origin, opt_tileSize) {
|
ol.TileGrid = function(resolutions, extent, origin, opt_tileSize) {
|
||||||
|
|
||||||
@@ -63,10 +63,10 @@ ol.TileGrid = function(resolutions, extent, origin, opt_tileSize) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {goog.math.Size}
|
* @type {ol.Size}
|
||||||
*/
|
*/
|
||||||
this.tileSize_ = goog.isDef(opt_tileSize) ?
|
this.tileSize_ = goog.isDef(opt_tileSize) ?
|
||||||
opt_tileSize : new goog.math.Size(256, 256);
|
opt_tileSize : new ol.Size(256, 256);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -214,7 +214,7 @@ ol.TileGrid.prototype.getTileCoordResolution = function(tileCoord) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {goog.math.Size} Tile size.
|
* @return {ol.Size} Tile size.
|
||||||
*/
|
*/
|
||||||
ol.TileGrid.prototype.getTileSize = function() {
|
ol.TileGrid.prototype.getTileSize = function() {
|
||||||
return this.tileSize_;
|
return this.tileSize_;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
goog.require('goog.math.Size');
|
|
||||||
goog.require('goog.testing.jsunit');
|
goog.require('goog.testing.jsunit');
|
||||||
goog.require('ol.Coordinate');
|
goog.require('ol.Coordinate');
|
||||||
goog.require('ol.Extent');
|
goog.require('ol.Extent');
|
||||||
|
goog.require('ol.Size');
|
||||||
goog.require('ol.TileCoord');
|
goog.require('ol.TileCoord');
|
||||||
goog.require('ol.TileGrid');
|
goog.require('ol.TileGrid');
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@ function setUp() {
|
|||||||
extent = new ol.Extent(0, 0, 100000, 100000);
|
extent = new ol.Extent(0, 0, 100000, 100000);
|
||||||
origin = new ol.Coordinate(0, 0);
|
origin = new ol.Coordinate(0, 0);
|
||||||
origins = [];
|
origins = [];
|
||||||
tileSize = new goog.math.Size(100, 100);
|
tileSize = new ol.Size(100, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ goog.require('goog.events.EventType');
|
|||||||
goog.require('goog.vec.Mat4');
|
goog.require('goog.vec.Mat4');
|
||||||
goog.require('goog.webgl');
|
goog.require('goog.webgl');
|
||||||
goog.require('ol.Coordinate');
|
goog.require('ol.Coordinate');
|
||||||
|
goog.require('ol.Size');
|
||||||
goog.require('ol.TileLayer');
|
goog.require('ol.TileLayer');
|
||||||
goog.require('ol.webgl.LayerRenderer');
|
goog.require('ol.webgl.LayerRenderer');
|
||||||
goog.require('ol.webgl.shader.Fragment');
|
goog.require('ol.webgl.shader.Fragment');
|
||||||
@@ -122,7 +123,7 @@ ol.webgl.TileLayerRenderer = function(map, tileLayer) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {goog.math.Size}
|
* @type {ol.Size}
|
||||||
*/
|
*/
|
||||||
this.framebufferSize_ = null;
|
this.framebufferSize_ = null;
|
||||||
|
|
||||||
@@ -230,12 +231,12 @@ ol.webgl.TileLayerRenderer.prototype.redraw = function() {
|
|||||||
var tileBoundsSize = tileBounds.getSize();
|
var tileBoundsSize = tileBounds.getSize();
|
||||||
var tileSize = tileGrid.getTileSize();
|
var tileSize = tileGrid.getTileSize();
|
||||||
|
|
||||||
var framebufferSize = new goog.math.Size(
|
var framebufferSize = new ol.Size(
|
||||||
tileSize.width * tileBoundsSize.width,
|
tileSize.width * tileBoundsSize.width,
|
||||||
tileSize.height * tileBoundsSize.height);
|
tileSize.height * tileBoundsSize.height);
|
||||||
|
|
||||||
if (goog.isNull(this.framebufferSize_) ||
|
if (goog.isNull(this.framebufferSize_) ||
|
||||||
!goog.math.Size.equals(this.framebufferSize_, framebufferSize)) {
|
!this.framebufferSize_.equals(framebufferSize)) {
|
||||||
|
|
||||||
gl.deleteFramebuffer(this.framebuffer_);
|
gl.deleteFramebuffer(this.framebuffer_);
|
||||||
gl.deleteRenderbuffer(this.renderbuffer_);
|
gl.deleteRenderbuffer(this.renderbuffer_);
|
||||||
|
|||||||
Reference in New Issue
Block a user