Merge pull request #956 from tschaub/extent
Change structure for ol.Extent. This makes extent use `[minX, minY, maxX, maxY]` order.
This commit is contained in:
@@ -129,22 +129,22 @@ ol.expr.lib[ol.expr.functions.CONCAT] = function(var_args) {
|
||||
/**
|
||||
* Determine if a feature's extent intersects the provided extent.
|
||||
* @param {number} minX Minimum x-coordinate value.
|
||||
* @param {number} maxX Maximum x-coordinate value.
|
||||
* @param {number} minY Minimum y-coordinate value.
|
||||
* @param {number} maxX Maximum x-coordinate value.
|
||||
* @param {number} maxY Maximum y-coordinate value.
|
||||
* @param {string=} opt_projection Projection of the extent.
|
||||
* @param {string=} opt_attribute Name of the geometry attribute to use.
|
||||
* @return {boolean} The provided extent intersects the feature's extent.
|
||||
* @this {ol.Feature}
|
||||
*/
|
||||
ol.expr.lib[ol.expr.functions.EXTENT] = function(minX, maxX, minY, maxY,
|
||||
ol.expr.lib[ol.expr.functions.EXTENT] = function(minX, minY, maxX, maxY,
|
||||
opt_projection, opt_attribute) {
|
||||
var intersects = false;
|
||||
var geometry = goog.isDef(opt_attribute) ?
|
||||
this.get(opt_attribute) : this.getGeometry();
|
||||
if (geometry) {
|
||||
intersects = ol.extent.intersects(geometry.getBounds(),
|
||||
[minX, maxX, minY, maxY]);
|
||||
[minX, minY, maxX, maxY]);
|
||||
}
|
||||
return intersects;
|
||||
};
|
||||
|
||||
@@ -48,6 +48,17 @@ ol.extent.boundingExtentXYs_ = function(xs, ys, opt_extent) {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Creates a clone of an extent.
|
||||
*
|
||||
* @param {ol.Extent} extent Extent to clone.
|
||||
* @return {ol.Extent} The clone.
|
||||
*/
|
||||
ol.extent.clone = function(extent) {
|
||||
return extent.slice();
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Checks if the passed coordinate is contained or on the edge of the extent.
|
||||
*
|
||||
@@ -56,8 +67,8 @@ ol.extent.boundingExtentXYs_ = function(xs, ys, opt_extent) {
|
||||
* @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];
|
||||
return extent[0] <= coordinate[0] && coordinate[0] <= extent[2] &&
|
||||
extent[1] <= coordinate[1] && coordinate[1] <= extent[3];
|
||||
};
|
||||
|
||||
|
||||
@@ -69,8 +80,8 @@ ol.extent.containsCoordinate = function(extent, coordinate) {
|
||||
* @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 extent1[0] <= extent2[0] && extent2[2] <= extent1[2] &&
|
||||
extent1[1] <= extent2[1] && extent2[3] <= extent1[3];
|
||||
};
|
||||
|
||||
|
||||
@@ -78,7 +89,7 @@ ol.extent.containsExtent = function(extent1, extent2) {
|
||||
* @return {ol.Extent} Empty extent.
|
||||
*/
|
||||
ol.extent.createEmpty = function() {
|
||||
return [Infinity, -Infinity, Infinity, -Infinity];
|
||||
return [Infinity, Infinity, -Infinity, -Infinity];
|
||||
};
|
||||
|
||||
|
||||
@@ -93,12 +104,12 @@ ol.extent.createEmpty = function() {
|
||||
ol.extent.createOrUpdate = function(minX, maxX, minY, maxY, opt_extent) {
|
||||
if (goog.isDef(opt_extent)) {
|
||||
opt_extent[0] = minX;
|
||||
opt_extent[1] = maxX;
|
||||
opt_extent[2] = minY;
|
||||
opt_extent[2] = maxX;
|
||||
opt_extent[1] = minY;
|
||||
opt_extent[3] = maxY;
|
||||
return opt_extent;
|
||||
} else {
|
||||
return [minX, maxX, minY, maxY];
|
||||
return [minX, minY, maxX, maxY];
|
||||
}
|
||||
};
|
||||
|
||||
@@ -109,8 +120,8 @@ ol.extent.createOrUpdate = function(minX, maxX, minY, maxY, opt_extent) {
|
||||
* @return {ol.Extent} Extent.
|
||||
*/
|
||||
ol.extent.empty = function(extent) {
|
||||
extent[0] = extent[2] = Infinity;
|
||||
extent[1] = extent[3] = -Infinity;
|
||||
extent[0] = extent[1] = Infinity;
|
||||
extent[2] = extent[3] = -Infinity;
|
||||
return extent;
|
||||
};
|
||||
|
||||
@@ -121,8 +132,8 @@ ol.extent.empty = function(extent) {
|
||||
* @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];
|
||||
return extent1[0] == extent2[0] && extent1[2] == extent2[2] &&
|
||||
extent1[1] == extent2[1] && extent1[3] == extent2[3];
|
||||
};
|
||||
|
||||
|
||||
@@ -134,12 +145,12 @@ 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]) {
|
||||
if (extent2[2] > extent1[2]) {
|
||||
extent1[2] = extent2[2];
|
||||
}
|
||||
if (extent2[1] < extent1[1]) {
|
||||
extent1[1] = extent2[1];
|
||||
}
|
||||
if (extent2[3] > extent1[3]) {
|
||||
extent1[3] = extent2[3];
|
||||
}
|
||||
@@ -154,11 +165,11 @@ 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[0] > extent[2]) {
|
||||
extent[2] = coordinate[0];
|
||||
}
|
||||
if (coordinate[1] < extent[2]) {
|
||||
extent[2] = coordinate[1];
|
||||
if (coordinate[1] < extent[1]) {
|
||||
extent[1] = coordinate[1];
|
||||
}
|
||||
if (coordinate[1] > extent[3]) {
|
||||
extent[3] = coordinate[1];
|
||||
@@ -171,7 +182,7 @@ ol.extent.extendCoordinate = function(extent, coordinate) {
|
||||
* @return {ol.Coordinate} Bottom left coordinate.
|
||||
*/
|
||||
ol.extent.getBottomLeft = function(extent) {
|
||||
return [extent[0], extent[2]];
|
||||
return [extent[0], extent[1]];
|
||||
};
|
||||
|
||||
|
||||
@@ -180,7 +191,7 @@ ol.extent.getBottomLeft = function(extent) {
|
||||
* @return {ol.Coordinate} Bottom right coordinate.
|
||||
*/
|
||||
ol.extent.getBottomRight = function(extent) {
|
||||
return [extent[1], extent[2]];
|
||||
return [extent[2], extent[1]];
|
||||
};
|
||||
|
||||
|
||||
@@ -189,7 +200,7 @@ ol.extent.getBottomRight = function(extent) {
|
||||
* @return {ol.Coordinate} Center.
|
||||
*/
|
||||
ol.extent.getCenter = function(extent) {
|
||||
return [(extent[0] + extent[1]) / 2, (extent[2] + extent[3]) / 2];
|
||||
return [(extent[0] + extent[2]) / 2, (extent[1] + extent[3]) / 2];
|
||||
};
|
||||
|
||||
|
||||
@@ -227,7 +238,7 @@ ol.extent.getForView2DAndSize =
|
||||
* @return {number} Height.
|
||||
*/
|
||||
ol.extent.getHeight = function(extent) {
|
||||
return extent[3] - extent[2];
|
||||
return extent[3] - extent[1];
|
||||
};
|
||||
|
||||
|
||||
@@ -236,7 +247,7 @@ ol.extent.getHeight = function(extent) {
|
||||
* @return {ol.Size} Size.
|
||||
*/
|
||||
ol.extent.getSize = function(extent) {
|
||||
return [extent[1] - extent[0], extent[3] - extent[2]];
|
||||
return [extent[2] - extent[0], extent[3] - extent[1]];
|
||||
};
|
||||
|
||||
|
||||
@@ -254,7 +265,7 @@ ol.extent.getTopLeft = function(extent) {
|
||||
* @return {ol.Coordinate} Top right coordinate.
|
||||
*/
|
||||
ol.extent.getTopRight = function(extent) {
|
||||
return [extent[1], extent[3]];
|
||||
return [extent[2], extent[3]];
|
||||
};
|
||||
|
||||
|
||||
@@ -263,7 +274,7 @@ ol.extent.getTopRight = function(extent) {
|
||||
* @return {number} Width.
|
||||
*/
|
||||
ol.extent.getWidth = function(extent) {
|
||||
return extent[1] - extent[0];
|
||||
return extent[2] - extent[0];
|
||||
};
|
||||
|
||||
|
||||
@@ -273,10 +284,10 @@ ol.extent.getWidth = function(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];
|
||||
return extent1[0] <= extent2[2] &&
|
||||
extent1[2] >= extent2[0] &&
|
||||
extent1[1] <= extent2[3] &&
|
||||
extent1[3] >= extent2[1];
|
||||
};
|
||||
|
||||
|
||||
@@ -285,7 +296,7 @@ ol.extent.intersects = function(extent1, extent2) {
|
||||
* @return {boolean} Is empty.
|
||||
*/
|
||||
ol.extent.isEmpty = function(extent) {
|
||||
return extent[1] < extent[0] || extent[3] < extent[2];
|
||||
return extent[2] < extent[0] || extent[3] < extent[1];
|
||||
};
|
||||
|
||||
|
||||
@@ -296,8 +307,8 @@ ol.extent.isEmpty = function(extent) {
|
||||
*/
|
||||
ol.extent.normalize = function(extent, coordinate) {
|
||||
return [
|
||||
(coordinate[0] - extent[0]) / (extent[1] - extent[0]),
|
||||
(coordinate[1] - extent[2]) / (extent[3] - extent[2])
|
||||
(coordinate[0] - extent[0]) / (extent[2] - extent[0]),
|
||||
(coordinate[1] - extent[1]) / (extent[3] - extent[1])
|
||||
];
|
||||
};
|
||||
|
||||
@@ -307,11 +318,11 @@ ol.extent.normalize = function(extent, coordinate) {
|
||||
* @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);
|
||||
var deltaX = ((extent[2] - extent[0]) / 2) * (value - 1);
|
||||
var deltaY = ((extent[3] - extent[1]) / 2) * (value - 1);
|
||||
extent[0] -= deltaX;
|
||||
extent[1] += deltaX;
|
||||
extent[2] -= deltaY;
|
||||
extent[2] += deltaX;
|
||||
extent[1] -= deltaY;
|
||||
extent[3] += deltaY;
|
||||
};
|
||||
|
||||
@@ -321,7 +332,8 @@ ol.extent.scaleFromCenter = function(extent, value) {
|
||||
* @return {string} String.
|
||||
*/
|
||||
ol.extent.toString = function(extent) {
|
||||
return '(' + [extent[0], extent[1], extent[2], extent[3]].join(', ') + ')';
|
||||
return '(' + [extent[0], extent[2], extent[1],
|
||||
extent[3]].join(', ') + ')';
|
||||
};
|
||||
|
||||
|
||||
@@ -333,10 +345,10 @@ ol.extent.toString = function(extent) {
|
||||
*/
|
||||
ol.extent.transform = function(extent, transformFn, opt_extent) {
|
||||
var coordinates = [
|
||||
extent[0], extent[2],
|
||||
extent[0], extent[1],
|
||||
extent[0], extent[3],
|
||||
extent[1], extent[2],
|
||||
extent[1], extent[3]
|
||||
extent[2], extent[1],
|
||||
extent[2], extent[3]
|
||||
];
|
||||
transformFn(coordinates, coordinates, 2);
|
||||
var xs = [coordinates[0], coordinates[2], coordinates[4], coordinates[6]];
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
goog.provide('ol.geom.AbstractCollection');
|
||||
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.geom.Geometry');
|
||||
|
||||
|
||||
@@ -38,22 +39,12 @@ goog.inherits(ol.geom.AbstractCollection, ol.geom.Geometry);
|
||||
*/
|
||||
ol.geom.AbstractCollection.prototype.getBounds = function() {
|
||||
if (goog.isNull(this.bounds)) {
|
||||
var minX,
|
||||
minY = minX = Infinity,
|
||||
maxX,
|
||||
maxY = maxX = -Infinity,
|
||||
components = this.components,
|
||||
len = components.length,
|
||||
bounds, i;
|
||||
|
||||
for (i = 0; i < len; ++i) {
|
||||
bounds = components[i].getBounds();
|
||||
minX = Math.min(bounds[0], minX);
|
||||
maxX = Math.max(bounds[1], maxX);
|
||||
minY = Math.min(bounds[2], minY);
|
||||
maxY = Math.max(bounds[3], maxY);
|
||||
var bounds = ol.extent.createEmpty();
|
||||
var components = this.components;
|
||||
for (var i = 0, ii = components.length; i < ii; ++i) {
|
||||
ol.extent.extend(bounds, components[i].getBounds());
|
||||
}
|
||||
this.bounds = [minX, maxX, minY, maxY];
|
||||
this.bounds = bounds;
|
||||
}
|
||||
return this.bounds;
|
||||
};
|
||||
|
||||
@@ -126,7 +126,7 @@ ol.geom.LineString.prototype.getBounds = function() {
|
||||
maxY = y;
|
||||
}
|
||||
}
|
||||
this.bounds_ = [minX, maxX, minY, maxY];
|
||||
this.bounds_ = [minX, minY, maxX, maxY];
|
||||
}
|
||||
return this.bounds_;
|
||||
};
|
||||
|
||||
@@ -68,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_ = [x, x, y, y];
|
||||
this.bounds_ = [x, y, x, y];
|
||||
}
|
||||
return this.bounds_;
|
||||
};
|
||||
|
||||
@@ -2,6 +2,7 @@ goog.provide('ol.geom2');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.Extent');
|
||||
goog.require('ol.extent');
|
||||
|
||||
|
||||
/**
|
||||
@@ -10,22 +11,17 @@ goog.require('ol.Extent');
|
||||
* @return {ol.Extent} Extent.
|
||||
*/
|
||||
ol.geom2.getExtent = function(buf, dim) {
|
||||
var extent = new Array(2 * dim);
|
||||
var extentIndex = 0;
|
||||
var i;
|
||||
for (i = 0; i < dim; ++i) {
|
||||
extent[extentIndex++] = Infinity;
|
||||
extent[extentIndex++] = -Infinity;
|
||||
}
|
||||
var extent = ol.extent.createEmpty();
|
||||
var bufArr = buf.getArray();
|
||||
buf.forEachRange(function(start, stop) {
|
||||
var extentIndex, i, j;
|
||||
for (i = start; i < stop; i += dim) {
|
||||
extentIndex = 0;
|
||||
for (j = 0; j < dim; ++j) {
|
||||
extent[extentIndex++] = Math.min(extent[2 * j], bufArr[i + j]);
|
||||
extent[extentIndex++] = Math.max(extent[2 * j + 1], bufArr[i + j]);
|
||||
}
|
||||
var x, y;
|
||||
for (var i = start; i < stop; i += dim) {
|
||||
x = bufArr[i];
|
||||
y = bufArr[i + 1];
|
||||
extent[0] = Math.min(extent[0], x);
|
||||
extent[1] = Math.min(extent[1], y);
|
||||
extent[2] = Math.max(extent[2], x);
|
||||
extent[3] = Math.max(extent[3], y);
|
||||
}
|
||||
});
|
||||
return extent;
|
||||
|
||||
@@ -107,12 +107,15 @@ ol.layer.FeatureCache.prototype.getFeaturesObject = function(opt_expr) {
|
||||
} else if (name === ol.expr.functions.EXTENT) {
|
||||
var args = /** @type {ol.expr.Call} */ (opt_expr).getArgs();
|
||||
goog.asserts.assert(args.length === 4);
|
||||
var extent = [];
|
||||
for (var i = 0; i < 4; ++i) {
|
||||
goog.asserts.assert(args[i] instanceof ol.expr.Literal);
|
||||
extent[i] = /** @type {ol.expr.Literal} */ (args[i]).evaluate();
|
||||
goog.asserts.assertNumber(extent[i]);
|
||||
}
|
||||
var extent = [
|
||||
/** @type {ol.expr.Literal} */ (args[0]).evaluate(),
|
||||
/** @type {ol.expr.Literal} */ (args[1]).evaluate(),
|
||||
/** @type {ol.expr.Literal} */ (args[2]).evaluate(),
|
||||
/** @type {ol.expr.Literal} */ (args[3]).evaluate()
|
||||
];
|
||||
features = this.rTree_.searchReturningObject(extent);
|
||||
} else {
|
||||
// not a call expression, check logical
|
||||
@@ -133,13 +136,16 @@ ol.layer.FeatureCache.prototype.getFeaturesObject = function(opt_expr) {
|
||||
} else if (name === ol.expr.functions.EXTENT) {
|
||||
args = /** @type {ol.expr.Call} */ (expr).getArgs();
|
||||
goog.asserts.assert(args.length === 4);
|
||||
extent = [];
|
||||
for (var j = 0; j < 4; ++j) {
|
||||
goog.asserts.assert(args[j] instanceof ol.expr.Literal);
|
||||
extent[j] =
|
||||
/** @type {ol.expr.Literal} */ (args[j]).evaluate();
|
||||
goog.asserts.assertNumber(extent[j]);
|
||||
}
|
||||
extent = [[
|
||||
/** @type {ol.expr.Literal} */ (args[0]).evaluate(),
|
||||
/** @type {ol.expr.Literal} */ (args[1]).evaluate()
|
||||
], [
|
||||
/** @type {ol.expr.Literal} */ (args[2]).evaluate(),
|
||||
/** @type {ol.expr.Literal} */ (args[3]).evaluate()
|
||||
]];
|
||||
}
|
||||
}
|
||||
if (type && extent) {
|
||||
|
||||
@@ -92,9 +92,12 @@ ol.parser.ogc.Filter_v1_0_0 = function() {
|
||||
goog.asserts.assert(args[2] instanceof ol.expr.Literal);
|
||||
goog.asserts.assert(args[3] instanceof ol.expr.Literal);
|
||||
goog.asserts.assert(args[4] instanceof ol.expr.Literal);
|
||||
var property = args[5], bbox = [args[0].getValue(), args[1].getValue(),
|
||||
args[2].getValue(), args[3].getValue()],
|
||||
projection = args[4].getValue();
|
||||
var bbox = [
|
||||
args[0].getValue(), args[1].getValue(),
|
||||
args[2].getValue(), args[3].getValue()
|
||||
];
|
||||
var projection = args[4].getValue();
|
||||
var property = args[5];
|
||||
// PropertyName is mandatory in 1.0.0, but e.g. GeoServer also
|
||||
// accepts filters without it.
|
||||
if (goog.isDefAndNotNull(property)) {
|
||||
@@ -129,8 +132,10 @@ ol.parser.ogc.Filter_v1_0_0.prototype.writeSpatial_ = function(filter, name) {
|
||||
goog.asserts.assert(args[1] instanceof ol.expr.Literal);
|
||||
goog.asserts.assert(args[2] instanceof ol.expr.Literal);
|
||||
goog.asserts.assert(args[3] instanceof ol.expr.Literal);
|
||||
bbox = [args[0].getValue(), args[1].getValue(), args[2].getValue(),
|
||||
args[3].getValue()];
|
||||
bbox = [
|
||||
args[0].getValue(), args[1].getValue(),
|
||||
args[2].getValue(), args[3].getValue()
|
||||
];
|
||||
projection = args[4];
|
||||
property = args[5];
|
||||
} else if (args[0] instanceof ol.expr.Literal &&
|
||||
|
||||
@@ -130,9 +130,12 @@ ol.parser.ogc.Filter_v1_1_0 = function() {
|
||||
goog.asserts.assert(args[2] instanceof ol.expr.Literal);
|
||||
goog.asserts.assert(args[3] instanceof ol.expr.Literal);
|
||||
goog.asserts.assert(args[4] instanceof ol.expr.Literal);
|
||||
var property = args[5], bbox = [args[0].getValue(), args[1].getValue(),
|
||||
args[2].getValue(), args[3].getValue()],
|
||||
projection = args[4].getValue();
|
||||
var bbox = [
|
||||
args[0].getValue(), args[1].getValue(),
|
||||
args[2].getValue(), args[3].getValue()
|
||||
];
|
||||
var projection = args[4].getValue();
|
||||
var property = args[5];
|
||||
// PropertyName is optional in 1.1.0
|
||||
if (goog.isDefAndNotNull(property)) {
|
||||
this.writeNode('PropertyName', property, null, node);
|
||||
@@ -187,8 +190,10 @@ ol.parser.ogc.Filter_v1_1_0.prototype.writeSpatial_ = function(filter, name) {
|
||||
goog.asserts.assert(args[1] instanceof ol.expr.Literal);
|
||||
goog.asserts.assert(args[2] instanceof ol.expr.Literal);
|
||||
goog.asserts.assert(args[3] instanceof ol.expr.Literal);
|
||||
bbox = [args[0].getValue(), args[1].getValue(), args[2].getValue(),
|
||||
args[3].getValue()];
|
||||
bbox = [
|
||||
args[0].getValue(), args[1].getValue(),
|
||||
args[2].getValue(), args[3].getValue()
|
||||
];
|
||||
projection = args[4];
|
||||
property = args[5];
|
||||
} else if (args[0] instanceof ol.expr.Literal &&
|
||||
|
||||
@@ -35,8 +35,10 @@ ol.parser.ogc.GML_v2 = function(opt_options) {
|
||||
[node, coordinates, container]);
|
||||
this.readChildNodes(node, coordinates);
|
||||
container.projection = node.getAttribute('srsName');
|
||||
container.bounds = [coordinates[0][0][0], coordinates[0][1][0],
|
||||
coordinates[0][0][1], coordinates[0][1][1]];
|
||||
container.bounds = [
|
||||
coordinates[0][0][0], coordinates[0][0][1],
|
||||
coordinates[0][1][0], coordinates[0][1][1]
|
||||
];
|
||||
}
|
||||
});
|
||||
goog.object.extend(this.writers['http://www.opengis.net/gml'], {
|
||||
@@ -104,8 +106,11 @@ ol.parser.ogc.GML_v2 = function(opt_options) {
|
||||
},
|
||||
'Box': function(extent) {
|
||||
var node = this.createElementNS('gml:Box');
|
||||
this.writeNode('coordinates', [[extent[0], extent[1]],
|
||||
[extent[2], extent[3]]], null, node);
|
||||
var coordinates = [
|
||||
[extent[0], extent[1]],
|
||||
[extent[2], extent[3]]
|
||||
];
|
||||
this.writeNode('coordinates', coordinates, null, node);
|
||||
// srsName attribute is optional for gml:Box
|
||||
if (goog.isDefAndNotNull(this.srsName)) {
|
||||
node.setAttribute('srsName', this.srsName);
|
||||
|
||||
@@ -113,7 +113,7 @@ ol.parser.ogc.GML_v3 = function(opt_options) {
|
||||
if (coords.length === 2) {
|
||||
obj.push([coords.reverse()]);
|
||||
} else if (coords.length === 3) {
|
||||
obj.push([coords[1], coords[0], coords[2]]);
|
||||
obj.push([[coords[1], coords[0], coords[2]]]);
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -215,20 +215,22 @@ ol.parser.ogc.GML_v3 = function(opt_options) {
|
||||
[node, coordinates, container]);
|
||||
this.readChildNodes(node, coordinates);
|
||||
container.projection = node.getAttribute('srsName');
|
||||
container.bounds = [coordinates[0][0][0][0], coordinates[1][0][0][0],
|
||||
coordinates[0][0][0][1], coordinates[1][0][0][1]];
|
||||
container.bounds = [
|
||||
coordinates[0][0], coordinates[0][1],
|
||||
coordinates[1][0], coordinates[1][1]
|
||||
];
|
||||
},
|
||||
'lowerCorner': function(node, envelope) {
|
||||
var coordinates = [];
|
||||
this.readers[this.defaultNamespaceURI]['pos'].apply(this,
|
||||
[node, coordinates]);
|
||||
envelope.push(coordinates);
|
||||
envelope.push(coordinates[0][0]);
|
||||
},
|
||||
'upperCorner': function(node, envelope) {
|
||||
var coordinates = [];
|
||||
this.readers[this.defaultNamespaceURI]['pos'].apply(this,
|
||||
[node, coordinates]);
|
||||
envelope.push(coordinates);
|
||||
envelope.push(coordinates[0][0]);
|
||||
}
|
||||
});
|
||||
goog.object.extend(this.writers['http://www.opengis.net/gml'], {
|
||||
@@ -391,9 +393,9 @@ ol.parser.ogc.GML_v3 = function(opt_options) {
|
||||
// only 2d for simple features profile
|
||||
var pos;
|
||||
if (this.axisOrientation.substr(0, 2) === 'en') {
|
||||
pos = (bounds[0] + ' ' + bounds[2]);
|
||||
pos = (bounds[0] + ' ' + bounds[1]);
|
||||
} else {
|
||||
pos = (bounds[2] + ' ' + bounds[0]);
|
||||
pos = (bounds[1] + ' ' + bounds[0]);
|
||||
}
|
||||
var node = this.createElementNS('gml:lowerCorner');
|
||||
node.appendChild(this.createTextNode(pos));
|
||||
@@ -403,9 +405,9 @@ ol.parser.ogc.GML_v3 = function(opt_options) {
|
||||
// only 2d for simple features profile
|
||||
var pos;
|
||||
if (this.axisOrientation.substr(0, 2) === 'en') {
|
||||
pos = (bounds[1] + ' ' + bounds[3]);
|
||||
pos = (bounds[2] + ' ' + bounds[3]);
|
||||
} else {
|
||||
pos = (bounds[3] + ' ' + bounds[1]);
|
||||
pos = (bounds[3] + ' ' + bounds[2]);
|
||||
}
|
||||
var node = this.createElementNS('gml:upperCorner');
|
||||
node.appendChild(this.createTextNode(pos));
|
||||
|
||||
@@ -410,7 +410,7 @@ goog.inherits(ol.proj.EPSG2056, ol.proj.CH);
|
||||
* @type {ol.Extent}
|
||||
*/
|
||||
ol.proj.EPSG2056.EXTENT =
|
||||
[2485869.5728, 2837076.5648, 1076443.1884, 1299941.7864];
|
||||
[2485869.5728, 1076443.1884, 2837076.5648, 1299941.7864];
|
||||
|
||||
|
||||
/**
|
||||
@@ -447,7 +447,10 @@ goog.inherits(ol.proj.EPSG21781, ol.proj.CH);
|
||||
* @const
|
||||
* @type {ol.Extent}
|
||||
*/
|
||||
ol.proj.EPSG21781.EXTENT = [485869.5728, 837076.5648, 76443.1884, 299941.7864];
|
||||
ol.proj.EPSG21781.EXTENT = [
|
||||
485869.5728, 76443.1884,
|
||||
837076.5648, 299941.7864
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -44,8 +44,8 @@ ol.proj.EPSG3857.HALF_SIZE = Math.PI * ol.proj.EPSG3857.RADIUS;
|
||||
* @type {ol.Extent}
|
||||
*/
|
||||
ol.proj.EPSG3857.EXTENT = [
|
||||
-ol.proj.EPSG3857.HALF_SIZE, ol.proj.EPSG3857.HALF_SIZE,
|
||||
-ol.proj.EPSG3857.HALF_SIZE, ol.proj.EPSG3857.HALF_SIZE
|
||||
-ol.proj.EPSG3857.HALF_SIZE, -ol.proj.EPSG3857.HALF_SIZE,
|
||||
ol.proj.EPSG3857.HALF_SIZE, ol.proj.EPSG3857.HALF_SIZE
|
||||
];
|
||||
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ goog.inherits(ol.proj.EPSG4326, ol.Projection);
|
||||
* @const
|
||||
* @type {ol.Extent}
|
||||
*/
|
||||
ol.proj.EPSG4326.EXTENT = [-180, 180, -90, 90];
|
||||
ol.proj.EPSG4326.EXTENT = [-180, -90, 180, 90];
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -478,8 +478,8 @@ ol.renderer.canvas.VectorLayer.prototype.renderFrame =
|
||||
} else if (idle) {
|
||||
tileExtent = tileGrid.getTileCoordExtent(tileCoord);
|
||||
tileExtent[0] -= tileGutter;
|
||||
tileExtent[1] += tileGutter;
|
||||
tileExtent[2] -= tileGutter;
|
||||
tileExtent[2] += tileGutter;
|
||||
tileExtent[1] -= tileGutter;
|
||||
tileExtent[3] += tileGutter;
|
||||
tileHasFeatures = false;
|
||||
for (i = 0; i < numTypes; ++i) {
|
||||
|
||||
@@ -170,11 +170,11 @@ ol.renderer.webgl.ImageLayer.prototype.updateProjectionMatrix_ =
|
||||
goog.vec.Mat4.rotateZ(projectionMatrix, -viewRotation);
|
||||
goog.vec.Mat4.translate(projectionMatrix,
|
||||
imageExtent[0] - viewCenter[0],
|
||||
imageExtent[2] - viewCenter[1],
|
||||
imageExtent[1] - viewCenter[1],
|
||||
0);
|
||||
goog.vec.Mat4.scale(projectionMatrix,
|
||||
(imageExtent[1] - imageExtent[0]) / 2,
|
||||
(imageExtent[3] - imageExtent[2]) / 2,
|
||||
(imageExtent[2] - imageExtent[0]) / 2,
|
||||
(imageExtent[3] - imageExtent[1]) / 2,
|
||||
1);
|
||||
goog.vec.Mat4.translate(projectionMatrix, 1, 1, 0);
|
||||
|
||||
|
||||
@@ -161,8 +161,8 @@ ol.renderer.webgl.TileLayer.prototype.renderFrame =
|
||||
var minX = origin[0] + tileRange.minX * tileSize[0] * tileResolution;
|
||||
var minY = origin[1] + tileRange.minY * tileSize[1] * tileResolution;
|
||||
framebufferExtent = [
|
||||
minX, minX + framebufferExtentDimension,
|
||||
minY, minY + framebufferExtentDimension
|
||||
minX, minY,
|
||||
minX + framebufferExtentDimension, minY + framebufferExtentDimension
|
||||
];
|
||||
|
||||
this.bindFramebuffer(frameState, framebufferDimension);
|
||||
@@ -246,11 +246,13 @@ ol.renderer.webgl.TileLayer.prototype.renderFrame =
|
||||
for (tileKey in tilesToDraw) {
|
||||
tile = tilesToDraw[tileKey];
|
||||
tileExtent = tileGrid.getTileCoordExtent(tile.tileCoord, tmpExtent);
|
||||
sx = 2 * (tileExtent[1] - tileExtent[0]) / framebufferExtentDimension;
|
||||
sy = 2 * (tileExtent[3] - tileExtent[2]) / framebufferExtentDimension;
|
||||
sx = 2 * (tileExtent[2] - tileExtent[0]) /
|
||||
framebufferExtentDimension;
|
||||
sy = 2 * (tileExtent[3] - tileExtent[1]) /
|
||||
framebufferExtentDimension;
|
||||
tx = 2 * (tileExtent[0] - framebufferExtent[0]) /
|
||||
framebufferExtentDimension - 1;
|
||||
ty = 2 * (tileExtent[2] - framebufferExtent[2]) /
|
||||
ty = 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);
|
||||
@@ -295,16 +297,16 @@ ol.renderer.webgl.TileLayer.prototype.renderFrame =
|
||||
goog.vec.Mat4.makeIdentity(texCoordMatrix);
|
||||
goog.vec.Mat4.translate(texCoordMatrix,
|
||||
(center[0] - framebufferExtent[0]) /
|
||||
(framebufferExtent[1] - framebufferExtent[0]),
|
||||
(center[1] - framebufferExtent[2]) /
|
||||
(framebufferExtent[3] - framebufferExtent[2]),
|
||||
(framebufferExtent[2] - framebufferExtent[0]),
|
||||
(center[1] - framebufferExtent[1]) /
|
||||
(framebufferExtent[3] - framebufferExtent[1]),
|
||||
0);
|
||||
goog.vec.Mat4.rotateZ(texCoordMatrix, view2DState.rotation);
|
||||
goog.vec.Mat4.scale(texCoordMatrix,
|
||||
frameState.size[0] * view2DState.resolution /
|
||||
(framebufferExtent[1] - framebufferExtent[0]),
|
||||
(framebufferExtent[2] - framebufferExtent[0]),
|
||||
frameState.size[1] * view2DState.resolution /
|
||||
(framebufferExtent[3] - framebufferExtent[2]),
|
||||
(framebufferExtent[3] - framebufferExtent[1]),
|
||||
1);
|
||||
goog.vec.Mat4.translate(texCoordMatrix,
|
||||
-0.5,
|
||||
|
||||
@@ -20,7 +20,7 @@ ol.source.ImageStatic = function(options) {
|
||||
|
||||
var imageExtent = options.imageExtent;
|
||||
var imageSize = options.imageSize;
|
||||
var imageResolution = (imageExtent[3] - imageExtent[2]) / imageSize[1];
|
||||
var imageResolution = (imageExtent[3] - imageExtent[1]) / imageSize[1];
|
||||
var projection = ol.proj.get(options.projection);
|
||||
|
||||
goog.base(this, {
|
||||
|
||||
@@ -89,8 +89,8 @@ ol.source.ImageWMS.prototype.getImage =
|
||||
|
||||
extent = extent.slice();
|
||||
ol.extent.scaleFromCenter(extent, this.ratio_);
|
||||
var width = (extent[1] - extent[0]) / resolution;
|
||||
var height = (extent[3] - extent[2]) / resolution;
|
||||
var width = (extent[2] - extent[0]) / resolution;
|
||||
var height = (extent[3] - extent[1]) / resolution;
|
||||
var size = [width, height];
|
||||
|
||||
this.image_ = this.createImage(extent, resolution, size, projection);
|
||||
|
||||
@@ -69,15 +69,15 @@ goog.inherits(ol.source.TileJSON, ol.source.TileImage);
|
||||
* @protected
|
||||
*/
|
||||
ol.source.TileJSON.prototype.handleTileJSONResponse = function() {
|
||||
|
||||
var tileJSON = ol.tilejson.grids_.pop();
|
||||
|
||||
var epsg4326Projection = ol.proj.get('EPSG:4326');
|
||||
|
||||
var extent;
|
||||
if (goog.isDef(tileJSON.bounds)) {
|
||||
var bounds = tileJSON.bounds;
|
||||
var epsg4326Extent = [bounds[0], bounds[2], bounds[1], bounds[3]];
|
||||
var epsg4326Extent = [
|
||||
tileJSON.bounds.slice(0, 2), tileJSON.bounds.slice(2)
|
||||
];
|
||||
var transform = ol.proj.getTransformFromProjections(
|
||||
epsg4326Projection, this.getProjection());
|
||||
extent = ol.extent.transform(epsg4326Extent, transform);
|
||||
|
||||
@@ -76,9 +76,10 @@ ol.source.TileWMS = function(options) {
|
||||
|
||||
if (!goog.isNull(extent) && projection.isGlobal() &&
|
||||
extent[0] === projectionExtent[0] &&
|
||||
extent[1] === projectionExtent[1]) {
|
||||
extent[2] === projectionExtent[2]) {
|
||||
var numCols = Math.ceil(
|
||||
(extent[1] - extent[0]) / (tileExtent[1] - tileExtent[0]));
|
||||
(extent[2] - extent[0]) /
|
||||
(tileExtent[2] - tileExtent[0]));
|
||||
x = goog.math.modulo(x, numCols);
|
||||
tileExtent = tileGrid.getTileCoordExtent(
|
||||
new ol.TileCoord(tileCoord.z, x, tileCoord.y));
|
||||
|
||||
@@ -54,8 +54,8 @@ ol.source.wms.getUrl =
|
||||
|
||||
var axisOrientation = projection.getAxisOrientation();
|
||||
var bboxValues = (wms13 && axisOrientation.substr(0, 2) == 'ne') ?
|
||||
[extent[2], extent[0], extent[3], extent[1]] :
|
||||
[extent[0], extent[2], extent[1], extent[3]];
|
||||
[extent[1], extent[0], extent[3], extent[2]] :
|
||||
[extent[0], extent[1], extent[2], extent[3]];
|
||||
baseParams['BBOX'] = bboxValues.join(',');
|
||||
|
||||
return goog.uri.utils.appendParamsFromMap(baseUrl, baseParams);
|
||||
|
||||
@@ -155,9 +155,10 @@ ol.source.WMTS = function(options) {
|
||||
|
||||
if (!goog.isNull(extent) && projection.isGlobal() &&
|
||||
extent[0] === projectionExtent[0] &&
|
||||
extent[1] === projectionExtent[1]) {
|
||||
extent[2] === projectionExtent[2]) {
|
||||
var numCols = Math.ceil(
|
||||
(extent[1] - extent[0]) / (tileExtent[1] - tileExtent[0]));
|
||||
(extent[2] - extent[0]) /
|
||||
(tileExtent[2] - tileExtent[0]));
|
||||
x = goog.math.modulo(x, numCols);
|
||||
tmpTileCoord.z = tileCoord.z;
|
||||
tmpTileCoord.x = x;
|
||||
|
||||
@@ -85,8 +85,8 @@ ol.structs.RTree.recalculateExtent_ = function(node) {
|
||||
} else {
|
||||
var firstNodeExtent = node.nodes[0].extent;
|
||||
extent[0] = firstNodeExtent[0];
|
||||
extent[1] = firstNodeExtent[1];
|
||||
extent[2] = firstNodeExtent[2];
|
||||
extent[1] = firstNodeExtent[1];
|
||||
extent[3] = firstNodeExtent[3];
|
||||
var i;
|
||||
for (i = 1; i < n; ++i) {
|
||||
@@ -151,19 +151,19 @@ ol.structs.RTree.prototype.chooseLeafSubtree_ = function(rect, root) {
|
||||
}
|
||||
// Area of new enlarged rectangle
|
||||
var oldLRatio = ol.structs.RTree.squarifiedRatio_(
|
||||
lTree.extent[1] - lTree.extent[0],
|
||||
lTree.extent[3] - lTree.extent[2],
|
||||
lTree.extent[2] - lTree.extent[0],
|
||||
lTree.extent[3] - lTree.extent[1],
|
||||
lTree.nodes.length + 1);
|
||||
|
||||
// Enlarge rectangle to fit new rectangle
|
||||
var nw = (lTree.extent[1] > rect.extent[1] ?
|
||||
lTree.extent[1] : rect.extent[1]) -
|
||||
var nw = (lTree.extent[2] > rect.extent[2] ?
|
||||
lTree.extent[2] : rect.extent[2]) -
|
||||
(lTree.extent[0] < rect.extent[0] ?
|
||||
lTree.extent[0] : rect.extent[0]);
|
||||
var nh = (lTree.extent[3] > rect.extent[3] ?
|
||||
lTree.extent[3] : rect.extent[3]) -
|
||||
(lTree.extent[2] < rect.extent[2] ?
|
||||
lTree.extent[2] : rect.extent[2]);
|
||||
(lTree.extent[1] < rect.extent[1] ?
|
||||
lTree.extent[1] : rect.extent[1]);
|
||||
|
||||
// Area of new enlarged rectangle
|
||||
var lRatio = ol.structs.RTree.squarifiedRatio_(
|
||||
@@ -210,7 +210,7 @@ ol.structs.RTree.prototype.insertSubtree_ = function(node, root) {
|
||||
// Initial insertion is special because we resize the Tree and we don't
|
||||
// care about any overflow (seriously, how can the first object overflow?)
|
||||
if (root.nodes.length === 0) {
|
||||
root.extent = node.extent.concat();
|
||||
root.extent = ol.extent.clone(node.extent);
|
||||
root.nodes.push(node);
|
||||
return;
|
||||
}
|
||||
@@ -253,7 +253,7 @@ ol.structs.RTree.prototype.insertSubtree_ = function(node, root) {
|
||||
}
|
||||
|
||||
if (bc.nodes.length <= this.maxWidth_) { // Start Resizeing Up the Tree
|
||||
workingObject = {extent: bc.extent.concat()};
|
||||
workingObject = {extent: ol.extent.clone(bc.extent)};
|
||||
} else { // Otherwise Split this Node
|
||||
// linearSplit_() returns an array containing two new nodes
|
||||
// formed from the split of the previous node's overflow
|
||||
@@ -269,7 +269,7 @@ ol.structs.RTree.prototype.insertSubtree_ = function(node, root) {
|
||||
} else { // Otherwise Do Resize
|
||||
//Just keep applying the new bounding rectangle to the parents..
|
||||
ol.extent.extend(bc.extent, workingObject.extent);
|
||||
workingObject = ({extent: bc.extent.concat()});
|
||||
workingObject = ({extent: ol.extent.clone(bc.extent)});
|
||||
}
|
||||
} while (treeStack.length > 0);
|
||||
};
|
||||
@@ -310,19 +310,19 @@ ol.structs.RTree.prototype.pickLinear_ = function(nodes) {
|
||||
var l = nodes[i];
|
||||
if (l.extent[0] > nodes[highestLowX].extent[0]) {
|
||||
highestLowX = i;
|
||||
} else if (l.extent[1] < nodes[lowestHighX].extent[2]) {
|
||||
} else if (l.extent[2] < nodes[lowestHighX].extent[1]) {
|
||||
lowestHighX = i;
|
||||
}
|
||||
if (l.extent[2] > nodes[highestLowY].extent[2]) {
|
||||
if (l.extent[1] > nodes[highestLowY].extent[1]) {
|
||||
highestLowY = i;
|
||||
} else if (l.extent[3] < nodes[lowestHighY].extent[3]) {
|
||||
lowestHighY = i;
|
||||
}
|
||||
}
|
||||
var dx = Math.abs(nodes[lowestHighX].extent[1] -
|
||||
var dx = Math.abs(nodes[lowestHighX].extent[2] -
|
||||
nodes[highestLowX].extent[0]);
|
||||
var dy = Math.abs(nodes[lowestHighY].extent[3] -
|
||||
nodes[highestLowY].extent[2]);
|
||||
nodes[highestLowY].extent[1]);
|
||||
if (dx > dy) {
|
||||
if (lowestHighX > highestLowX) {
|
||||
t1 = nodes.splice(lowestHighX, 1)[0];
|
||||
@@ -342,9 +342,9 @@ ol.structs.RTree.prototype.pickLinear_ = function(nodes) {
|
||||
}
|
||||
return [
|
||||
/** @type {ol.structs.RTreeNode} */
|
||||
({extent: t1.extent.concat(), nodes: [t1]}),
|
||||
({extent: ol.extent.clone(t1.extent), nodes: [t1]}),
|
||||
/** @type {ol.structs.RTreeNode} */
|
||||
({extent: t2.extent.concat(), nodes: [t2]})
|
||||
({extent: ol.extent.clone(t2.extent), nodes: [t2]})
|
||||
];
|
||||
};
|
||||
|
||||
@@ -359,10 +359,10 @@ ol.structs.RTree.prototype.pickLinear_ = function(nodes) {
|
||||
*/
|
||||
ol.structs.RTree.prototype.pickNext_ = function(nodes, a, b) {
|
||||
// Area of new enlarged rectangle
|
||||
var areaA = ol.structs.RTree.squarifiedRatio_(a.extent[1] - a.extent[0],
|
||||
a.extent[3] - a.extent[2], a.nodes.length + 1);
|
||||
var areaB = ol.structs.RTree.squarifiedRatio_(b.extent[1] - b.extent[0],
|
||||
b.extent[3] - b.extent[2], b.nodes.length + 1);
|
||||
var areaA = ol.structs.RTree.squarifiedRatio_(a.extent[2] - a.extent[0],
|
||||
a.extent[3] - a.extent[1], a.nodes.length + 1);
|
||||
var areaB = ol.structs.RTree.squarifiedRatio_(b.extent[2] - b.extent[0],
|
||||
b.extent[3] - b.extent[1], b.nodes.length + 1);
|
||||
var highAreaDelta;
|
||||
var highAreaNode;
|
||||
var lowestGrowthGroup;
|
||||
@@ -372,8 +372,8 @@ ol.structs.RTree.prototype.pickNext_ = function(nodes, a, b) {
|
||||
|
||||
var newAreaA = [
|
||||
a.extent[0] < l.extent[0] ? a.extent[0] : l.extent[0],
|
||||
a.extent[1] > l.extent[1] ? a.extent[1] : l.extent[1],
|
||||
a.extent[2] < l.extent[2] ? a.extent[2] : l.extent[2],
|
||||
a.extent[2] > l.extent[2] ? a.extent[2] : l.extent[2],
|
||||
a.extent[1] < l.extent[1] ? a.extent[1] : l.extent[1],
|
||||
a.extent[3] > l.extent[3] ? a.extent[3] : l.extent[3]
|
||||
];
|
||||
var changeNewAreaA = Math.abs(ol.structs.RTree.squarifiedRatio_(
|
||||
@@ -382,8 +382,8 @@ ol.structs.RTree.prototype.pickNext_ = function(nodes, a, b) {
|
||||
|
||||
var newAreaB = [
|
||||
b.extent[0] < l.extent[0] ? b.extent[0] : l.extent[0],
|
||||
b.extent[1] > l.extent[1] ? b.extent[1] : l.extent[1],
|
||||
b.extent[2] < l.extent[2] ? b.extent[2] : l.extent[2],
|
||||
b.extent[2] > l.extent[2] ? b.extent[2] : l.extent[2],
|
||||
b.extent[1] < l.extent[1] ? b.extent[1] : l.extent[1],
|
||||
b.extent[3] > l.extent[3] ? b.extent[3] : l.extent[3]
|
||||
];
|
||||
var changeNewAreaB = Math.abs(ol.structs.RTree.squarifiedRatio_(
|
||||
@@ -466,7 +466,7 @@ ol.structs.RTree.prototype.removeSubtree_ = function(rect, obj, root) {
|
||||
|
||||
/** @type {ol.structs.RTreeNode} */
|
||||
var workingObject = /** @type {ol.structs.RTreeNode} */
|
||||
({extent: rect.extent.concat(), target: obj});
|
||||
({extent: ol.extent.clone(rect.extent), target: obj});
|
||||
|
||||
countStack.push(root.nodes.length);
|
||||
hitStack.push(root);
|
||||
|
||||
@@ -232,11 +232,11 @@ ol.tilegrid.TileGrid.prototype.getTileRangeForExtentAndResolution =
|
||||
function(extent, resolution, opt_tileRange) {
|
||||
var tileCoord = ol.tilegrid.TileGrid.tmpTileCoord_;
|
||||
this.getTileCoordForXYAndResolution_(
|
||||
extent[0], extent[2], resolution, false, tileCoord);
|
||||
extent[0], extent[1], resolution, false, tileCoord);
|
||||
var minX = tileCoord.x;
|
||||
var minY = tileCoord.y;
|
||||
this.getTileCoordForXYAndResolution_(
|
||||
extent[1], extent[3], resolution, true, tileCoord);
|
||||
extent[2], extent[3], resolution, true, tileCoord);
|
||||
return ol.TileRange.createOrUpdate(
|
||||
minX, tileCoord.x, minY, tileCoord.y, opt_tileRange);
|
||||
};
|
||||
@@ -414,8 +414,8 @@ ol.tilegrid.createForProjection =
|
||||
var size = goog.isNull(projectionExtent) ?
|
||||
360 * ol.METERS_PER_UNIT[ol.ProjectionUnits.DEGREES] /
|
||||
projection.getMetersPerUnit() :
|
||||
Math.max(projectionExtent[1] - projectionExtent[0],
|
||||
projectionExtent[3] - projectionExtent[2]);
|
||||
Math.max(projectionExtent[2] - projectionExtent[0],
|
||||
projectionExtent[3] - projectionExtent[1]);
|
||||
var maxZoom = goog.isDef(opt_maxZoom) ?
|
||||
opt_maxZoom : ol.DEFAULT_MAX_ZOOM;
|
||||
var tileSize = goog.isDef(opt_tileSize) ?
|
||||
|
||||
@@ -226,7 +226,7 @@ ol.View2D.prototype.calculateExtent = function(size) {
|
||||
var maxX = center[0] + resolution * size[0] / 2;
|
||||
var minY = center[1] - resolution * size[1] / 2;
|
||||
var maxY = center[1] + resolution * size[1] / 2;
|
||||
return [minX, maxX, minY, maxY];
|
||||
return [minX, minY, maxX, maxY];
|
||||
};
|
||||
|
||||
|
||||
@@ -262,8 +262,8 @@ goog.exportProperty(
|
||||
* @return {number} Resolution.
|
||||
*/
|
||||
ol.View2D.prototype.getResolutionForExtent = function(extent, size) {
|
||||
var xResolution = (extent[1] - extent[0]) / size[0];
|
||||
var yResolution = (extent[3] - extent[2]) / size[1];
|
||||
var xResolution = (extent[2] - extent[0]) / size[0];
|
||||
var yResolution = (extent[3] - extent[1]) / size[1];
|
||||
return Math.max(xResolution, yResolution);
|
||||
};
|
||||
|
||||
@@ -498,8 +498,8 @@ ol.View2D.createResolutionConstraint_ = function(options) {
|
||||
// use an extent that can fit the whole world if need be
|
||||
360 * ol.METERS_PER_UNIT[ol.ProjectionUnits.DEGREES] /
|
||||
ol.METERS_PER_UNIT[projection.getUnits()] :
|
||||
Math.max(projectionExtent[1] - projectionExtent[0],
|
||||
projectionExtent[3] - projectionExtent[2]);
|
||||
Math.max(projectionExtent[2] - projectionExtent[0],
|
||||
projectionExtent[3] - projectionExtent[1]);
|
||||
maxResolution = size / ol.DEFAULT_TILE_SIZE;
|
||||
}
|
||||
var maxZoom = options.maxZoom;
|
||||
|
||||
Reference in New Issue
Block a user