Merge branch 'master' of github.com:openlayers/ol3 into vector

This commit is contained in:
ahocevar
2013-03-06 11:20:40 +01:00
11 changed files with 164 additions and 24 deletions
+16
View File
@@ -144,6 +144,22 @@ describe('ol.projection', function() {
expect(point.y).toRoughlyEqual(200146.976, 1);
});
it('caches the new Proj4js projections given their srsCode', function() {
Proj4js.defs['EPSG:21781'] =
'+proj=somerc +lat_0=46.95240555555556 +lon_0=7.439583333333333 ' +
'+k_0=1 +x_0=600000 +y_0=200000 +ellps=bessel ' +
'+towgs84=674.374,15.056,405.346,0,0,0,0 +units=m +no_defs';
var code = 'urn:ogc:def:crs:EPSG:21781';
var srsCode = 'EPSG:21781';
var proj = ol.projection.getFromCode(code);
expect(ol.projection.proj4jsProjections_.hasOwnProperty(code))
.toBeTruthy();
expect(ol.projection.proj4jsProjections_.hasOwnProperty(srsCode))
.toBeTruthy();
var proj2 = ol.projection.getFromCode(srsCode);
expect(proj2).toBe(proj);
});
it('numerically estimates point scale at the equator', function() {
var googleProjection = ol.projection.getFromCode('GOOGLE');
expect(googleProjection.getPointResolution(1, new ol.Coordinate(0, 0))).
+23 -4
View File
@@ -21,13 +21,20 @@ describe('ol.TileQueue', function() {
}
function addRandomPriorityTiles(tq, num) {
var tiles = [];
var i, tile, priority;
for (i = 0; i < num; i++) {
tile = new ol.Tile();
tile.toDrop = (i % 2 === 0) ? true : false;
goog.events.listen(tile, goog.events.EventType.CHANGE,
goog.nullFunction);
priority = Math.floor(Math.random() * 100);
tq.heap_.push([priority, tile, '', new ol.Coordinate(0, 0)]);
tq.queuedTileKeys_[tile.getKey()] = true;
tile.inQueue++;
tiles.push(tile);
}
return tiles;
}
describe('heapify', function() {
@@ -45,16 +52,15 @@ describe('ol.TileQueue', function() {
it('does reprioritize the array', function() {
var tq = new ol.TileQueue(function() {});
addRandomPriorityTiles(tq, 100);
var tiles = addRandomPriorityTiles(tq, 100);
tq.heapify_();
// now reprioritize, changing the priority of 50 tiles and removing the
// rest
var i = 0;
tq.tilePriorityFunction_ = function() {
if ((i++) % 2 === 0) {
tq.tilePriorityFunction_ = function(tile) {
if (tile.toDrop) {
return ol.TileQueue.DROP;
}
return Math.floor(Math.random() * 100);
@@ -64,10 +70,23 @@ describe('ol.TileQueue', function() {
expect(tq.heap_.length).toEqual(50);
expect(isHeap(tq)).toBeTruthy();
var i, tile;
for (i = 0; i < tiles.length; ++i) {
tile = tiles[i];
var hasListener = goog.events.hasListener(tile);
if (tile.toDrop) {
expect(hasListener).toBeFalsy();
} else {
expect(hasListener).toBeTruthy();
}
}
});
});
});
goog.require('goog.events');
goog.require('goog.events.EventType');
goog.require('ol.Coordinate');
goog.require('ol.Tile');
goog.require('ol.TileQueue');