Changing extent structure back to single array: [minX, minY, maxX, maxY]

This means we'll have to have a new structure and new methods for 3D envelopes.
This commit is contained in:
Tim Schaub
2013-09-15 00:15:24 -06:00
parent de0e8aeced
commit e806f51b3d
63 changed files with 379 additions and 392 deletions

View File

@@ -11,8 +11,8 @@ var map = new ol.Map({
controls: ol.control.defaults().extend([ controls: ol.control.defaults().extend([
new ol.control.ZoomToExtent({ new ol.control.ZoomToExtent({
extent: [ extent: [
[813079.7791264898, 5929220.284081122], 813079.7791264898, 5929220.284081122,
[848966.9639063801, 5936863.986909639] 848966.9639063801, 5936863.986909639
] ]
}) })
]), ]),

View File

@@ -12,10 +12,10 @@ goog.require('ol.source.TileWMS');
var projection = ol.proj.configureProj4jsProjection({ var projection = ol.proj.configureProj4jsProjection({
code: 'EPSG:21781', code: 'EPSG:21781',
extent: [[485869.5728, 76443.1884], [837076.5648, 299941.7864]] extent: [485869.5728, 76443.1884, 837076.5648, 299941.7864]
}); });
var extent = [[420000, 30000], [900000, 350000]]; var extent = [420000, 30000, 900000, 350000];
var layers = [ var layers = [
new ol.layer.Tile({ new ol.layer.Tile({
source: new ol.source.TileWMS({ source: new ol.source.TileWMS({

View File

@@ -9,10 +9,10 @@ goog.require('ol.source.ImageWMS');
var projection = ol.proj.configureProj4jsProjection({ var projection = ol.proj.configureProj4jsProjection({
code: 'EPSG:21781', code: 'EPSG:21781',
extent: [[485869.5728, 76443.1884], [837076.5648, 299941.7864]] extent: [485869.5728, 76443.1884, 837076.5648, 299941.7864]
}); });
var extent = [[420000, 30000], [900000, 350000]]; var extent = [420000, 30000, 900000, 350000];
var layers = [ var layers = [
new ol.layer.Image({ new ol.layer.Image({
source: new ol.source.ImageWMS({ source: new ol.source.ImageWMS({

View File

@@ -15,7 +15,7 @@ var layers = [
source: new ol.source.ImageWMS({ source: new ol.source.ImageWMS({
url: 'http://demo.opengeo.org/geoserver/wms', url: 'http://demo.opengeo.org/geoserver/wms',
params: {'LAYERS': 'topp:states'}, params: {'LAYERS': 'topp:states'},
extent: [[-13884991, 2870341], [-7455066, 6338219]] extent: [-13884991, 2870341, -7455066, 6338219]
}) })
}) })
]; ];

View File

@@ -14,7 +14,7 @@ var layers = [
source: new ol.source.TileWMS({ source: new ol.source.TileWMS({
url: 'http://demo.opengeo.org/geoserver/wms', url: 'http://demo.opengeo.org/geoserver/wms',
params: {'LAYERS': 'topp:states', 'TILED': true}, params: {'LAYERS': 'topp:states', 'TILED': true},
extent: [[-13884991, 2870341], [-7455066, 6338219]] extent: [-13884991, 2870341, -7455066, 6338219]
}) })
}) })
]; ];

View File

@@ -76,8 +76,8 @@ xhr.onload = function() {
var view = new ol.View2D(); var view = new ol.View2D();
view.fitExtent([ view.fitExtent([
[257596.65942095537, 6250898.984085131], 257596.65942095537, 6250898.984085131,
[262082.55751844167, 6251854.446938695]], map.getSize()); 262082.55751844167, 6251854.446938695], map.getSize());
map.setView(view); map.setView(view);
} }
}; };

View File

@@ -39,7 +39,7 @@ var map = new ol.Map({
matrixIds: matrixIds matrixIds: matrixIds
}), }),
style: '_null', style: '_null',
extent: [[-13682835, 5204068], [-13667473, 5221690]] extent: [-13682835, 5204068, -13667473, 5221690]
}) })
}) })
], ],

View File

@@ -144,7 +144,7 @@ ol.expr.lib[ol.expr.functions.EXTENT] = function(minX, minY, maxX, maxY,
this.get(opt_attribute) : this.getGeometry(); this.get(opt_attribute) : this.getGeometry();
if (geometry) { if (geometry) {
intersects = ol.extent.intersects(geometry.getBounds(), intersects = ol.extent.intersects(geometry.getBounds(),
[[minX, minY], [maxX, maxY]]); [minX, minY, maxX, maxY]);
} }
return intersects; return intersects;
}; };

View File

