Merge pull request #555 from twpayne/extent-as-array
ol.Extent as Array.<number>
This commit is contained in:
@@ -1,11 +1,16 @@
|
||||
@exportSymbol ol.Extent
|
||||
@exportProperty ol.Extent.prototype.getCenter
|
||||
@exportProperty ol.Extent.prototype.getHeight
|
||||
@exportProperty ol.Extent.prototype.getWidth
|
||||
@exportProperty ol.Extent.prototype.containsCoordinate
|
||||
@exportProperty ol.Extent.prototype.containsExtent
|
||||
@exportProperty ol.Extent.prototype.getBottomLeft
|
||||
@exportProperty ol.Extent.prototype.getBottomRight
|
||||
@exportProperty ol.Extent.prototype.getTopLeft
|
||||
@exportProperty ol.Extent.prototype.getTopRight
|
||||
@exportProperty ol.Extent.prototype.transform
|
||||
@exportSymbol ol.extent.boundingExtent
|
||||
@exportSymbol ol.extent.containsCoordinate
|
||||
@exportSymbol ol.extent.containsExtent
|
||||
@exportSymbol ol.extent.equals
|
||||
@exportSymbol ol.extent.extend
|
||||
@exportSymbol ol.extent.getBottomLeft
|
||||
@exportSymbol ol.extent.getBottomRight
|
||||
@exportSymbol ol.extent.getCenter
|
||||
@exportSymbol ol.extent.getHeight
|
||||
@exportSymbol ol.extent.getSize
|
||||
@exportSymbol ol.extent.getTopLeft
|
||||
@exportSymbol ol.extent.getTopRight
|
||||
@exportSymbol ol.extent.getWidth
|
||||
@exportSymbol ol.extent.intersects
|
||||
@exportSymbol ol.extent.isEmpty
|
||||
@exportSymbol ol.extent.transform
|
||||
|
||||
359
src/ol/extent.js
359
src/ol/extent.js
@@ -1,52 +1,193 @@
|
||||
goog.provide('ol.Extent');
|
||||
goog.provide('ol.extent');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.Coordinate');
|
||||
goog.require('ol.Rectangle');
|
||||
goog.require('ol.Size');
|
||||
goog.require('ol.TransformFunction');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Rectangular extent which is not rotated. An extent does not know its
|
||||
* projection.
|
||||
*
|
||||
* @constructor
|
||||
* @extends {ol.Rectangle}
|
||||
* @param {number} minX Minimum X.
|
||||
* @param {number} minY Minimum Y.
|
||||
* @param {number} maxX Maximum X.
|
||||
* @param {number} maxY Maximum Y.
|
||||
* @typedef {Array.<number>}
|
||||
*/
|
||||
ol.Extent = function(minX, minY, maxX, maxY) {
|
||||
goog.base(this, minX, minY, maxX, maxY);
|
||||
};
|
||||
goog.inherits(ol.Extent, ol.Rectangle);
|
||||
ol.Extent;
|
||||
|
||||
|
||||
/**
|
||||
* Builds an extent that includes all given coordinates.
|
||||
*
|
||||
* @param {...ol.Coordinate} var_args Coordinates.
|
||||
* @return {!ol.Extent} Bounding extent.
|
||||
* @param {Array.<ol.Coordinate>} coordinates Coordinates.
|
||||
* @return {ol.Extent} Bounding extent.
|
||||
*/
|
||||
ol.Extent.boundingExtent = function(var_args) {
|
||||
var coordinate0 = arguments[0];
|
||||
var extent = new ol.Extent(coordinate0[0], coordinate0[1],
|
||||
coordinate0[0], coordinate0[1]);
|
||||
ol.extent.boundingExtent = function(coordinates) {
|
||||
var extent = ol.extent.createEmptyExtent();
|
||||
var n = coordinates.length;
|
||||
var i;
|
||||
for (i = 1; i < arguments.length; ++i) {
|
||||
var coordinate = arguments[i];
|
||||
extent.extendXY(coordinate[0], coordinate[1]);
|
||||
for (i = 0; i < n; ++i) {
|
||||
ol.extent.extendCoordinate(extent, coordinates[i]);
|
||||
}
|
||||
return extent;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {Array.<number>} xs Xs.
|
||||
* @param {Array.<number>} ys Ys.
|
||||
* @param {ol.Extent=} opt_extent Destination extent.
|
||||
* @private
|
||||
* @return {ol.Extent}
|
||||
*/
|
||||
ol.extent.boundingExtentXYs_ = function(xs, ys, opt_extent) {
|
||||
goog.asserts.assert(xs.length > 0);
|
||||
goog.asserts.assert(ys.length > 0);
|
||||
var minX = Math.min.apply(null, xs);
|
||||
var maxX = Math.max.apply(null, xs);
|
||||
var minY = Math.min.apply(null, ys);
|
||||
var maxY = Math.max.apply(null, ys);
|
||||
if (goog.isDef(opt_extent)) {
|
||||
opt_extent[0] = minX;
|
||||
opt_extent[1] = maxX;
|
||||
opt_extent[2] = minY;
|
||||
opt_extent[3] = maxY;
|
||||
return opt_extent;
|
||||
} else {
|
||||
return [minX, maxX, minY, maxY];
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Checks if the passed coordinate is contained or on the edge
|
||||
* of the extent.
|
||||
*
|
||||
* @param {ol.Extent} extent Extent.
|
||||
* @param {ol.Coordinate} coordinate Coordinate.
|
||||
* @return {boolean} Contains.
|
||||
*/
|
||||
ol.extent.containsCoordinate = function(extent, coordinate) {
|
||||
return extent[0] <= coordinate[0] && coordinate[0] <= extent[1] &&
|
||||
extent[2] <= coordinate[1] && coordinate[1] <= extent[3];
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Checks if the passed extent is contained or on the edge of the
|
||||
* extent.
|
||||
*
|
||||
* @param {ol.Extent} extent1 Extent 1.
|
||||
* @param {ol.Extent} extent2 Extent 2.
|
||||
* @return {boolean} Contains.
|
||||
*/
|
||||
ol.extent.containsExtent = function(extent1, extent2) {
|
||||
return extent1[0] <= extent2[0] && extent2[1] <= extent1[1] &&
|
||||
extent1[2] <= extent2[2] && extent2[3] <= extent1[3];
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {ol.Extent} Empty extent.
|
||||
*/
|
||||
ol.Extent.createEmptyExtent = function() {
|
||||
return new ol.Extent(Infinity, Infinity, -Infinity, -Infinity);
|
||||
ol.extent.createEmptyExtent = function() {
|
||||
return [Infinity, -Infinity, Infinity, -Infinity];
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {number} minX Minimum X.
|
||||
* @param {number} maxX Maximum X.
|
||||
* @param {number} minY Minimum Y.
|
||||
* @param {number} maxY Maximum Y.
|
||||
* @param {ol.Extent|undefined} extent Extent.
|
||||
* @return {ol.Extent} Extent.
|
||||
*/
|
||||
ol.extent.createOrUpdate = function(minX, maxX, minY, maxY, extent) {
|
||||
if (goog.isDef(extent)) {
|
||||
extent[0] = minX;
|
||||
extent[1] = maxX;
|
||||
extent[2] = minY;
|
||||
extent[3] = maxY;
|
||||
return extent;
|
||||
} else {
|
||||
return [minX, maxX, minY, maxY];
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.Extent} extent1 Extent 1.
|
||||
* @param {ol.Extent} extent2 Extent 2.
|
||||
* @return {boolean} Equals.
|
||||
*/
|
||||
ol.extent.equals = function(extent1, extent2) {
|
||||
return extent1[0] == extent2[0] && extent1[1] == extent2[1] &&
|
||||
extent1[2] == extent2[2] && extent1[3] == extent2[3];
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.Extent} extent1 Extent 1.
|
||||
* @param {ol.Extent} extent2 Extent 2.
|
||||
*/
|
||||
ol.extent.extend = function(extent1, extent2) {
|
||||
if (extent2[0] < extent1[0]) {
|
||||
extent1[0] = extent2[0];
|
||||
}
|
||||
if (extent2[1] > extent1[1]) {
|
||||
extent1[1] = extent2[1];
|
||||
}
|
||||
if (extent2[2] < extent1[2]) {
|
||||
extent1[2] = extent2[2];
|
||||
}
|
||||
if (extent2[3] > extent1[3]) {
|
||||
extent1[3] = extent2[3];
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.Extent} extent Extent.
|
||||
* @param {ol.Coordinate} coordinate Coordinate.
|
||||
*/
|
||||
ol.extent.extendCoordinate = function(extent, coordinate) {
|
||||
if (coordinate[0] < extent[0]) {
|
||||
extent[0] = coordinate[0];
|
||||
}
|
||||
if (coordinate[0] > extent[1]) {
|
||||
extent[1] = coordinate[0];
|
||||
}
|
||||
if (coordinate[1] < extent[2]) {
|
||||
extent[2] = coordinate[1];
|
||||
}
|
||||
if (coordinate[1] > extent[3]) {
|
||||
extent[3] = coordinate[1];
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.Extent} extent Extent.
|
||||
* @return {ol.Coordinate} Bottom left coordinate.
|
||||
*/
|
||||
ol.extent.getBottomLeft = function(extent) {
|
||||
return [extent[0], extent[2]];
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.Extent} extent Extent.
|
||||
* @return {ol.Coordinate} Bottom right coordinate.
|
||||
*/
|
||||
ol.extent.getBottomRight = function(extent) {
|
||||
return [extent[1], extent[2]];
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.Extent} extent Extent.
|
||||
* @return {ol.Coordinate} Center.
|
||||
*/
|
||||
ol.extent.getCenter = function(extent) {
|
||||
return [(extent[0] + extent[1]) / 2, (extent[2] + extent[3]) / 2];
|
||||
};
|
||||
|
||||
|
||||
@@ -55,9 +196,11 @@ ol.Extent.createEmptyExtent = function() {
|
||||
* @param {number} resolution Resolution.
|
||||
* @param {number} rotation Rotation.
|
||||
* @param {ol.Size} size Size.
|
||||
* @param {ol.Extent=} opt_extent Destination extent.
|
||||
* @return {ol.Extent} Extent.
|
||||
*/
|
||||
ol.Extent.getForView2DAndSize = function(center, resolution, rotation, size) {
|
||||
ol.extent.getForView2DAndSize =
|
||||
function(center, resolution, rotation, size, opt_extent) {
|
||||
var dx = resolution * size.width / 2;
|
||||
var dy = resolution * size.height / 2;
|
||||
var cosRotation = Math.cos(rotation);
|
||||
@@ -71,102 +214,128 @@ ol.Extent.getForView2DAndSize = function(center, resolution, rotation, size) {
|
||||
xs[i] = center[0] + x * cosRotation - y * sinRotation;
|
||||
ys[i] = center[1] + x * sinRotation + y * cosRotation;
|
||||
}
|
||||
var minX = Math.min.apply(null, xs);
|
||||
var minY = Math.min.apply(null, ys);
|
||||
var maxX = Math.max.apply(null, xs);
|
||||
var maxY = Math.max.apply(null, ys);
|
||||
return new ol.Extent(minX, minY, maxX, maxY);
|
||||
return ol.extent.boundingExtentXYs_(xs, ys, opt_extent);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Checks if the passed coordinate is contained or on the edge
|
||||
* of the extent.
|
||||
*
|
||||
* @param {ol.Coordinate} coordinate Coordinate.
|
||||
* @return {boolean} Contains.
|
||||
*/
|
||||
ol.Extent.prototype.containsCoordinate = function(coordinate) {
|
||||
return this.minX <= coordinate[0] && coordinate[0] <= this.maxX &&
|
||||
this.minY <= coordinate[1] && coordinate[1] <= this.maxY;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {number} minX Minimum X.
|
||||
* @param {number} minY Minimum Y.
|
||||
* @param {number} maxX Maximum X.
|
||||
* @param {number} maxY Maximum Y.
|
||||
* @param {ol.Extent|undefined} extent Extent.
|
||||
* @return {ol.Extent} Extent.
|
||||
*/
|
||||
ol.Extent.createOrUpdate = function(minX, minY, maxX, maxY, extent) {
|
||||
if (goog.isDef(extent)) {
|
||||
extent.minX = minX;
|
||||
extent.minY = minY;
|
||||
extent.maxX = maxX;
|
||||
extent.maxY = maxY;
|
||||
return extent;
|
||||
} else {
|
||||
return new ol.Extent(minX, minY, maxX, maxY);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Checks if the passed extent is contained or on the edge of the
|
||||
* extent.
|
||||
*
|
||||
* @param {ol.Extent} extent Extent.
|
||||
* @return {boolean} Contains.
|
||||
* @return {number} Height.
|
||||
*/
|
||||
ol.Extent.prototype.containsExtent = function(extent) {
|
||||
return this.minX <= extent.minX && extent.maxX <= this.maxX &&
|
||||
this.minY <= extent.minY && extent.maxY <= this.maxY;
|
||||
ol.extent.getHeight = function(extent) {
|
||||
return extent[3] - extent[2];
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {ol.Coordinate} Bottom left coordinate.
|
||||
* @param {ol.Extent} extent Extent.
|
||||
* @return {ol.Size} Size.
|
||||
*/
|
||||
ol.Extent.prototype.getBottomLeft = function() {
|
||||
return [this.minX, this.minY];
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {ol.Coordinate} Bottom right coordinate.
|
||||
*/
|
||||
ol.Extent.prototype.getBottomRight = function() {
|
||||
return [this.maxX, this.minY];
|
||||
ol.extent.getSize = function(extent) {
|
||||
return new ol.Size(extent[1] - extent[0], extent[3] - extent[2]);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.Extent} extent Extent.
|
||||
* @return {ol.Coordinate} Top left coordinate.
|
||||
*/
|
||||
ol.Extent.prototype.getTopLeft = function() {
|
||||
return [this.minX, this.maxY];
|
||||
ol.extent.getTopLeft = function(extent) {
|
||||
return [extent[0], extent[3]];
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.Extent} extent Extent.
|
||||
* @return {ol.Coordinate} Top right coordinate.
|
||||
*/
|
||||
ol.Extent.prototype.getTopRight = function() {
|
||||
return [this.maxX, this.maxY];
|
||||
ol.extent.getTopRight = function(extent) {
|
||||
return [extent[1], extent[3]];
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.Extent} extent Extent.
|
||||
* @return {number} Width.
|
||||
*/
|
||||
ol.extent.getWidth = function(extent) {
|
||||
return extent[1] - extent[0];
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.Extent} extent1 Extent 1.
|
||||
* @param {ol.Extent} extent2 Extent.
|
||||
* @return {boolean} Intersects.
|
||||
*/
|
||||
ol.extent.intersects = function(extent1, extent2) {
|
||||
return extent1[0] <= extent2[1] &&
|
||||
extent1[1] >= extent2[0] &&
|
||||
extent1[2] <= extent2[3] &&
|
||||
extent1[3] >= extent2[2];
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.Extent} extent Extent.
|
||||
* @return {boolean} Is empty.
|
||||
*/
|
||||
ol.extent.isEmpty = function(extent) {
|
||||
return extent[1] < extent[0] || extent[3] < extent[2];
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.Extent} extent Extent.
|
||||
* @param {ol.Coordinate} coordinate Coordinate.
|
||||
* @return {ol.Coordinate} Coordinate.
|
||||
*/
|
||||
ol.extent.normalize = function(extent, coordinate) {
|
||||
return [
|
||||
(coordinate[0] - extent[0]) / (extent[1] - extent[0]),
|
||||
(coordinate[1] - extent[2]) / (extent[3] - extent[2])
|
||||
];
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.Extent} extent Extent.
|
||||
* @param {number} value Value.
|
||||
*/
|
||||
ol.extent.scaleFromCenter = function(extent, value) {
|
||||
var deltaX = ((extent[1] - extent[0]) / 2) * (value - 1);
|
||||
var deltaY = ((extent[3] - extent[2]) / 2) * (value - 1);
|
||||
extent[0] -= deltaX;
|
||||
extent[1] += deltaX;
|
||||
extent[2] -= deltaY;
|
||||
extent[3] += deltaY;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.Extent} extent Extent.
|
||||
* @return {string} String.
|
||||
*/
|
||||
ol.extent.toString = function(extent) {
|
||||
return '(' + [extent[0], extent[1], extent[2], extent[3]].join(', ') + ')';
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.Extent} extent Extent.
|
||||
* @param {ol.TransformFunction} transformFn Transform function.
|
||||
* @param {ol.Extent=} opt_extent Destination extent.
|
||||
* @return {ol.Extent} Extent.
|
||||
*/
|
||||
ol.Extent.prototype.transform = function(transformFn) {
|
||||
var input = [this.minX, this.minY, this.maxX, this.maxY];
|
||||
input = transformFn(input, input, 2);
|
||||
return new ol.Extent(Math.min(input[0], input[2]),
|
||||
Math.min(input[1], input[3]),
|
||||
Math.max(input[0], input[2]),
|
||||
Math.max(input[1], input[3]));
|
||||
ol.extent.transform = function(extent, transformFn, opt_extent) {
|
||||
var coordinates = [
|
||||
extent[0], extent[2],
|
||||
extent[0], extent[3],
|
||||
extent[1], extent[2],
|
||||
extent[1], extent[3]
|
||||
];
|
||||
transformFn(coordinates, coordinates, 2);
|
||||
var xs = [coordinates[0], coordinates[2], coordinates[4], coordinates[6]];
|
||||
var ys = [coordinates[1], coordinates[3], coordinates[5], coordinates[7]];
|
||||
return ol.extent.boundingExtentXYs_(xs, ys, opt_extent);
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
goog.provide('ol.filter.Extent');
|
||||
|
||||
goog.require('ol.Extent');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.filter.Filter');
|
||||
|
||||
|
||||
@@ -35,5 +35,5 @@ ol.filter.Extent.prototype.getExtent = function() {
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.filter.Extent.prototype.applies = function(feature) {
|
||||
return feature.getGeometry().getBounds().intersects(this.extent_);
|
||||
return ol.extent.intersects(feature.getGeometry().getBounds(), this.extent_);
|
||||
};
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
goog.provide('ol.geom.AbstractCollection');
|
||||
|
||||
goog.require('ol.Extent');
|
||||
goog.require('ol.geom.Geometry');
|
||||
|
||||
|
||||
@@ -49,12 +48,12 @@ ol.geom.AbstractCollection.prototype.getBounds = function() {
|
||||
|
||||
for (i = 0; i < len; ++i) {
|
||||
bounds = components[i].getBounds();
|
||||
minX = Math.min(bounds.minX, minX);
|
||||
minY = Math.min(bounds.minY, minY);
|
||||
maxX = Math.max(bounds.maxX, maxX);
|
||||
maxY = Math.max(bounds.maxY, maxY);
|
||||
minX = Math.min(bounds[0], minX);
|
||||
maxX = Math.max(bounds[1], maxX);
|
||||
minY = Math.min(bounds[2], minY);
|
||||
maxY = Math.max(bounds[3], maxY);
|
||||
}
|
||||
this.bounds = new ol.Extent(minX, minY, maxX, maxY);
|
||||
this.bounds = [minX, maxX, minY, maxY];
|
||||
}
|
||||
return this.bounds;
|
||||
};
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
goog.provide('ol.geom.LineString');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.Extent');
|
||||
goog.require('ol.geom.Geometry');
|
||||
goog.require('ol.geom.GeometryType');
|
||||
goog.require('ol.geom.SharedVertices');
|
||||
@@ -126,7 +125,7 @@ ol.geom.LineString.prototype.getBounds = function() {
|
||||
maxY = y;
|
||||
}
|
||||
}
|
||||
this.bounds_ = new ol.Extent(minX, minY, maxX, maxY);
|
||||
this.bounds_ = [minX, maxX, minY, maxY];
|
||||
}
|
||||
return this.bounds_;
|
||||
};
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
goog.provide('ol.geom.Point');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.Extent');
|
||||
goog.require('ol.geom.Geometry');
|
||||
goog.require('ol.geom.GeometryType');
|
||||
goog.require('ol.geom.SharedVertices');
|
||||
@@ -69,7 +68,7 @@ ol.geom.Point.prototype.getBounds = function() {
|
||||
if (goog.isNull(this.bounds_)) {
|
||||
var x = this.get(0),
|
||||
y = this.get(1);
|
||||
this.bounds_ = new ol.Extent(x, y, x, y);
|
||||
this.bounds_ = [x, x, y, y];
|
||||
}
|
||||
return this.bounds_;
|
||||
};
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
goog.provide('ol.ImageUrlFunction');
|
||||
goog.provide('ol.ImageUrlFunctionType');
|
||||
|
||||
goog.require('ol.Extent');
|
||||
goog.require('ol.Size');
|
||||
|
||||
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
goog.provide('ol.interaction.DragZoom');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.Extent');
|
||||
goog.require('ol.Size');
|
||||
goog.require('ol.View2D');
|
||||
goog.require('ol.control.DragBox');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.interaction.ConditionType');
|
||||
goog.require('ol.interaction.Drag');
|
||||
|
||||
@@ -63,9 +63,8 @@ ol.interaction.DragZoom.prototype.handleDragEnd =
|
||||
if (this.deltaX * this.deltaX + this.deltaY * this.deltaY >=
|
||||
ol.SHIFT_DRAG_ZOOM_HYSTERESIS_PIXELS_SQUARED) {
|
||||
var map = mapBrowserEvent.map;
|
||||
var extent = ol.Extent.boundingExtent(
|
||||
this.startCoordinate,
|
||||
mapBrowserEvent.getCoordinate());
|
||||
var extent = ol.extent.boundingExtent(
|
||||
[this.startCoordinate, mapBrowserEvent.getCoordinate()]);
|
||||
map.withFrozenRendering(function() {
|
||||
// FIXME works for View2D only
|
||||
var view = map.getView();
|
||||
|
||||
@@ -32,7 +32,6 @@ goog.require('ol.Collection');
|
||||
goog.require('ol.CollectionEvent');
|
||||
goog.require('ol.CollectionEventType');
|
||||
goog.require('ol.Color');
|
||||
goog.require('ol.Extent');
|
||||
goog.require('ol.FrameState');
|
||||
goog.require('ol.IView');
|
||||
goog.require('ol.MapBrowserEvent');
|
||||
@@ -52,6 +51,7 @@ goog.require('ol.View');
|
||||
goog.require('ol.View2D');
|
||||
goog.require('ol.ViewHint');
|
||||
goog.require('ol.control.defaults');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.interaction.defaults');
|
||||
goog.require('ol.layer.Layer');
|
||||
goog.require('ol.projection');
|
||||
@@ -838,7 +838,7 @@ ol.Map.prototype.renderFrame_ = function(time) {
|
||||
|
||||
if (!goog.isNull(frameState)) {
|
||||
// FIXME works for View2D only
|
||||
frameState.extent = ol.Extent.getForView2DAndSize(view2DState.center,
|
||||
frameState.extent = ol.extent.getForView2DAndSize(view2DState.center,
|
||||
view2DState.resolution, view2DState.rotation, frameState.size);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
goog.provide('ol.parser.ogc.OWSCommon_v1');
|
||||
goog.require('ol.Extent');
|
||||
goog.require('ol.parser.XML');
|
||||
|
||||
|
||||
@@ -196,9 +195,10 @@ ol.parser.ogc.OWSCommon_v1 = function() {
|
||||
var pointList = str.split(this.regExes.splitSpace);
|
||||
obj['right'] = pointList[0];
|
||||
obj['top'] = pointList[1];
|
||||
obj['bounds'] = new ol.Extent(parseFloat(obj['left']),
|
||||
parseFloat(obj['bottom']), parseFloat(obj['right']),
|
||||
parseFloat(obj['top']));
|
||||
obj['bounds'] = [
|
||||
parseFloat(obj['left']), parseFloat(obj['right']),
|
||||
parseFloat(obj['bottom']), parseFloat(obj['top'])
|
||||
];
|
||||
delete obj['left'];
|
||||
delete obj['bottom'];
|
||||
delete obj['right'];
|
||||
|
||||
@@ -1,18 +1,34 @@
|
||||
goog.provide('ol.PixelBounds');
|
||||
|
||||
goog.require('ol.Rectangle');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.Rectangle}
|
||||
* @param {number} minX Minimum X.
|
||||
* @param {number} minY Minimum Y.
|
||||
* @param {number} maxX Maximum X.
|
||||
* @param {number} minY Minimum Y.
|
||||
* @param {number} maxY Maximum Y.
|
||||
*/
|
||||
ol.PixelBounds = function(minX, minY, maxX, maxY) {
|
||||
goog.base(this, minX, minY, maxX, maxY);
|
||||
ol.PixelBounds = function(minX, maxX, minY, maxY) {
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.minX = minX;
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.maxX = maxX;
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.minY = minY;
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.maxY = maxY;
|
||||
|
||||
};
|
||||
goog.inherits(ol.PixelBounds, ol.Rectangle);
|
||||
|
||||
@@ -2,7 +2,6 @@ goog.provide('ol.projection.EPSG3857');
|
||||
|
||||
goog.require('goog.array');
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.Extent');
|
||||
goog.require('ol.Projection');
|
||||
goog.require('ol.ProjectionUnits');
|
||||
goog.require('ol.math');
|
||||
@@ -44,9 +43,10 @@ ol.projection.EPSG3857.HALF_SIZE = Math.PI * ol.projection.EPSG3857.RADIUS;
|
||||
* @const
|
||||
* @type {ol.Extent}
|
||||
*/
|
||||
ol.projection.EPSG3857.EXTENT = new ol.Extent(
|
||||
-ol.projection.EPSG3857.HALF_SIZE, -ol.projection.EPSG3857.HALF_SIZE,
|
||||
ol.projection.EPSG3857.HALF_SIZE, ol.projection.EPSG3857.HALF_SIZE);
|
||||
ol.projection.EPSG3857.EXTENT = [
|
||||
-ol.projection.EPSG3857.HALF_SIZE, ol.projection.EPSG3857.HALF_SIZE,
|
||||
-ol.projection.EPSG3857.HALF_SIZE, ol.projection.EPSG3857.HALF_SIZE
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
goog.provide('ol.projection.EPSG4326');
|
||||
|
||||
goog.require('ol.Extent');
|
||||
goog.require('ol.Projection');
|
||||
goog.require('ol.ProjectionUnits');
|
||||
goog.require('ol.projection');
|
||||
@@ -31,7 +30,7 @@ goog.inherits(ol.projection.EPSG4326, ol.Projection);
|
||||
* @const
|
||||
* @type {ol.Extent}
|
||||
*/
|
||||
ol.projection.EPSG4326.EXTENT = new ol.Extent(-180, -90, 180, 90);
|
||||
ol.projection.EPSG4326.EXTENT = [-180, 180, -90, 90];
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,171 +0,0 @@
|
||||
goog.provide('ol.Rectangle');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.Size');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @param {number} minX Minimum X.
|
||||
* @param {number} minY Minimum Y.
|
||||
* @param {number} maxX Maximum X.
|
||||
* @param {number} maxY Maximum Y.
|
||||
*/
|
||||
ol.Rectangle = function(minX, minY, maxX, maxY) {
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.minX = minX;
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.minY = minY;
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.maxX = maxX;
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.maxY = maxY;
|
||||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.Rectangle} rectangle Rectangle.
|
||||
* @return {boolean} Equals.
|
||||
*/
|
||||
ol.Rectangle.prototype.equals = function(rectangle) {
|
||||
return this.minX == rectangle.minX && this.minY == rectangle.minY &&
|
||||
this.maxX == rectangle.maxX && this.maxY == rectangle.maxY;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.Rectangle} rectangle Rectangle.
|
||||
*/
|
||||
ol.Rectangle.prototype.extend = function(rectangle) {
|
||||
if (rectangle.minX < this.minX) {
|
||||
this.minX = rectangle.minX;
|
||||
}
|
||||
if (rectangle.minY < this.minY) {
|
||||
this.minY = rectangle.minY;
|
||||
}
|
||||
if (rectangle.maxX > this.maxX) {
|
||||
this.maxX = rectangle.maxX;
|
||||
}
|
||||
if (rectangle.maxY > this.maxY) {
|
||||
this.maxY = rectangle.maxY;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {number} x X.
|
||||
* @param {number} y Y.
|
||||
*/
|
||||
ol.Rectangle.prototype.extendXY = function(x, y) {
|
||||
if (x < this.minX) {
|
||||
this.minX = x;
|
||||
}
|
||||
if (y < this.minY) {
|
||||
this.minY = y;
|
||||
}
|
||||
if (x > this.maxX) {
|
||||
this.maxX = x;
|
||||
}
|
||||
if (y > this.maxY) {
|
||||
this.maxY = y;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {ol.Coordinate} Center.
|
||||
*/
|
||||
ol.Rectangle.prototype.getCenter = function() {
|
||||
return [(this.minX + this.maxX) / 2, (this.minY + this.maxY) / 2];
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {number} Height.
|
||||
*/
|
||||
ol.Rectangle.prototype.getHeight = function() {
|
||||
return this.maxY - this.minY;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {ol.Size} Size.
|
||||
*/
|
||||
ol.Rectangle.prototype.getSize = function() {
|
||||
return new ol.Size(this.getWidth(), this.getHeight());
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {number} Width.
|
||||
*/
|
||||
ol.Rectangle.prototype.getWidth = function() {
|
||||
return this.maxX - this.minX;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.Rectangle} rectangle Rectangle.
|
||||
* @return {boolean} Intersects.
|
||||
*/
|
||||
ol.Rectangle.prototype.intersects = function(rectangle) {
|
||||
return this.minX <= rectangle.maxX &&
|
||||
this.maxX >= rectangle.minX &&
|
||||
this.minY <= rectangle.maxY &&
|
||||
this.maxY >= rectangle.minY;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {boolean} Is empty.
|
||||
*/
|
||||
ol.Rectangle.prototype.isEmpty = function() {
|
||||
return this.maxX < this.minX || this.maxY < this.minY;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.Coordinate} coordinate Coordinate.
|
||||
* @return {ol.Coordinate} Coordinate.
|
||||
*/
|
||||
ol.Rectangle.prototype.normalize = function(coordinate) {
|
||||
return [
|
||||
(coordinate[0] - this.minX) / this.getWidth(),
|
||||
(coordinate[1] - this.minY) / this.getHeight()
|
||||
];
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {string} String.
|
||||
*/
|
||||
ol.Rectangle.prototype.toString = function() {
|
||||
return '(' + [this.minX, this.minY, this.maxX, this.maxY].join(', ') + ')';
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {number} value Value.
|
||||
*/
|
||||
ol.Rectangle.prototype.scaleFromCenter = function(value) {
|
||||
var deltaX = (this.getWidth() / 2.0) * (value - 1);
|
||||
var deltaY = (this.getHeight() / 2.0) * (value - 1);
|
||||
this.minX -= deltaX;
|
||||
this.minY -= deltaY;
|
||||
this.maxX += deltaX;
|
||||
this.maxY += deltaY;
|
||||
};
|
||||
@@ -113,8 +113,8 @@ ol.renderer.canvas.ImageLayer.prototype.renderFrame =
|
||||
1);
|
||||
goog.vec.Mat4.translate(
|
||||
transform,
|
||||
(imageExtent.minX - viewCenter[0]) / imageResolution,
|
||||
(viewCenter[1] - imageExtent.maxY) / imageResolution,
|
||||
(imageExtent[0] - viewCenter[0]) / imageResolution,
|
||||
(viewCenter[1] - imageExtent[3]) / imageResolution,
|
||||
0);
|
||||
|
||||
this.updateAttributions(frameState.attributions, image.getAttributions());
|
||||
|
||||
@@ -9,12 +9,12 @@ goog.require('goog.dom');
|
||||
goog.require('goog.dom.TagName');
|
||||
goog.require('goog.object');
|
||||
goog.require('goog.vec.Mat4');
|
||||
goog.require('ol.Extent');
|
||||
goog.require('ol.Size');
|
||||
goog.require('ol.Tile');
|
||||
goog.require('ol.TileCoord');
|
||||
goog.require('ol.TileRange');
|
||||
goog.require('ol.TileState');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.layer.TileLayer');
|
||||
goog.require('ol.renderer.Map');
|
||||
goog.require('ol.renderer.canvas.Layer');
|
||||
@@ -187,7 +187,7 @@ ol.renderer.canvas.TileLayer.prototype.renderFrame =
|
||||
var extent;
|
||||
if (tileResolution == view2DState.resolution) {
|
||||
center = this.snapCenterToPixel(center, tileResolution, frameState.size);
|
||||
extent = ol.Extent.getForView2DAndSize(
|
||||
extent = ol.extent.getForView2DAndSize(
|
||||
center, tileResolution, view2DState.rotation, frameState.size);
|
||||
} else {
|
||||
extent = frameState.extent;
|
||||
@@ -244,8 +244,8 @@ ol.renderer.canvas.TileLayer.prototype.renderFrame =
|
||||
Math.floor((canvasTileRangeHeight - tileRange.getHeight()) / 2);
|
||||
this.renderedCanvasZ_ = z;
|
||||
this.renderedCanvasTileRange_ = new ol.TileRange(
|
||||
minX, minY,
|
||||
minX + canvasTileRangeWidth - 1, minY + canvasTileRangeHeight - 1);
|
||||
minX, minX + canvasTileRangeWidth - 1,
|
||||
minY, minY + canvasTileRangeHeight - 1);
|
||||
this.renderedTiles_ =
|
||||
new Array(canvasTileRangeWidth * canvasTileRangeHeight);
|
||||
canvasTileRange = this.renderedCanvasTileRange_;
|
||||
@@ -271,7 +271,7 @@ ol.renderer.canvas.TileLayer.prototype.renderFrame =
|
||||
tilesToDrawByZ, getTileIfLoaded);
|
||||
|
||||
var allTilesLoaded = true;
|
||||
var tmpExtent = new ol.Extent(0, 0, 0, 0);
|
||||
var tmpExtent = ol.extent.createEmptyExtent();
|
||||
var tmpTileRange = new ol.TileRange(0, 0, 0, 0);
|
||||
var childTileRange, fullyLoaded, tile, tileState, x, y;
|
||||
for (x = tileRange.minX; x <= tileRange.maxX; ++x) {
|
||||
@@ -315,8 +315,9 @@ ol.renderer.canvas.TileLayer.prototype.renderFrame =
|
||||
var zs = goog.array.map(goog.object.getKeys(tilesToDrawByZ), Number);
|
||||
goog.array.sort(zs);
|
||||
var opaque = tileSource.getOpaque();
|
||||
var origin = tileGrid.getTileCoordExtent(new ol.TileCoord(
|
||||
z, canvasTileRange.minX, canvasTileRange.maxY), tmpExtent).getTopLeft();
|
||||
var origin = ol.extent.getTopLeft(tileGrid.getTileCoordExtent(
|
||||
new ol.TileCoord(z, canvasTileRange.minX, canvasTileRange.maxY),
|
||||
tmpExtent));
|
||||
var currentZ, index, scale, tileCoordKey, tileExtent, tilesToDraw;
|
||||
var ix, iy, interimTileExtent, interimTileRange, maxX, maxY;
|
||||
var height, width;
|
||||
@@ -348,8 +349,8 @@ ol.renderer.canvas.TileLayer.prototype.renderFrame =
|
||||
for (tileCoordKey in tilesToDraw) {
|
||||
tile = tilesToDraw[tileCoordKey];
|
||||
tileExtent = tileGrid.getTileCoordExtent(tile.tileCoord, tmpExtent);
|
||||
x = (tileExtent.minX - origin[0]) / tileResolution;
|
||||
y = (origin[1] - tileExtent.maxY) / tileResolution;
|
||||
x = (tileExtent[0] - origin[0]) / tileResolution;
|
||||
y = (origin[1] - tileExtent[3]) / tileResolution;
|
||||
width = scale * tileSize.width;
|
||||
height = scale * tileSize.height;
|
||||
tileState = tile.getState();
|
||||
|
||||
@@ -6,11 +6,11 @@ goog.require('goog.events');
|
||||
goog.require('goog.events.EventType');
|
||||
goog.require('goog.object');
|
||||
goog.require('goog.vec.Mat4');
|
||||
goog.require('ol.Extent');
|
||||
goog.require('ol.Size');
|
||||
goog.require('ol.TileCache');
|
||||
goog.require('ol.TileCoord');
|
||||
goog.require('ol.ViewHint');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.filter.Extent');
|
||||
goog.require('ol.filter.Geometry');
|
||||
goog.require('ol.filter.Logical');
|
||||
@@ -229,7 +229,7 @@ ol.renderer.canvas.VectorLayer.prototype.renderFrame =
|
||||
extent, tileResolution),
|
||||
tileRangeExtent = tileGrid.getTileRangeExtent(z, tileRange),
|
||||
tileSize = tileGrid.getTileSize(z),
|
||||
sketchOrigin = tileRangeExtent.getTopLeft(),
|
||||
sketchOrigin = ol.extent.getTopLeft(tileRangeExtent),
|
||||
transform = this.transform_;
|
||||
|
||||
goog.vec.Mat4.makeIdentity(transform);
|
||||
@@ -324,10 +324,10 @@ ol.renderer.canvas.VectorLayer.prototype.renderFrame =
|
||||
tilesToRender[key] = tileCoord;
|
||||
} else if (!frameState.viewHints[ol.ViewHint.ANIMATING]) {
|
||||
tileExtent = tileGrid.getTileCoordExtent(tileCoord);
|
||||
tileExtent.minX -= tileGutter;
|
||||
tileExtent.minY -= tileGutter;
|
||||
tileExtent.maxX += tileGutter;
|
||||
tileExtent.maxY += tileGutter;
|
||||
tileExtent[0] -= tileGutter;
|
||||
tileExtent[1] += tileGutter;
|
||||
tileExtent[2] -= tileGutter;
|
||||
tileExtent[3] += tileGutter;
|
||||
extentFilter = new ol.filter.Extent(tileExtent);
|
||||
for (i = 0; i < numFilters; ++i) {
|
||||
geomFilter = filters[i];
|
||||
|
||||
@@ -100,8 +100,8 @@ ol.renderer.dom.ImageLayer.prototype.renderFrame =
|
||||
1);
|
||||
goog.vec.Mat4.translate(
|
||||
transform,
|
||||
(imageExtent.minX - viewCenter[0]) / imageResolution,
|
||||
(viewCenter[1] - imageExtent.maxY) / imageResolution,
|
||||
(imageExtent[0] - viewCenter[0]) / imageResolution,
|
||||
(viewCenter[1] - imageExtent[3]) / imageResolution,
|
||||
0);
|
||||
if (image != this.image_) {
|
||||
var imageElement = image.getImageElement(this);
|
||||
|
||||
@@ -11,13 +11,13 @@ goog.require('goog.object');
|
||||
goog.require('goog.style');
|
||||
goog.require('goog.vec.Mat4');
|
||||
goog.require('ol.Coordinate');
|
||||
goog.require('ol.Extent');
|
||||
goog.require('ol.Tile');
|
||||
goog.require('ol.TileCoord');
|
||||
goog.require('ol.TileRange');
|
||||
goog.require('ol.TileState');
|
||||
goog.require('ol.ViewHint');
|
||||
goog.require('ol.dom');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.layer.TileLayer');
|
||||
goog.require('ol.renderer.dom.Layer');
|
||||
goog.require('ol.tilegrid.TileGrid');
|
||||
@@ -98,7 +98,7 @@ ol.renderer.dom.TileLayer.prototype.renderFrame =
|
||||
var extent;
|
||||
if (tileResolution == view2DState.resolution) {
|
||||
center = this.snapCenterToPixel(center, tileResolution, frameState.size);
|
||||
extent = ol.Extent.getForView2DAndSize(
|
||||
extent = ol.extent.getForView2DAndSize(
|
||||
center, tileResolution, view2DState.rotation, frameState.size);
|
||||
} else {
|
||||
extent = frameState.extent;
|
||||
@@ -117,7 +117,7 @@ ol.renderer.dom.TileLayer.prototype.renderFrame =
|
||||
tilesToDrawByZ, getTileIfLoaded);
|
||||
|
||||
var allTilesLoaded = true;
|
||||
var tmpExtent = new ol.Extent(0, 0, 0, 0);
|
||||
var tmpExtent = ol.extent.createEmptyExtent();
|
||||
var tmpTileRange = new ol.TileRange(0, 0, 0, 0);
|
||||
var childTileRange, fullyLoaded, tile, tileState, x, y;
|
||||
for (x = tileRange.minX; x <= tileRange.maxX; ++x) {
|
||||
@@ -272,7 +272,8 @@ ol.renderer.dom.TileLayerZ_ = function(tileGrid, tileCoordOrigin) {
|
||||
* @private
|
||||
* @type {ol.Coordinate}
|
||||
*/
|
||||
this.origin_ = tileGrid.getTileCoordExtent(tileCoordOrigin).getTopLeft();
|
||||
this.origin_ =
|
||||
ol.extent.getTopLeft(tileGrid.getTileCoordExtent(tileCoordOrigin));
|
||||
|
||||
/**
|
||||
* @private
|
||||
|
||||
@@ -169,11 +169,13 @@ ol.renderer.webgl.ImageLayer.prototype.updateProjectionMatrix_ =
|
||||
2 / canvasExtentWidth, 2 / canvasExtentHeight, 1);
|
||||
goog.vec.Mat4.rotateZ(projectionMatrix, -viewRotation);
|
||||
goog.vec.Mat4.translate(projectionMatrix,
|
||||
imageExtent.minX - viewCenter[0],
|
||||
imageExtent.minY - viewCenter[1],
|
||||
imageExtent[0] - viewCenter[0],
|
||||
imageExtent[2] - viewCenter[1],
|
||||
0);
|
||||
goog.vec.Mat4.scale(projectionMatrix,
|
||||
imageExtent.getWidth() / 2, imageExtent.getHeight() / 2, 1);
|
||||
(imageExtent[1] - imageExtent[0]) / 2,
|
||||
(imageExtent[3] - imageExtent[2]) / 2,
|
||||
1);
|
||||
goog.vec.Mat4.translate(projectionMatrix, 1, 1, 0);
|
||||
|
||||
};
|
||||
|
||||
@@ -8,11 +8,11 @@ goog.require('goog.object');
|
||||
goog.require('goog.vec.Mat4');
|
||||
goog.require('goog.vec.Vec4');
|
||||
goog.require('goog.webgl');
|
||||
goog.require('ol.Extent');
|
||||
goog.require('ol.Size');
|
||||
goog.require('ol.Tile');
|
||||
goog.require('ol.TileRange');
|
||||
goog.require('ol.TileState');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.layer.TileLayer');
|
||||
goog.require('ol.math');
|
||||
goog.require('ol.renderer.webgl.Layer');
|
||||
@@ -129,7 +129,7 @@ ol.renderer.webgl.TileLayer.prototype.renderFrame =
|
||||
var extent;
|
||||
if (tileResolution == view2DState.resolution) {
|
||||
center = this.snapCenterToPixel(center, tileResolution, frameState.size);
|
||||
extent = ol.Extent.getForView2DAndSize(
|
||||
extent = ol.extent.getForView2DAndSize(
|
||||
center, tileResolution, view2DState.rotation, frameState.size);
|
||||
} else {
|
||||
extent = frameState.extent;
|
||||
@@ -156,11 +156,10 @@ ol.renderer.webgl.TileLayer.prototype.renderFrame =
|
||||
var origin = tileGrid.getOrigin(z);
|
||||
var minX = origin[0] + tileRange.minX * tileSize.width * tileResolution;
|
||||
var minY = origin[1] + tileRange.minY * tileSize.height * tileResolution;
|
||||
framebufferExtent = new ol.Extent(
|
||||
minX,
|
||||
minY,
|
||||
minX + framebufferExtentSize.width,
|
||||
minY + framebufferExtentSize.height);
|
||||
framebufferExtent = [
|
||||
minX, minX + framebufferExtentSize.width,
|
||||
minY, minY + framebufferExtentSize.height
|
||||
];
|
||||
|
||||
this.bindFramebuffer(frameState, framebufferDimension);
|
||||
gl.viewport(0, 0, framebufferDimension, framebufferDimension);
|
||||
@@ -200,7 +199,7 @@ ol.renderer.webgl.TileLayer.prototype.renderFrame =
|
||||
tilesToDrawByZ, getTileIfLoaded);
|
||||
|
||||
var allTilesLoaded = true;
|
||||
var tmpExtent = new ol.Extent(0, 0, 0, 0);
|
||||
var tmpExtent = ol.extent.createEmptyExtent();
|
||||
var tmpTileRange = new ol.TileRange(0, 0, 0, 0);
|
||||
var childTileRange, fullyLoaded, tile, tileState, x, y;
|
||||
for (x = tileRange.minX; x <= tileRange.maxX; ++x) {
|
||||
@@ -240,11 +239,13 @@ ol.renderer.webgl.TileLayer.prototype.renderFrame =
|
||||
goog.array.forEach(zs, function(z) {
|
||||
goog.object.forEach(tilesToDrawByZ[z], function(tile) {
|
||||
var tileExtent = tileGrid.getTileCoordExtent(tile.tileCoord, tmpExtent);
|
||||
var sx = 2 * tileExtent.getWidth() / framebufferExtentSize.width;
|
||||
var sy = 2 * tileExtent.getHeight() / framebufferExtentSize.height;
|
||||
var tx = 2 * (tileExtent.minX - framebufferExtent.minX) /
|
||||
var sx =
|
||||
2 * (tileExtent[1] - tileExtent[0]) / framebufferExtentSize.width;
|
||||
var sy =
|
||||
2 * (tileExtent[3] - tileExtent[2]) / framebufferExtentSize.height;
|
||||
var tx = 2 * (tileExtent[0] - framebufferExtent[0]) /
|
||||
framebufferExtentSize.width - 1;
|
||||
var ty = 2 * (tileExtent.minY - framebufferExtent.minY) /
|
||||
var ty = 2 * (tileExtent[2] - framebufferExtent[2]) /
|
||||
framebufferExtentSize.height - 1;
|
||||
goog.vec.Vec4.setFromValues(u_tileOffset, sx, sy, tx, ty);
|
||||
gl.uniform4fv(this.locations_.u_tileOffset, u_tileOffset);
|
||||
@@ -286,17 +287,17 @@ ol.renderer.webgl.TileLayer.prototype.renderFrame =
|
||||
var texCoordMatrix = this.texCoordMatrix;
|
||||
goog.vec.Mat4.makeIdentity(texCoordMatrix);
|
||||
goog.vec.Mat4.translate(texCoordMatrix,
|
||||
(center[0] - framebufferExtent.minX) /
|
||||
(framebufferExtent.maxX - framebufferExtent.minX),
|
||||
(center[1] - framebufferExtent.minY) /
|
||||
(framebufferExtent.maxY - framebufferExtent.minY),
|
||||
(center[0] - framebufferExtent[0]) /
|
||||
(framebufferExtent[1] - framebufferExtent[0]),
|
||||
(center[1] - framebufferExtent[2]) /
|
||||
(framebufferExtent[3] - framebufferExtent[2]),
|
||||
0);
|
||||
goog.vec.Mat4.rotateZ(texCoordMatrix, view2DState.rotation);
|
||||
goog.vec.Mat4.scale(texCoordMatrix,
|
||||
frameState.size.width * view2DState.resolution /
|
||||
(framebufferExtent.maxX - framebufferExtent.minX),
|
||||
(framebufferExtent[1] - framebufferExtent[0]),
|
||||
frameState.size.height * view2DState.resolution /
|
||||
(framebufferExtent.maxY - framebufferExtent.minY),
|
||||
(framebufferExtent[3] - framebufferExtent[2]),
|
||||
1);
|
||||
goog.vec.Mat4.translate(texCoordMatrix,
|
||||
-0.5,
|
||||
|
||||
@@ -6,11 +6,11 @@ goog.require('goog.asserts');
|
||||
goog.require('goog.math');
|
||||
goog.require('goog.net.Jsonp');
|
||||
goog.require('ol.Attribution');
|
||||
goog.require('ol.Extent');
|
||||
goog.require('ol.Size');
|
||||
goog.require('ol.TileCoord');
|
||||
goog.require('ol.TileRange');
|
||||
goog.require('ol.TileUrlFunction');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.projection');
|
||||
goog.require('ol.source.ImageTileSource');
|
||||
goog.require('ol.tilegrid.XYZ');
|
||||
@@ -129,9 +129,8 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse =
|
||||
var minZ = coverageArea.zoomMin;
|
||||
var maxZ = coverageArea.zoomMax;
|
||||
var bbox = coverageArea.bbox;
|
||||
var epsg4326Extent =
|
||||
new ol.Extent(bbox[1], bbox[0], bbox[3], bbox[2]);
|
||||
var extent = epsg4326Extent.transform(transform);
|
||||
var epsg4326Extent = [bbox[1], bbox[3], bbox[0], bbox[2]];
|
||||
var extent = ol.extent.transform(epsg4326Extent, transform);
|
||||
var tileRange, z, zKey;
|
||||
for (z = minZ; z <= maxZ; ++z) {
|
||||
zKey = z.toString();
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
goog.provide('ol.source.SingleImageWMS');
|
||||
|
||||
goog.require('ol.Extent');
|
||||
goog.require('ol.Image');
|
||||
goog.require('ol.ImageUrlFunction');
|
||||
goog.require('ol.Size');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.source.ImageSource');
|
||||
goog.require('ol.source.wms');
|
||||
|
||||
@@ -56,15 +56,14 @@ ol.source.SingleImageWMS.prototype.getImage =
|
||||
var image = this.image_;
|
||||
if (!goog.isNull(image) &&
|
||||
image.getResolution() == resolution &&
|
||||
image.getExtent().containsExtent(extent)) {
|
||||
ol.extent.containsExtent(image.getExtent(), extent)) {
|
||||
return image;
|
||||
}
|
||||
|
||||
extent = new ol.Extent(extent.minX, extent.minY,
|
||||
extent.maxX, extent.maxY);
|
||||
extent.scaleFromCenter(this.ratio_);
|
||||
var width = extent.getWidth() / resolution;
|
||||
var height = extent.getHeight() / resolution;
|
||||
extent = extent.slice();
|
||||
ol.extent.scaleFromCenter(extent, this.ratio_);
|
||||
var width = (extent[1] - extent[0]) / resolution;
|
||||
var height = (extent[3] - extent[2]) / resolution;
|
||||
var size = new ol.Size(width, height);
|
||||
|
||||
this.image_ = this.createImage(extent, resolution, size, projection);
|
||||
|
||||
@@ -2,6 +2,7 @@ goog.provide('ol.source.StaticImage');
|
||||
|
||||
goog.require('ol.Image');
|
||||
goog.require('ol.ImageUrlFunctionType');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.projection');
|
||||
goog.require('ol.source.ImageSource');
|
||||
|
||||
@@ -19,7 +20,7 @@ ol.source.StaticImage = function(options) {
|
||||
|
||||
var imageExtent = options.imageExtent;
|
||||
var imageSize = options.imageSize;
|
||||
var imageResolution = imageExtent.getHeight() / imageSize.height;
|
||||
var imageResolution = (imageExtent[3] - imageExtent[2]) / imageSize.height;
|
||||
var projection = ol.projection.get(options.projection);
|
||||
|
||||
goog.base(this, {
|
||||
@@ -47,7 +48,7 @@ goog.inherits(ol.source.StaticImage, ol.source.ImageSource);
|
||||
*/
|
||||
ol.source.StaticImage.prototype.getImage =
|
||||
function(extent, resolution, projection) {
|
||||
if (extent.intersects(this.image_.getExtent())) {
|
||||
if (ol.extent.intersects(extent, this.image_.getExtent())) {
|
||||
return this.image_;
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -4,9 +4,9 @@ goog.provide('ol.source.TiledWMS');
|
||||
|
||||
goog.require('goog.array');
|
||||
goog.require('goog.math');
|
||||
goog.require('ol.Extent');
|
||||
goog.require('ol.TileCoord');
|
||||
goog.require('ol.TileUrlFunction');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.source.ImageTileSource');
|
||||
goog.require('ol.source.wms');
|
||||
|
||||
@@ -56,16 +56,15 @@ ol.source.TiledWMS = function(options) {
|
||||
extent = goog.isDef(extent) ? extent : projectionExtent;
|
||||
|
||||
if (!goog.isNull(extent) && projection.isGlobal() &&
|
||||
extent.minX === projectionExtent.minX &&
|
||||
extent.maxX === projectionExtent.maxX) {
|
||||
extent[0] === projectionExtent[0] &&
|
||||
extent[1] === projectionExtent[1]) {
|
||||
var numCols = Math.ceil(
|
||||
(extent.maxX - extent.minX) / (tileExtent.maxX - tileExtent.minX));
|
||||
(extent[1] - extent[0]) / (tileExtent[1] - tileExtent[0]));
|
||||
x = goog.math.modulo(x, numCols);
|
||||
tileExtent = tileGrid.getTileCoordExtent(
|
||||
new ol.TileCoord(tileCoord.z, x, tileCoord.y));
|
||||
}
|
||||
// FIXME We shouldn't need a typecast here.
|
||||
if (!tileExtent.intersects(/** @type {ol.Extent} */ (extent))) {
|
||||
if (!ol.extent.intersects(tileExtent, extent)) {
|
||||
return null;
|
||||
}
|
||||
return new ol.TileCoord(tileCoord.z, x, tileCoord.y);
|
||||
|
||||
@@ -13,10 +13,10 @@ goog.require('goog.asserts');
|
||||
goog.require('goog.math');
|
||||
goog.require('goog.net.jsloader');
|
||||
goog.require('ol.Attribution');
|
||||
goog.require('ol.Extent');
|
||||
goog.require('ol.TileCoord');
|
||||
goog.require('ol.TileRange');
|
||||
goog.require('ol.TileUrlFunction');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.projection');
|
||||
goog.require('ol.source.ImageTileSource');
|
||||
goog.require('ol.tilegrid.XYZ');
|
||||
@@ -80,10 +80,10 @@ ol.source.TileJSON.prototype.handleTileJSONResponse = function() {
|
||||
var epsg4326Extent, extent;
|
||||
if (goog.isDef(tileJSON.bounds)) {
|
||||
var bounds = tileJSON.bounds;
|
||||
epsg4326Extent = new ol.Extent(
|
||||
bounds[0], bounds[1], bounds[2], bounds[3]);
|
||||
extent = epsg4326Extent.transform(ol.projection.getTransformFromProjections(
|
||||
epsg4326Projection, this.getProjection()));
|
||||
epsg4326Extent = [bounds[0], bounds[2], bounds[1], bounds[3]];
|
||||
var transform = ol.projection.getTransformFromProjections(
|
||||
epsg4326Projection, this.getProjection());
|
||||
extent = ol.extent.transform(epsg4326Extent, transform);
|
||||
this.setExtent(extent);
|
||||
} else {
|
||||
epsg4326Extent = null;
|
||||
@@ -116,7 +116,7 @@ ol.source.TileJSON.prototype.handleTileJSONResponse = function() {
|
||||
if (!goog.isNull(extent)) {
|
||||
var tileExtent = tileGrid.getTileCoordExtent(
|
||||
new ol.TileCoord(tileCoord.z, x, tileCoord.y));
|
||||
if (!tileExtent.intersects(extent)) {
|
||||
if (!ol.extent.intersects(tileExtent, extent)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,8 +34,8 @@ ol.source.wms.getUrl =
|
||||
|
||||
var axisOrientation = projection.getAxisOrientation();
|
||||
var bboxValues = (wms13 && axisOrientation.substr(0, 2) == 'ne') ?
|
||||
[extent.minY, extent.minX, extent.maxY, extent.maxX] :
|
||||
[extent.minX, extent.minY, extent.maxX, extent.maxY];
|
||||
[extent[2], extent[0], extent[3], extent[1]] :
|
||||
[extent[0], extent[2], extent[1], extent[3]];
|
||||
baseParams['BBOX'] = bboxValues.join(',');
|
||||
|
||||
return goog.uri.utils.appendParamsFromMap(baseUrl, baseParams);
|
||||
|
||||
@@ -6,10 +6,10 @@ goog.require('goog.asserts');
|
||||
goog.require('goog.math');
|
||||
goog.require('goog.object');
|
||||
goog.require('goog.uri.utils');
|
||||
goog.require('ol.Extent');
|
||||
goog.require('ol.TileCoord');
|
||||
goog.require('ol.TileUrlFunction');
|
||||
goog.require('ol.TileUrlFunctionType');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.projection');
|
||||
goog.require('ol.source.ImageTileSource');
|
||||
goog.require('ol.tilegrid.WMTS');
|
||||
@@ -114,7 +114,7 @@ ol.source.WMTS = function(options) {
|
||||
}));
|
||||
}
|
||||
|
||||
var tmpExtent = new ol.Extent(0, 0, 0, 0);
|
||||
var tmpExtent = ol.extent.createEmptyExtent();
|
||||
var tmpTileCoord = new ol.TileCoord(0, 0, 0);
|
||||
tileUrlFunction = ol.TileUrlFunction.withTileCoordTransform(
|
||||
function(tileCoord, projection) {
|
||||
@@ -131,18 +131,17 @@ ol.source.WMTS = function(options) {
|
||||
options.extent : projectionExtent;
|
||||
|
||||
if (!goog.isNull(extent) && projection.isGlobal() &&
|
||||
extent.minX === projectionExtent.minX &&
|
||||
extent.maxX === projectionExtent.maxX) {
|
||||
extent[0] === projectionExtent[0] &&
|
||||
extent[1] === projectionExtent[1]) {
|
||||
var numCols = Math.ceil(
|
||||
(extent.maxX - extent.minX) /
|
||||
(tileExtent.maxX - tileExtent.minX));
|
||||
(extent[1] - extent[0]) / (tileExtent[1] - tileExtent[0]));
|
||||
x = goog.math.modulo(x, numCols);
|
||||
tmpTileCoord.z = tileCoord.z;
|
||||
tmpTileCoord.x = x;
|
||||
tmpTileCoord.y = tileCoord.y;
|
||||
tileExtent = tileGrid.getTileCoordExtent(tmpTileCoord, tmpExtent);
|
||||
}
|
||||
if (!tileExtent.intersects(extent)) {
|
||||
if (!ol.extent.intersects(tileExtent, extent)) {
|
||||
return null;
|
||||
}
|
||||
return new ol.TileCoord(tileCoord.z, x, y);
|
||||
|
||||
@@ -5,11 +5,11 @@ goog.provide('ol.source.XYZOptions');
|
||||
|
||||
goog.require('goog.math');
|
||||
goog.require('ol.Attribution');
|
||||
goog.require('ol.Extent');
|
||||
goog.require('ol.Projection');
|
||||
goog.require('ol.TileCoord');
|
||||
goog.require('ol.TileUrlFunction');
|
||||
goog.require('ol.TileUrlFunctionType');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.projection');
|
||||
goog.require('ol.source.ImageTileSource');
|
||||
goog.require('ol.tilegrid.XYZ');
|
||||
@@ -58,10 +58,10 @@ ol.source.XYZ = function(options) {
|
||||
});
|
||||
|
||||
// FIXME factor out common code
|
||||
var extent = options.extent;
|
||||
if (goog.isDefAndNotNull(extent)) {
|
||||
if (goog.isDef(options.extent)) {
|
||||
|
||||
var tmpExtent = new ol.Extent(0, 0, 0, 0);
|
||||
var extent = options.extent;
|
||||
var tmpExtent = ol.extent.createEmptyExtent();
|
||||
var tmpTileCoord = new ol.TileCoord(0, 0, 0);
|
||||
tileUrlFunction = ol.TileUrlFunction.withTileCoordTransform(
|
||||
function(tileCoord) {
|
||||
@@ -78,8 +78,7 @@ ol.source.XYZ = function(options) {
|
||||
tmpTileCoord.x = x;
|
||||
tmpTileCoord.y = tileCoord.y;
|
||||
var tileExtent = tileGrid.getTileCoordExtent(tmpTileCoord, tmpExtent);
|
||||
// FIXME we shouldn't need a typecast here
|
||||
if (!tileExtent.intersects(/** @type {ol.Extent} */ (extent))) {
|
||||
if (!ol.extent.intersects(tileExtent, extent)) {
|
||||
return null;
|
||||
}
|
||||
return new ol.TileCoord(tileCoord.z, x, y);
|
||||
|
||||
@@ -1,24 +1,23 @@
|
||||
goog.provide('ol.structs.RTree');
|
||||
|
||||
goog.require('goog.object');
|
||||
goog.require('ol.Rectangle');
|
||||
goog.require('ol.extent');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @constructor
|
||||
* @param {number} minX Minimum X.
|
||||
* @param {number} minY Minimum Y.
|
||||
* @param {number} maxX Maximum X.
|
||||
* @param {number} maxY Maximum Y.
|
||||
* @param {ol.Extent} bounds Extent.
|
||||
* @param {ol.structs.RTreeNode_} parent Parent node.
|
||||
* @param {number} level Level in the tree hierarchy.
|
||||
* @extends {ol.Rectangle}
|
||||
*/
|
||||
ol.structs.RTreeNode_ = function(minX, minY, maxX, maxY, parent, level) {
|
||||
ol.structs.RTreeNode_ = function(bounds, parent, level) {
|
||||
|
||||
goog.base(this, minX, minY, maxX, maxY);
|
||||
/**
|
||||
* @type {ol.Extent}
|
||||
*/
|
||||
this.bounds = bounds;
|
||||
|
||||
/**
|
||||
* @type {Object}
|
||||
@@ -51,17 +50,16 @@ ol.structs.RTreeNode_ = function(minX, minY, maxX, maxY, parent, level) {
|
||||
this.children = [];
|
||||
|
||||
};
|
||||
goog.inherits(ol.structs.RTreeNode_, ol.Rectangle);
|
||||
|
||||
|
||||
/**
|
||||
* Find all objects intersected by a rectangle.
|
||||
* @param {ol.Rectangle} bounds Bounding box.
|
||||
* @param {ol.Extent} bounds Bounding box.
|
||||
* @param {Object.<string, Object>} results Target object for results.
|
||||
* @param {string=} opt_type Type for another indexing dimension.
|
||||
*/
|
||||
ol.structs.RTreeNode_.prototype.find = function(bounds, results, opt_type) {
|
||||
if (this.intersects(bounds) &&
|
||||
if (ol.extent.intersects(this.bounds, bounds) &&
|
||||
(!goog.isDef(opt_type) || this.types[opt_type] === true)) {
|
||||
var numChildren = this.children.length;
|
||||
if (numChildren === 0) {
|
||||
@@ -79,11 +77,11 @@ ol.structs.RTreeNode_.prototype.find = function(bounds, results, opt_type) {
|
||||
|
||||
/**
|
||||
* Find the appropriate node for insertion.
|
||||
* @param {ol.Rectangle} bounds Bounding box.
|
||||
* @param {ol.Extent} bounds Bounding box.
|
||||
* @return {ol.structs.RTreeNode_|undefined} Matching node.
|
||||
*/
|
||||
ol.structs.RTreeNode_.prototype.get = function(bounds) {
|
||||
if (this.intersects(bounds)) {
|
||||
if (ol.extent.intersects(this.bounds, bounds)) {
|
||||
var numChildren = this.children.length;
|
||||
if (numChildren === 0) {
|
||||
return goog.isNull(this.parent) ? this : this.parent;
|
||||
@@ -102,10 +100,10 @@ ol.structs.RTreeNode_.prototype.get = function(bounds) {
|
||||
|
||||
/**
|
||||
* Update boxes up to the root to ensure correct bounding
|
||||
* @param {ol.Rectangle} bounds Bounding box.
|
||||
* @param {ol.Extent} bounds Bounding box.
|
||||
*/
|
||||
ol.structs.RTreeNode_.prototype.update = function(bounds) {
|
||||
this.extend(bounds);
|
||||
ol.extent.extend(this.bounds, bounds);
|
||||
if (!goog.isNull(this.parent)) {
|
||||
this.parent.update(bounds);
|
||||
}
|
||||
@@ -129,15 +127,15 @@ ol.structs.RTreeNode_.prototype.divide = function() {
|
||||
for (var i = 0; i < numChildren; ++i) {
|
||||
child = this.children[i];
|
||||
if (i % half === 0) {
|
||||
node = new ol.structs.RTreeNode_(child.minX, child.minY,
|
||||
child.maxX, child.maxY, this, this.level + 1);
|
||||
node = new ol.structs.RTreeNode_(
|
||||
child.bounds.slice(), this, this.level + 1);
|
||||
goog.object.extend(this.types, node.types);
|
||||
this.children.push(node);
|
||||
}
|
||||
child.parent = /** @type {ol.structs.RTreeNode_} */ (node);
|
||||
goog.object.extend(node.types, child.types);
|
||||
node.children.push(child);
|
||||
node.extend(child);
|
||||
ol.extent.extend(node.bounds, child.bounds);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -153,13 +151,13 @@ ol.structs.RTree = function() {
|
||||
* @type {ol.structs.RTreeNode_}
|
||||
*/
|
||||
this.root_ = new ol.structs.RTreeNode_(
|
||||
-Infinity, -Infinity, Infinity, Infinity, null, 0);
|
||||
[-Infinity, Infinity, -Infinity, Infinity], null, 0);
|
||||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.Rectangle} bounds Bounding box.
|
||||
* @param {ol.Extent} bounds Bounding box.
|
||||
* @param {string=} opt_type Type for another indexing dimension.
|
||||
* @return {Object.<string, Object>} Results for the passed bounding box.
|
||||
*/
|
||||
@@ -171,16 +169,14 @@ ol.structs.RTree.prototype.find = function(bounds, opt_type) {
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.Rectangle} bounds Bounding box.
|
||||
* @param {ol.Extent} bounds Bounding box.
|
||||
* @param {Object} object Object to store with the passed bounds.
|
||||
* @param {string=} opt_type Type for another indexing dimension.
|
||||
*/
|
||||
ol.structs.RTree.prototype.put = function(bounds, object, opt_type) {
|
||||
var found = this.root_.get(bounds);
|
||||
if (found) {
|
||||
var node = new ol.structs.RTreeNode_(
|
||||
bounds.minX, bounds.minY, bounds.maxX, bounds.maxY,
|
||||
found, found.level + 1);
|
||||
var node = new ol.structs.RTreeNode_(bounds, found, found.level + 1);
|
||||
node.object = object;
|
||||
node.objectId = goog.getUid(object).toString();
|
||||
|
||||
|
||||
@@ -5,13 +5,13 @@ goog.provide('ol.tilegrid.TileGrid');
|
||||
goog.require('goog.array');
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.Coordinate');
|
||||
goog.require('ol.Extent');
|
||||
goog.require('ol.PixelBounds');
|
||||
goog.require('ol.Projection');
|
||||
goog.require('ol.Size');
|
||||
goog.require('ol.TileCoord');
|
||||
goog.require('ol.TileRange');
|
||||
goog.require('ol.array');
|
||||
goog.require('ol.extent');
|
||||
|
||||
|
||||
/**
|
||||
@@ -150,10 +150,10 @@ ol.tilegrid.TileGrid.prototype.getPixelBoundsForTileCoordAndResolution =
|
||||
var tileWidth = tileSize.width / scale;
|
||||
var tileHeight = tileSize.height / scale;
|
||||
var minX = Math.round(tileCoord.x * tileWidth);
|
||||
var minY = Math.round(tileCoord.y * tileHeight);
|
||||
var maxX = Math.round((tileCoord.x + 1) * tileWidth);
|
||||
var minY = Math.round(tileCoord.y * tileHeight);
|
||||
var maxY = Math.round((tileCoord.y + 1) * tileHeight);
|
||||
return new ol.PixelBounds(minX, minY, maxX, maxY);
|
||||
return new ol.PixelBounds(minX, maxX, minY, maxY);
|
||||
};
|
||||
|
||||
|
||||
@@ -205,10 +205,10 @@ ol.tilegrid.TileGrid.prototype.getTileRangeExtent =
|
||||
var resolution = this.getResolution(z);
|
||||
var tileSize = this.getTileSize(z);
|
||||
var minX = origin[0] + tileRange.minX * tileSize.width * resolution;
|
||||
var minY = origin[1] + tileRange.minY * tileSize.height * resolution;
|
||||
var maxX = origin[0] + (tileRange.maxX + 1) * tileSize.width * resolution;
|
||||
var minY = origin[1] + tileRange.minY * tileSize.height * resolution;
|
||||
var maxY = origin[1] + (tileRange.maxY + 1) * tileSize.height * resolution;
|
||||
return new ol.Extent(minX, minY, maxX, maxY);
|
||||
return ol.extent.createOrUpdate(minX, maxX, minY, maxY, opt_extent);
|
||||
};
|
||||
|
||||
|
||||
@@ -222,13 +222,13 @@ ol.tilegrid.TileGrid.prototype.getTileRangeForExtentAndResolution =
|
||||
function(extent, resolution, opt_tileRange) {
|
||||
var tileCoord = ol.tilegrid.TileGrid.tmpTileCoord_;
|
||||
this.getTileCoordForXYAndResolution_(
|
||||
extent.minX, extent.minY, resolution, false, tileCoord);
|
||||
extent[0], extent[2], resolution, false, tileCoord);
|
||||
var minX = tileCoord.x;
|
||||
var minY = tileCoord.y;
|
||||
this.getTileCoordForXYAndResolution_(
|
||||
extent.maxX, extent.maxY, resolution, true, tileCoord);
|
||||
extent[1], extent[3], resolution, true, tileCoord);
|
||||
return ol.TileRange.createOrUpdate(
|
||||
minX, minY, tileCoord.x, tileCoord.y, opt_tileRange);
|
||||
minX, tileCoord.x, minY, tileCoord.y, opt_tileRange);
|
||||
};
|
||||
|
||||
|
||||
@@ -272,10 +272,10 @@ ol.tilegrid.TileGrid.prototype.getTileCoordExtent =
|
||||
var resolution = this.getResolution(tileCoord.z);
|
||||
var tileSize = this.getTileSize(tileCoord.z);
|
||||
var minX = origin[0] + tileCoord.x * tileSize.width * resolution;
|
||||
var minY = origin[1] + tileCoord.y * tileSize.height * resolution;
|
||||
var maxX = minX + tileSize.width * resolution;
|
||||
var minY = origin[1] + tileCoord.y * tileSize.height * resolution;
|
||||
var maxY = minY + tileSize.height * resolution;
|
||||
return ol.Extent.createOrUpdate(minX, minY, maxX, maxY, opt_extent);
|
||||
return ol.extent.createOrUpdate(minX, maxX, minY, maxY, opt_extent);
|
||||
};
|
||||
|
||||
|
||||
@@ -401,8 +401,8 @@ ol.tilegrid.createForProjection =
|
||||
function(projection, opt_maxZoom, opt_tileSize) {
|
||||
var projectionExtent = projection.getExtent();
|
||||
var size = Math.max(
|
||||
projectionExtent.maxX - projectionExtent.minX,
|
||||
projectionExtent.maxY - projectionExtent.minY);
|
||||
projectionExtent[1] - projectionExtent[0],
|
||||
projectionExtent[3] - projectionExtent[2]);
|
||||
var maxZoom = goog.isDef(opt_maxZoom) ?
|
||||
opt_maxZoom : ol.DEFAULT_MAX_ZOOM;
|
||||
var tileSize = goog.isDef(opt_tileSize) ?
|
||||
@@ -414,7 +414,7 @@ ol.tilegrid.createForProjection =
|
||||
resolutions[z] = size / Math.pow(2, z);
|
||||
}
|
||||
return new ol.tilegrid.TileGrid({
|
||||
origin: projectionExtent.getBottomLeft(),
|
||||
origin: ol.extent.getBottomLeft(projectionExtent),
|
||||
resolutions: resolutions,
|
||||
tileSize: tileSize
|
||||
});
|
||||
|
||||
@@ -46,8 +46,8 @@ ol.tilegrid.XYZ.prototype.getTileCoordChildTileRange =
|
||||
function(tileCoord, opt_tileRange) {
|
||||
if (tileCoord.z < this.maxZoom_) {
|
||||
return ol.TileRange.createOrUpdate(
|
||||
tileCoord.x << 1, tileCoord.y << 1,
|
||||
tileCoord.x + 1 << 1, tileCoord.y + 1 << 1,
|
||||
tileCoord.x << 1, tileCoord.x + 1 << 1,
|
||||
tileCoord.y << 1, tileCoord.y + 1 << 1,
|
||||
opt_tileRange);
|
||||
} else {
|
||||
return null;
|
||||
@@ -61,7 +61,7 @@ ol.tilegrid.XYZ.prototype.getTileCoordChildTileRange =
|
||||
ol.tilegrid.XYZ.prototype.forEachTileCoordParentTileRange =
|
||||
function(tileCoord, callback, opt_obj, opt_tileRange) {
|
||||
var tileRange = ol.TileRange.createOrUpdate(
|
||||
0, 0, tileCoord.x, tileCoord.y, opt_tileRange);
|
||||
0, tileCoord.x, 0, tileCoord.y, opt_tileRange);
|
||||
var z;
|
||||
for (z = tileCoord.z - 1; z >= 0; --z) {
|
||||
tileRange.minX = tileRange.maxX >>= 1;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
goog.provide('ol.TileRange');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.Rectangle');
|
||||
goog.require('ol.Size');
|
||||
goog.require('ol.TileCoord');
|
||||
|
||||
|
||||
@@ -11,13 +11,12 @@ goog.require('ol.TileCoord');
|
||||
* by its min/max tile coordinates and is inclusive of coordinates.
|
||||
*
|
||||
* @constructor
|
||||
* @extends {ol.Rectangle}
|
||||
* @param {number} minX Minimum X.
|
||||
* @param {number} minY Minimum Y.
|
||||
* @param {number} maxX Maximum X.
|
||||
* @param {number} minY Minimum Y.
|
||||
* @param {number} maxY Maximum Y.
|
||||
*/
|
||||
ol.TileRange = function(minX, minY, maxX, maxY) {
|
||||
ol.TileRange = function(minX, maxX, minY, maxY) {
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
@@ -27,12 +26,12 @@ ol.TileRange = function(minX, minY, maxX, maxY) {
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.minY = minY;
|
||||
this.maxX = maxX;
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.maxX = maxX;
|
||||
this.minY = minY;
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
@@ -40,7 +39,6 @@ ol.TileRange = function(minX, minY, maxX, maxY) {
|
||||
this.maxY = maxY;
|
||||
|
||||
};
|
||||
goog.inherits(ol.TileRange, ol.Rectangle);
|
||||
|
||||
|
||||
/**
|
||||
@@ -49,15 +47,15 @@ goog.inherits(ol.TileRange, ol.Rectangle);
|
||||
*/
|
||||
ol.TileRange.boundingTileRange = function(var_args) {
|
||||
var tileCoord0 = arguments[0];
|
||||
var tileRange = new ol.TileRange(tileCoord0.x, tileCoord0.y,
|
||||
tileCoord0.x, tileCoord0.y);
|
||||
var tileRange = new ol.TileRange(tileCoord0.x, tileCoord0.x,
|
||||
tileCoord0.y, tileCoord0.y);
|
||||
var i, tileCoord;
|
||||
for (i = 1; i < arguments.length; ++i) {
|
||||
tileCoord = arguments[i];
|
||||
goog.asserts.assert(tileCoord.z == tileCoord0.z);
|
||||
tileRange.minX = Math.min(tileRange.minX, tileCoord.x);
|
||||
tileRange.minY = Math.min(tileRange.minY, tileCoord.y);
|
||||
tileRange.maxX = Math.max(tileRange.maxX, tileCoord.x);
|
||||
tileRange.minY = Math.min(tileRange.minY, tileCoord.y);
|
||||
tileRange.maxY = Math.max(tileRange.maxY, tileCoord.y);
|
||||
}
|
||||
return tileRange;
|
||||
@@ -66,21 +64,21 @@ ol.TileRange.boundingTileRange = function(var_args) {
|
||||
|
||||
/**
|
||||
* @param {number} minX Minimum X.
|
||||
* @param {number} minY Minimum Y.
|
||||
* @param {number} maxX Maximum X.
|
||||
* @param {number} minY Minimum Y.
|
||||
* @param {number} maxY Maximum Y.
|
||||
* @param {ol.TileRange|undefined} tileRange TileRange.
|
||||
* @return {ol.TileRange} Tile range.
|
||||
*/
|
||||
ol.TileRange.createOrUpdate = function(minX, minY, maxX, maxY, tileRange) {
|
||||
ol.TileRange.createOrUpdate = function(minX, maxX, minY, maxY, tileRange) {
|
||||
if (goog.isDef(tileRange)) {
|
||||
tileRange.minX = minX;
|
||||
tileRange.minY = minY;
|
||||
tileRange.maxX = maxX;
|
||||
tileRange.minY = minY;
|
||||
tileRange.maxY = maxY;
|
||||
return tileRange;
|
||||
} else {
|
||||
return new ol.TileRange(minX, minY, maxX, maxY);
|
||||
return new ol.TileRange(minX, maxX, minY, maxY);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -106,7 +104,35 @@ ol.TileRange.prototype.containsTileRange = function(tileRange) {
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @param {ol.TileRange} tileRange Tile range.
|
||||
* @return {boolean} Equals.
|
||||
*/
|
||||
ol.TileRange.prototype.equals = function(tileRange) {
|
||||
return this.minX == tileRange.minX && this.minY == tileRange.minY &&
|
||||
this.maxX == tileRange.maxX && this.maxY == tileRange.maxY;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.TileRange} tileRange Tile range.
|
||||
*/
|
||||
ol.TileRange.prototype.extend = function(tileRange) {
|
||||
if (tileRange.minX < this.minX) {
|
||||
this.minX = tileRange.minX;
|
||||
}
|
||||
if (tileRange.maxX > this.maxX) {
|
||||
this.maxX = tileRange.maxX;
|
||||
}
|
||||
if (tileRange.minY < this.minY) {
|
||||
this.minY = tileRange.minY;
|
||||
}
|
||||
if (tileRange.maxY > this.maxY) {
|
||||
this.maxY = tileRange.maxY;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {number} Height.
|
||||
*/
|
||||
ol.TileRange.prototype.getHeight = function() {
|
||||
@@ -115,9 +141,28 @@ ol.TileRange.prototype.getHeight = function() {
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @return {ol.Size} Size.
|
||||
*/
|
||||
ol.TileRange.prototype.getSize = function() {
|
||||
return new ol.Size(this.getWidth(), this.getHeight());
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {number} Width.
|
||||
*/
|
||||
ol.TileRange.prototype.getWidth = function() {
|
||||
return this.maxX - this.minX + 1;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.TileRange} tileRange Tile range.
|
||||
* @return {boolean} Intersects.
|
||||
*/
|
||||
ol.TileRange.prototype.intersects = function(tileRange) {
|
||||
return this.minX <= tileRange.maxX &&
|
||||
this.maxX >= tileRange.minX &&
|
||||
this.minY <= tileRange.maxY &&
|
||||
this.maxY >= tileRange.minY;
|
||||
};
|
||||
|
||||
@@ -3,8 +3,8 @@ goog.provide('ol.TileUrlFunctionType');
|
||||
|
||||
goog.require('goog.array');
|
||||
goog.require('goog.math');
|
||||
goog.require('ol.Extent');
|
||||
goog.require('ol.TileCoord');
|
||||
goog.require('ol.extent');
|
||||
|
||||
|
||||
/**
|
||||
@@ -69,7 +69,7 @@ ol.TileUrlFunction.createFromTileUrlFunctions = function(tileUrlFunctions) {
|
||||
*/
|
||||
ol.TileUrlFunction.createFromParamsFunction =
|
||||
function(baseUrl, params, paramsFunction) {
|
||||
var tmpExtent = new ol.Extent(0, 0, 0, 0);
|
||||
var tmpExtent = ol.extent.createEmptyExtent();
|
||||
return function(tileCoord, projection) {
|
||||
if (goog.isNull(tileCoord)) {
|
||||
return undefined;
|
||||
|
||||
@@ -6,7 +6,6 @@ goog.provide('ol.View2DProperty');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.Constraints');
|
||||
goog.require('ol.Extent');
|
||||
goog.require('ol.IView2D');
|
||||
goog.require('ol.IView3D');
|
||||
goog.require('ol.Projection');
|
||||
@@ -16,6 +15,7 @@ goog.require('ol.RotationConstraintType');
|
||||
goog.require('ol.Size');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.coordinate');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.projection');
|
||||
|
||||
|
||||
@@ -55,8 +55,8 @@ ol.View2D = function(opt_options) {
|
||||
} else if (goog.isDef(options.zoom)) {
|
||||
var projectionExtent = values[ol.View2DProperty.PROJECTION].getExtent();
|
||||
var size = Math.max(
|
||||
projectionExtent.maxX - projectionExtent.minX,
|
||||
projectionExtent.maxY - projectionExtent.minY);
|
||||
projectionExtent[1] - projectionExtent[0],
|
||||
projectionExtent[3] - projectionExtent[2]);
|
||||
values[ol.View2DProperty.RESOLUTION] =
|
||||
size / (ol.DEFAULT_TILE_SIZE * Math.pow(2, options.zoom));
|
||||
}
|
||||
@@ -175,10 +175,10 @@ ol.View2D.prototype.getExtent = function(size) {
|
||||
var center = this.getCenter();
|
||||
var resolution = this.getResolution();
|
||||
var minX = center[0] - resolution * size.width / 2;
|
||||
var minY = center[1] - resolution * size.height / 2;
|
||||
var maxX = center[0] + resolution * size.width / 2;
|
||||
var minY = center[1] - resolution * size.height / 2;
|
||||
var maxY = center[1] + resolution * size.height / 2;
|
||||
return new ol.Extent(minX, minY, maxX, maxY);
|
||||
return [minX, maxX, minY, maxX];
|
||||
};
|
||||
|
||||
|
||||
@@ -214,8 +214,8 @@ goog.exportProperty(
|
||||
* @return {number} Resolution.
|
||||
*/
|
||||
ol.View2D.prototype.getResolutionForExtent = function(extent, size) {
|
||||
var xResolution = (extent.maxX - extent.minX) / size.width;
|
||||
var yResolution = (extent.maxY - extent.minY) / size.height;
|
||||
var xResolution = (extent[1] - extent[0]) / size.width;
|
||||
var yResolution = (extent[3] - extent[2]) / size.height;
|
||||
return Math.max(xResolution, yResolution);
|
||||
};
|
||||
|
||||
@@ -310,7 +310,7 @@ ol.View2D.prototype.getView3D = function() {
|
||||
* @param {ol.Size} size Box pixel size.
|
||||
*/
|
||||
ol.View2D.prototype.fitExtent = function(extent, size) {
|
||||
this.setCenter(extent.getCenter());
|
||||
this.setCenter(ol.extent.getCenter(extent));
|
||||
var resolution = this.getResolutionForExtent(extent, size);
|
||||
resolution = this.constrainResolution(resolution, 0, 0);
|
||||
this.setResolution(resolution);
|
||||
@@ -396,8 +396,8 @@ ol.View2D.createResolutionConstraint_ = function(options) {
|
||||
var projectionExtent = ol.projection.createProjection(
|
||||
options.projection, 'EPSG:3857').getExtent();
|
||||
maxResolution = Math.max(
|
||||
projectionExtent.maxX - projectionExtent.minX,
|
||||
projectionExtent.maxY - projectionExtent.minY) / ol.DEFAULT_TILE_SIZE;
|
||||
projectionExtent[1] - projectionExtent[0],
|
||||
projectionExtent[3] - projectionExtent[2]) / ol.DEFAULT_TILE_SIZE;
|
||||
}
|
||||
var maxZoom = options.maxZoom;
|
||||
if (!goog.isDef(maxZoom)) {
|
||||
|
||||
Reference in New Issue
Block a user