@@ -8,7 +8,7 @@ goog.require('ol.TransformFunction');
/** /**
* @typedef {Array.<ol.Coordinate>} * @typedef {Array.<number>}
*/ */
ol.Extent; ol.Extent;
@@ -55,7 +55,7 @@ ol.extent.boundingExtentXYs_ = function(xs, ys, opt_extent) {
* @return {ol.Extent} The clone. * @return {ol.Extent} The clone.
*/ */
ol.extent.clone = function(extent) { ol.extent.clone = function(extent) {
return [[extent[0][0], extent[0][1]], [extent[1][0], extent[1][1]]]; return extent.slice();
}; };
@@ -67,8 +67,8 @@ ol.extent.clone = function(extent) {
* @return {boolean} Contains. * @return {boolean} Contains.
*/ */
ol.extent.containsCoordinate = function(extent, coordinate) { ol.extent.containsCoordinate = function(extent, coordinate) {
return extent[0][0] <= coordinate[0] && coordinate[0] <= extent[1][0] && return extent[0] <= coordinate[0] && coordinate[0] <= extent[2] &&
extent[0][1] <= coordinate[1] && coordinate[1] <= extent[1][1]; extent[1] <= coordinate[1] && coordinate[1] <= extent[3];
}; };
@@ -80,8 +80,8 @@ ol.extent.containsCoordinate = function(extent, coordinate) {
* @return {boolean} Contains. * @return {boolean} Contains.
*/ */
ol.extent.containsExtent = function(extent1, extent2) { ol.extent.containsExtent = function(extent1, extent2) {
return extent1[0][0] <= extent2[0][0] && extent2[1][0] <= extent1[1][0] && return extent1[0] <= extent2[0] && extent2[2] <= extent1[2] &&
extent1[0][1] <= extent2[0][1] && extent2[1][1] <= extent1[1][1]; extent1[1] <= extent2[1] && extent2[3] <= extent1[3];
}; };
@@ -89,7 +89,7 @@ ol.extent.containsExtent = function(extent1, extent2) {
* @return {ol.Extent} Empty extent. * @return {ol.Extent} Empty extent.
*/ */
ol.extent.createEmpty = function() { ol.extent.createEmpty = function() {
return [[Infinity, Infinity], [-Infinity, -Infinity]]; return [Infinity, Infinity, -Infinity, -Infinity];
}; };
@@ -103,13 +103,13 @@ ol.extent.createEmpty = function() {
*/ */
ol.extent.createOrUpdate = function(minX, maxX, minY, maxY, opt_extent) { ol.extent.createOrUpdate = function(minX, maxX, minY, maxY, opt_extent) {
if (goog.isDef(opt_extent)) { if (goog.isDef(opt_extent)) {
opt_extent[0][0] = minX; opt_extent[0] = minX;
opt_extent[1][0] = maxX; opt_extent[2] = maxX;
opt_extent[0][1] = minY; opt_extent[1] = minY;
opt_extent[1][1] = maxY; opt_extent[3] = maxY;
return opt_extent; return opt_extent;
} else { } else {
return [[minX, minY], [maxX, maxY]]; return [minX, minY, maxX, maxY];
} }
}; };
@@ -120,8 +120,8 @@ ol.extent.createOrUpdate = function(minX, maxX, minY, maxY, opt_extent) {
* @return {ol.Extent} Extent. * @return {ol.Extent} Extent.
*/ */
ol.extent.empty = function(extent) { ol.extent.empty = function(extent) {
extent[0][0] = extent[0][1] = Infinity; extent[0] = extent[1] = Infinity;
extent[1][0] = extent[1][1] = -Infinity; extent[2] = extent[3] = -Infinity;
return extent; return extent;
}; };
@@ -132,8 +132,8 @@ ol.extent.empty = function(extent) {
* @return {boolean} Equals. * @return {boolean} Equals.
*/ */
ol.extent.equals = function(extent1, extent2) { ol.extent.equals = function(extent1, extent2) {
return extent1[0][0] == extent2[0][0] && extent1[1][0] == extent2[1][0] && return extent1[0] == extent2[0] && extent1[2] == extent2[2] &&
extent1[0][1] == extent2[0][1] && extent1[1][1] == extent2[1][1]; extent1[1] == extent2[1] && extent1[3] == extent2[3];
}; };
@@ -142,17 +142,17 @@ ol.extent.equals = function(extent1, extent2) {
* @param {ol.Extent} extent2 Extent 2. * @param {ol.Extent} extent2 Extent 2.
*/ */
ol.extent.extend = function(extent1, extent2) { ol.extent.extend = function(extent1, extent2) {
if (extent2[0][0] < extent1[0][0]) { if (extent2[0] < extent1[0]) {
extent1[0][0] = extent2[0][0]; extent1[0] = extent2[0];
} }
if (extent2[1][0] > extent1[1][0]) { if (extent2[2] > extent1[2]) {
extent1[1][0] = extent2[1][0]; extent1[2] = extent2[2];
} }
if (extent2[0][1] < extent1[0][1]) { if (extent2[1] < extent1[1]) {
extent1[0][1] = extent2[0][1]; extent1[1] = extent2[1];
} }
if (extent2[1][1] > extent1[1][1]) { if (extent2[3] > extent1[3]) {
extent1[1][1] = extent2[1][1]; extent1[3] = extent2[3];
} }
}; };
@@ -162,17 +162,17 @@ ol.extent.extend = function(extent1, extent2) {
* @param {ol.Coordinate} coordinate Coordinate. * @param {ol.Coordinate} coordinate Coordinate.
*/ */
ol.extent.extendCoordinate = function(extent, coordinate) { ol.extent.extendCoordinate = function(extent, coordinate) {
if (coordinate[0] < extent[0][0]) { if (coordinate[0] < extent[0]) {
extent[0][0] = coordinate[0]; extent[0] = coordinate[0];
} }
if (coordinate[0] > extent[1][0]) { if (coordinate[0] > extent[2]) {
extent[1][0] = coordinate[0]; extent[2] = coordinate[0];
} }
if (coordinate[1] < extent[0][1]) { if (coordinate[1] < extent[1]) {
extent[0][1] = coordinate[1]; extent[1] = coordinate[1];
} }
if (coordinate[1] > extent[1][1]) { if (coordinate[1] > extent[3]) {
extent[1][1] = coordinate[1]; extent[3] = coordinate[1];
} }
}; };
@@ -182,7 +182,7 @@ ol.extent.extendCoordinate = function(extent, coordinate) {
* @return {ol.Coordinate} Bottom left coordinate. * @return {ol.Coordinate} Bottom left coordinate.
*/ */
ol.extent.getBottomLeft = function(extent) { ol.extent.getBottomLeft = function(extent) {
return [extent[0][0], extent[0][1]]; return [extent[0], extent[1]];
}; };
@@ -191,7 +191,7 @@ ol.extent.getBottomLeft = function(extent) {
* @return {ol.Coordinate} Bottom right coordinate. * @return {ol.Coordinate} Bottom right coordinate.
*/ */
ol.extent.getBottomRight = function(extent) { ol.extent.getBottomRight = function(extent) {
return [extent[1][0], extent[0][1]]; return [extent[2], extent[1]];
}; };
@@ -200,7 +200,7 @@ ol.extent.getBottomRight = function(extent) {
* @return {ol.Coordinate} Center. * @return {ol.Coordinate} Center.
*/ */
ol.extent.getCenter = function(extent) { ol.extent.getCenter = function(extent) {
return [(extent[0][0] + extent[1][0]) / 2, (extent[0][1] + extent[1][1]) / 2]; return [(extent[0] + extent[2]) / 2, (extent[1] + extent[3]) / 2];
}; };
@@ -238,7 +238,7 @@ ol.extent.getForView2DAndSize =
* @return {number} Height. * @return {number} Height.
*/ */
ol.extent.getHeight = function(extent) { ol.extent.getHeight = function(extent) {
return extent[1][1] - extent[0][1]; return extent[3] - extent[1];
}; };
@@ -247,7 +247,7 @@ ol.extent.getHeight = function(extent) {
* @return {ol.Size} Size. * @return {ol.Size} Size.
*/ */
ol.extent.getSize = function(extent) { ol.extent.getSize = function(extent) {
return [extent[1][0] - extent[0][0], extent[1][1] - extent[0][1]]; return [extent[2] - extent[0], extent[3] - extent[1]];
}; };
@@ -256,7 +256,7 @@ ol.extent.getSize = function(extent) {
* @return {ol.Coordinate} Top left coordinate. * @return {ol.Coordinate} Top left coordinate.
*/ */
ol.extent.getTopLeft = function(extent) { ol.extent.getTopLeft = function(extent) {
return [extent[0][0], extent[1][1]]; return [extent[0], extent[3]];
}; };
@@ -265,7 +265,7 @@ ol.extent.getTopLeft = function(extent) {
* @return {ol.Coordinate} Top right coordinate. * @return {ol.Coordinate} Top right coordinate.
*/ */
ol.extent.getTopRight = function(extent) { ol.extent.getTopRight = function(extent) {
return [extent[1][0], extent[1][1]]; return [extent[2], extent[3]];
}; };
@@ -274,7 +274,7 @@ ol.extent.getTopRight = function(extent) {
* @return {number} Width. * @return {number} Width.
*/ */
ol.extent.getWidth = function(extent) { ol.extent.getWidth = function(extent) {
return extent[1][0] - extent[0][0]; return extent[2] - extent[0];
}; };
@@ -284,10 +284,10 @@ ol.extent.getWidth = function(extent) {
* @return {boolean} Intersects. * @return {boolean} Intersects.
*/ */
ol.extent.intersects = function(extent1, extent2) { ol.extent.intersects = function(extent1, extent2) {
return extent1[0][0] <= extent2[1][0] && return extent1[0] <= extent2[2] &&
extent1[1][0] >= extent2[0][0] && extent1[2] >= extent2[0] &&
extent1[0][1] <= extent2[1][1] && extent1[1] <= extent2[3] &&
extent1[1][1] >= extent2[0][1]; extent1[3] >= extent2[1];
}; };
@@ -296,7 +296,7 @@ ol.extent.intersects = function(extent1, extent2) {
* @return {boolean} Is empty. * @return {boolean} Is empty.
*/ */
ol.extent.isEmpty = function(extent) { ol.extent.isEmpty = function(extent) {
return extent[1][0] < extent[0][0] || extent[1][1] < extent[0][1]; return extent[2] < extent[0] || extent[3] < extent[1];
}; };
@@ -307,8 +307,8 @@ ol.extent.isEmpty = function(extent) {
*/ */
ol.extent.normalize = function(extent, coordinate) { ol.extent.normalize = function(extent, coordinate) {
return [ return [
(coordinate[0] - extent[0][0]) / (extent[1][0] - extent[0][0]), (coordinate[0] - extent[0]) / (extent[2] - extent[0]),
(coordinate[1] - extent[0][1]) / (extent[1][1] - extent[0][1]) (coordinate[1] - extent[1]) / (extent[3] - extent[1])
]; ];
}; };
@@ -318,12 +318,12 @@ ol.extent.normalize = function(extent, coordinate) {
* @param {number} value Value. * @param {number} value Value.
*/ */
ol.extent.scaleFromCenter = function(extent, value) { ol.extent.scaleFromCenter = function(extent, value) {
var deltaX = ((extent[1][0] - extent[0][0]) / 2) * (value - 1); var deltaX = ((extent[2] - extent[0]) / 2) * (value - 1);
var deltaY = ((extent[1][1] - extent[0][1]) / 2) * (value - 1); var deltaY = ((extent[3] - extent[1]) / 2) * (value - 1);
extent[0][0] -= deltaX; extent[0] -= deltaX;
extent[1][0] += deltaX; extent[2] += deltaX;
extent[0][1] -= deltaY; extent[1] -= deltaY;
extent[1][1] += deltaY; extent[3] += deltaY;
}; };
@@ -332,8 +332,8 @@ ol.extent.scaleFromCenter = function(extent, value) {
* @return {string} String. * @return {string} String.
*/ */
ol.extent.toString = function(extent) { ol.extent.toString = function(extent) {
return '(' + [extent[0][0], extent[1][0], extent[0][1], return '(' + [extent[0], extent[2], extent[1],
extent[1][1]].join(', ') + ')'; extent[3]].join(', ') + ')';
}; };
@@ -345,10 +345,10 @@ ol.extent.toString = function(extent) {
*/ */
ol.extent.transform = function(extent, transformFn, opt_extent) { ol.extent.transform = function(extent, transformFn, opt_extent) {
var coordinates = [ var coordinates = [
extent[0][0], extent[0][1], extent[0], extent[1],
extent[0][0], extent[1][1], extent[0], extent[3],
extent[1][0], extent[0][1], extent[2], extent[1],
extent[1][0], extent[1][1] extent[2], extent[3]
]; ];
transformFn(coordinates, coordinates, 2); transformFn(coordinates, coordinates, 2);
var xs = [coordinates[0], coordinates[2], coordinates[4], coordinates[6]]; var xs = [coordinates[0], coordinates[2], coordinates[4], coordinates[6]];

View File

@@ -126,7 +126,7 @@ ol.geom.LineString.prototype.getBounds = function() {
maxY = y; maxY = y;
} }
} }
this.bounds_ = [[minX, minY], [maxX, maxY]]; this.bounds_ = [minX, minY, maxX, maxY];
} }
return this.bounds_; return this.bounds_;
}; };

View File

@@ -68,7 +68,7 @@ ol.geom.Point.prototype.getBounds = function() {
if (goog.isNull(this.bounds_)) { if (goog.isNull(this.bounds_)) {
var x = this.get(0), var x = this.get(0),
y = this.get(1); y = this.get(1);
this.bounds_ = [[x, y], [x, y]]; this.bounds_ = [x, y, x, y];
} }
return this.bounds_; return this.bounds_;
}; };

View File

@@ -11,20 +11,17 @@ goog.require('ol.extent');
* @return {ol.Extent} Extent. * @return {ol.Extent} Extent.
*/ */
ol.geom2.getExtent = function(buf, dim) { ol.geom2.getExtent = function(buf, dim) {
var extent = ol.extent.createEmpty(); // TODO: make this accept a dimension var extent = ol.extent.createEmpty();
for (var i = 0; i < dim; ++i) {
extent[0][i] = Infinity;
extent[1][i] = -Infinity;
}
var bufArr = buf.getArray(); var bufArr = buf.getArray();
buf.forEachRange(function(start, stop) { buf.forEachRange(function(start, stop) {
var i, j, value; var x, y;
for (i = start; i < stop; i += dim) { for (var i = start; i < stop; i += dim) {
for (j = 0; j < dim; ++j) { x = bufArr[i];
value = bufArr[i + j]; y = bufArr[i + 1];
extent[0][j] = Math.min(extent[0][j], value); extent[0] = Math.min(extent[0], x);
extent[1][j] = Math.max(extent[1][j], value); extent[1] = Math.min(extent[1], y);
} extent[2] = Math.max(extent[2], x);
extent[3] = Math.max(extent[3], y);
} }
}); });
return extent; return extent;

View File

@@ -110,13 +110,12 @@ ol.layer.FeatureCache.prototype.getFeaturesObject = function(opt_expr) {
for (var i = 0; i < 4; ++i) { for (var i = 0; i < 4; ++i) {
goog.asserts.assert(args[i] instanceof ol.expr.Literal); goog.asserts.assert(args[i] instanceof ol.expr.Literal);
} }
var extent = [[ var extent = [
/** @type {ol.expr.Literal} */ (args[0]).evaluate(), /** @type {ol.expr.Literal} */ (args[0]).evaluate(),
/** @type {ol.expr.Literal} */ (args[1]).evaluate() /** @type {ol.expr.Literal} */ (args[1]).evaluate(),
], [
/** @type {ol.expr.Literal} */ (args[2]).evaluate(), /** @type {ol.expr.Literal} */ (args[2]).evaluate(),
/** @type {ol.expr.Literal} */ (args[3]).evaluate() /** @type {ol.expr.Literal} */ (args[3]).evaluate()
]]; ];
features = this.rTree_.searchReturningObject(extent); features = this.rTree_.searchReturningObject(extent);
} else { } else {
// not a call expression, check logical // not a call expression, check logical

View File

@@ -184,10 +184,10 @@ ol.parser.ogc.Filter_v1 = function() {
if (goog.isDef(container.geometry)) { if (goog.isDef(container.geometry)) {
args.push(new ol.expr.Literal(this.gml_.createGeometry(container))); args.push(new ol.expr.Literal(this.gml_.createGeometry(container)));
} else { } else {
args = [new ol.expr.Literal(container.bounds[0][0]), args = [new ol.expr.Literal(container.bounds[0]),
new ol.expr.Literal(container.bounds[0][1]), new ol.expr.Literal(container.bounds[1]),
new ol.expr.Literal(container.bounds[1][0]), new ol.expr.Literal(container.bounds[2]),
new ol.expr.Literal(container.bounds[1][1])]; new ol.expr.Literal(container.bounds[3])];
} }
if (goog.isDef(container.distance)) { if (goog.isDef(container.distance)) {
args.push(container.distance); args.push(container.distance);

View File

@@ -93,8 +93,8 @@ ol.parser.ogc.Filter_v1_0_0 = function() {
goog.asserts.assert(args[3] instanceof ol.expr.Literal); goog.asserts.assert(args[3] instanceof ol.expr.Literal);
goog.asserts.assert(args[4] instanceof ol.expr.Literal); goog.asserts.assert(args[4] instanceof ol.expr.Literal);
var bbox = [ var bbox = [
[args[0].getValue(), args[1].getValue()], args[0].getValue(), args[1].getValue(),
[args[2].getValue(), args[3].getValue()] args[2].getValue(), args[3].getValue()
]; ];
var projection = args[4].getValue(); var projection = args[4].getValue();
var property = args[5]; var property = args[5];
@@ -133,8 +133,8 @@ ol.parser.ogc.Filter_v1_0_0.prototype.writeSpatial_ = function(filter, name) {
goog.asserts.assert(args[2] instanceof ol.expr.Literal); goog.asserts.assert(args[2] instanceof ol.expr.Literal);
goog.asserts.assert(args[3] instanceof ol.expr.Literal); goog.asserts.assert(args[3] instanceof ol.expr.Literal);
bbox = [ bbox = [
[args[0].getValue(), args[1].getValue()], args[0].getValue(), args[1].getValue(),
[args[2].getValue(), args[3].getValue()] args[2].getValue(), args[3].getValue()
]; ];
projection = args[4]; projection = args[4];
property = args[5]; property = args[5];
@@ -168,7 +168,7 @@ ol.parser.ogc.Filter_v1_0_0.prototype.writeSpatial_ = function(filter, name) {
if (geom !== null) { if (geom !== null) {
child = this.writeNode('_geometry', geom, child = this.writeNode('_geometry', geom,
this.gml_.featureNS).firstChild; this.gml_.featureNS).firstChild;
} else if (bbox.length === 2) { } else if (bbox.length === 4) {
child = this.writeNode('Box', bbox, child = this.writeNode('Box', bbox,
'http://www.opengis.net/gml'); 'http://www.opengis.net/gml');
} }

View File

@@ -131,8 +131,8 @@ ol.parser.ogc.Filter_v1_1_0 = function() {
goog.asserts.assert(args[3] instanceof ol.expr.Literal); goog.asserts.assert(args[3] instanceof ol.expr.Literal);
goog.asserts.assert(args[4] instanceof ol.expr.Literal); goog.asserts.assert(args[4] instanceof ol.expr.Literal);
var bbox = [ var bbox = [
[args[0].getValue(), args[1].getValue()], args[0].getValue(), args[1].getValue(),
[args[2].getValue(), args[3].getValue()] args[2].getValue(), args[3].getValue()
]; ];
var projection = args[4].getValue(); var projection = args[4].getValue();
var property = args[5]; var property = args[5];
@@ -191,8 +191,8 @@ ol.parser.ogc.Filter_v1_1_0.prototype.writeSpatial_ = function(filter, name) {
goog.asserts.assert(args[2] instanceof ol.expr.Literal); goog.asserts.assert(args[2] instanceof ol.expr.Literal);
goog.asserts.assert(args[3] instanceof ol.expr.Literal); goog.asserts.assert(args[3] instanceof ol.expr.Literal);
bbox = [ bbox = [
[args[0].getValue(), args[1].getValue()], args[0].getValue(), args[1].getValue(),
[args[2].getValue(), args[3].getValue()] args[2].getValue(), args[3].getValue()
]; ];
projection = args[4]; projection = args[4];
property = args[5]; property = args[5];
@@ -226,7 +226,7 @@ ol.parser.ogc.Filter_v1_1_0.prototype.writeSpatial_ = function(filter, name) {
if (geom !== null) { if (geom !== null) {
child = this.writeNode('_geometry', geom, child = this.writeNode('_geometry', geom,
this.gml_.featureNS).firstChild; this.gml_.featureNS).firstChild;
} else if (bbox.length === 2) { } else if (bbox.length === 4) {
child = this.writeNode('Envelope', bbox, child = this.writeNode('Envelope', bbox,
'http://www.opengis.net/gml'); 'http://www.opengis.net/gml');
} }

View File

@@ -2,7 +2,6 @@ goog.provide('ol.parser.ogc.GML_v2');
goog.require('goog.array'); goog.require('goog.array');
goog.require('goog.object'); goog.require('goog.object');
goog.require('ol.extent');
goog.require('ol.parser.ogc.GML'); goog.require('ol.parser.ogc.GML');
@@ -36,7 +35,10 @@ ol.parser.ogc.GML_v2 = function(opt_options) {
[node, coordinates, container]); [node, coordinates, container]);
this.readChildNodes(node, coordinates); this.readChildNodes(node, coordinates);
container.projection = node.getAttribute('srsName'); container.projection = node.getAttribute('srsName');
container.bounds = ol.extent.clone(coordinates[0]); 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'], { goog.object.extend(this.writers['http://www.opengis.net/gml'], {
@@ -104,7 +106,11 @@ ol.parser.ogc.GML_v2 = function(opt_options) {
}, },
'Box': function(extent) { 'Box': function(extent) {
var node = this.createElementNS('gml:Box'); var node = this.createElementNS('gml:Box');
this.writeNode('coordinates', extent, 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 // srsName attribute is optional for gml:Box
if (goog.isDefAndNotNull(this.srsName)) { if (goog.isDefAndNotNull(this.srsName)) {
node.setAttribute('srsName', this.srsName); node.setAttribute('srsName', this.srsName);

View File

@@ -3,7 +3,6 @@ goog.provide('ol.parser.ogc.GML_v3');
goog.require('goog.array'); goog.require('goog.array');
goog.require('goog.functions'); goog.require('goog.functions');
goog.require('goog.object'); goog.require('goog.object');
goog.require('ol.extent');
goog.require('ol.geom.GeometryType'); goog.require('ol.geom.GeometryType');
goog.require('ol.parser.ogc.GML'); goog.require('ol.parser.ogc.GML');
@@ -216,7 +215,10 @@ ol.parser.ogc.GML_v3 = function(opt_options) {
[node, coordinates, container]); [node, coordinates, container]);
this.readChildNodes(node, coordinates); this.readChildNodes(node, coordinates);
container.projection = node.getAttribute('srsName'); container.projection = node.getAttribute('srsName');
container.bounds = ol.extent.clone(coordinates); container.bounds = [
coordinates[0][0], coordinates[0][1],
coordinates[1][0], coordinates[1][1]
];
}, },
'lowerCorner': function(node, envelope) { 'lowerCorner': function(node, envelope) {
var coordinates = []; var coordinates = [];
@@ -391,9 +393,9 @@ ol.parser.ogc.GML_v3 = function(opt_options) {
// only 2d for simple features profile // only 2d for simple features profile
var pos; var pos;
if (this.axisOrientation.substr(0, 2) === 'en') { if (this.axisOrientation.substr(0, 2) === 'en') {
pos = (bounds[0][0] + ' ' + bounds[0][1]); pos = (bounds[0] + ' ' + bounds[1]);
} else { } else {
pos = (bounds[0][1] + ' ' + bounds[0][0]); pos = (bounds[1] + ' ' + bounds[0]);
} }
var node = this.createElementNS('gml:lowerCorner'); var node = this.createElementNS('gml:lowerCorner');
node.appendChild(this.createTextNode(pos)); node.appendChild(this.createTextNode(pos));
@@ -403,9 +405,9 @@ ol.parser.ogc.GML_v3 = function(opt_options) {
// only 2d for simple features profile // only 2d for simple features profile
var pos; var pos;
if (this.axisOrientation.substr(0, 2) === 'en') { if (this.axisOrientation.substr(0, 2) === 'en') {
pos = (bounds[1][0] + ' ' + bounds[1][1]); pos = (bounds[2] + ' ' + bounds[3]);
} else { } else {
pos = (bounds[1][1] + ' ' + bounds[1][0]); pos = (bounds[3] + ' ' + bounds[2]);
} }
var node = this.createElementNS('gml:upperCorner'); var node = this.createElementNS('gml:upperCorner');
node.appendChild(this.createTextNode(pos)); node.appendChild(this.createTextNode(pos));

View File

@@ -31,13 +31,12 @@ ol.parser.ogc.WMSCapabilities_v1 = function() {
}, },
'BoundingBox': function(node, obj) { 'BoundingBox': function(node, obj) {
var bbox = {}; var bbox = {};
bbox['bbox'] = [[ bbox['bbox'] = [
parseFloat(node.getAttribute('minx')), parseFloat(node.getAttribute('minx')),
parseFloat(node.getAttribute('miny')) parseFloat(node.getAttribute('miny')),
], [
parseFloat(node.getAttribute('maxx')), parseFloat(node.getAttribute('maxx')),
parseFloat(node.getAttribute('maxy')) parseFloat(node.getAttribute('maxy'))
]]; ];
var res = { var res = {
x: parseFloat(node.getAttribute('resx')), x: parseFloat(node.getAttribute('resx')),
y: parseFloat(node.getAttribute('resy')) y: parseFloat(node.getAttribute('resy'))

View File

@@ -47,13 +47,12 @@ ol.parser.ogc.WMSCapabilities_v1_1 = function() {
obj['userSymbols'] = userSymbols; obj['userSymbols'] = userSymbols;
}, },
'LatLonBoundingBox': function(node, obj) { 'LatLonBoundingBox': function(node, obj) {
obj['llbbox'] = [[ obj['llbbox'] = [
parseFloat(node.getAttribute('minx')), parseFloat(node.getAttribute('minx')),
parseFloat(node.getAttribute('miny')) parseFloat(node.getAttribute('miny')),
], [
parseFloat(node.getAttribute('maxx')), parseFloat(node.getAttribute('maxx')),
parseFloat(node.getAttribute('maxy')) parseFloat(node.getAttribute('maxy'))
]]; ];
}, },
'BoundingBox': function(node, obj) { 'BoundingBox': function(node, obj) {
var bbox = bboxreader.apply(this, arguments); var bbox = bboxreader.apply(this, arguments);

View File

@@ -410,7 +410,7 @@ goog.inherits(ol.proj.EPSG2056, ol.proj.CH);
* @type {ol.Extent} * @type {ol.Extent}
*/ */
ol.proj.EPSG2056.EXTENT = ol.proj.EPSG2056.EXTENT =
[[2485869.5728, 1076443.1884], [2837076.5648, 1299941.7864]]; [2485869.5728, 1076443.1884, 2837076.5648, 1299941.7864];
/** /**
@@ -448,8 +448,8 @@ goog.inherits(ol.proj.EPSG21781, ol.proj.CH);
* @type {ol.Extent} * @type {ol.Extent}
*/ */
ol.proj.EPSG21781.EXTENT = [ ol.proj.EPSG21781.EXTENT = [
[485869.5728, 76443.1884], 485869.5728, 76443.1884,
[837076.5648, 299941.7864] 837076.5648, 299941.7864
]; ];

View File

@@ -44,8 +44,8 @@ ol.proj.EPSG3857.HALF_SIZE = Math.PI * ol.proj.EPSG3857.RADIUS;
* @type {ol.Extent} * @type {ol.Extent}
*/ */
ol.proj.EPSG3857.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
]; ];

View File

@@ -30,7 +30,7 @@ goog.inherits(ol.proj.EPSG4326, ol.Projection);
* @const * @const
* @type {ol.Extent} * @type {ol.Extent}
*/ */
ol.proj.EPSG4326.EXTENT = [[-180, -90], [180, 90]]; ol.proj.EPSG4326.EXTENT = [-180, -90, 180, 90];
/** /**

View File

@@ -113,8 +113,8 @@ ol.renderer.canvas.ImageLayer.prototype.renderFrame =
1); 1);
goog.vec.Mat4.translate( goog.vec.Mat4.translate(
transform, transform,
(imageExtent[0][0] - viewCenter[0]) / imageResolution, (imageExtent[0] - viewCenter[0]) / imageResolution,
(viewCenter[1] - imageExtent[1][1]) / imageResolution, (viewCenter[1] - imageExtent[3]) / imageResolution,
0); 0);
this.updateAttributions(frameState.attributions, image.getAttributions()); this.updateAttributions(frameState.attributions, image.getAttributions());

View File

@@ -348,8 +348,8 @@ ol.renderer.canvas.TileLayer.prototype.renderFrame =
for (tileCoordKey in tilesToDraw) { for (tileCoordKey in tilesToDraw) {
tile = tilesToDraw[tileCoordKey]; tile = tilesToDraw[tileCoordKey];
tileExtent = tileGrid.getTileCoordExtent(tile.tileCoord, tmpExtent); tileExtent = tileGrid.getTileCoordExtent(tile.tileCoord, tmpExtent);
x = (tileExtent[0][0] - origin[0]) / tileResolution; x = (tileExtent[0] - origin[0]) / tileResolution;
y = (origin[1] - tileExtent[1][1]) / tileResolution; y = (origin[1] - tileExtent[3]) / tileResolution;
width = scale * tileSize[0]; width = scale * tileSize[0];
height = scale * tileSize[1]; height = scale * tileSize[1];
tileState = tile.getState(); tileState = tile.getState();

View File

@@ -477,10 +477,10 @@ ol.renderer.canvas.VectorLayer.prototype.renderFrame =
tilesToRender[key] = tileCoord; tilesToRender[key] = tileCoord;
} else if (idle) { } else if (idle) {
tileExtent = tileGrid.getTileCoordExtent(tileCoord); tileExtent = tileGrid.getTileCoordExtent(tileCoord);
tileExtent[0][0] -= tileGutter; tileExtent[0] -= tileGutter;
tileExtent[1][0] += tileGutter; tileExtent[2] += tileGutter;
tileExtent[0][1] -= tileGutter; tileExtent[1] -= tileGutter;
tileExtent[1][1] += tileGutter; tileExtent[3] += tileGutter;
tileHasFeatures = false; tileHasFeatures = false;
for (i = 0; i < numTypes; ++i) { for (i = 0; i < numTypes; ++i) {
type = types[i]; type = types[i];

View File

@@ -99,8 +99,8 @@ ol.renderer.dom.ImageLayer.prototype.renderFrame =
1); 1);
goog.vec.Mat4.translate( goog.vec.Mat4.translate(
transform, transform,
(imageExtent[0][0] - viewCenter[0]) / imageResolution, (imageExtent[0] - viewCenter[0]) / imageResolution,
(viewCenter[1] - imageExtent[1][1]) / imageResolution, (viewCenter[1] - imageExtent[3]) / imageResolution,
0); 0);
if (image != this.image_) { if (image != this.image_) {
var imageElement = image.getImageElement(this); var imageElement = image.getImageElement(this);

View File

@@ -169,12 +169,12 @@ ol.renderer.webgl.ImageLayer.prototype.updateProjectionMatrix_ =
2 / canvasExtentWidth, 2 / canvasExtentHeight, 1); 2 / canvasExtentWidth, 2 / canvasExtentHeight, 1);
goog.vec.Mat4.rotateZ(projectionMatrix, -viewRotation); goog.vec.Mat4.rotateZ(projectionMatrix, -viewRotation);
goog.vec.Mat4.translate(projectionMatrix, goog.vec.Mat4.translate(projectionMatrix,
imageExtent[0][0] - viewCenter[0], imageExtent[0] - viewCenter[0],
imageExtent[0][1] - viewCenter[1], imageExtent[1] - viewCenter[1],
0); 0);
goog.vec.Mat4.scale(projectionMatrix, goog.vec.Mat4.scale(projectionMatrix,
(imageExtent[1][0] - imageExtent[0][0]) / 2, (imageExtent[2] - imageExtent[0]) / 2,
(imageExtent[1][1] - imageExtent[0][1]) / 2, (imageExtent[3] - imageExtent[1]) / 2,
1); 1);
goog.vec.Mat4.translate(projectionMatrix, 1, 1, 0); goog.vec.Mat4.translate(projectionMatrix, 1, 1, 0);

View File

@@ -161,8 +161,8 @@ ol.renderer.webgl.TileLayer.prototype.renderFrame =
var minX = origin[0] + tileRange.minX * tileSize[0] * tileResolution; var minX = origin[0] + tileRange.minX * tileSize[0] * tileResolution;
var minY = origin[1] + tileRange.minY * tileSize[1] * tileResolution; var minY = origin[1] + tileRange.minY * tileSize[1] * tileResolution;
framebufferExtent = [ framebufferExtent = [
[minX, minY], minX, minY,
[minX + framebufferExtentDimension, minY + framebufferExtentDimension] minX + framebufferExtentDimension, minY + framebufferExtentDimension
]; ];
this.bindFramebuffer(frameState, framebufferDimension); this.bindFramebuffer(frameState, framebufferDimension);
@@ -246,13 +246,13 @@ ol.renderer.webgl.TileLayer.prototype.renderFrame =
for (tileKey in tilesToDraw) { for (tileKey in tilesToDraw) {
tile = tilesToDraw[tileKey]; tile = tilesToDraw[tileKey];
tileExtent = tileGrid.getTileCoordExtent(tile.tileCoord, tmpExtent); tileExtent = tileGrid.getTileCoordExtent(tile.tileCoord, tmpExtent);
sx = 2 * (tileExtent[1][0] - tileExtent[0][0]) / sx = 2 * (tileExtent[2] - tileExtent[0]) /
framebufferExtentDimension; framebufferExtentDimension;
sy = 2 * (tileExtent[1][1] - tileExtent[0][1]) / sy = 2 * (tileExtent[3] - tileExtent[1]) /
framebufferExtentDimension; framebufferExtentDimension;
tx = 2 * (tileExtent[0][0] - framebufferExtent[0][0]) / tx = 2 * (tileExtent[0] - framebufferExtent[0]) /
framebufferExtentDimension - 1; framebufferExtentDimension - 1;
ty = 2 * (tileExtent[0][1] - framebufferExtent[0][1]) / ty = 2 * (tileExtent[1] - framebufferExtent[1]) /
framebufferExtentDimension - 1; framebufferExtentDimension - 1;
goog.vec.Vec4.setFromValues(u_tileOffset, sx, sy, tx, ty); goog.vec.Vec4.setFromValues(u_tileOffset, sx, sy, tx, ty);
gl.uniform4fv(this.locations_.u_tileOffset, u_tileOffset); gl.uniform4fv(this.locations_.u_tileOffset, u_tileOffset);
@@ -296,17 +296,17 @@ ol.renderer.webgl.TileLayer.prototype.renderFrame =
var texCoordMatrix = this.texCoordMatrix; var texCoordMatrix = this.texCoordMatrix;
goog.vec.Mat4.makeIdentity(texCoordMatrix); goog.vec.Mat4.makeIdentity(texCoordMatrix);
goog.vec.Mat4.translate(texCoordMatrix, goog.vec.Mat4.translate(texCoordMatrix,
(center[0] - framebufferExtent[0][0]) / (center[0] - framebufferExtent[0]) /
(framebufferExtent[1][0] - framebufferExtent[0][0]), (framebufferExtent[2] - framebufferExtent[0]),
(center[1] - framebufferExtent[0][1]) / (center[1] - framebufferExtent[1]) /
(framebufferExtent[1][1] - framebufferExtent[0][1]), (framebufferExtent[3] - framebufferExtent[1]),
0); 0);
goog.vec.Mat4.rotateZ(texCoordMatrix, view2DState.rotation); goog.vec.Mat4.rotateZ(texCoordMatrix, view2DState.rotation);
goog.vec.Mat4.scale(texCoordMatrix, goog.vec.Mat4.scale(texCoordMatrix,
frameState.size[0] * view2DState.resolution / frameState.size[0] * view2DState.resolution /
(framebufferExtent[1][0] - framebufferExtent[0][0]), (framebufferExtent[2] - framebufferExtent[0]),
frameState.size[1] * view2DState.resolution / frameState.size[1] * view2DState.resolution /
(framebufferExtent[1][1] - framebufferExtent[0][1]), (framebufferExtent[3] - framebufferExtent[1]),
1); 1);
goog.vec.Mat4.translate(texCoordMatrix, goog.vec.Mat4.translate(texCoordMatrix,
-0.5, -0.5,

View File

@@ -20,7 +20,7 @@ ol.source.ImageStatic = function(options) {
var imageExtent = options.imageExtent; var imageExtent = options.imageExtent;
var imageSize = options.imageSize; var imageSize = options.imageSize;
var imageResolution = (imageExtent[1][1] - imageExtent[0][1]) / imageSize[1]; var imageResolution = (imageExtent[3] - imageExtent[1]) / imageSize[1];
var projection = ol.proj.get(options.projection); var projection = ol.proj.get(options.projection);
goog.base(this, { goog.base(this, {

View File

@@ -89,8 +89,8 @@ ol.source.ImageWMS.prototype.getImage =
extent = extent.slice(); extent = extent.slice();
ol.extent.scaleFromCenter(extent, this.ratio_); ol.extent.scaleFromCenter(extent, this.ratio_);
var width = (extent[1][0] - extent[0][0]) / resolution; var width = (extent[2] - extent[0]) / resolution;
var height = (extent[1][1] - extent[0][1]) / resolution; var height = (extent[3] - extent[1]) / resolution;
var size = [width, height]; var size = [width, height];
this.image_ = this.createImage(extent, resolution, size, projection); this.image_ = this.createImage(extent, resolution, size, projection);

View File

@@ -75,11 +75,11 @@ ol.source.TileWMS = function(options) {
extent = goog.isDef(extent) ? extent : projectionExtent; extent = goog.isDef(extent) ? extent : projectionExtent;
if (!goog.isNull(extent) && projection.isGlobal() && if (!goog.isNull(extent) && projection.isGlobal() &&
extent[0][0] === projectionExtent[0][0] && extent[0] === projectionExtent[0] &&
extent[1][0] === projectionExtent[1][0]) { extent[2] === projectionExtent[2]) {
var numCols = Math.ceil( var numCols = Math.ceil(
(extent[1][0] - extent[0][0]) / (extent[2] - extent[0]) /
(tileExtent[1][0] - tileExtent[0][0])); (tileExtent[2] - tileExtent[0]));
x = goog.math.modulo(x, numCols); x = goog.math.modulo(x, numCols);
tileExtent = tileGrid.getTileCoordExtent( tileExtent = tileGrid.getTileCoordExtent(
new ol.TileCoord(tileCoord.z, x, tileCoord.y)); new ol.TileCoord(tileCoord.z, x, tileCoord.y));

View File

@@ -54,8 +54,8 @@ ol.source.wms.getUrl =
var axisOrientation = projection.getAxisOrientation(); var axisOrientation = projection.getAxisOrientation();
var bboxValues = (wms13 && axisOrientation.substr(0, 2) == 'ne') ? var bboxValues = (wms13 && axisOrientation.substr(0, 2) == 'ne') ?
[extent[0][1], extent[0][0], extent[1][1], extent[1][0]] : [extent[1], extent[0], extent[3], extent[2]] :
[extent[0][0], extent[0][1], extent[1][0], extent[1][1]]; [extent[0], extent[1], extent[2], extent[3]];
baseParams['BBOX'] = bboxValues.join(','); baseParams['BBOX'] = bboxValues.join(',');
return goog.uri.utils.appendParamsFromMap(baseUrl, baseParams); return goog.uri.utils.appendParamsFromMap(baseUrl, baseParams);

View File

@@ -154,11 +154,11 @@ ol.source.WMTS = function(options) {
options.extent : projectionExtent; options.extent : projectionExtent;
if (!goog.isNull(extent) && projection.isGlobal() && if (!goog.isNull(extent) && projection.isGlobal() &&
extent[0][0] === projectionExtent[0][0] && extent[0] === projectionExtent[0] &&
extent[1][0] === projectionExtent[1][0]) { extent[2] === projectionExtent[2]) {
var numCols = Math.ceil( var numCols = Math.ceil(
(extent[1][0] - extent[0][0]) / (extent[2] - extent[0]) /
(tileExtent[1][0] - tileExtent[0][0])); (tileExtent[2] - tileExtent[0]));
x = goog.math.modulo(x, numCols); x = goog.math.modulo(x, numCols);
tmpTileCoord.z = tileCoord.z; tmpTileCoord.z = tileCoord.z;
tmpTileCoord.x = x; tmpTileCoord.x = x;

View File

@@ -84,10 +84,10 @@ ol.structs.RTree.recalculateExtent_ = function(node) {
ol.extent.empty(extent); ol.extent.empty(extent);
} else { } else {
var firstNodeExtent = node.nodes[0].extent; var firstNodeExtent = node.nodes[0].extent;
extent[0][0] = firstNodeExtent[0][0]; extent[0] = firstNodeExtent[0];
extent[1][0] = firstNodeExtent[1][0]; extent[2] = firstNodeExtent[2];
extent[0][1] = firstNodeExtent[0][1]; extent[1] = firstNodeExtent[1];
extent[1][1] = firstNodeExtent[1][1]; extent[3] = firstNodeExtent[3];
var i; var i;
for (i = 1; i < n; ++i) { for (i = 1; i < n; ++i) {
ol.extent.extend(extent, node.nodes[i].extent); ol.extent.extend(extent, node.nodes[i].extent);
@@ -151,19 +151,19 @@ ol.structs.RTree.prototype.chooseLeafSubtree_ = function(rect, root) {
} }
// Area of new enlarged rectangle // Area of new enlarged rectangle
var oldLRatio = ol.structs.RTree.squarifiedRatio_( var oldLRatio = ol.structs.RTree.squarifiedRatio_(
lTree.extent[1][0] - lTree.extent[0][0], lTree.extent[2] - lTree.extent[0],
lTree.extent[1][1] - lTree.extent[0][1], lTree.extent[3] - lTree.extent[1],
lTree.nodes.length + 1); lTree.nodes.length + 1);
// Enlarge rectangle to fit new rectangle // Enlarge rectangle to fit new rectangle
var nw = (lTree.extent[1][0] > rect.extent[1][0] ? var nw = (lTree.extent[2] > rect.extent[2] ?
lTree.extent[1][0] : rect.extent[1][0]) - lTree.extent[2] : rect.extent[2]) -
(lTree.extent[0][0] < rect.extent[0][0] ? (lTree.extent[0] < rect.extent[0] ?
lTree.extent[0][0] : rect.extent[0][0]); lTree.extent[0] : rect.extent[0]);
var nh = (lTree.extent[1][1] > rect.extent[1][1] ? var nh = (lTree.extent[3] > rect.extent[3] ?
lTree.extent[1][1] : rect.extent[1][1]) - lTree.extent[3] : rect.extent[3]) -
(lTree.extent[0][1] < rect.extent[0][1] ? (lTree.extent[1] < rect.extent[1] ?
lTree.extent[0][1] : rect.extent[0][1]); lTree.extent[1] : rect.extent[1]);
// Area of new enlarged rectangle // Area of new enlarged rectangle
var lRatio = ol.structs.RTree.squarifiedRatio_( var lRatio = ol.structs.RTree.squarifiedRatio_(
@@ -308,21 +308,21 @@ ol.structs.RTree.prototype.pickLinear_ = function(nodes) {
for (var i = nodes.length - 2; i >= 0; --i) { for (var i = nodes.length - 2; i >= 0; --i) {
var l = nodes[i]; var l = nodes[i];
if (l.extent[0][0] > nodes[highestLowX].extent[0][0]) { if (l.extent[0] > nodes[highestLowX].extent[0]) {
highestLowX = i; highestLowX = i;
} else if (l.extent[1][0] < nodes[lowestHighX].extent[0][1]) { } else if (l.extent[2] < nodes[lowestHighX].extent[1]) {
lowestHighX = i; lowestHighX = i;
} }
if (l.extent[0][1] > nodes[highestLowY].extent[0][1]) { if (l.extent[1] > nodes[highestLowY].extent[1]) {
highestLowY = i; highestLowY = i;
} else if (l.extent[1][1] < nodes[lowestHighY].extent[1][1]) { } else if (l.extent[3] < nodes[lowestHighY].extent[3]) {
lowestHighY = i; lowestHighY = i;
} }
} }
var dx = Math.abs(nodes[lowestHighX].extent[1][0] - var dx = Math.abs(nodes[lowestHighX].extent[2] -
nodes[highestLowX].extent[0][0]); nodes[highestLowX].extent[0]);
var dy = Math.abs(nodes[lowestHighY].extent[1][1] - var dy = Math.abs(nodes[lowestHighY].extent[3] -
nodes[highestLowY].extent[0][1]); nodes[highestLowY].extent[1]);
if (dx > dy) { if (dx > dy) {
if (lowestHighX > highestLowX) { if (lowestHighX > highestLowX) {
t1 = nodes.splice(lowestHighX, 1)[0]; t1 = nodes.splice(lowestHighX, 1)[0];
@@ -359,10 +359,10 @@ ol.structs.RTree.prototype.pickLinear_ = function(nodes) {
*/ */
ol.structs.RTree.prototype.pickNext_ = function(nodes, a, b) { ol.structs.RTree.prototype.pickNext_ = function(nodes, a, b) {
// Area of new enlarged rectangle // Area of new enlarged rectangle
var areaA = ol.structs.RTree.squarifiedRatio_(a.extent[1][0] - a.extent[0][0], var areaA = ol.structs.RTree.squarifiedRatio_(a.extent[2] - a.extent[0],
a.extent[1][1] - a.extent[0][1], a.nodes.length + 1); a.extent[3] - a.extent[1], a.nodes.length + 1);
var areaB = ol.structs.RTree.squarifiedRatio_(b.extent[1][0] - b.extent[0][0], var areaB = ol.structs.RTree.squarifiedRatio_(b.extent[2] - b.extent[0],
b.extent[1][1] - b.extent[0][1], b.nodes.length + 1); b.extent[3] - b.extent[1], b.nodes.length + 1);
var highAreaDelta; var highAreaDelta;
var highAreaNode; var highAreaNode;
var lowestGrowthGroup; var lowestGrowthGroup;
@@ -371,20 +371,20 @@ ol.structs.RTree.prototype.pickNext_ = function(nodes, a, b) {
var l = nodes[i]; var l = nodes[i];
var newAreaA = [ var newAreaA = [
a.extent[0][0] < l.extent[0][0] ? a.extent[0][0] : l.extent[0][0], a.extent[0] < l.extent[0] ? a.extent[0] : l.extent[0],
a.extent[1][0] > l.extent[1][0] ? a.extent[1][0] : l.extent[1][0], a.extent[2] > l.extent[2] ? a.extent[2] : l.extent[2],
a.extent[0][1] < l.extent[0][1] ? a.extent[0][1] : l.extent[0][1], a.extent[1] < l.extent[1] ? a.extent[1] : l.extent[1],
a.extent[1][1] > l.extent[1][1] ? a.extent[1][1] : l.extent[1][1] a.extent[3] > l.extent[3] ? a.extent[3] : l.extent[3]
]; ];
var changeNewAreaA = Math.abs(ol.structs.RTree.squarifiedRatio_( var changeNewAreaA = Math.abs(ol.structs.RTree.squarifiedRatio_(
newAreaA[1] - newAreaA[0], newAreaA[1] - newAreaA[0],
newAreaA[3] - newAreaA[2], a.nodes.length + 2) - areaA); newAreaA[3] - newAreaA[2], a.nodes.length + 2) - areaA);
var newAreaB = [ var newAreaB = [
b.extent[0][0] < l.extent[0][0] ? b.extent[0][0] : l.extent[0][0], b.extent[0] < l.extent[0] ? b.extent[0] : l.extent[0],
b.extent[1][0] > l.extent[1][0] ? b.extent[1][0] : l.extent[1][0], b.extent[2] > l.extent[2] ? b.extent[2] : l.extent[2],
b.extent[0][1] < l.extent[0][1] ? b.extent[0][1] : l.extent[0][1], b.extent[1] < l.extent[1] ? b.extent[1] : l.extent[1],
b.extent[1][1] > l.extent[1][1] ? b.extent[1][1] : l.extent[1][1] b.extent[3] > l.extent[3] ? b.extent[3] : l.extent[3]
]; ];
var changeNewAreaB = Math.abs(ol.structs.RTree.squarifiedRatio_( var changeNewAreaB = Math.abs(ol.structs.RTree.squarifiedRatio_(
newAreaB[1] - newAreaB[0], newAreaB[3] - newAreaB[2], newAreaB[1] - newAreaB[0], newAreaB[3] - newAreaB[2],

View File

@@ -232,11 +232,11 @@ ol.tilegrid.TileGrid.prototype.getTileRangeForExtentAndResolution =
function(extent, resolution, opt_tileRange) { function(extent, resolution, opt_tileRange) {
var tileCoord = ol.tilegrid.TileGrid.tmpTileCoord_; var tileCoord = ol.tilegrid.TileGrid.tmpTileCoord_;
this.getTileCoordForXYAndResolution_( this.getTileCoordForXYAndResolution_(
extent[0][0], extent[0][1], resolution, false, tileCoord); extent[0], extent[1], resolution, false, tileCoord);
var minX = tileCoord.x; var minX = tileCoord.x;
var minY = tileCoord.y; var minY = tileCoord.y;
this.getTileCoordForXYAndResolution_( this.getTileCoordForXYAndResolution_(
extent[1][0], extent[1][1], resolution, true, tileCoord); extent[2], extent[3], resolution, true, tileCoord);
return ol.TileRange.createOrUpdate( return ol.TileRange.createOrUpdate(
minX, tileCoord.x, minY, tileCoord.y, opt_tileRange); minX, tileCoord.x, minY, tileCoord.y, opt_tileRange);
}; };
@@ -414,8 +414,8 @@ ol.tilegrid.createForProjection =
var size = goog.isNull(projectionExtent) ? var size = goog.isNull(projectionExtent) ?
360 * ol.METERS_PER_UNIT[ol.ProjectionUnits.DEGREES] / 360 * ol.METERS_PER_UNIT[ol.ProjectionUnits.DEGREES] /
projection.getMetersPerUnit() : projection.getMetersPerUnit() :
Math.max(projectionExtent[1][0] - projectionExtent[0][0], Math.max(projectionExtent[2] - projectionExtent[0],
projectionExtent[1][1] - projectionExtent[0][1]); projectionExtent[3] - projectionExtent[1]);
var maxZoom = goog.isDef(opt_maxZoom) ? var maxZoom = goog.isDef(opt_maxZoom) ?
opt_maxZoom : ol.DEFAULT_MAX_ZOOM; opt_maxZoom : ol.DEFAULT_MAX_ZOOM;
var tileSize = goog.isDef(opt_tileSize) ? var tileSize = goog.isDef(opt_tileSize) ?

View File

@@ -226,7 +226,7 @@ ol.View2D.prototype.calculateExtent = function(size) {
var maxX = center[0] + resolution * size[0] / 2; var maxX = center[0] + resolution * size[0] / 2;
var minY = center[1] - resolution * size[1] / 2; var minY = center[1] - resolution * size[1] / 2;
var maxY = center[1] + resolution * size[1] / 2; var maxY = center[1] + resolution * size[1] / 2;
return [[minX, minY], [maxX, maxY]]; return [minX, minY, maxX, maxY];
}; };
@@ -262,8 +262,8 @@ goog.exportProperty(
* @return {number} Resolution. * @return {number} Resolution.
*/ */
ol.View2D.prototype.getResolutionForExtent = function(extent, size) { ol.View2D.prototype.getResolutionForExtent = function(extent, size) {
var xResolution = (extent[1][0] - extent[0][0]) / size[0]; var xResolution = (extent[2] - extent[0]) / size[0];
var yResolution = (extent[1][1] - extent[0][1]) / size[1]; var yResolution = (extent[3] - extent[1]) / size[1];
return Math.max(xResolution, yResolution); 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 // use an extent that can fit the whole world if need be
360 * ol.METERS_PER_UNIT[ol.ProjectionUnits.DEGREES] / 360 * ol.METERS_PER_UNIT[ol.ProjectionUnits.DEGREES] /
ol.METERS_PER_UNIT[projection.getUnits()] : ol.METERS_PER_UNIT[projection.getUnits()] :
Math.max(projectionExtent[1][0] - projectionExtent[0][0], Math.max(projectionExtent[2] - projectionExtent[0],
projectionExtent[1][1] - projectionExtent[0][1]); projectionExtent[3] - projectionExtent[1]);
maxResolution = size / ol.DEFAULT_TILE_SIZE; maxResolution = size / ol.DEFAULT_TILE_SIZE;
} }
var maxZoom = options.maxZoom; var maxZoom = options.maxZoom;

View File

@@ -20,7 +20,7 @@ describe('ol.extent', function() {
describe('positive', function() { describe('positive', function() {
it('returns true', function() { it('returns true', function() {
var extent = [[1, 2], [3, 4]]; var extent = [1, 2, 3, 4];
expect(ol.extent.containsCoordinate(extent, [1, 2])).to.be.ok(); expect(ol.extent.containsCoordinate(extent, [1, 2])).to.be.ok();
expect(ol.extent.containsCoordinate(extent, [1, 3])).to.be.ok(); expect(ol.extent.containsCoordinate(extent, [1, 3])).to.be.ok();
expect(ol.extent.containsCoordinate(extent, [1, 4])).to.be.ok(); expect(ol.extent.containsCoordinate(extent, [1, 4])).to.be.ok();
@@ -35,7 +35,7 @@ describe('ol.extent', function() {
describe('negative', function() { describe('negative', function() {
it('returns false', function() { it('returns false', function() {
var extent = [[1, 2], [3, 4]]; var extent = [1, 2, 3, 4];
expect(ol.extent.containsCoordinate(extent, [0, 1])).to.not.be(); expect(ol.extent.containsCoordinate(extent, [0, 1])).to.not.be();
expect(ol.extent.containsCoordinate(extent, [0, 2])).to.not.be(); expect(ol.extent.containsCoordinate(extent, [0, 2])).to.not.be();
expect(ol.extent.containsCoordinate(extent, [0, 3])).to.not.be(); expect(ol.extent.containsCoordinate(extent, [0, 3])).to.not.be();
@@ -58,7 +58,7 @@ describe('ol.extent', function() {
describe('getCenter', function() { describe('getCenter', function() {
it('returns the expected center', function() { it('returns the expected center', function() {
var extent = [[1, 2], [3, 4]]; var extent = [1, 2, 3, 4];
var center = ol.extent.getCenter(extent); var center = ol.extent.getCenter(extent);
expect(center[0]).to.eql(2); expect(center[0]).to.eql(2);
expect(center[1]).to.eql(3); expect(center[1]).to.eql(3);
@@ -70,53 +70,53 @@ describe('ol.extent', function() {
it('works for a unit square', function() { it('works for a unit square', function() {
var extent = ol.extent.getForView2DAndSize( var extent = ol.extent.getForView2DAndSize(
[0, 0], 1, 0, [1, 1]); [0, 0], 1, 0, [1, 1]);
expect(extent[0][0]).to.be(-0.5); expect(extent[0]).to.be(-0.5);
expect(extent[1][0]).to.be(0.5); expect(extent[2]).to.be(0.5);
expect(extent[0][1]).to.be(-0.5); expect(extent[1]).to.be(-0.5);
expect(extent[1][1]).to.be(0.5); expect(extent[3]).to.be(0.5);
}); });
it('works for center', function() { it('works for center', function() {
var extent = ol.extent.getForView2DAndSize( var extent = ol.extent.getForView2DAndSize(
[5, 10], 1, 0, [1, 1]); [5, 10], 1, 0, [1, 1]);
expect(extent[0][0]).to.be(4.5); expect(extent[0]).to.be(4.5);
expect(extent[1][0]).to.be(5.5); expect(extent[2]).to.be(5.5);
expect(extent[0][1]).to.be(9.5); expect(extent[1]).to.be(9.5);
expect(extent[1][1]).to.be(10.5); expect(extent[3]).to.be(10.5);
}); });
it('works for rotation', function() { it('works for rotation', function() {
var extent = ol.extent.getForView2DAndSize( var extent = ol.extent.getForView2DAndSize(
[0, 0], 1, Math.PI / 4, [1, 1]); [0, 0], 1, Math.PI / 4, [1, 1]);
expect(extent[0][0]).to.roughlyEqual(-Math.sqrt(0.5), 1e-9); expect(extent[0]).to.roughlyEqual(-Math.sqrt(0.5), 1e-9);
expect(extent[1][0]).to.roughlyEqual(Math.sqrt(0.5), 1e-9); expect(extent[2]).to.roughlyEqual(Math.sqrt(0.5), 1e-9);
expect(extent[0][1]).to.roughlyEqual(-Math.sqrt(0.5), 1e-9); expect(extent[1]).to.roughlyEqual(-Math.sqrt(0.5), 1e-9);
expect(extent[1][1]).to.roughlyEqual(Math.sqrt(0.5), 1e-9); expect(extent[3]).to.roughlyEqual(Math.sqrt(0.5), 1e-9);
}); });
it('works for resolution', function() { it('works for resolution', function() {
var extent = ol.extent.getForView2DAndSize( var extent = ol.extent.getForView2DAndSize(
[0, 0], 2, 0, [1, 1]); [0, 0], 2, 0, [1, 1]);
expect(extent[0][0]).to.be(-1); expect(extent[0]).to.be(-1);
expect(extent[1][0]).to.be(1); expect(extent[2]).to.be(1);
expect(extent[0][1]).to.be(-1); expect(extent[1]).to.be(-1);
expect(extent[1][1]).to.be(1); expect(extent[3]).to.be(1);
}); });
it('works for size', function() { it('works for size', function() {
var extent = ol.extent.getForView2DAndSize( var extent = ol.extent.getForView2DAndSize(
[0, 0], 1, 0, [10, 5]); [0, 0], 1, 0, [10, 5]);
expect(extent[0][0]).to.be(-5); expect(extent[0]).to.be(-5);
expect(extent[1][0]).to.be(5); expect(extent[2]).to.be(5);
expect(extent[0][1]).to.be(-2.5); expect(extent[1]).to.be(-2.5);
expect(extent[1][1]).to.be(2.5); expect(extent[3]).to.be(2.5);
}); });
}); });
describe('getSize', function() { describe('getSize', function() {
it('returns the expected size', function() { it('returns the expected size', function() {
var extent = [[0, 1], [2, 4]]; var extent = [0, 1, 2, 4];
var size = ol.extent.getSize(extent); var size = ol.extent.getSize(extent);
expect(size).to.eql([2, 3]); expect(size).to.eql([2, 3]);
}); });
@@ -126,40 +126,40 @@ describe('ol.extent', function() {
it('returns the expected value', function() { it('returns the expected value', function() {
var intersects = ol.extent.intersects; var intersects = ol.extent.intersects;
var extent = [[50, 50], [100, 100]]; var extent = [50, 50, 100, 100];
expect(intersects(extent, extent)).to.be(true); expect(intersects(extent, extent)).to.be(true);
expect(intersects(extent, [[20, 20], [80, 80]])).to.be(true); expect(intersects(extent, [20, 20, 80, 80])).to.be(true);
expect(intersects(extent, [[20, 50], [80, 100]])).to.be(true); expect(intersects(extent, [20, 50, 80, 100])).to.be(true);
expect(intersects(extent, [[20, 80], [80, 120]])).to.be(true); expect(intersects(extent, [20, 80, 80, 120])).to.be(true);
expect(intersects(extent, [[50, 20], [100, 80]])).to.be(true); expect(intersects(extent, [50, 20, 100, 80])).to.be(true);
expect(intersects(extent, [[50, 80], [100, 120]])).to.be(true); expect(intersects(extent, [50, 80, 100, 120])).to.be(true);
expect(intersects(extent, [[80, 20], [120, 80]])).to.be(true); expect(intersects(extent, [80, 20, 120, 80])).to.be(true);
expect(intersects(extent, [[80, 50], [120, 100]])).to.be(true); expect(intersects(extent, [80, 50, 120, 100])).to.be(true);
expect(intersects(extent, [[80, 80], [120, 120]])).to.be(true); expect(intersects(extent, [80, 80, 120, 120])).to.be(true);
expect(intersects(extent, [[20, 20], [120, 120]])).to.be(true); expect(intersects(extent, [20, 20, 120, 120])).to.be(true);
expect(intersects(extent, [[70, 70], [80, 80]])).to.be(true); expect(intersects(extent, [70, 70, 80, 80])).to.be(true);
expect(intersects(extent, [[10, 10], [30, 30]])).to.be(false); expect(intersects(extent, [10, 10, 30, 30])).to.be(false);
expect(intersects(extent, [[30, 10], [70, 30]])).to.be(false); expect(intersects(extent, [30, 10, 70, 30])).to.be(false);
expect(intersects(extent, [[50, 10], [100, 30]])).to.be(false); expect(intersects(extent, [50, 10, 100, 30])).to.be(false);
expect(intersects(extent, [[80, 10], [120, 30]])).to.be(false); expect(intersects(extent, [80, 10, 120, 30])).to.be(false);
expect(intersects(extent, [[120, 10], [140, 30]])).to.be(false); expect(intersects(extent, [120, 10, 140, 30])).to.be(false);
expect(intersects(extent, [[10, 30], [30, 70]])).to.be(false); expect(intersects(extent, [10, 30, 30, 70])).to.be(false);
expect(intersects(extent, [[120, 30], [140, 70]])).to.be(false); expect(intersects(extent, [120, 30, 140, 70])).to.be(false);
expect(intersects(extent, [[10, 50], [30, 100]])).to.be(false); expect(intersects(extent, [10, 50, 30, 100])).to.be(false);
expect(intersects(extent, [[120, 50], [140, 100]])).to.be(false); expect(intersects(extent, [120, 50, 140, 100])).to.be(false);
expect(intersects(extent, [[10, 80], [30, 120]])).to.be(false); expect(intersects(extent, [10, 80, 30, 120])).to.be(false);
expect(intersects(extent, [[120, 80], [140, 120]])).to.be(false); expect(intersects(extent, [120, 80, 140, 120])).to.be(false);
expect(intersects(extent, [[10, 120], [30, 140]])).to.be(false); expect(intersects(extent, [10, 120, 30, 140])).to.be(false);
expect(intersects(extent, [[30, 120], [70, 140]])).to.be(false); expect(intersects(extent, [30, 120, 70, 140])).to.be(false);
expect(intersects(extent, [[50, 120], [100, 140]])).to.be(false); expect(intersects(extent, [50, 120, 100, 140])).to.be(false);
expect(intersects(extent, [[80, 120], [120, 140]])).to.be(false); expect(intersects(extent, [80, 120, 120, 140])).to.be(false);
expect(intersects(extent, [[120, 120], [140, 140]])).to.be(false); expect(intersects(extent, [120, 120, 140, 140])).to.be(false);
}); });
}); });
describe('normalize', function() { describe('normalize', function() {
it('returns the expected coordinate', function() { it('returns the expected coordinate', function() {
var extent = [[0, 1], [2, 3]]; var extent = [0, 1, 2, 3];
var coordinate; var coordinate;
coordinate = ol.extent.normalize(extent, [1, 2]); coordinate = ol.extent.normalize(extent, [1, 2]);
@@ -186,18 +186,18 @@ describe('ol.extent', function() {
describe('scaleFromCenter', function() { describe('scaleFromCenter', function() {
it('scales the extent from its center', function() { it('scales the extent from its center', function() {
var extent = [[1, 1], [3, 3]]; var extent = [1, 1, 3, 3];
ol.extent.scaleFromCenter(extent, 2); ol.extent.scaleFromCenter(extent, 2);
expect(extent[0][0]).to.eql(0); expect(extent[0]).to.eql(0);
expect(extent[1][0]).to.eql(4); expect(extent[2]).to.eql(4);
expect(extent[0][1]).to.eql(0); expect(extent[1]).to.eql(0);
expect(extent[1][1]).to.eql(4); expect(extent[3]).to.eql(4);
}); });
}); });
describe('toString', function() { describe('toString', function() {
it('returns the expected string', function() { it('returns the expected string', function() {
var extent = [[0, 1], [2, 3]]; var extent = [0, 1, 2, 3];
expect(ol.extent.toString(extent)).to.eql('(0, 2, 1, 3)'); expect(ol.extent.toString(extent)).to.eql('(0, 2, 1, 3)');
}); });
}); });
@@ -206,16 +206,16 @@ describe('ol.extent', function() {
it('does transform', function() { it('does transform', function() {
var transformFn = ol.proj.getTransform('EPSG:4326', 'EPSG:3857'); var transformFn = ol.proj.getTransform('EPSG:4326', 'EPSG:3857');
var sourceExtent = [[-15, -30], [45, 60]]; var sourceExtent = [-15, -30, 45, 60];
var destinationExtent = ol.extent.transform(sourceExtent, transformFn); var destinationExtent = ol.extent.transform(sourceExtent, transformFn);
expect(destinationExtent).not.to.be(undefined); expect(destinationExtent).not.to.be(undefined);
expect(destinationExtent).not.to.be(null); expect(destinationExtent).not.to.be(null);
// FIXME check values with third-party tool // FIXME check values with third-party tool
expect(destinationExtent[0][0]) expect(destinationExtent[0])
.to.roughlyEqual(-1669792.3618991037, 1e-9); .to.roughlyEqual(-1669792.3618991037, 1e-9);
expect(destinationExtent[1][0]).to.roughlyEqual(5009377.085697311, 1e-9); expect(destinationExtent[2]).to.roughlyEqual(5009377.085697311, 1e-9);
expect(destinationExtent[0][1]).to.roughlyEqual(-3503549.843504376, 1e-8); expect(destinationExtent[1]).to.roughlyEqual(-3503549.843504376, 1e-8);
expect(destinationExtent[1][1]).to.roughlyEqual(8399737.889818361, 1e-9); expect(destinationExtent[3]).to.roughlyEqual(8399737.889818361, 1e-9);
}); });
it('takes arbitrary function', function() { it('takes arbitrary function', function() {
@@ -232,14 +232,14 @@ describe('ol.extent', function() {
} }
return output; return output;
}; };
var sourceExtent = [[-15, -30], [45, 60]]; var sourceExtent = [-15, -30, 45, 60];
var destinationExtent = ol.extent.transform(sourceExtent, transformFn); var destinationExtent = ol.extent.transform(sourceExtent, transformFn);
expect(destinationExtent).not.to.be(undefined); expect(destinationExtent).not.to.be(undefined);
expect(destinationExtent).not.to.be(null); expect(destinationExtent).not.to.be(null);
expect(destinationExtent[0][0]).to.be(-45); expect(destinationExtent[0]).to.be(-45);
expect(destinationExtent[1][0]).to.be(15); expect(destinationExtent[2]).to.be(15);
expect(destinationExtent[0][1]).to.be(-60); expect(destinationExtent[1]).to.be(-60);
expect(destinationExtent[1][1]).to.be(30); expect(destinationExtent[3]).to.be(30);
}); });
}); });

View File

@@ -79,10 +79,10 @@ describe('ol.geom.GeometryCollection', function() {
var line = new ol.geom.LineString([[1, 20], [30, 40]]); var line = new ol.geom.LineString([[1, 20], [30, 40]]);
var multi = new ol.geom.GeometryCollection([point, line]); var multi = new ol.geom.GeometryCollection([point, line]);
var bounds = multi.getBounds(); var bounds = multi.getBounds();
expect(bounds[0][0]).to.be(1); expect(bounds[0]).to.be(1);
expect(bounds[1][0]).to.be(30); expect(bounds[2]).to.be(30);
expect(bounds[0][1]).to.be(2); expect(bounds[1]).to.be(2);
expect(bounds[1][1]).to.be(40); expect(bounds[3]).to.be(40);
}); });
}); });

View File

@@ -39,10 +39,10 @@ describe('ol.geom.LineString', function() {
it('returns the bounding extent', function() { it('returns the bounding extent', function() {
var line = new ol.geom.LineString([[10, 20], [20, 30], [30, 40]]); var line = new ol.geom.LineString([[10, 20], [20, 30], [30, 40]]);
var bounds = line.getBounds(); var bounds = line.getBounds();
expect(bounds[0][0]).to.be(10); expect(bounds[0]).to.be(10);
expect(bounds[1][0]).to.be(30); expect(bounds[2]).to.be(30);
expect(bounds[0][1]).to.be(20); expect(bounds[1]).to.be(20);
expect(bounds[1][1]).to.be(40); expect(bounds[3]).to.be(40);
}); });
}); });

View File

@@ -61,10 +61,10 @@ describe('ol.geom.MultiLineString', function() {
[[10, 20], [30, 40]], [[10, 20], [30, 40]],
[[20, 30], [40, 50]]]); [[20, 30], [40, 50]]]);
var bounds = multi.getBounds(); var bounds = multi.getBounds();
expect(bounds[0][0]).to.be(10); expect(bounds[0]).to.be(10);
expect(bounds[1][0]).to.be(40); expect(bounds[2]).to.be(40);
expect(bounds[0][1]).to.be(20); expect(bounds[1]).to.be(20);
expect(bounds[1][1]).to.be(50); expect(bounds[3]).to.be(50);
}); });
}); });

View File

@@ -51,10 +51,10 @@ describe('ol.geom.MultiPoint', function() {
it('returns the bounding extent', function() { it('returns the bounding extent', function() {
var multi = new ol.geom.MultiPoint([[10, 20], [30, 40]]); var multi = new ol.geom.MultiPoint([[10, 20], [30, 40]]);
var bounds = multi.getBounds(); var bounds = multi.getBounds();
expect(bounds[0][0]).to.be(10); expect(bounds[0]).to.be(10);
expect(bounds[1][0]).to.be(30); expect(bounds[2]).to.be(30);
expect(bounds[0][1]).to.be(20); expect(bounds[1]).to.be(20);
expect(bounds[1][1]).to.be(40); expect(bounds[3]).to.be(40);
}); });
}); });

View File

@@ -64,10 +64,10 @@ describe('ol.geom.MultiPolygon', function() {
[outer1, inner1a, inner1b], [outer1, inner1a, inner1b],
[outer2]]); [outer2]]);
var bounds = multi.getBounds(); var bounds = multi.getBounds();
expect(bounds[0][0]).to.be(0); expect(bounds[0]).to.be(0);
expect(bounds[1][0]).to.be(20); expect(bounds[2]).to.be(20);
expect(bounds[0][1]).to.be(0); expect(bounds[1]).to.be(0);
expect(bounds[1][1]).to.be(50); expect(bounds[3]).to.be(50);
}); });
}); });

View File

@@ -48,10 +48,10 @@ describe('ol.geom.Point', function() {
it('returns the bounding extent', function() { it('returns the bounding extent', function() {
var point = new ol.geom.Point([10, 20]); var point = new ol.geom.Point([10, 20]);
var bounds = point.getBounds(); var bounds = point.getBounds();
expect(bounds[0][0]).to.be(10); expect(bounds[0]).to.be(10);
expect(bounds[1][0]).to.be(10); expect(bounds[2]).to.be(10);
expect(bounds[0][1]).to.be(20); expect(bounds[1]).to.be(20);
expect(bounds[1][1]).to.be(20); expect(bounds[3]).to.be(20);
}); });
}); });

View File

@@ -80,10 +80,10 @@ describe('ol.geom.Polygon', function() {
it('returns the bounding extent', function() { it('returns the bounding extent', function() {
var poly = new ol.geom.Polygon([outer, inner1, inner2]); var poly = new ol.geom.Polygon([outer, inner1, inner2]);
var bounds = poly.getBounds(); var bounds = poly.getBounds();
expect(bounds[0][0]).to.be(0); expect(bounds[0]).to.be(0);
expect(bounds[1][0]).to.be(10); expect(bounds[2]).to.be(10);
expect(bounds[0][1]).to.be(0); expect(bounds[1]).to.be(0);
expect(bounds[1][1]).to.be(10); expect(bounds[3]).to.be(10);
}); });
}); });

View File

@@ -13,22 +13,7 @@ describe('ol.geom2', function() {
it('returns the expected extent', function() { it('returns the expected extent', function() {
var extent = ol.geom2.getExtent(buf, dim); var extent = ol.geom2.getExtent(buf, dim);
expect(extent).to.eql([[0, 1], [10, 11]]); expect(extent).to.eql([0, 1, 10, 11]);
});
it('returns the expect extent in three dimensions', function() {
var extent = ol.geom2.getExtent(buf, 3);
expect(extent).to.eql([[0, 1, 2], [9, 10, 11]]);
});
it('returns the expect extent in four dimensions', function() {
var extent = ol.geom2.getExtent(buf, 4);
expect(extent).to.eql([[0, 1, 2, 3], [8, 9, 10, 11]]);
});
it('returns the expect extent in six dimensions', function() {
var extent = ol.geom2.getExtent(buf, 6);
expect(extent).to.eql([[0, 1, 2, 3, 4, 5], [6, 7, 8, 9, 10, 11]]);
}); });
}); });

View File

@@ -189,7 +189,7 @@ describe('ol.geom2.LineStringCollection', function() {
describe('getExtent', function() { describe('getExtent', function() {
it('returns the expected extent', function() { it('returns the expected extent', function() {
expect(lsc.getExtent()).to.eql([[0, 1], [2, 3]]); expect(lsc.getExtent()).to.eql([0, 1, 2, 3]);
}); });
}); });
@@ -268,7 +268,7 @@ describe('ol.geom2.LineStringCollection', function() {
describe('getExtent', function() { describe('getExtent', function() {
it('returns the expected value', function() { it('returns the expected value', function() {
expect(lsc.getExtent()).to.eql([[0, 1], [8, 9]]); expect(lsc.getExtent()).to.eql([0, 1, 8, 9]);
}); });
}); });

View File

@@ -198,7 +198,7 @@ describe('ol.geom2.PointCollection', function() {
it('returns the expected value', function() { it('returns the expected value', function() {
var extent = pc.getExtent(); var extent = pc.getExtent();
expect(extent).to.eql([[0, 1], [2, 3]]); expect(extent).to.eql([0, 1, 2, 3]);
}); });
}); });

View File

@@ -202,7 +202,7 @@ describe('ol.parser.GeoJSON', function() {
var firstGeom = first.getGeometry(); var firstGeom = first.getGeometry();
expect(firstGeom).to.be.a(ol.geom.Polygon); expect(firstGeom).to.be.a(ol.geom.Polygon);
expect(ol.extent.equals(firstGeom.getBounds(), expect(ol.extent.equals(firstGeom.getBounds(),
[[60.52843, 29.318572], [75.158028, 38.486282]])) [60.52843, 29.318572, 75.158028, 38.486282]))
.to.be(true); .to.be(true);
var last = result[178]; var last = result[178];
@@ -212,7 +212,7 @@ describe('ol.parser.GeoJSON', function() {
var lastGeom = last.getGeometry(); var lastGeom = last.getGeometry();
expect(lastGeom).to.be.a(ol.geom.Polygon); expect(lastGeom).to.be.a(ol.geom.Polygon);
expect(ol.extent.equals(lastGeom.getBounds(), expect(ol.extent.equals(lastGeom.getBounds(),
[[25.264226, -22.271612], [32.849861, -15.507787]])) [25.264226, -22.271612, 32.849861, -15.507787]))
.to.be(true); .to.be(true);
done(); done();
}); });
@@ -251,7 +251,7 @@ describe('ol.parser.GeoJSON', function() {
var firstGeom = first.getGeometry(); var firstGeom = first.getGeometry();
expect(firstGeom).to.be.a(ol.geom.Polygon); expect(firstGeom).to.be.a(ol.geom.Polygon);
expect(ol.extent.equals(firstGeom.getBounds(), expect(ol.extent.equals(firstGeom.getBounds(),
[[60.52843, 29.318572], [75.158028, 38.486282]])) [60.52843, 29.318572, 75.158028, 38.486282]))
.to.be(true); .to.be(true);
var last = result[178]; var last = result[178];
@@ -260,7 +260,7 @@ describe('ol.parser.GeoJSON', function() {
var lastGeom = last.getGeometry(); var lastGeom = last.getGeometry();
expect(lastGeom).to.be.a(ol.geom.Polygon); expect(lastGeom).to.be.a(ol.geom.Polygon);
expect(ol.extent.equals(lastGeom.getBounds(), expect(ol.extent.equals(lastGeom.getBounds(),
[[25.264226, -22.271612], [32.849861, -15.507787]])) [25.264226, -22.271612, 32.849861, -15.507787]))
.to.be(true); .to.be(true);
}); });
}); });

View File

@@ -204,7 +204,7 @@ describe('ol.parser.gml_v2', function() {
var url = 'spec/ol/parser/ogc/xml/gml_v2/box-coord.xml'; var url = 'spec/ol/parser/ogc/xml/gml_v2/box-coord.xml';
afterLoadXml(url, function(xml) { afterLoadXml(url, function(xml) {
var obj = parser.read(xml); var obj = parser.read(xml);
expect(obj.bounds).to.eql([[1, 2], [3, 4]]); expect(obj.bounds).to.eql([1, 2, 3, 4]);
done(); done();
}); });
}); });
@@ -212,7 +212,7 @@ describe('ol.parser.gml_v2', function() {
var url = 'spec/ol/parser/ogc/xml/gml_v2/box-coordinates.xml'; var url = 'spec/ol/parser/ogc/xml/gml_v2/box-coordinates.xml';
afterLoadXml(url, function(xml) { afterLoadXml(url, function(xml) {
var obj = parser.read(xml); var obj = parser.read(xml);
expect(obj.bounds).to.eql([[1, 2], [3, 4]]); expect(obj.bounds).to.eql([1, 2, 3, 4]);
done(); done();
}); });
}); });

View File

@@ -9,7 +9,7 @@ describe('ol.parser.gml_v3', function() {
var url = 'spec/ol/parser/ogc/xml/gml_v3/envelope.xml'; var url = 'spec/ol/parser/ogc/xml/gml_v3/envelope.xml';
afterLoadXml(url, function(xml) { afterLoadXml(url, function(xml) {
var obj = parser.read(xml); var obj = parser.read(xml);
expect(obj.bounds).to.eql([[1, 2], [3, 4]]); expect(obj.bounds).to.eql([1, 2, 3, 4]);
done(); done();
}); });
}); });

View File

@@ -50,8 +50,8 @@ describe('ol.parser.ogc.wmscapabilities_v1_1_1', function() {
var abstr = 'Highly simplified road layout of Manhattan in New York..'; var abstr = 'Highly simplified road layout of Manhattan in New York..';
expect(layer['abstract']).to.eql(abstr); expect(layer['abstract']).to.eql(abstr);
var bbox = [ var bbox = [
[-74.08769307536667, 40.660618924633326], -74.08769307536667, 40.660618924633326,
[-73.84653192463333, 40.90178007536667] -73.84653192463333, 40.90178007536667
]; ];
expect(layer.llbbox).to.eql(bbox); expect(layer.llbbox).to.eql(bbox);
expect(layer.styles.length).to.eql(1); expect(layer.styles.length).to.eql(1);
@@ -89,13 +89,13 @@ describe('ol.parser.ogc.wmscapabilities_v1_1_1', function() {
expect(layers['ROADS_RIVERS'].srs).to.eql(srs); expect(layers['ROADS_RIVERS'].srs).to.eql(srs);
expect(layers['Temperature'].srs).to.eql({'EPSG:4326': true}); expect(layers['Temperature'].srs).to.eql({'EPSG:4326': true});
var bbox = layers['ROADS_RIVERS'].bbox['EPSG:26986']; var bbox = layers['ROADS_RIVERS'].bbox['EPSG:26986'];
expect(bbox.bbox).to.eql([[189000, 834000], [285000, 962000]]); expect(bbox.bbox).to.eql([189000, 834000, 285000, 962000]);
expect(bbox.res).to.eql({x: 1, y: 1}); expect(bbox.res).to.eql({x: 1, y: 1});
bbox = layers['ROADS_RIVERS'].bbox['EPSG:4326']; bbox = layers['ROADS_RIVERS'].bbox['EPSG:4326'];
expect(bbox.bbox).to.eql([[-71.63, 41.75], [-70.78, 42.90]]); expect(bbox.bbox).to.eql([-71.63, 41.75, -70.78, 42.90]);
expect(bbox.res).to.eql({x: 0.01, y: 0.01}); expect(bbox.res).to.eql({x: 0.01, y: 0.01});
bbox = layers['ROADS_1M'].bbox['EPSG:26986']; bbox = layers['ROADS_1M'].bbox['EPSG:26986'];
expect(bbox.bbox).to.eql([[189000, 834000], [285000, 962000]]); expect(bbox.bbox).to.eql([189000, 834000, 285000, 962000]);
expect(bbox.res).to.eql({x: 1, y: 1}); expect(bbox.res).to.eql({x: 1, y: 1});
expect(identifiers).to.be.ok(); expect(identifiers).to.be.ok();
expect('DIF_ID' in identifiers).to.be.ok(); expect('DIF_ID' in identifiers).to.be.ok();

View File

@@ -17,8 +17,8 @@ describe('ol.parser.ogc.wmscapabilities_v1_1_1_wmsc', function() {
tileset = tilesets[0]; tileset = tilesets[0];
expect(tilesets.length).to.eql(2); expect(tilesets.length).to.eql(2);
var bbox = [ var bbox = [
[-13697515.466796875, 5165920.118906248], -13697515.466796875, 5165920.118906248,
[-13619243.94984375, 5244191.635859374] -13619243.94984375, 5244191.635859374
]; ];
expect(tileset.bbox['EPSG:900913'].bbox).to.eql(bbox); expect(tileset.bbox['EPSG:900913'].bbox).to.eql(bbox);
expect(tileset.format).to.eql('image/png'); expect(tileset.format).to.eql('image/png');

View File

@@ -53,13 +53,13 @@ describe('ol.parser.ogc.wmscapabilities_v1_3_0', function() {
var infoFormats = ['text/xml', 'text/plain', 'text/html']; var infoFormats = ['text/xml', 'text/plain', 'text/html'];
expect(layers['Temperature'].infoFormats).to.eql(infoFormats); expect(layers['Temperature'].infoFormats).to.eql(infoFormats);
var bbox = layers['ROADS_RIVERS'].bbox['EPSG:26986']; var bbox = layers['ROADS_RIVERS'].bbox['EPSG:26986'];
expect(bbox.bbox).to.eql([[189000, 834000], [285000, 962000]]); expect(bbox.bbox).to.eql([189000, 834000, 285000, 962000]);
expect(bbox.res).to.eql({x: 1, y: 1}); expect(bbox.res).to.eql({x: 1, y: 1});
bbox = layers['ROADS_RIVERS'].bbox['CRS:84']; bbox = layers['ROADS_RIVERS'].bbox['CRS:84'];
expect(bbox.bbox).to.eql([[-71.63, 41.75], [-70.78, 42.90]]); expect(bbox.bbox).to.eql([-71.63, 41.75, -70.78, 42.90]);
expect(bbox.res).to.eql({x: 0.01, y: 0.01}); expect(bbox.res).to.eql({x: 0.01, y: 0.01});
bbox = layers['ROADS_1M'].bbox['EPSG:26986']; bbox = layers['ROADS_1M'].bbox['EPSG:26986'];
expect(bbox.bbox).to.eql([[189000, 834000], [285000, 962000]]); expect(bbox.bbox).to.eql([189000, 834000, 285000, 962000]);
expect(bbox.res).to.eql({x: 1, y: 1}); expect(bbox.res).to.eql({x: 1, y: 1});
expect(identifiers).to.be.ok(); expect(identifiers).to.be.ok();
expect('DIF_ID' in identifiers).to.be.ok(); expect('DIF_ID' in identifiers).to.be.ok();

View File

@@ -47,8 +47,8 @@ describe('ol.parser.TopoJSON', function() {
expect(geometry).to.be.a(ol.geom.Polygon); expect(geometry).to.be.a(ol.geom.Polygon);
expect(geometry.getBounds()).to.eql([ expect(geometry.getBounds()).to.eql([
[-70.08100810081008, 12.417091709170947], -70.08100810081008, 12.417091709170947,
[-69.9009900990099, 12.608069195591469] -69.9009900990099, 12.608069195591469
]); ]);
}); });
@@ -88,15 +88,15 @@ describe('ol.parser.TopoJSON', function() {
var firstGeom = first.getGeometry(); var firstGeom = first.getGeometry();
expect(firstGeom).to.be.a(ol.geom.MultiPolygon); expect(firstGeom).to.be.a(ol.geom.MultiPolygon);
expect(firstGeom.getBounds()).to.eql( expect(firstGeom.getBounds()).to.eql(
[[-180, -85.60903777459777], [180, 83.64513000000002]]); [-180, -85.60903777459777, 180, 83.64513000000002]);
var last = result.features[177]; var last = result.features[177];
expect(last).to.be.a(ol.Feature); expect(last).to.be.a(ol.Feature);
var lastGeom = last.getGeometry(); var lastGeom = last.getGeometry();
expect(lastGeom).to.be.a(ol.geom.Polygon); expect(lastGeom).to.be.a(ol.geom.Polygon);
expect(lastGeom.getBounds()).to.eql([ expect(lastGeom.getBounds()).to.eql([
[25.26325263252633, -22.271802279310577], 25.26325263252633, -22.271802279310577,
[32.848528485284874, -15.50833810039586] 32.848528485284874, -15.50833810039586
]); ]);
done(); done();

View File

@@ -90,8 +90,8 @@ describe('ol.proj.EPSG21781', function() {
var fromEPSG4326 = ol.proj.getTransform('EPSG:4326', 'EPSG:21781'); var fromEPSG4326 = ol.proj.getTransform('EPSG:4326', 'EPSG:21781');
var toEPSG4326 = ol.proj.getTransform('EPSG:21781', 'EPSG:4326'); var toEPSG4326 = ol.proj.getTransform('EPSG:21781', 'EPSG:4326');
var roundTripped, x, y; var roundTripped, x, y;
for (x = extent[0][0]; x < extent[1][0]; x += 50000) { for (x = extent[0]; x < extent[2]; x += 50000) {
for (y = extent[0][1]; y < extent[1][1]; y += 50000) { for (y = extent[1]; y < extent[3]; y += 50000) {
roundTripped = fromEPSG4326(toEPSG4326([x, y])); roundTripped = fromEPSG4326(toEPSG4326([x, y]));
expect(roundTripped).to.be.an(Array); expect(roundTripped).to.be.an(Array);
expect(roundTripped).to.have.length(2); expect(roundTripped).to.have.length(2);

View File

@@ -284,7 +284,7 @@ describe('ol.proj', function() {
describe('ol.proj.removeTransform()', function() { describe('ol.proj.removeTransform()', function() {
var extent = [[180, -90], [180, 90]]; var extent = [180, -90, 180, 90];
var units = ol.ProjectionUnits.DEGREES; var units = ol.ProjectionUnits.DEGREES;
it('removes functions cached by addTransform', function() { it('removes functions cached by addTransform', function() {
@@ -347,7 +347,7 @@ describe('ol.proj', function() {
}); });
it('returns a configured projection', function() { it('returns a configured projection', function() {
var extent = [[485869.5728, 76443.1884], [837076.5648, 299941.7864]]; var extent = [485869.5728, 76443.1884, 837076.5648, 299941.7864];
var epsg21781 = ol.proj.configureProj4jsProjection({ var epsg21781 = ol.proj.configureProj4jsProjection({
code: 'EPSG:21781', code: 'EPSG:21781',
extent: extent extent: extent

View File

@@ -17,7 +17,7 @@ describe('ol.renderer.webgl.ImageLayer', function() {
}); });
var layer = new ol.layer.Image({ var layer = new ol.layer.Image({
source: new ol.source.Image({ source: new ol.source.Image({
extent: [[0, 0], [1, 1]] extent: [0, 0, 1, 1]
}) })
}); });
renderer = new ol.renderer.webgl.ImageLayer(map.getRenderer(), layer); renderer = new ol.renderer.webgl.ImageLayer(map.getRenderer(), layer);
@@ -32,7 +32,7 @@ describe('ol.renderer.webgl.ImageLayer', function() {
// image size is 1024, 768 // image size is 1024, 768
// image resolution is 10 // image resolution is 10
imageExtent = [[0, 0], [10240, 7680]]; imageExtent = [0, 0, 10240, 7680];
}); });
afterEach(function() { afterEach(function() {

View File

@@ -192,7 +192,7 @@ describe('ol.source.Tile', function() {
* @param {Object.<string, boolean>} loaded Lookup of already loaded tiles. * @param {Object.<string, boolean>} loaded Lookup of already loaded tiles.
*/ */
ol.test.source.TileMock = function(loaded) { ol.test.source.TileMock = function(loaded) {
var extent = [[-180, -180], [180, 180]]; var extent = [-180, -180, 180, 180];
var tileGrid = new ol.tilegrid.TileGrid({ var tileGrid = new ol.tilegrid.TileGrid({
resolutions: [360 / 256, 180 / 256, 90 / 256, 45 / 256], resolutions: [360 / 256, 180 / 256, 90 / 256, 45 / 256],
extent: extent, extent: extent,

View File

@@ -20,7 +20,7 @@ describe('ol.source.Vector', function() {
var layer = new ol.layer.Vector({ var layer = new ol.layer.Vector({
source: source source: source
}); });
source.prepareFeatures(layer, [[-180, -90], [180, 90]], source.prepareFeatures(layer, [-180, -90, 180, 90],
ol.proj.get('EPSG:4326'), ol.proj.get('EPSG:4326'),
function() { function() {
expect(source.loadState_).to.be(ol.source.VectorLoadState.LOADED); expect(source.loadState_).to.be(ol.source.VectorLoadState.LOADED);
@@ -66,7 +66,7 @@ describe('ol.source.Vector', function() {
var layer = new ol.layer.Vector({ var layer = new ol.layer.Vector({
source: source source: source
}); });
source.prepareFeatures(layer, [[-180, -90], [180, 90]], source.prepareFeatures(layer, [-180, -90, 180, 90],
ol.proj.get('EPSG:4326'), ol.proj.get('EPSG:4326'),
function() { function() {
expect(source.loadState_).to.be(ol.source.VectorLoadState.LOADED); expect(source.loadState_).to.be(ol.source.VectorLoadState.LOADED);

View File

@@ -5,7 +5,7 @@ describe('ol.source.wms', function() {
describe('ol.source.wms.getUrl', function() { describe('ol.source.wms.getUrl', function() {
it('creates expected URL', function() { it('creates expected URL', function() {
var epsg3857 = ol.proj.get('EPSG:3857'); var epsg3857 = ol.proj.get('EPSG:3857');
var extent = [[-20037508.342789244, -20037508.342789244], [0, 0]]; var extent = [-20037508.342789244, -20037508.342789244, 0, 0];
var expected = 'http://wms?SERVICE=WMS&VERSION=1.3.0&REQUEST=' + var expected = 'http://wms?SERVICE=WMS&VERSION=1.3.0&REQUEST=' +
'GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&WIDTH=256&HEIGHT=256&' + 'GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&WIDTH=256&HEIGHT=256&' +
'foo=bar&STYLES=&CRS=EPSG%3A3857&BBOX=' + 'foo=bar&STYLES=&CRS=EPSG%3A3857&BBOX=' +
@@ -16,7 +16,7 @@ describe('ol.source.wms', function() {
}); });
it('creates expected URL respecting axis orientation', function() { it('creates expected URL respecting axis orientation', function() {
var epsg4326 = ol.proj.get('EPSG:4326'); var epsg4326 = ol.proj.get('EPSG:4326');
var extent = [[-180, -90], [0, 90]]; var extent = [-180, -90, 0, 90];
var expected = 'http://wms?SERVICE=WMS&VERSION=1.3.0&REQUEST=' + var expected = 'http://wms?SERVICE=WMS&VERSION=1.3.0&REQUEST=' +
'GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&WIDTH=256&HEIGHT=256&' + 'GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&WIDTH=256&HEIGHT=256&' +
'foo=bar&STYLES=&CRS=EPSG%3A4326&BBOX=-90%2C-180%2C90%2C0'; 'foo=bar&STYLES=&CRS=EPSG%3A4326&BBOX=-90%2C-180%2C90%2C0';

View File

@@ -11,11 +11,11 @@ describe('ol.structs.RTree', function() {
while (i > 0) { while (i > 0) {
var min = [Math.random() * 10000, Math.random() * 10000]; var min = [Math.random() * 10000, Math.random() * 10000];
var max = [min[0] + Math.random() * 500, min[1] + Math.random() * 500]; var max = [min[0] + Math.random() * 500, min[1] + Math.random() * 500];
var bounds = [min, max]; var bounds = [min[0], min[1], max[0], max[1]];
rTree.insert(bounds, 'JUST A TEST OBJECT!_' + i); rTree.insert(bounds, 'JUST A TEST OBJECT!_' + i);
i--; i--;
} }
expect(goog.object.getCount(rTree.search([[0, 0], [10600, 10600]]))) expect(goog.object.getCount(rTree.search([0, 0, 10600, 10600])))
.to.be(1000); .to.be(1000);
}); });
it('can insert 1k more objects', function() { it('can insert 1k more objects', function() {
@@ -23,11 +23,11 @@ describe('ol.structs.RTree', function() {
while (i > 0) { while (i > 0) {
var min = [Math.random() * 10000, Math.random() * 10000]; var min = [Math.random() * 10000, Math.random() * 10000];
var max = [min[0] + Math.random() * 500, min[1] + Math.random() * 500]; var max = [min[0] + Math.random() * 500, min[1] + Math.random() * 500];
var bounds = [min, max]; var bounds = [min[0], min[1], max[0], max[1]];
rTree.insert(bounds, 'JUST A TEST OBJECT!_' + i); rTree.insert(bounds, 'JUST A TEST OBJECT!_' + i);
i--; i--;
} }
expect(goog.object.getCount(rTree.search([[0, 0], [10600, 10600]]))) expect(goog.object.getCount(rTree.search([0, 0, 10600, 10600])))
.to.be(2000); .to.be(2000);
}); });
}); });
@@ -40,7 +40,7 @@ describe('ol.structs.RTree', function() {
var min = [-(Math.random() * 10000 + 501), var min = [-(Math.random() * 10000 + 501),
-(Math.random() * 10000 + 501)]; -(Math.random() * 10000 + 501)];
var max = [min[0] + Math.random() * 500, min[1] + Math.random() * 500]; var max = [min[0] + Math.random() * 500, min[1] + Math.random() * 500];
var bounds = [min, max]; var bounds = [min[0], min[1], max[0], max[1]];
len += rTree.search(bounds).length; len += rTree.search(bounds).length;
i--; i--;
} }
@@ -52,7 +52,7 @@ describe('ol.structs.RTree', function() {
while (i > 0) { while (i > 0) {
var min = [Math.random() * 10000, Math.random() * 10000]; var min = [Math.random() * 10000, Math.random() * 10000];
var max = [min[0] + Math.random() * 500, min[1] + Math.random() * 500]; var max = [min[0] + Math.random() * 500, min[1] + Math.random() * 500];
var bounds = [min, max]; var bounds = [min[0], min[1], max[0], max[1]];
len += rTree.search(bounds).length; len += rTree.search(bounds).length;
i--; i--;
} }
@@ -63,12 +63,12 @@ describe('ol.structs.RTree', function() {
describe('deletion', function() { describe('deletion', function() {
var len = 0; var len = 0;
it('can delete half the RTree', function() { it('can delete half the RTree', function() {
var bounds = [[5000, 0], [10500, 10500]]; var bounds = [5000, 0, 10500, 10500];
len += rTree.remove(bounds).length; len += rTree.remove(bounds).length;
expect(len).to.not.be(0); expect(len).to.not.be(0);
}); });
it('can delete the other half of the RTree', function() { it('can delete the other half of the RTree', function() {
var bounds = [[0, 0], [5000, 10500]]; var bounds = [0, 0, 5000, 10500];
len += rTree.remove(bounds).length; len += rTree.remove(bounds).length;
expect(len).to.be(2000); expect(len).to.be(2000);
}); });
@@ -77,42 +77,42 @@ describe('ol.structs.RTree', function() {
describe('result plausibility and structure', function() { describe('result plausibility and structure', function() {
it('filters by rectangle', function() { it('filters by rectangle', function() {
rTree.insert([[0, 0], [1, 1]], 1); rTree.insert([0, 0, 1, 1], 1);
rTree.insert([[1, 1], [4, 4]], 2); rTree.insert([1, 1, 4, 4], 2);
rTree.insert([[2, 2], [3, 3]], 3); rTree.insert([2, 2, 3, 3], 3);
rTree.insert([[-5, -5], [-4, -4]], 4); rTree.insert([-5, -5, -4, -4], 4);
rTree.insert([[-4, -4], [-1, -1]], 5); rTree.insert([-4, -4, -1, -1], 5);
rTree.insert([[-3, -3], [-2, -2]], 6); rTree.insert([-3, -3, -2, -2], 6);
var result; var result;
result = goog.object.getValues(rTree.search([[2, 2], [3, 3]])); result = goog.object.getValues(rTree.search([2, 2, 3, 3]));
expect(result).to.contain(2); expect(result).to.contain(2);
expect(result).to.contain(3); expect(result).to.contain(3);
expect(result.length).to.be(2); expect(result.length).to.be(2);
result = goog.object.getValues(rTree.search([[-1, -1], [2, 2]])); result = goog.object.getValues(rTree.search([-1, -1, 2, 2]));
expect(result).to.contain(1); expect(result).to.contain(1);
expect(result).to.contain(2); expect(result).to.contain(2);
expect(result).to.contain(3); expect(result).to.contain(3);
expect(result).to.contain(5); expect(result).to.contain(5);
expect(result.length).to.be(4); expect(result.length).to.be(4);
expect(goog.object.getCount(rTree.search([[5, 5], [6, 6]]))).to.be(0); expect(goog.object.getCount(rTree.search([5, 5, 6, 6]))).to.be(0);
}); });
it('filters by type', function() { it('filters by type', function() {
rTree.insert([[2, 2], [3, 3]], 7, 'type1'); rTree.insert([2, 2, 3, 3], 7, 'type1');
var result; var result;
result = rTree.search([[1, 2], [4, 4]], 'type1'); result = rTree.search([1, 2, 4, 4], 'type1');
expect(result).to.contain(7); expect(result).to.contain(7);
expect(result.length).to.be(1); expect(result.length).to.be(1);
result = rTree.search([[1, 2], [4, 4]]); result = rTree.search([1, 2, 4, 4]);
expect(result.length).to.be(3); expect(result.length).to.be(3);
}); });
it('can return objects instead of arrays', function() { it('can return objects instead of arrays', function() {
var obj = {foo: 'bar'}; var obj = {foo: 'bar'};
rTree.insert([[5, 5], [5, 5]], obj); rTree.insert([5, 5, 5, 5], obj);
var result = rTree.searchReturningObject([[4, 4], [6, 6]]); var result = rTree.searchReturningObject([4, 4, 6, 6]);
expect(result[goog.getUid(obj)]).to.equal(obj); expect(result[goog.getUid(obj)]).to.equal(obj);
}); });

View File

@@ -9,7 +9,7 @@ describe('ol.tilegrid.TileGrid', function() {
beforeEach(function() { beforeEach(function() {
resolutions = [1000, 500, 250, 100]; resolutions = [1000, 500, 250, 100];
extent = [[0, 0], [100000, 100000]]; extent = [0, 0, 100000, 100000];
origin = [0, 0]; origin = [0, 0];
origins = []; origins = [];
tileSize = [100, 100]; tileSize = [100, 100];
@@ -462,22 +462,22 @@ describe('ol.tilegrid.TileGrid', function() {
var tileCoordExtent; var tileCoordExtent;
tileCoordExtent = tileGrid.getTileCoordExtent(new ol.TileCoord(0, 0, 0)); tileCoordExtent = tileGrid.getTileCoordExtent(new ol.TileCoord(0, 0, 0));
expect(tileCoordExtent[0][0]).to.eql(0); expect(tileCoordExtent[0]).to.eql(0);
expect(tileCoordExtent[1][0]).to.eql(100000); expect(tileCoordExtent[2]).to.eql(100000);
expect(tileCoordExtent[0][1]).to.eql(0); expect(tileCoordExtent[1]).to.eql(0);
expect(tileCoordExtent[1][1]).to.eql(100000); expect(tileCoordExtent[3]).to.eql(100000);
tileCoordExtent = tileGrid.getTileCoordExtent(new ol.TileCoord(3, 9, 0)); tileCoordExtent = tileGrid.getTileCoordExtent(new ol.TileCoord(3, 9, 0));
expect(tileCoordExtent[0][0]).to.eql(90000); expect(tileCoordExtent[0]).to.eql(90000);
expect(tileCoordExtent[1][0]).to.eql(100000); expect(tileCoordExtent[2]).to.eql(100000);
expect(tileCoordExtent[0][1]).to.eql(0); expect(tileCoordExtent[1]).to.eql(0);
expect(tileCoordExtent[1][1]).to.eql(10000); expect(tileCoordExtent[3]).to.eql(10000);
tileCoordExtent = tileGrid.getTileCoordExtent(new ol.TileCoord(3, 0, 9)); tileCoordExtent = tileGrid.getTileCoordExtent(new ol.TileCoord(3, 0, 9));
expect(tileCoordExtent[0][0]).to.eql(0); expect(tileCoordExtent[0]).to.eql(0);
expect(tileCoordExtent[1][0]).to.eql(10000); expect(tileCoordExtent[2]).to.eql(10000);
expect(tileCoordExtent[0][1]).to.eql(90000); expect(tileCoordExtent[1]).to.eql(90000);
expect(tileCoordExtent[1][1]).to.eql(100000); expect(tileCoordExtent[3]).to.eql(100000);
}); });
}); });
@@ -529,7 +529,7 @@ describe('ol.tilegrid.TileGrid', function() {
origin: origin, origin: origin,
tileSize: tileSize tileSize: tileSize
}); });
var e = [[45000, 5000], [55000, 15000]]; var e = [45000, 5000, 55000, 15000];
var tileRange; var tileRange;
tileRange = tileGrid.getTileRangeForExtentAndZ(e, 0); tileRange = tileGrid.getTileRangeForExtentAndZ(e, 0);