Merge pull request #465 from twpayne/coordinate-as-array

Replace ol.Coordinate with Array.<number>
This commit is contained in:
Tom Payne
2013-04-05 06:58:20 -07:00
75 changed files with 633 additions and 695 deletions

View File

@@ -1,4 +1,3 @@
goog.require('ol.Coordinate');
goog.require('ol.Map');
goog.require('ol.RendererHints');
goog.require('ol.View2D');
@@ -10,15 +9,15 @@ goog.require('ol.source.OpenStreetMap');
var london = ol.projection.transform(
new ol.Coordinate(-0.12755, 51.507222), 'EPSG:4326', 'EPSG:3857');
[-0.12755, 51.507222], 'EPSG:4326', 'EPSG:3857');
var moscow = ol.projection.transform(
new ol.Coordinate(37.6178, 55.7517), 'EPSG:4326', 'EPSG:3857');
[37.6178, 55.7517], 'EPSG:4326', 'EPSG:3857');
var istanbul = ol.projection.transform(
new ol.Coordinate(28.9744, 41.0128), 'EPSG:4326', 'EPSG:3857');
[28.9744, 41.0128], 'EPSG:4326', 'EPSG:3857');
var rome = ol.projection.transform(
new ol.Coordinate(12.5, 41.9), 'EPSG:4326', 'EPSG:3857');
[12.5, 41.9], 'EPSG:4326', 'EPSG:3857');
var bern = ol.projection.transform(
new ol.Coordinate(7.4458, 46.95), 'EPSG:4326', 'EPSG:3857');
[7.4458, 46.95], 'EPSG:4326', 'EPSG:3857');
var map = new ol.Map({
layers: [

View File

@@ -1,4 +1,3 @@
goog.require('ol.Coordinate');
goog.require('ol.Map');
goog.require('ol.RendererHints');
goog.require('ol.View2D');
@@ -14,7 +13,7 @@ var map = new ol.Map({
renderers: ol.RendererHints.createFromQueryData(),
target: 'map',
view: new ol.View2D({
center: new ol.Coordinate(0, 0),
center: [0, 0],
zoom: 2
})
});

View File

@@ -1,4 +1,3 @@
goog.require('ol.Coordinate');
goog.require('ol.Map');
goog.require('ol.RendererHints');
goog.require('ol.View2D');
@@ -24,8 +23,7 @@ var map = new ol.Map({
renderers: ol.RendererHints.createFromQueryData(),
target: 'map',
view: new ol.View2D({
center: ol.projection.transform(
new ol.Coordinate(-123.1, 49.25), 'EPSG:4326', 'EPSG:3857'),
center: ol.projection.transform([-123.1, 49.25], 'EPSG:4326', 'EPSG:3857'),
zoom: 8
})
});

View File

@@ -1,4 +1,3 @@
goog.require('ol.Coordinate');
goog.require('ol.Map');
goog.require('ol.RendererHint');
goog.require('ol.View2D');
@@ -15,7 +14,7 @@ var map = new ol.Map({
renderer: ol.RendererHint.WEBGL,
target: 'map',
view: new ol.View2D({
center: new ol.Coordinate(0, 0),
center: [0, 0],
zoom: 2
})
});

View File

@@ -1,4 +1,3 @@
goog.require('ol.Coordinate');
goog.require('ol.Map');
goog.require('ol.RendererHints');
goog.require('ol.View2D');
@@ -27,7 +26,7 @@ var map = new ol.Map({
target: 'map',
view: new ol.View2D({
center: ol.projection.transform(
new ol.Coordinate(-0.1275, 51.507222), 'EPSG:4326', 'EPSG:3857'),
[-0.1275, 51.507222], 'EPSG:4326', 'EPSG:3857'),
zoom: 10
})
});

View File

@@ -1,4 +1,3 @@
goog.require('ol.Coordinate');
goog.require('ol.Map');
goog.require('ol.RendererHint');
goog.require('ol.View2D');
@@ -34,7 +33,7 @@ var map = new ol.Map({
target: 'map',
view: new ol.View2D({
projection: 'EPSG:4326',
center: new ol.Coordinate(0, 0),
center: [0, 0],
zoom: 2
})
});

View File

@@ -1,4 +1,3 @@
goog.require('ol.Coordinate');
goog.require('ol.Map');
goog.require('ol.RendererHint');
goog.require('ol.View2D');
@@ -15,7 +14,7 @@ var map = new ol.Map({
renderer: ol.RendererHint.CANVAS,
target: 'map',
view: new ol.View2D({
center: new ol.Coordinate(0, 0),
center: [0, 0],
zoom: 2
})
});

View File

@@ -1,4 +1,3 @@
goog.require('ol.Coordinate');
goog.require('ol.Map');
goog.require('ol.RendererHints');
goog.require('ol.View2D');
@@ -14,7 +13,7 @@ var map = new ol.Map({
renderers: ol.RendererHints.createFromQueryData(),
target: 'map',
view: new ol.View2D({
center: new ol.Coordinate(0, 0),
center: [0, 0],
zoom: 0
})
});

View File

@@ -1,4 +1,3 @@
goog.require('ol.Coordinate');
goog.require('ol.Geolocation');
goog.require('ol.Map');
goog.require('ol.Overlay');
@@ -17,7 +16,7 @@ var map = new ol.Map({
renderers: ol.RendererHints.createFromQueryData(),
target: 'map',
view: new ol.View2D({
center: new ol.Coordinate(0, 0),
center: [0, 0],
zoom: 2
})
});

View File

@@ -1,4 +1,3 @@
goog.require('ol.Coordinate');
goog.require('ol.Map');
goog.require('ol.RendererHint');
goog.require('ol.View2D');
@@ -20,7 +19,7 @@ var map = new ol.Map({
target: 'map',
view: new ol.View2D({
center: ol.projection.transform(
new ol.Coordinate(-9.375, 51.483333), 'EPSG:4326', 'EPSG:3857'),
[-9.375, 51.483333], 'EPSG:4326', 'EPSG:3857'),
zoom: 15
})
});

View File

@@ -1,4 +1,3 @@
goog.require('ol.Coordinate');
goog.require('ol.Map');
goog.require('ol.RendererHints');
goog.require('ol.View2D');
@@ -17,7 +16,7 @@ var map = new ol.Map({
target: 'map',
view: new ol.View2D({
center: ol.projection.transform(
new ol.Coordinate(139.6917, 35.689506), 'EPSG:4326', 'EPSG:3857'),
[139.6917, 35.689506], 'EPSG:4326', 'EPSG:3857'),
zoom: 9
})
});

View File

@@ -1,9 +1,9 @@
goog.require('ol.Coordinate');
goog.require('ol.Map');
goog.require('ol.RendererHints');
goog.require('ol.View2D');
goog.require('ol.control.MousePosition');
goog.require('ol.control.defaults');
goog.require('ol.coordinate');
goog.require('ol.layer.TileLayer');
goog.require('ol.source.OpenStreetMap');
@@ -11,7 +11,7 @@ goog.require('ol.source.OpenStreetMap');
var map = new ol.Map({
controls: ol.control.defaults({}, [
new ol.control.MousePosition({
coordinateFormat: ol.Coordinate.toStringHDMS,
coordinateFormat: ol.coordinate.toStringHDMS,
projection: 'EPSG:4326',
target: document.getElementById('mouse-position'),
undefinedHTML: '&nbsp;'
@@ -25,7 +25,7 @@ var map = new ol.Map({
renderers: ol.RendererHints.createFromQueryData(),
target: 'map',
view: new ol.View2D({
center: new ol.Coordinate(0, 0),
center: [0, 0],
zoom: 2
})
});

View File

@@ -1,8 +1,8 @@
goog.require('ol.Coordinate');
goog.require('ol.Map');
goog.require('ol.Overlay');
goog.require('ol.RendererHints');
goog.require('ol.View2D');
goog.require('ol.coordinate');
goog.require('ol.layer.TileLayer');
goog.require('ol.projection');
goog.require('ol.source.MapQuestOpenAerial');
@@ -17,7 +17,7 @@ var map = new ol.Map({
renderers: ol.RendererHints.createFromQueryData(),
target: 'map',
view: new ol.View2D({
center: new ol.Coordinate(0, 0),
center: [0, 0],
zoom: 2
})
});
@@ -26,7 +26,7 @@ var map = new ol.Map({
var vienna = new ol.Overlay({
map: map,
position: ol.projection.transform(
new ol.Coordinate(16.3725, 48.208889), 'EPSG:4326', 'EPSG:3857'),
[16.3725, 48.208889], 'EPSG:4326', 'EPSG:3857'),
element: document.getElementById('vienna')
});
@@ -38,7 +38,7 @@ var popup = new ol.Overlay({
map.on('click', function(evt) {
var element = popup.getElement();
var coordinate = evt.getCoordinate();
var hdms = ol.Coordinate.toStringHDMS(ol.projection.transform(
var hdms = ol.coordinate.toStringHDMS(ol.projection.transform(
coordinate, 'EPSG:3857', 'EPSG:4326'));
$(element).popover('destroy');

View File

@@ -1,4 +1,3 @@
goog.require('ol.Coordinate');
goog.require('ol.Map');
goog.require('ol.RendererHints');
goog.require('ol.View2D');
@@ -19,7 +18,7 @@ var map1 = new ol.Map({
renderers: ol.RendererHints.createFromQueryData(),
target: 'map1',
view: new ol.View2D({
center: new ol.Coordinate(-4808600, -2620936),
center: [-4808600, -2620936],
zoom: 8
})
});

View File

@@ -1,4 +1,3 @@
goog.require('ol.Coordinate');
goog.require('ol.Map');
goog.require('ol.RendererHints');
goog.require('ol.View2D');
@@ -16,7 +15,7 @@ var map = new ol.Map({
renderers: ol.RendererHints.createFromQueryData(),
target: 'map',
view: new ol.View2D({
center: new ol.Coordinate(-25860000, 4130000),
center: [-25860000, 4130000],
rotation: Math.PI / 6,
zoom: 10
})

View File

@@ -1,4 +1,3 @@
goog.require('ol.Coordinate');
goog.require('ol.Map');
goog.require('ol.RendererHints');
goog.require('ol.View2D');
@@ -23,7 +22,7 @@ var map = new ol.Map({
renderers: ol.RendererHints.createFromQueryData(),
target: 'map',
view: new ol.View2D({
center: new ol.Coordinate(0, 0),
center: [0, 0],
zoom: 2
})
});

View File

@@ -1,4 +1,3 @@
goog.require('ol.Coordinate');
goog.require('ol.Map');
goog.require('ol.RendererHints');
goog.require('ol.View2D');
@@ -24,7 +23,7 @@ var map = new ol.Map({
target: 'map',
view: new ol.View2D({
center: ol.projection.transform(
new ol.Coordinate(-77.93255, 37.9555), 'EPSG:4326', 'EPSG:3857'),
[-77.93255, 37.9555], 'EPSG:4326', 'EPSG:3857'),
zoom: 5
})
});

View File

@@ -1,4 +1,3 @@
goog.require('ol.Coordinate');
goog.require('ol.Map');
goog.require('ol.RendererHint');
goog.require('ol.View2D');
@@ -15,7 +14,7 @@ var domMap = new ol.Map({
renderer: ol.RendererHint.DOM,
target: 'domMap',
view: new ol.View2D({
center: new ol.Coordinate(0, 0),
center: [0, 0],
zoom: 1
})
});

View File

@@ -1,4 +1,3 @@
goog.require('ol.Coordinate');
goog.require('ol.Map');
goog.require('ol.RendererHints');
goog.require('ol.View2D');
@@ -15,7 +14,7 @@ var map = new ol.Map({
renderers: ol.RendererHints.createFromQueryData(),
target: 'map',
view: new ol.View2D({
center: new ol.Coordinate(0, 0),
center: [0, 0],
zoom: 2
})
});

View File

@@ -1,4 +1,3 @@
goog.require('ol.Coordinate');
goog.require('ol.Map');
goog.require('ol.RendererHints');
goog.require('ol.View2D');
@@ -25,7 +24,7 @@ var map = new ol.Map({
target: 'map',
view: new ol.View2D({
center: ol.projection.transform(
new ol.Coordinate(-122.416667, 37.783333), 'EPSG:4326', 'EPSG:3857'),
[-122.416667, 37.783333], 'EPSG:4326', 'EPSG:3857'),
zoom: 12
})
});

View File

@@ -1,5 +1,4 @@
goog.require('ol.Collection');
goog.require('ol.Coordinate');
goog.require('ol.Expression');
goog.require('ol.Map');
goog.require('ol.RendererHint');
@@ -128,7 +127,7 @@ var map = new ol.Map({
renderer: ol.RendererHint.CANVAS,
target: 'map',
view: new ol.View2D({
center: new ol.Coordinate(0, 0),
center: [0, 0],
zoom: 1
})
});

View File

@@ -1,4 +1,3 @@
goog.require('ol.Coordinate');
goog.require('ol.Map');
goog.require('ol.RendererHints');
goog.require('ol.View2D');
@@ -18,7 +17,7 @@ var map = new ol.Map({
renderers: ol.RendererHints.createFromQueryData(),
target: 'map',
view: new ol.View2D({
center: new ol.Coordinate(0, 0),
center: [0, 0],
zoom: 2
})
});

View File

@@ -1,5 +1,4 @@
goog.require('ol.Collection');
goog.require('ol.Coordinate');
goog.require('ol.Map');
goog.require('ol.RendererHint');
goog.require('ol.View2D');
@@ -38,7 +37,7 @@ var map = new ol.Map({
renderer: ol.RendererHint.CANVAS,
target: 'map',
view: new ol.View2D({
center: new ol.Coordinate(0, 0),
center: [0, 0],
zoom: 1
})
});

View File

@@ -1,5 +1,4 @@
goog.require('ol.Attribution');
goog.require('ol.Coordinate');
goog.require('ol.Extent');
goog.require('ol.Map');
goog.require('ol.RendererHints');
@@ -59,7 +58,7 @@ var map = new ol.Map({
target: 'map',
view: new ol.View2D({
projection: projection,
center: new ol.Coordinate(660000, 190000),
center: [660000, 190000],
zoom: 2
})
});

View File

@@ -1,5 +1,4 @@
goog.require('ol.Attribution');
goog.require('ol.Coordinate');
goog.require('ol.Extent');
goog.require('ol.Map');
goog.require('ol.RendererHints');
@@ -51,7 +50,7 @@ var map = new ol.Map({
target: 'map',
view: new ol.View2D({
projection: projection,
center: new ol.Coordinate(660000, 190000),
center: [660000, 190000],
zoom: 2
})
});

View File

@@ -1,4 +1,3 @@
goog.require('ol.Coordinate');
goog.require('ol.Extent');
goog.require('ol.Map');
goog.require('ol.RendererHint');
@@ -26,7 +25,7 @@ var map = new ol.Map({
layers: layers,
target: 'map',
view: new ol.View2D({
center: new ol.Coordinate(-10997148, 4569099),
center: [-10997148, 4569099],
zoom: 4
})
});

View File

@@ -1,4 +1,3 @@
goog.require('ol.Coordinate');
goog.require('ol.Extent');
goog.require('ol.Map');
goog.require('ol.RendererHint');
@@ -25,7 +24,7 @@ var map = new ol.Map({
layers: layers,
target: 'map',
view: new ol.View2D({
center: new ol.Coordinate(-10997148, 4569099),
center: [-10997148, 4569099],
zoom: 4
})
});

View File

@@ -1,4 +1,3 @@
goog.require('ol.Coordinate');
goog.require('ol.Map');
goog.require('ol.RendererHint');
goog.require('ol.View2D');
@@ -40,7 +39,7 @@ xhr.onload = function() {
renderer: ol.RendererHint.CANVAS,
target: 'map',
view: new ol.View2D({
center: new ol.Coordinate(1823849, 6143760),
center: [1823849, 6143760],
projection: 'EPSG:3857',
zoom: 11
})

View File

@@ -1,4 +1,3 @@
goog.require('ol.Coordinate');
goog.require('ol.Extent');
goog.require('ol.Map');
goog.require('ol.RendererHint');
@@ -47,7 +46,7 @@ var map = new ol.Map({
renderer: ol.RendererHint.CANVAS,
target: 'map',
view: new ol.View2D({
center: new ol.Coordinate(-13677832, 5213272),
center: [-13677832, 5213272],
zoom: 13
})
});

View File

@@ -1,4 +1,3 @@
goog.require('ol.Coordinate');
goog.require('ol.Map');
goog.require('ol.View2D');
goog.require('ol.control.ZoomSlider');
@@ -26,7 +25,7 @@ var createMap = function(divId) {
layers: [layer],
target: divId,
view: new ol.View2D({
center: new ol.Coordinate(0, 0),
center: [0, 0],
zoom: 2
})
});

View File

@@ -43,8 +43,8 @@ ol.animation.bounce = function(options) {
ol.animation.pan = function(options) {
var source = options.source;
var start = goog.isDef(options.start) ? options.start : goog.now();
var sourceX = source.x;
var sourceY = source.y;
var sourceX = source[0];
var sourceY = source[1];
var duration = goog.isDef(options.duration) ? options.duration : 1000;
var easing = goog.isDef(options.easing) ?
options.easing : ol.easing.inAndOut;
@@ -55,11 +55,11 @@ ol.animation.pan = function(options) {
return true;
} else if (frameState.time < start + duration) {
var delta = 1 - easing((frameState.time - start) / duration);
var deltaX = sourceX - frameState.view2DState.center.x;
var deltaY = sourceY - frameState.view2DState.center.y;
var deltaX = sourceX - frameState.view2DState.center[0];
var deltaY = sourceY - frameState.view2DState.center[1];
frameState.animate = true;
frameState.view2DState.center.x += delta * deltaX;
frameState.view2DState.center.y += delta * deltaY;
frameState.view2DState.center[0] += delta * deltaX;
frameState.view2DState.center[1] += delta * deltaY;
frameState.viewHints[ol.ViewHint.ANIMATING] += 1;
return true;
} else {

View File

@@ -8,7 +8,6 @@ goog.require('goog.dom');
goog.require('goog.events');
goog.require('goog.events.EventType');
goog.require('goog.style');
goog.require('ol.Coordinate');
goog.require('ol.CoordinateFormatType');
goog.require('ol.MapEvent');
goog.require('ol.MapEventType');
@@ -179,9 +178,7 @@ ol.control.MousePosition.prototype.updateHTML_ = function(pixel) {
var map = this.getMap();
var coordinate = map.getCoordinateFromPixel(pixel);
if (!goog.isNull(coordinate)) {
var vertex = [coordinate.x, coordinate.y];
vertex = this.transform_(vertex, vertex);
coordinate = new ol.Coordinate(vertex[0], vertex[1]);
this.transform_(coordinate, coordinate);
if (goog.isDef(this.coordinateFormat_)) {
html = this.coordinateFormat_(coordinate);
} else {

View File

@@ -167,7 +167,7 @@ ol.control.ScaleLine.prototype.updateElement_ = function(frameState) {
// Convert pointResolution from degrees to meters
this.toEPSG4326_ = null;
cosLatitude = Math.cos(goog.math.toRadians(center.y));
cosLatitude = Math.cos(goog.math.toRadians(center[1]));
pointResolution *= Math.PI * cosLatitude * ol.sphere.NORMAL.radius / 180;
projectionUnits = ol.ProjectionUnits.METERS;
@@ -180,9 +180,7 @@ ol.control.ScaleLine.prototype.updateElement_ = function(frameState) {
this.toEPSG4326_ = ol.projection.getTransformFromProjections(
projection, ol.projection.get('EPSG:4326'));
}
var vertex = [center.x, center.y];
vertex = this.toEPSG4326_(vertex, vertex, 2);
cosLatitude = Math.cos(goog.math.toRadians(vertex[1]));
cosLatitude = Math.cos(goog.math.toRadians(this.toEPSG4326_(center)[1]));
var radius = ol.sphere.NORMAL.radius;
if (projectionUnits == ol.ProjectionUnits.FEET) {
radius /= 0.3048;

View File

@@ -1,5 +1,5 @@
@exportSymbol ol.Coordinate
@exportSymbol ol.Coordinate.createStringXY
@exportSymbol ol.Coordinate.toStringHDMS
@exportSymbol ol.Coordinate.toStringXY
@exportSymbol ol.Coordinate.fromProjectedArray
@exportSymbol ol.coordinate
@exportSymbol ol.coordinate.createStringXY
@exportSymbol ol.coordinate.toStringHDMS
@exportSymbol ol.coordinate.toStringXY
@exportSymbol ol.coordinate.fromProjectedArray

View File

@@ -1,8 +1,8 @@
goog.provide('ol.Coordinate');
goog.provide('ol.CoordinateFormatType');
goog.provide('ol.coordinate');
goog.require('goog.math');
goog.require('goog.math.Vec2');
/**
@@ -11,44 +11,31 @@ goog.require('goog.math.Vec2');
ol.CoordinateFormatType;
/**
* @typedef {Array.<number>}
*/
ol.Coordinate;
/**
* Two dimensional coordinate which does not know its projection.
*
* @constructor
* @extends {goog.math.Vec2}
* @param {number} x X.
* @param {number} y Y.
* @param {number=} opt_z Z.
* @param {ol.Coordinate} coordinate Coordinate.
* @param {ol.Coordinate} delta Delta.
* @return {ol.Coordinate} Coordinate.
*/
ol.Coordinate = function(x, y, opt_z) {
goog.base(this, x, y);
/**
* @expose
* @type {number}
*/
this.z = goog.isDef(opt_z) ? opt_z : NaN;
ol.coordinate.add = function(coordinate, delta) {
coordinate[0] += delta[0];
coordinate[1] += delta[1];
return coordinate;
};
goog.inherits(ol.Coordinate, goog.math.Vec2);
/**
* @const
* @type {ol.Coordinate}
*/
ol.Coordinate.ZERO = new ol.Coordinate(0, 0);
/**
* @param {number=} opt_precision Precision.
* @return {ol.CoordinateFormatType} Coordinate format.
*/
ol.Coordinate.createStringXY = function(opt_precision) {
ol.coordinate.createStringXY = function(opt_precision) {
return function(coordinate) {
return ol.Coordinate.toStringXY(coordinate, opt_precision);
return ol.coordinate.toStringXY(coordinate, opt_precision);
};
};
@@ -59,7 +46,7 @@ ol.Coordinate.createStringXY = function(opt_precision) {
* @param {string} hemispheres Hemispheres.
* @return {string} String.
*/
ol.Coordinate.degreesToStringHDMS_ = function(degrees, hemispheres) {
ol.coordinate.degreesToStringHDMS_ = function(degrees, hemispheres) {
var normalizedDegrees = goog.math.modulo(degrees + 180, 360) - 180;
var x = Math.abs(Math.round(3600 * normalizedDegrees));
return Math.floor(x / 3600) + '\u00b0 ' +
@@ -69,14 +56,42 @@ ol.Coordinate.degreesToStringHDMS_ = function(degrees, hemispheres) {
};
/**
* @param {ol.Coordinate} coordinate Coordinate.
* @param {number} angle Angle.
* @return {ol.Coordinate} Coordinate.
*/
ol.coordinate.rotate = function(coordinate, angle) {
var cosAngle = Math.cos(angle);
var sinAngle = Math.sin(angle);
var x = coordinate[0] * cosAngle - coordinate[1] * sinAngle;
var y = coordinate[1] * cosAngle + coordinate[0] * sinAngle;
coordinate[0] = x;
coordinate[1] = y;
return coordinate;
};
/**
* @param {ol.Coordinate} coordinate Coordinate.
* @param {number} s Scale.
* @return {ol.Coordinate} Coordinate.
*/
ol.coordinate.scale = function(coordinate, s) {
coordinate[0] *= s;
coordinate[1] *= s;
return coordinate;
};
/**
* @param {ol.Coordinate|undefined} coordinate Coordinate.
* @return {string} Hemisphere, degrees, minutes and seconds.
*/
ol.Coordinate.toStringHDMS = function(coordinate) {
ol.coordinate.toStringHDMS = function(coordinate) {
if (goog.isDef(coordinate)) {
return ol.Coordinate.degreesToStringHDMS_(coordinate.y, 'NS') + ' ' +
ol.Coordinate.degreesToStringHDMS_(coordinate.x, 'EW');
return ol.coordinate.degreesToStringHDMS_(coordinate[1], 'NS') + ' ' +
ol.coordinate.degreesToStringHDMS_(coordinate[0], 'EW');
} else {
return '';
}
@@ -88,11 +103,11 @@ ol.Coordinate.toStringHDMS = function(coordinate) {
* @param {number=} opt_precision Precision.
* @return {string} XY.
*/
ol.Coordinate.toStringXY = function(coordinate, opt_precision) {
ol.coordinate.toStringXY = function(coordinate, opt_precision) {
if (goog.isDef(coordinate)) {
var precision = opt_precision || 0;
return coordinate.x.toFixed(precision) + ', ' +
coordinate.y.toFixed(precision);
return coordinate[0].toFixed(precision) + ', ' +
coordinate[1].toFixed(precision);
} else {
return '';
}
@@ -105,11 +120,11 @@ ol.Coordinate.toStringXY = function(coordinate, opt_precision) {
* @param {string} axis the axis info.
* @return {ol.Coordinate} The coordinate created.
*/
ol.Coordinate.fromProjectedArray = function(array, axis) {
ol.coordinate.fromProjectedArray = function(array, axis) {
var firstAxis = axis.charAt(0);
if (firstAxis === 'n' || firstAxis === 's') {
return new ol.Coordinate(array[1], array[0]);
return [array[1], array[0]];
} else {
return new ol.Coordinate(array[0], array[1]);
return array;
}
};

View File

@@ -45,9 +45,9 @@ ol.Ellipsoid.prototype.vincenty =
var maxIterations = goog.isDef(opt_maxIterations) ?
opt_maxIterations : 100;
var f = this.flattening;
var lat1 = goog.math.toRadians(c1.y);
var lat2 = goog.math.toRadians(c2.y);
var deltaLon = goog.math.toRadians(c2.x - c1.x);
var lat1 = goog.math.toRadians(c1[1]);
var lat2 = goog.math.toRadians(c2[1]);
var deltaLon = goog.math.toRadians(c2[0] - c1[0]);
var U1 = Math.atan((1 - f) * Math.tan(lat1));
var cosU1 = Math.cos(U1);
var sinU1 = Math.sin(U1);

View File

@@ -31,12 +31,12 @@ goog.inherits(ol.Extent, ol.Rectangle);
*/
ol.Extent.boundingExtent = function(var_args) {
var coordinate0 = arguments[0];
var extent = new ol.Extent(coordinate0.x, coordinate0.y,
coordinate0.x, coordinate0.y);
var extent = new ol.Extent(coordinate0[0], coordinate0[1],
coordinate0[0], coordinate0[1]);
var i;
for (i = 1; i < arguments.length; ++i) {
var coordinate = arguments[i];
extent.extendXY(coordinate.x, coordinate.y);
extent.extendXY(coordinate[0], coordinate[1]);
}
return extent;
};
@@ -68,8 +68,8 @@ ol.Extent.getForView2DAndSize = function(center, resolution, rotation, size) {
for (i = 0; i < 4; ++i) {
x = xs[i];
y = ys[i];
xs[i] = center.x + x * cosRotation - y * sinRotation;
ys[i] = center.y + x * sinRotation + y * cosRotation;
xs[i] = center[0] + x * cosRotation - y * sinRotation;
ys[i] = center[1] + x * sinRotation + y * cosRotation;
}
var minX = Math.min.apply(null, xs);
var minY = Math.min.apply(null, ys);
@@ -87,8 +87,8 @@ ol.Extent.getForView2DAndSize = function(center, resolution, rotation, size) {
* @return {boolean} Contains.
*/
ol.Extent.prototype.containsCoordinate = function(coordinate) {
return this.minX <= coordinate.x && coordinate.x <= this.maxX &&
this.minY <= coordinate.y && coordinate.y <= this.maxY;
return this.minX <= coordinate[0] && coordinate[0] <= this.maxX &&
this.minY <= coordinate[1] && coordinate[1] <= this.maxY;
};
@@ -109,7 +109,7 @@ ol.Extent.prototype.containsExtent = function(extent) {
* @return {ol.Coordinate} Bottom left coordinate.
*/
ol.Extent.prototype.getBottomLeft = function() {
return new ol.Coordinate(this.minX, this.minY);
return [this.minX, this.minY];
};
@@ -117,7 +117,7 @@ ol.Extent.prototype.getBottomLeft = function() {
* @return {ol.Coordinate} Bottom right coordinate.
*/
ol.Extent.prototype.getBottomRight = function() {
return new ol.Coordinate(this.maxX, this.minY);
return [this.maxX, this.minY];
};
@@ -125,7 +125,7 @@ ol.Extent.prototype.getBottomRight = function() {
* @return {ol.Coordinate} Top left coordinate.
*/
ol.Extent.prototype.getTopLeft = function() {
return new ol.Coordinate(this.minX, this.maxY);
return [this.minX, this.maxY];
};
@@ -133,7 +133,7 @@ ol.Extent.prototype.getTopLeft = function() {
* @return {ol.Coordinate} Top right coordinate.
*/
ol.Extent.prototype.getTopRight = function() {
return new ol.Coordinate(this.maxX, this.maxY);
return [this.maxX, this.maxY];
};

View File

@@ -80,10 +80,8 @@ ol.Geolocation.prototype.handleProjectionChanged_ = function() {
this.transformFn_ = ol.projection.getTransformFromProjections(
ol.projection.get('EPSG:4326'), projection);
if (!goog.isNull(this.position_)) {
var vertex = [this.position_.x, this.position_.y];
vertex = this.transformFn_(vertex, vertex, 2);
this.set(ol.GeolocationProperty.POSITION,
new ol.Coordinate(vertex[0], vertex[1]));
this.set(
ol.GeolocationProperty.POSITION, this.transformFn_(this.position_));
}
}
};
@@ -130,11 +128,13 @@ ol.Geolocation.prototype.positionChange_ = function(position) {
undefined : coords.altitudeAccuracy);
this.set(ol.GeolocationProperty.HEADING, goog.isNull(coords.heading) ?
undefined : goog.math.toRadians(coords.heading));
this.position_ = new ol.Coordinate(coords.longitude, coords.latitude);
var vertex = [coords.longitude, coords.latitude];
vertex = this.transformFn_(vertex, vertex, 2);
this.set(ol.GeolocationProperty.POSITION,
new ol.Coordinate(vertex[0], vertex[1]));
if (goog.isNull(this.position_)) {
this.position_ = [coords.longitude, coords.latitude];
} else {
this.position_[0] = coords.longitude;
this.position_[1] = coords.latitude;
}
this.set(ol.GeolocationProperty.POSITION, this.transformFn_(this.position_));
this.set(ol.GeolocationProperty.SPEED,
goog.isNull(coords.speed) ? undefined : coords.speed);
};

View File

@@ -3,12 +3,12 @@
goog.provide('ol.interaction.DragPan');
goog.require('goog.asserts');
goog.require('ol.Coordinate');
goog.require('ol.Kinetic');
goog.require('ol.Pixel');
goog.require('ol.PreRenderFunction');
goog.require('ol.View2D');
goog.require('ol.ViewHint');
goog.require('ol.coordinate');
goog.require('ol.interaction.ConditionType');
goog.require('ol.interaction.Drag');
@@ -61,11 +61,9 @@ ol.interaction.DragPan.prototype.handleDrag = function(mapBrowserEvent) {
goog.asserts.assert(view instanceof ol.View2D);
var resolution = view.getResolution();
var rotation = view.getRotation();
var delta =
new ol.Coordinate(-resolution * this.deltaX, resolution * this.deltaY);
delta.rotate(rotation);
var newCenter = new ol.Coordinate(
this.startCenter.x + delta.x, this.startCenter.y + delta.y);
var newCenter = [-resolution * this.deltaX, resolution * this.deltaY];
ol.coordinate.rotate(newCenter, rotation);
ol.coordinate.add(newCenter, this.startCenter);
map.requestRenderFrame();
view.setCenter(newCenter);
};

View File

@@ -4,8 +4,8 @@ goog.provide('ol.interaction.KeyboardPan');
goog.require('goog.events.KeyCodes');
goog.require('goog.events.KeyHandler.EventType');
goog.require('ol.Coordinate');
goog.require('ol.View2D');
goog.require('ol.coordinate');
goog.require('ol.interaction.Interaction');
@@ -67,8 +67,8 @@ ol.interaction.KeyboardPan.prototype.handleMapBrowserEvent =
} else {
deltaY = mapUnitsDelta;
}
var delta = new ol.Coordinate(deltaX, deltaY);
delta.rotate(rotation);
var delta = [deltaX, deltaY];
ol.coordinate.rotate(delta, rotation);
view.pan(map, delta, ol.interaction.KEYBOARD_PAN_DURATION);
keyEvent.preventDefault();
mapBrowserEvent.preventDefault();

View File

@@ -2,12 +2,12 @@
goog.provide('ol.interaction.TouchPan');
goog.require('goog.asserts');
goog.require('ol.Coordinate');
goog.require('ol.Kinetic');
goog.require('ol.Pixel');
goog.require('ol.PreRenderFunction');
goog.require('ol.View');
goog.require('ol.ViewHint');
goog.require('ol.coordinate');
goog.require('ol.interaction.Touch');
@@ -55,10 +55,10 @@ ol.interaction.TouchPan.prototype.handleTouchMove = function(mapBrowserEvent) {
var deltaX = this.lastCentroid.x - centroid.x;
var deltaY = centroid.y - this.lastCentroid.y;
var view = mapBrowserEvent.map.getView();
var center = new ol.Coordinate(deltaX, deltaY)
.scale(view.getResolution())
.rotate(view.getRotation())
.add(view.getCenter());
var center = [deltaX, deltaY];
ol.coordinate.scale(center, view.getResolution());
ol.coordinate.rotate(center, view.getRotation());
ol.coordinate.add(center, view.getCenter());
view.setCenter(center);
}
this.lastCentroid = centroid;

View File

@@ -25,7 +25,6 @@ goog.require('goog.style');
goog.require('ol.BrowserFeature');
goog.require('ol.Collection');
goog.require('ol.Color');
goog.require('ol.Coordinate');
goog.require('ol.Extent');
goog.require('ol.FrameState');
goog.require('ol.IView');
@@ -57,6 +56,7 @@ goog.require('ol.renderer.dom.SUPPORTED');
goog.require('ol.renderer.webgl.Map');
goog.require('ol.renderer.webgl.SUPPORTED');
goog.require('ol.structs.PriorityQueue');
goog.require('ol.vec.Mat4');
/**
@@ -398,9 +398,8 @@ ol.Map.prototype.getCoordinateFromPixel = function(pixel) {
if (goog.isNull(frameState)) {
return null;
} else {
var vec3 = [pixel.x, pixel.y, 0];
goog.vec.Mat4.multVec3(frameState.pixelToCoordinateMatrix, vec3, vec3);
return new ol.Coordinate(vec3[0], vec3[1]);
var vec2 = [pixel.x, pixel.y];
return ol.vec.Mat4.multVec2(frameState.pixelToCoordinateMatrix, vec2, vec2);
}
};
@@ -434,9 +433,9 @@ ol.Map.prototype.getPixelFromCoordinate = function(coordinate) {
if (goog.isNull(frameState)) {
return null;
} else {
var vec3 = [coordinate.x, coordinate.y, 0];
goog.vec.Mat4.multVec3(frameState.coordinateToPixelMatrix, vec3, vec3);
return new ol.Pixel(vec3[0], vec3[1]);
var vec2 = coordinate.slice(0, 2);
ol.vec.Mat4.multVec2(frameState.coordinateToPixelMatrix, vec2, vec2);
return new ol.Pixel(vec2[0], vec2[1]);
}
};
@@ -508,8 +507,8 @@ ol.Map.prototype.getTilePriority =
// between the center of the tile and the focus. The factor of 65536 means
// that the prioritization should behave as desired for tiles up to
// 65536 * Math.log(2) = 45426 pixels from the focus.
var deltaX = tileCenter.x - frameState.focus.x;
var deltaY = tileCenter.y - frameState.focus.y;
var deltaX = tileCenter[0] - frameState.focus[0];
var deltaY = tileCenter[1] - frameState.focus[1];
return 65536 * Math.log(tileResolution) +
Math.sqrt(deltaX * deltaX + deltaY * deltaY) / tileResolution;
};

View File

@@ -1,6 +1,6 @@
goog.provide('ol.parser.ogc.WMTSCapabilities_v1_0_0');
goog.require('goog.dom.xml');
goog.require('ol.Coordinate');
goog.require('ol.coordinate');
goog.require('ol.parser.XML');
goog.require('ol.parser.ogc.OWSCommon_v1_1_0');
goog.require('ol.projection');
@@ -80,7 +80,7 @@ ol.parser.ogc.WMTSCapabilities_v1_0_0 = function() {
var coords = topLeftCorner.split(' ');
var axisOrientation =
ol.projection.get(obj['supportedCRS']).getAxisOrientation();
obj['topLeftCorner'] = ol.Coordinate.fromProjectedArray(
obj['topLeftCorner'] = ol.coordinate.fromProjectedArray(
[parseFloat(coords[0]), parseFloat(coords[1])], axisOrientation);
},
'TileWidth': function(node, obj) {

View File

@@ -141,5 +141,5 @@ ol.projection.EPSG3857.toEPSG4326 = function(input, opt_output, opt_dimension) {
*/
ol.projection.EPSG3857.prototype.getPointResolution =
function(resolution, point) {
return resolution / ol.math.cosh(point.y / ol.projection.EPSG3857.RADIUS);
return resolution / ol.math.cosh(point[1] / ol.projection.EPSG3857.RADIUS);
};

View File

@@ -6,7 +6,6 @@ goog.provide('ol.projection');
goog.require('goog.array');
goog.require('goog.asserts');
goog.require('goog.object');
goog.require('ol.Coordinate');
goog.require('ol.Extent');
goog.require('ol.TransformFunction');
goog.require('ol.sphere.NORMAL');
@@ -226,18 +225,16 @@ ol.Proj4jsProjection_.prototype.getPointResolution =
}));
}
var vertices = [
point.x - resolution / 2, point.y,
point.x + resolution / 2, point.y,
point.x, point.y - resolution / 2,
point.x, point.y + resolution / 2
point[0] - resolution / 2, point[1],
point[0] + resolution / 2, point[1],
point[0], point[1] - resolution / 2,
point[0], point[1] + resolution / 2
];
vertices = this.toEPSG4326_(vertices, vertices, 2);
var width = ol.sphere.NORMAL.haversineDistance(
new ol.Coordinate(vertices[0], vertices[1]),
new ol.Coordinate(vertices[2], vertices[3]));
vertices.slice(0, 2), vertices.slice(2, 4));
var height = ol.sphere.NORMAL.haversineDistance(
new ol.Coordinate(vertices[4], vertices[5]),
new ol.Coordinate(vertices[6], vertices[7]));
vertices.slice(4, 6), vertices.slice(6, 8));
var pointResolution = (width + height) / 2;
if (this.getUnits() == ol.ProjectionUnits.FEET) {
// The radius of the normal sphere is defined in meters, so we must
@@ -651,9 +648,7 @@ ol.projection.cloneTransform = function(input, opt_output, opt_dimension) {
*/
ol.projection.transform = function(point, source, destination) {
var transformFn = ol.projection.getTransform(source, destination);
var vertex = [point.x, point.y];
vertex = transformFn(vertex, vertex, 2);
return new ol.Coordinate(vertex[0], vertex[1]);
return transformFn(point);
};
@@ -669,9 +664,7 @@ ol.projection.transformWithProjections =
function(point, sourceProjection, destinationProjection) {
var transformFn = ol.projection.getTransformFromProjections(
sourceProjection, destinationProjection);
var vertex = [point.x, point.y];
vertex = transformFn(vertex, vertex, 2);
return new ol.Coordinate(vertex[0], vertex[1]);
return transformFn(point);
};

View File

@@ -1,7 +1,6 @@
goog.provide('ol.Rectangle');
goog.require('goog.asserts');
goog.require('ol.Coordinate');
goog.require('ol.Size');
@@ -91,8 +90,7 @@ ol.Rectangle.prototype.extendXY = function(x, y) {
* @return {ol.Coordinate} Center.
*/
ol.Rectangle.prototype.getCenter = function() {
return new ol.Coordinate(
(this.minX + this.maxX) / 2, (this.minY + this.maxY) / 2);
return [(this.minX + this.maxX) / 2, (this.minY + this.maxY) / 2];
};
@@ -145,9 +143,10 @@ ol.Rectangle.prototype.isEmpty = function() {
* @return {ol.Coordinate} Coordinate.
*/
ol.Rectangle.prototype.normalize = function(coordinate) {
return new ol.Coordinate(
(coordinate.x - this.minX) / this.getWidth(),
(coordinate.y - this.minY) / this.getHeight());
return [
(coordinate[0] - this.minX) / this.getWidth(),
(coordinate[1] - this.minY) / this.getHeight()
];
};

View File

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

View File

@@ -254,8 +254,8 @@ ol.renderer.canvas.TileLayer.prototype.renderFrame =
for (tileCoordKey in tilesToDraw) {
tile = tilesToDraw[tileCoordKey];
tileExtent = tileGrid.getTileCoordExtent(tile.tileCoord);
x = (tileExtent.minX - origin.x) / tileResolution;
y = (origin.y - tileExtent.maxY) / tileResolution;
x = (tileExtent.minX - origin[0]) / tileResolution;
y = (origin[1] - tileExtent.maxY) / tileResolution;
width = scale * tileSize.width;
height = scale * tileSize.height;
tileState = tile.getState();
@@ -299,8 +299,8 @@ ol.renderer.canvas.TileLayer.prototype.renderFrame =
1);
goog.vec.Mat4.translate(
transform,
(origin.x - center.x) / tileResolution,
(center.y - origin.y) / tileResolution,
(origin[0] - center[0]) / tileResolution,
(center[1] - origin[1]) / tileResolution,
0);
};

View File

@@ -236,8 +236,8 @@ ol.renderer.canvas.VectorLayer.prototype.renderFrame =
tileResolution / resolution, tileResolution / resolution, 1);
goog.vec.Mat4.rotateZ(transform, view2DState.rotation);
goog.vec.Mat4.translate(transform,
(sketchOrigin.x - view2DState.center.x) / tileResolution,
(view2DState.center.y - sketchOrigin.y) / tileResolution,
(sketchOrigin[0] - view2DState.center[0]) / tileResolution,
(view2DState.center[1] - sketchOrigin[1]) / tileResolution,
0);
/**
@@ -282,8 +282,8 @@ ol.renderer.canvas.VectorLayer.prototype.renderFrame =
-1 / tileResolution,
1);
goog.vec.Mat4.translate(sketchTransform,
-(sketchOrigin.x + halfWidth * tileResolution),
-(sketchOrigin.y - halfHeight * tileResolution),
-(sketchOrigin[0] + halfWidth * tileResolution),
-(sketchOrigin[1] - halfHeight * tileResolution),
0);
// clear/resize sketch canvas

View File

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

View File

@@ -184,8 +184,8 @@ ol.renderer.dom.TileLayer.prototype.renderFrame =
resolution / view2DState.resolution, 1);
goog.vec.Mat4.translate(
transform,
(origin.x - center.x) / resolution,
(center.y - origin.y) / resolution,
(origin[0] - center[0]) / resolution,
(center[1] - origin[1]) / resolution,
0);
tileLayerZ.setTransform(transform);
if (tileLayerZKey in newTileLayerZKeys) {

View File

@@ -271,9 +271,10 @@ ol.renderer.Layer.prototype.createGetTileIfLoadedFunction =
*/
ol.renderer.Layer.prototype.snapCenterToPixel =
function(center, resolution, size) {
return new ol.Coordinate(
resolution * (Math.round(center.x / resolution) + (size.width % 2) / 2),
resolution * (Math.round(center.y / resolution) + (size.height % 2) / 2));
return [
resolution * (Math.round(center[0] / resolution) + (size.width % 2) / 2),
resolution * (Math.round(center[1] / resolution) + (size.height % 2) / 2)
];
};

View File

@@ -104,8 +104,8 @@ ol.renderer.Map.prototype.calculateMatrices2D = function(frameState) {
goog.vec.Mat4.rotateZ(coordinateToPixelMatrix,
-view2DState.rotation);
goog.vec.Mat4.translate(coordinateToPixelMatrix,
-view2DState.center.x,
-view2DState.center.y,
-view2DState.center[0],
-view2DState.center[1],
0);
var inverted = goog.vec.Mat4.invert(

View File

@@ -163,8 +163,8 @@ ol.renderer.webgl.ImageLayer.prototype.updateProjectionMatrix_ =
2 / canvasExtentWidth, 2 / canvasExtentHeight, 1);
goog.vec.Mat4.rotateZ(projectionMatrix, -viewRotation);
goog.vec.Mat4.translate(projectionMatrix,
imageExtent.minX - viewCenter.x,
imageExtent.minY - viewCenter.y,
imageExtent.minX - viewCenter[0],
imageExtent.minY - viewCenter[1],
0);
goog.vec.Mat4.scale(projectionMatrix,
imageExtent.getWidth() / 2, imageExtent.getHeight() / 2, 1);

View File

@@ -174,8 +174,8 @@ ol.renderer.webgl.Map = function(container, map) {
var tile = /** @type {ol.Tile} */ (element[0]);
var tileCenter = /** @type {ol.Coordinate} */ (element[1]);
var tileResolution = /** @type {number} */ (element[2]);
var deltaX = tileCenter.x - this.focus_.x;
var deltaY = tileCenter.y - this.focus_.y;
var deltaX = tileCenter[0] - this.focus_[0];
var deltaY = tileCenter[1] - this.focus_[1];
return 65536 * Math.log(tileResolution) +
Math.sqrt(deltaX * deltaX + deltaY * deltaY) / tileResolution;
}, this),

View File

@@ -156,8 +156,8 @@ ol.renderer.webgl.TileLayer.prototype.renderFrame =
tileResolution * framebufferDimension,
tileResolution * framebufferDimension);
var origin = tileGrid.getOrigin(z);
var minX = origin.x + tileRange.minX * tileSize.width * tileResolution;
var minY = origin.y + tileRange.minY * tileSize.height * tileResolution;
var minX = origin[0] + tileRange.minX * tileSize.width * tileResolution;
var minY = origin[1] + tileRange.minY * tileSize.height * tileResolution;
framebufferExtent = new ol.Extent(
minX,
minY,
@@ -286,9 +286,9 @@ ol.renderer.webgl.TileLayer.prototype.renderFrame =
var texCoordMatrix = this.texCoordMatrix;
goog.vec.Mat4.makeIdentity(texCoordMatrix);
goog.vec.Mat4.translate(texCoordMatrix,
(center.x - framebufferExtent.minX) /
(center[0] - framebufferExtent.minX) /
(framebufferExtent.maxX - framebufferExtent.minX),
(center.y - framebufferExtent.minY) /
(center[1] - framebufferExtent.minY) /
(framebufferExtent.maxY - framebufferExtent.minY),
0);
goog.vec.Mat4.rotateZ(texCoordMatrix, view2DState.rotation);

View File

@@ -11,7 +11,6 @@
goog.provide('ol.Sphere');
goog.require('goog.math');
goog.require('ol.Coordinate');
@@ -37,9 +36,9 @@ ol.Sphere = function(radius) {
* @return {number} Spherical law of cosines distance.
*/
ol.Sphere.prototype.cosineDistance = function(c1, c2) {
var lat1 = goog.math.toRadians(c1.y);
var lat2 = goog.math.toRadians(c2.y);
var deltaLon = goog.math.toRadians(c2.x - c1.x);
var lat1 = goog.math.toRadians(c1[1]);
var lat2 = goog.math.toRadians(c2[1]);
var deltaLon = goog.math.toRadians(c2[0] - c1[0]);
return this.radius * Math.acos(
Math.sin(lat1) * Math.sin(lat2) +
Math.cos(lat1) * Math.cos(lat2) * Math.cos(deltaLon));
@@ -73,9 +72,9 @@ ol.Sphere.prototype.crossTrackDistance = function(c1, c2, c3) {
* @return {number} Equirectangular distance.
*/
ol.Sphere.prototype.equirectangularDistance = function(c1, c2) {
var lat1 = goog.math.toRadians(c1.y);
var lat2 = goog.math.toRadians(c2.y);
var deltaLon = goog.math.toRadians(c2.x - c1.x);
var lat1 = goog.math.toRadians(c1[1]);
var lat2 = goog.math.toRadians(c2[1]);
var deltaLon = goog.math.toRadians(c2[0] - c1[0]);
var x = deltaLon * Math.cos((lat1 + lat2) / 2);
var y = lat2 - lat1;
return this.radius * Math.sqrt(x * x + y * y);
@@ -102,10 +101,10 @@ ol.Sphere.prototype.finalBearing = function(c1, c2) {
* @return {number} Haversine distance.
*/
ol.Sphere.prototype.haversineDistance = function(c1, c2) {
var lat1 = goog.math.toRadians(c1.y);
var lat2 = goog.math.toRadians(c2.y);
var lat1 = goog.math.toRadians(c1[1]);
var lat2 = goog.math.toRadians(c2[1]);
var deltaLatBy2 = (lat2 - lat1) / 2;
var deltaLonBy2 = goog.math.toRadians(c2.x - c1.x) / 2;
var deltaLonBy2 = goog.math.toRadians(c2[0] - c1[0]) / 2;
var a = Math.sin(deltaLatBy2) * Math.sin(deltaLatBy2) +
Math.sin(deltaLonBy2) * Math.sin(deltaLonBy2) *
Math.cos(lat1) * Math.cos(lat2);
@@ -121,9 +120,9 @@ ol.Sphere.prototype.haversineDistance = function(c1, c2) {
* @return {number} Initial bearing.
*/
ol.Sphere.prototype.initialBearing = function(c1, c2) {
var lat1 = goog.math.toRadians(c1.y);
var lat2 = goog.math.toRadians(c2.y);
var deltaLon = goog.math.toRadians(c2.x - c1.x);
var lat1 = goog.math.toRadians(c1[1]);
var lat2 = goog.math.toRadians(c2[1]);
var deltaLon = goog.math.toRadians(c2[0] - c1[0]);
var y = Math.sin(deltaLon) * Math.cos(lat2);
var x = Math.cos(lat1) * Math.sin(lat2) -
Math.sin(lat1) * Math.cos(lat2) * Math.cos(deltaLon);
@@ -153,17 +152,17 @@ ol.Sphere.prototype.maximumLatitude = function(bearing, latitude) {
* @return {ol.Coordinate} Midpoint.
*/
ol.Sphere.prototype.midpoint = function(c1, c2) {
var lat1 = goog.math.toRadians(c1.y);
var lat2 = goog.math.toRadians(c2.y);
var lon1 = goog.math.toRadians(c1.x);
var deltaLon = goog.math.toRadians(c2.x - c1.x);
var lat1 = goog.math.toRadians(c1[1]);
var lat2 = goog.math.toRadians(c2[1]);
var lon1 = goog.math.toRadians(c1[0]);
var deltaLon = goog.math.toRadians(c2[0] - c1[0]);
var Bx = Math.cos(lat2) * Math.cos(deltaLon);
var By = Math.cos(lat2) * Math.sin(deltaLon);
var cosLat1PlusBx = Math.cos(lat1) + Bx;
var lat = Math.atan2(Math.sin(lat1) + Math.sin(lat2),
Math.sqrt(cosLat1PlusBx * cosLat1PlusBx + By * By));
var lon = lon1 + Math.atan2(By, cosLat1PlusBx);
return new ol.Coordinate(goog.math.toDegrees(lon), goog.math.toDegrees(lat));
return [goog.math.toDegrees(lon), goog.math.toDegrees(lat)];
};
@@ -176,8 +175,8 @@ ol.Sphere.prototype.midpoint = function(c1, c2) {
* @return {ol.Coordinate} Coordinate.
*/
ol.Sphere.prototype.offset = function(c1, distance, bearing) {
var lat1 = goog.math.toRadians(c1.y);
var lon1 = goog.math.toRadians(c1.x);
var lat1 = goog.math.toRadians(c1[1]);
var lon1 = goog.math.toRadians(c1[0]);
var dByR = distance / this.radius;
var lat = Math.asin(
Math.sin(lat1) * Math.cos(dByR) +
@@ -185,5 +184,5 @@ ol.Sphere.prototype.offset = function(c1, distance, bearing) {
var lon = lon1 + Math.atan2(
Math.sin(bearing) * Math.sin(dByR) * Math.cos(lat1),
Math.cos(dByR) - Math.sin(lat1) * Math.sin(lat));
return new ol.Coordinate(goog.math.toDegrees(lon), goog.math.toDegrees(lat));
return [goog.math.toDegrees(lon), goog.math.toDegrees(lat)];
};

View File

@@ -1,7 +1,6 @@
goog.provide('ol.TileCoord');
goog.require('goog.array');
goog.require('ol.Coordinate');
/**
@@ -18,23 +17,29 @@ ol.QuadKeyCharCode = {
/**
* @constructor
* @extends {ol.Coordinate}
* @param {number} z Zoom level.
* @param {number} x X.
* @param {number} y Y.
*/
ol.TileCoord = function(z, x, y) {
goog.base(this, x, y);
/**
* Zoom level.
* @type {number}
*/
this.z = z;
/**
* @type {number}
*/
this.x = x;
/**
* @type {number}
*/
this.y = y;
};
goog.inherits(ol.TileCoord, ol.Coordinate);
/**

View File

@@ -174,10 +174,10 @@ ol.tilegrid.TileGrid.prototype.getTileRangeExtent = function(z, tileRange) {
var origin = this.getOrigin(z);
var resolution = this.getResolution(z);
var tileSize = this.getTileSize(z);
var minX = origin.x + tileRange.minX * tileSize.width * resolution;
var minY = origin.y + tileRange.minY * tileSize.height * resolution;
var maxX = origin.x + (tileRange.maxX + 1) * tileSize.width * resolution;
var maxY = origin.y + (tileRange.maxY + 1) * tileSize.height * resolution;
var minX = origin[0] + tileRange.minX * tileSize.width * resolution;
var minY = origin[1] + tileRange.minY * tileSize.height * resolution;
var maxX = origin[0] + (tileRange.maxX + 1) * tileSize.width * resolution;
var maxY = origin[1] + (tileRange.maxY + 1) * tileSize.height * resolution;
return new ol.Extent(minX, minY, maxX, maxY);
};
@@ -216,9 +216,10 @@ ol.tilegrid.TileGrid.prototype.getTileCoordCenter = function(tileCoord) {
var origin = this.getOrigin(tileCoord.z);
var resolution = this.getResolution(tileCoord.z);
var tileSize = this.getTileSize(tileCoord.z);
var x = origin.x + (tileCoord.x + 0.5) * tileSize.width * resolution;
var y = origin.y + (tileCoord.y + 0.5) * tileSize.height * resolution;
return new ol.Coordinate(x, y);
return [
origin[0] + (tileCoord.x + 0.5) * tileSize.width * resolution,
origin[1] + (tileCoord.y + 0.5) * tileSize.height * resolution
];
};
@@ -230,8 +231,8 @@ ol.tilegrid.TileGrid.prototype.getTileCoordExtent = function(tileCoord) {
var origin = this.getOrigin(tileCoord.z);
var resolution = this.getResolution(tileCoord.z);
var tileSize = this.getTileSize(tileCoord.z);
var minX = origin.x + tileCoord.x * tileSize.width * resolution;
var minY = origin.y + tileCoord.y * tileSize.height * resolution;
var minX = origin[0] + tileCoord.x * tileSize.width * resolution;
var minY = origin[1] + tileCoord.y * tileSize.height * resolution;
var maxX = minX + tileSize.width * resolution;
var maxY = minY + tileSize.height * resolution;
return new ol.Extent(minX, minY, maxX, maxY);
@@ -250,7 +251,7 @@ ol.tilegrid.TileGrid.prototype.getTileCoordExtent = function(tileCoord) {
ol.tilegrid.TileGrid.prototype.getTileCoordForCoordAndResolution = function(
coordinate, resolution) {
return this.getTileCoordForXYAndResolution_(
coordinate.x, coordinate.y, resolution, false);
coordinate[0], coordinate[1], resolution, false);
};
@@ -271,8 +272,8 @@ ol.tilegrid.TileGrid.prototype.getTileCoordForXYAndResolution_ = function(
var origin = this.getOrigin(z);
var tileSize = this.getTileSize(z);
var tileCoordX = scale * (x - origin.x) / (resolution * tileSize.width);
var tileCoordY = scale * (y - origin.y) / (resolution * tileSize.height);
var tileCoordX = scale * (x - origin[0]) / (resolution * tileSize.width);
var tileCoordY = scale * (y - origin[1]) / (resolution * tileSize.height);
if (reverseIntersectionPolicy) {
tileCoordX = Math.ceil(tileCoordX) - 1;
@@ -295,7 +296,7 @@ ol.tilegrid.TileGrid.prototype.getTileCoordForCoordAndZ =
function(coordinate, z) {
var resolution = this.getResolution(z);
return this.getTileCoordForXYAndResolution_(
coordinate.x, coordinate.y, resolution, false);
coordinate[0], coordinate[1], resolution, false);
};

View File

@@ -1,6 +1,5 @@
goog.provide('ol.tilegrid.XYZ');
goog.require('ol.Coordinate');
goog.require('ol.Size');
goog.require('ol.TileRange');
goog.require('ol.projection');
@@ -24,8 +23,8 @@ ol.tilegrid.XYZ = function(xyzOptions) {
}
goog.base(this, {
origin: new ol.Coordinate(-ol.projection.EPSG3857.HALF_SIZE,
ol.projection.EPSG3857.HALF_SIZE),
origin: [-ol.projection.EPSG3857.HALF_SIZE,
ol.projection.EPSG3857.HALF_SIZE],
resolutions: resolutions,
tileSize: new ol.Size(ol.DEFAULT_TILE_SIZE, ol.DEFAULT_TILE_SIZE)
});

View File

@@ -90,3 +90,23 @@ ol.vec.Mat4.makeSaturation = function(matrix, value) {
v03, v13, v23, v33);
return matrix;
};
/**
* Transforms the given vector with the given matrix storing the resulting,
* transformed vector into resultVec. The input vector is multiplied against the
* upper 2x4 matrix omitting the projective component.
*
* @param {goog.vec.Mat4.AnyType} mat The matrix supplying the transformation.
* @param {Array.<number>} vec The 3 element vector to transform.
* @param {Array.<number>} resultVec The 3 element vector to receive the results
* (may be vec).
* @return {Array.<number>} return resultVec so that operations can be
* chained together.
*/
ol.vec.Mat4.multVec2 = function(mat, vec, resultVec) {
var x = vec[0], y = vec[1];
resultVec[0] = x * mat[0] + y * mat[4] + mat[12];
resultVec[1] = x * mat[1] + y * mat[5] + mat[13];
return resultVec;
};

View File

@@ -5,7 +5,6 @@ goog.provide('ol.View2D');
goog.provide('ol.View2DProperty');
goog.require('ol.Constraints');
goog.require('ol.Coordinate');
goog.require('ol.Extent');
goog.require('ol.IView2D');
goog.require('ol.IView3D');
@@ -15,6 +14,7 @@ goog.require('ol.RotationConstraint');
goog.require('ol.Size');
goog.require('ol.View');
goog.require('ol.animation');
goog.require('ol.coordinate');
goog.require('ol.easing');
goog.require('ol.projection');
@@ -94,10 +94,10 @@ ol.View2D.prototype.getExtent = function(size) {
goog.asserts.assert(this.isDef());
var center = this.getCenter();
var resolution = this.getResolution();
var minX = center.x - resolution * size.width / 2;
var minY = center.y - resolution * size.height / 2;
var maxX = center.x + resolution * size.width / 2;
var maxY = center.y + resolution * size.height / 2;
var minX = center[0] - resolution * size.width / 2;
var minY = center[1] - resolution * size.height / 2;
var maxX = center[0] + resolution * size.width / 2;
var maxY = center[1] + resolution * size.height / 2;
return new ol.Extent(minX, minY, maxX, maxY);
};
@@ -171,7 +171,7 @@ ol.View2D.prototype.getView2DState = function() {
var resolution = /** @type {number} */ (this.getResolution());
var rotation = /** @type {number} */ (this.getRotation());
return {
center: new ol.Coordinate(center.x, center.y),
center: center.slice(),
projection: projection,
resolution: resolution,
rotation: rotation
@@ -271,8 +271,7 @@ ol.View2D.prototype.pan = function(map, delta, opt_duration) {
easing: ol.easing.linear
}));
}
this.setCenter(new ol.Coordinate(
currentCenter.x + delta.x, currentCenter.y + delta.y));
this.setCenter([currentCenter[0] + delta[0], currentCenter[1] + delta[1]]);
}
};
@@ -320,12 +319,9 @@ ol.View2D.prototype.rotateWithoutConstraints =
if (goog.isDefAndNotNull(opt_anchor)) {
var anchor = opt_anchor;
var oldCenter = /** @type {!ol.Coordinate} */ (this.getCenter());
var center = new ol.Coordinate(
oldCenter.x - anchor.x,
oldCenter.y - anchor.y);
center.rotate(rotation - this.getRotation());
center.x += anchor.x;
center.y += anchor.y;
var center = [oldCenter[0] - anchor[0], oldCenter[1] - anchor[1]];
ol.coordinate.rotate(center, rotation - this.getRotation());
ol.coordinate.add(center, anchor);
map.withFrozenRendering(function() {
this.setCenter(center);
this.setRotation(rotation);
@@ -404,9 +400,11 @@ ol.View2D.prototype.zoomWithoutConstraints =
var anchor = opt_anchor;
var oldCenter = /** @type {!ol.Coordinate} */ (this.getCenter());
var oldResolution = this.getResolution();
var x = anchor.x - resolution * (anchor.x - oldCenter.x) / oldResolution;
var y = anchor.y - resolution * (anchor.y - oldCenter.y) / oldResolution;
var center = new ol.Coordinate(x, y);
var x =
anchor[0] - resolution * (anchor[0] - oldCenter[0]) / oldResolution;
var y =
anchor[1] - resolution * (anchor[1] - oldCenter[1]) / oldResolution;
var center = [x, y];
map.withFrozenRendering(function() {
this.setCenter(center);
this.setResolution(resolution);

View File

@@ -5,316 +5,316 @@ describe('ol.Ellipsoid', function() {
var expected = [
{
c1: new ol.Coordinate(0, 0),
c2: new ol.Coordinate(0, 0),
c1: [0, 0],
c2: [0, 0],
vincentyFinalBearing: 0,
vincentyInitialBearing: 0,
vincentyDistance: 0
},
{
c1: new ol.Coordinate(0, 0),
c2: new ol.Coordinate(45, 45),
c1: [0, 0],
c2: [45, 45],
vincentyFinalBearing: 54.890773827979565,
vincentyInitialBearing: 35.41005890511814,
vincentyDistance: 6662472.718217184
},
{
c1: new ol.Coordinate(0, 0),
c2: new ol.Coordinate(45, -45),
c1: [0, 0],
c2: [45, -45],
vincentyFinalBearing: 125.10922617202044,
vincentyInitialBearing: 144.58994109488185,
vincentyDistance: 6662472.718217184
},
{
c1: new ol.Coordinate(0, 0),
c2: new ol.Coordinate(-45, -45),
c1: [0, 0],
c2: [-45, -45],
vincentyFinalBearing: -125.10922617202044,
vincentyInitialBearing: -144.58994109488185,
vincentyDistance: 6662472.718217184
},
{
c1: new ol.Coordinate(0, 0),
c2: new ol.Coordinate(-45, 45),
c1: [0, 0],
c2: [-45, 45],
vincentyFinalBearing: -54.890773827979565,
vincentyInitialBearing: -35.41005890511814,
vincentyDistance: 6662472.718217184
},
{
c1: new ol.Coordinate(0, 0),
c2: new ol.Coordinate(180, 90),
c1: [0, 0],
c2: [180, 90],
vincentyFinalBearing: 180,
vincentyInitialBearing: 4.296211503097554e-31,
vincentyDistance: 10001965.729311794
},
{
c1: new ol.Coordinate(0, 0),
c2: new ol.Coordinate(180, -90),
c1: [0, 0],
c2: [180, -90],
vincentyFinalBearing: 7.0164775638926606e-15,
vincentyInitialBearing: 180,
vincentyDistance: 10001965.729311794
},
{
c1: new ol.Coordinate(0, 0),
c2: new ol.Coordinate(-180, 90),
c1: [0, 0],
c2: [-180, 90],
vincentyFinalBearing: -180,
vincentyInitialBearing: -4.296211503097554e-31,
vincentyDistance: 10001965.729311794
},
{
c1: new ol.Coordinate(0, 0),
c2: new ol.Coordinate(-180, 90),
c1: [0, 0],
c2: [-180, 90],
vincentyFinalBearing: -180,
vincentyInitialBearing: -4.296211503097554e-31,
vincentyDistance: 10001965.729311794
},
{
c1: new ol.Coordinate(45, 45),
c2: new ol.Coordinate(45, 45),
c1: [45, 45],
c2: [45, 45],
vincentyFinalBearing: 0,
vincentyInitialBearing: 0,
vincentyDistance: 0
},
{
c1: new ol.Coordinate(45, 45),
c2: new ol.Coordinate(45, -45),
c1: [45, 45],
c2: [45, -45],
vincentyFinalBearing: 180,
vincentyInitialBearing: 180,
vincentyDistance: 9969888.755957305
},
{
c1: new ol.Coordinate(45, 45),
c2: new ol.Coordinate(-45, -45),
c1: [45, 45],
c2: [-45, -45],
vincentyFinalBearing: -125.10922617202044,
vincentyInitialBearing: -125.10922617202044,
vincentyDistance: 13324945.436434371
},
{
c1: new ol.Coordinate(45, 45),
c2: new ol.Coordinate(-45, 45),
c1: [45, 45],
c2: [-45, 45],
vincentyFinalBearing: -125.27390277185786,
vincentyInitialBearing: -54.726097228142166,
vincentyDistance: 6690232.932559058
},
{
c1: new ol.Coordinate(45, 45),
c2: new ol.Coordinate(180, 90),
c1: [45, 45],
c2: [180, 90],
vincentyFinalBearing: 135,
vincentyInitialBearing: 3.5023624896823797e-15,
vincentyDistance: 5017021.35133314
},
{
c1: new ol.Coordinate(45, 45),
c2: new ol.Coordinate(180, -90),
c1: [45, 45],
c2: [180, -90],
vincentyFinalBearing: 45.00000000000001,
vincentyInitialBearing: 180,
vincentyDistance: 14986910.107290443
},
{
c1: new ol.Coordinate(45, 45),
c2: new ol.Coordinate(-180, 90),
c1: [45, 45],
c2: [-180, 90],
vincentyFinalBearing: 135.00000000000003,
vincentyInitialBearing: 3.5023624896823793e-15,
vincentyDistance: 5017021.35133314
},
{
c1: new ol.Coordinate(45, 45),
c2: new ol.Coordinate(-180, 90),
c1: [45, 45],
c2: [-180, 90],
vincentyFinalBearing: 135.00000000000003,
vincentyInitialBearing: 3.5023624896823793e-15,
vincentyDistance: 5017021.35133314
},
{
c1: new ol.Coordinate(45, -45),
c2: new ol.Coordinate(45, -45),
c1: [45, -45],
c2: [45, -45],
vincentyFinalBearing: 0,
vincentyInitialBearing: 0,
vincentyDistance: 0
},
{
c1: new ol.Coordinate(45, -45),
c2: new ol.Coordinate(-45, -45),
c1: [45, -45],
c2: [-45, -45],
vincentyFinalBearing: -54.726097228142166,
vincentyInitialBearing: -125.27390277185786,
vincentyDistance: 6690232.932559058
},
{
c1: new ol.Coordinate(45, -45),
c2: new ol.Coordinate(-45, 45),
c1: [45, -45],
c2: [-45, 45],
vincentyFinalBearing: -54.890773827979565,
vincentyInitialBearing: -54.890773827979565,
vincentyDistance: 13324945.436434371
},
{
c1: new ol.Coordinate(45, -45),
c2: new ol.Coordinate(180, 90),
c1: [45, -45],
c2: [180, 90],
vincentyFinalBearing: 135,
vincentyInitialBearing: 3.5023624896823797e-15,
vincentyDistance: 14986910.107290443
},
{
c1: new ol.Coordinate(45, -45),
c2: new ol.Coordinate(180, -90),
c1: [45, -45],
c2: [180, -90],
vincentyFinalBearing: 45.00000000000001,
vincentyInitialBearing: 180,
vincentyDistance: 5017021.35133314
},
{
c1: new ol.Coordinate(45, -45),
c2: new ol.Coordinate(-180, 90),
c1: [45, -45],
c2: [-180, 90],
vincentyFinalBearing: 135.00000000000003,
vincentyInitialBearing: 3.5023624896823793e-15,
vincentyDistance: 14986910.107290443
},
{
c1: new ol.Coordinate(45, -45),
c2: new ol.Coordinate(-180, 90),
c1: [45, -45],
c2: [-180, 90],
vincentyFinalBearing: 135.00000000000003,
vincentyInitialBearing: 3.5023624896823793e-15,
vincentyDistance: 14986910.107290443
},
{
c1: new ol.Coordinate(-45, -45),
c2: new ol.Coordinate(-45, -45),
c1: [-45, -45],
c2: [-45, -45],
vincentyFinalBearing: 0,
vincentyInitialBearing: 0,
vincentyDistance: 0
},
{
c1: new ol.Coordinate(-45, -45),
c2: new ol.Coordinate(-45, 45),
c1: [-45, -45],
c2: [-45, 45],
vincentyFinalBearing: 0,
vincentyInitialBearing: 0,
vincentyDistance: 9969888.755957305
},
{
c1: new ol.Coordinate(-45, -45),
c2: new ol.Coordinate(180, 90),
c1: [-45, -45],
c2: [180, 90],
vincentyFinalBearing: -135.00000000000003,
vincentyInitialBearing: -3.5023624896823793e-15,
vincentyDistance: 14986910.107290443
},
{
c1: new ol.Coordinate(-45, -45),
c2: new ol.Coordinate(180, -90),
c1: [-45, -45],
c2: [180, -90],
vincentyFinalBearing: -44.999999999999986,
vincentyInitialBearing: -180,
vincentyDistance: 5017021.35133314
},
{
c1: new ol.Coordinate(-45, -45),
c2: new ol.Coordinate(-180, 90),
c1: [-45, -45],
c2: [-180, 90],
vincentyFinalBearing: -135,
vincentyInitialBearing: -3.5023624896823797e-15,
vincentyDistance: 14986910.107290443
},
{
c1: new ol.Coordinate(-45, -45),
c2: new ol.Coordinate(-180, 90),
c1: [-45, -45],
c2: [-180, 90],
vincentyFinalBearing: -135,
vincentyInitialBearing: -3.5023624896823797e-15,
vincentyDistance: 14986910.107290443
},
{
c1: new ol.Coordinate(-45, 45),
c2: new ol.Coordinate(-45, 45),
c1: [-45, 45],
c2: [-45, 45],
vincentyFinalBearing: 0,
vincentyInitialBearing: 0,
vincentyDistance: 0
},
{
c1: new ol.Coordinate(-45, 45),
c2: new ol.Coordinate(180, 90),
c1: [-45, 45],
c2: [180, 90],
vincentyFinalBearing: -135.00000000000003,
vincentyInitialBearing: -3.5023624896823793e-15,
vincentyDistance: 5017021.35133314
},
{
c1: new ol.Coordinate(-45, 45),
c2: new ol.Coordinate(180, -90),
c1: [-45, 45],
c2: [180, -90],
vincentyFinalBearing: -44.999999999999986,
vincentyInitialBearing: -180,
vincentyDistance: 14986910.107290443
},
{
c1: new ol.Coordinate(-45, 45),
c2: new ol.Coordinate(-180, 90),
c1: [-45, 45],
c2: [-180, 90],
vincentyFinalBearing: -135,
vincentyInitialBearing: -3.5023624896823797e-15,
vincentyDistance: 5017021.35133314
},
{
c1: new ol.Coordinate(-45, 45),
c2: new ol.Coordinate(-180, 90),
c1: [-45, 45],
c2: [-180, 90],
vincentyFinalBearing: -135,
vincentyInitialBearing: -3.5023624896823797e-15,
vincentyDistance: 5017021.35133314
},
{
c1: new ol.Coordinate(180, 90),
c2: new ol.Coordinate(180, 90),
c1: [180, 90],
c2: [180, 90],
vincentyFinalBearing: 0,
vincentyInitialBearing: 0,
vincentyDistance: 0
},
{
c1: new ol.Coordinate(180, 90),
c2: new ol.Coordinate(180, -90),
c1: [180, 90],
c2: [180, -90],
vincentyFinalBearing: 180,
vincentyInitialBearing: 180,
vincentyDistance: 20003931.458623584
},
{
c1: new ol.Coordinate(180, 90),
c2: new ol.Coordinate(-180, 90),
c1: [180, 90],
c2: [-180, 90],
vincentyFinalBearing: 90,
vincentyInitialBearing: 90,
vincentyDistance: 9.565041537306137e-26
},
{
c1: new ol.Coordinate(180, 90),
c2: new ol.Coordinate(-180, 90),
c1: [180, 90],
c2: [-180, 90],
vincentyFinalBearing: 90,
vincentyInitialBearing: 90,
vincentyDistance: 9.565041537306137e-26
},
{
c1: new ol.Coordinate(180, -90),
c2: new ol.Coordinate(180, -90),
c1: [180, -90],
c2: [180, -90],
vincentyFinalBearing: 0,
vincentyInitialBearing: 0,
vincentyDistance: 0
},
{
c1: new ol.Coordinate(180, -90),
c2: new ol.Coordinate(-180, 90),
c1: [180, -90],
c2: [-180, 90],
vincentyFinalBearing: 7.0164775638926606e-15,
vincentyInitialBearing: 7.0164775638926606e-15,
vincentyDistance: 20003931.458623584
},
{
c1: new ol.Coordinate(180, -90),
c2: new ol.Coordinate(-180, 90),
c1: [180, -90],
c2: [-180, 90],
vincentyFinalBearing: 7.0164775638926606e-15,
vincentyInitialBearing: 7.0164775638926606e-15,
vincentyDistance: 20003931.458623584
},
{
c1: new ol.Coordinate(-180, 90),
c2: new ol.Coordinate(-180, 90),
c1: [-180, 90],
c2: [-180, 90],
vincentyFinalBearing: 0,
vincentyInitialBearing: 0,
vincentyDistance: 0
},
{
c1: new ol.Coordinate(-180, 90),
c2: new ol.Coordinate(-180, 90),
c1: [-180, 90],
c2: [-180, 90],
vincentyFinalBearing: 0,
vincentyInitialBearing: 0,
vincentyDistance: 0
},
{
c1: new ol.Coordinate(-180, 90),
c2: new ol.Coordinate(-180, 90),
c1: [-180, 90],
c2: [-180, 90],
vincentyFinalBearing: 0,
vincentyInitialBearing: 0,
vincentyDistance: 0
@@ -389,6 +389,5 @@ describe('ol.Ellipsoid', function() {
});
goog.require('ol.Coordinate');
goog.require('ol.Ellipsoid');
goog.require('ol.ellipsoid.WGS84');

View File

@@ -7,62 +7,37 @@ describe('ol.Extent', function() {
describe('positive', function() {
it('returns true', function() {
var extent = new ol.Extent(1, 2, 3, 4);
expect(extent.containsCoordinate(
new ol.Coordinate(1, 2))).to.be.ok();
expect(extent.containsCoordinate(
new ol.Coordinate(1, 3))).to.be.ok();
expect(extent.containsCoordinate(
new ol.Coordinate(1, 4))).to.be.ok();
expect(extent.containsCoordinate(
new ol.Coordinate(2, 2))).to.be.ok();
expect(extent.containsCoordinate(
new ol.Coordinate(2, 3))).to.be.ok();
expect(extent.containsCoordinate(
new ol.Coordinate(2, 4))).to.be.ok();
expect(extent.containsCoordinate(
new ol.Coordinate(3, 2))).to.be.ok();
expect(extent.containsCoordinate(
new ol.Coordinate(3, 3))).to.be.ok();
expect(extent.containsCoordinate(
new ol.Coordinate(3, 4))).to.be.ok();
expect(extent.containsCoordinate([1, 2])).to.be.ok();
expect(extent.containsCoordinate([1, 3])).to.be.ok();
expect(extent.containsCoordinate([1, 4])).to.be.ok();
expect(extent.containsCoordinate([2, 2])).to.be.ok();
expect(extent.containsCoordinate([2, 3])).to.be.ok();
expect(extent.containsCoordinate([2, 4])).to.be.ok();
expect(extent.containsCoordinate([3, 2])).to.be.ok();
expect(extent.containsCoordinate([3, 3])).to.be.ok();
expect(extent.containsCoordinate([3, 4])).to.be.ok();
});
});
describe('negative', function() {
it('returns false', function() {
var extent = new ol.Extent(1, 2, 3, 4);
expect(extent.containsCoordinate(
new ol.Coordinate(0, 1))).to.not.be();
expect(extent.containsCoordinate(
new ol.Coordinate(0, 2))).to.not.be();
expect(extent.containsCoordinate(
new ol.Coordinate(0, 3))).to.not.be();
expect(extent.containsCoordinate(
new ol.Coordinate(0, 4))).to.not.be();
expect(extent.containsCoordinate(
new ol.Coordinate(0, 5))).to.not.be();
expect(extent.containsCoordinate(
new ol.Coordinate(1, 1))).to.not.be();
expect(extent.containsCoordinate(
new ol.Coordinate(1, 5))).to.not.be();
expect(extent.containsCoordinate(
new ol.Coordinate(2, 1))).to.not.be();
expect(extent.containsCoordinate(
new ol.Coordinate(2, 5))).to.not.be();
expect(extent.containsCoordinate(
new ol.Coordinate(3, 1))).to.not.be();
expect(extent.containsCoordinate(
new ol.Coordinate(3, 5))).to.not.be();
expect(extent.containsCoordinate(
new ol.Coordinate(4, 1))).to.not.be();
expect(extent.containsCoordinate(
new ol.Coordinate(4, 2))).to.not.be();
expect(extent.containsCoordinate(
new ol.Coordinate(4, 3))).to.not.be();
expect(extent.containsCoordinate(
new ol.Coordinate(4, 4))).to.not.be();
expect(extent.containsCoordinate(
new ol.Coordinate(4, 5))).to.not.be();
expect(extent.containsCoordinate([0, 1])).to.not.be();
expect(extent.containsCoordinate([0, 2])).to.not.be();
expect(extent.containsCoordinate([0, 3])).to.not.be();
expect(extent.containsCoordinate([0, 4])).to.not.be();
expect(extent.containsCoordinate([0, 5])).to.not.be();
expect(extent.containsCoordinate([1, 1])).to.not.be();
expect(extent.containsCoordinate([1, 5])).to.not.be();
expect(extent.containsCoordinate([2, 1])).to.not.be();
expect(extent.containsCoordinate([2, 5])).to.not.be();
expect(extent.containsCoordinate([3, 1])).to.not.be();
expect(extent.containsCoordinate([3, 5])).to.not.be();
expect(extent.containsCoordinate([4, 1])).to.not.be();
expect(extent.containsCoordinate([4, 2])).to.not.be();
expect(extent.containsCoordinate([4, 3])).to.not.be();
expect(extent.containsCoordinate([4, 4])).to.not.be();
expect(extent.containsCoordinate([4, 5])).to.not.be();
});
});
});
@@ -102,7 +77,7 @@ describe('ol.Extent', function() {
it('works for a unit square', function() {
var extent = ol.Extent.getForView2DAndSize(
new ol.Coordinate(0, 0), 1, 0, new ol.Size(1, 1));
[0, 0], 1, 0, new ol.Size(1, 1));
expect(extent.minX).to.be(-0.5);
expect(extent.minY).to.be(-0.5);
expect(extent.maxX).to.be(0.5);
@@ -111,7 +86,7 @@ describe('ol.Extent', function() {
it('works for center', function() {
var extent = ol.Extent.getForView2DAndSize(
new ol.Coordinate(5, 10), 1, 0, new ol.Size(1, 1));
[5, 10], 1, 0, new ol.Size(1, 1));
expect(extent.minX).to.be(4.5);
expect(extent.minY).to.be(9.5);
expect(extent.maxX).to.be(5.5);
@@ -120,7 +95,7 @@ describe('ol.Extent', function() {
it('works for rotation', function() {
var extent = ol.Extent.getForView2DAndSize(
new ol.Coordinate(0, 0), 1, Math.PI / 4, new ol.Size(1, 1));
[0, 0], 1, Math.PI / 4, new ol.Size(1, 1));
expect(extent.minX).to.roughlyEqual(-Math.sqrt(0.5), 1e-9);
expect(extent.minY).to.roughlyEqual(-Math.sqrt(0.5), 1e-9);
expect(extent.maxX).to.roughlyEqual(Math.sqrt(0.5), 1e-9);
@@ -129,7 +104,7 @@ describe('ol.Extent', function() {
it('works for resolution', function() {
var extent = ol.Extent.getForView2DAndSize(
new ol.Coordinate(0, 0), 2, 0, new ol.Size(1, 1));
[0, 0], 2, 0, new ol.Size(1, 1));
expect(extent.minX).to.be(-1);
expect(extent.minY).to.be(-1);
expect(extent.maxX).to.be(1);
@@ -138,7 +113,7 @@ describe('ol.Extent', function() {
it('works for size', function() {
var extent = ol.Extent.getForView2DAndSize(
new ol.Coordinate(0, 0), 1, 0, new ol.Size(10, 5));
[0, 0], 1, 0, new ol.Size(10, 5));
expect(extent.minX).to.be(-5);
expect(extent.minY).to.be(-2.5);
expect(extent.maxX).to.be(5);
@@ -149,7 +124,6 @@ describe('ol.Extent', function() {
});
goog.require('ol.Coordinate');
goog.require('ol.Extent');
goog.require('ol.Size');
goog.require('ol.projection');

View File

@@ -140,7 +140,7 @@ describe('ol.Map', function() {
renderer: ol.RendererHint.DOM,
target: document.createElement('div'),
view: new ol.View2D({
center: new ol.Coordinate(0, 0),
center: [0, 0],
zoom: 1
})
});
@@ -161,14 +161,14 @@ describe('ol.Map', function() {
}
var duration = 500;
var destination = new ol.Coordinate(1000, 1000);
var destination = [1000, 1000];
var origin = map.getView().getCenter();
var start = new Date().getTime();
var x0 = origin.x;
var y0 = origin.y;
var dx = destination.x - origin.x;
var dy = destination.y - origin.y;
var x0 = origin[0];
var y0 = origin[1];
var dx = destination[0] - origin[0];
var dy = destination[1] - origin[1];
var o = {
callback: function() {
@@ -179,10 +179,10 @@ describe('ol.Map', function() {
x = quadInOut(dt, x0, dx, duration);
y = quadInOut(dt, y0, dy, duration);
} else {
x = destination.x;
y = destination.y;
x = destination[0];
y = destination[1];
}
map.getView().setCenter(new ol.Coordinate(x, y));
map.getView().setCenter([x, y]);
if (more) {
animationDelay.start();
}
@@ -200,19 +200,19 @@ describe('ol.Map', function() {
setTimeout(function() {
expect(o.callback).to.be.called();
var loc = map.getView().getCenter();
expect(loc.x).not.to.eql(origin.x);
expect(loc.y).not.to.eql(origin.y);
expect(loc[0]).not.to.eql(origin[0]);
expect(loc[1]).not.to.eql(origin[1]);
if (new Date().getTime() - start < duration) {
expect(loc.x).not.to.eql(destination.x);
expect(loc.y).not.to.eql(destination.y);
expect(loc[0]).not.to.eql(destination[0]);
expect(loc[1]).not.to.eql(destination[1]);
}
}, goog.async.AnimationDelay.TIMEOUT);
// confirm that the map has reached the destination after the duration
setTimeout(function() {
var loc = map.getView().getCenter();
expect(loc.x).to.eql(destination.x);
expect(loc.y).to.eql(destination.y);
expect(loc[0]).to.eql(destination[0]);
expect(loc[1]).to.eql(destination[1]);
done();
}, duration + 2 * goog.async.AnimationDelay.TIMEOUT);
@@ -225,7 +225,6 @@ describe('ol.Map', function() {
goog.require('goog.async.AnimationDelay');
goog.require('goog.dom');
goog.require('ol.Collection');
goog.require('ol.Coordinate');
goog.require('ol.Map');
goog.require('ol.RendererHint');
goog.require('ol.RendererHints');

View File

@@ -161,16 +161,16 @@ describe('ol.parser.ogc.wmtscapabilities_v1_0_0', function() {
expect(bigWorld.matrixIds[0].scaleDenominator).to.eql(1000000);
expect(bigWorld.matrixIds[0].tileWidth).to.eql(256);
expect(bigWorld.matrixIds[0].tileHeight).to.eql(256);
expect(bigWorld.matrixIds[0].topLeftCorner.x).to.eql(-180);
expect(bigWorld.matrixIds[0].topLeftCorner.y).to.eql(84);
expect(bigWorld.matrixIds[0].topLeftCorner[0]).to.eql(-180);
expect(bigWorld.matrixIds[0].topLeftCorner[1]).to.eql(84);
expect(bigWorld.matrixIds[1].identifier).to.eql('2.5e6');
expect(bigWorld.matrixIds[1].matrixHeight).to.eql(7000);
expect(bigWorld.matrixIds[1].matrixWidth).to.eql(9000);
expect(bigWorld.matrixIds[1].scaleDenominator).to.eql(2500000);
expect(bigWorld.matrixIds[1].tileWidth).to.eql(256);
expect(bigWorld.matrixIds[1].tileHeight).to.eql(256);
expect(bigWorld.matrixIds[1].topLeftCorner.x).to.eql(-180);
expect(bigWorld.matrixIds[1].topLeftCorner.y).to.eql(84);
expect(bigWorld.matrixIds[1].topLeftCorner[0]).to.eql(-180);
expect(bigWorld.matrixIds[1].topLeftCorner[1]).to.eql(84);
done();
});
});

View File

@@ -9,7 +9,7 @@ describe('ol.projection.EPSG3857', function() {
// @see http://msdn.microsoft.com/en-us/library/aa940990.aspx
var epsg3857 = ol.projection.get('EPSG:3857');
var resolution = 19.11;
var point = new ol.Coordinate(0, 0);
var point = [0, 0];
expect(epsg3857.getPointResolution(resolution, point)).
to.roughlyEqual(19.11, 1e-1);
});
@@ -20,8 +20,7 @@ describe('ol.projection.EPSG3857', function() {
var epsg3857 = ol.projection.get('EPSG:3857');
var epsg4326 = ol.projection.get('EPSG:4326');
var resolution = 19.11;
var point = ol.projection.transform(
new ol.Coordinate(0, 43.65), epsg4326, epsg3857);
var point = ol.projection.transform([0, 43.65], epsg4326, epsg3857);
expect(epsg3857.getPointResolution(resolution, point)).
to.roughlyEqual(19.11 * Math.cos(Math.PI * 43.65 / 180), 1e-9);
});
@@ -33,8 +32,7 @@ describe('ol.projection.EPSG3857', function() {
var resolution = 19.11;
var latitude;
for (latitude = 0; latitude < 90; ++latitude) {
var point = ol.projection.transform(
new ol.Coordinate(0, latitude), epsg4326, epsg3857);
var point = ol.projection.transform([0, latitude], epsg4326, epsg3857);
expect(epsg3857.getPointResolution(resolution, point)).
to.roughlyEqual(19.11 * Math.cos(Math.PI * latitude / 180), 1e-9);
}
@@ -45,6 +43,5 @@ describe('ol.projection.EPSG3857', function() {
});
goog.require('ol.Coordinate');
goog.require('ol.projection');
goog.require('ol.projection.EPSG3857');

View File

@@ -59,12 +59,12 @@ describe('ol.projection', function() {
it('returns a new object, with same coord values', function() {
var epsg4326 = ol.projection.get('EPSG:4326');
var uniqueObject = {};
var sourcePoint = new ol.Coordinate(uniqueObject, uniqueObject);
var sourcePoint = [uniqueObject, uniqueObject];
var destinationPoint = ol.projection.transform(
sourcePoint, epsg4326, epsg4326);
expect(sourcePoint === destinationPoint).to.not.be();
expect(destinationPoint.x === sourcePoint.x).to.be.ok();
expect(destinationPoint.y === sourcePoint.y).to.be.ok();
expect(destinationPoint[0] === sourcePoint[0]).to.be.ok();
expect(destinationPoint[1] === sourcePoint[1]).to.be.ok();
});
});
@@ -72,10 +72,10 @@ describe('ol.projection', function() {
it('returns expected value', function() {
var point = ol.projection.transform(
new ol.Coordinate(0, 0), 'EPSG:4326', 'EPSG:3857');
[0, 0], 'EPSG:4326', 'EPSG:3857');
expect(point).not.to.be(undefined);
expect(point).not.to.be(null);
expect(point.y).to.roughlyEqual(0, 1e-9);
expect(point[1]).to.roughlyEqual(0, 1e-9);
});
});
@@ -83,11 +83,11 @@ describe('ol.projection', function() {
it('returns expected value', function() {
var point = ol.projection.transform(
new ol.Coordinate(0, 0), 'EPSG:3857', 'EPSG:4326');
[0, 0], 'EPSG:3857', 'EPSG:4326');
expect(point).not.to.be(undefined);
expect(point).not.to.be(null);
expect(point.x).to.eql(0);
expect(point.y).to.eql(0);
expect(point[0]).to.eql(0);
expect(point[1]).to.eql(0);
});
});
@@ -96,13 +96,13 @@ describe('ol.projection', function() {
it('returns expected value', function() {
var point = ol.projection.transform(
new ol.Coordinate(-5.625, 52.4827802220782),
[-5.625, 52.4827802220782],
'EPSG:4326',
'EPSG:900913');
expect(point).not.to.be(undefined);
expect(point).not.to.be(null);
expect(point.x).to.roughlyEqual(-626172.13571216376, 1e-9);
expect(point.y).to.roughlyEqual(6887893.4928337997, 1e-8);
expect(point[0]).to.roughlyEqual(-626172.13571216376, 1e-9);
expect(point[1]).to.roughlyEqual(6887893.4928337997, 1e-8);
});
});
@@ -111,13 +111,13 @@ describe('ol.projection', function() {
it('returns expected value', function() {
var point = ol.projection.transform(
new ol.Coordinate(-626172.13571216376, 6887893.4928337997),
[-626172.13571216376, 6887893.4928337997],
'EPSG:900913',
'EPSG:4326');
expect(point).not.to.be(undefined);
expect(point).not.to.be(null);
expect(point.x).to.roughlyEqual(-5.625, 1e-9);
expect(point.y).to.roughlyEqual(52.4827802220782, 1e-9);
expect(point[0]).to.roughlyEqual(-5.625, 1e-9);
expect(point[1]).to.roughlyEqual(52.4827802220782, 1e-9);
});
});
@@ -125,11 +125,11 @@ describe('ol.projection', function() {
it('allows Proj4js projections to be used transparently', function() {
var point = ol.projection.transform(
new ol.Coordinate(-626172.13571216376, 6887893.4928337997),
[-626172.13571216376, 6887893.4928337997],
'GOOGLE',
'WGS84');
expect(point.x).to.roughlyEqual(-5.625, 1e-9);
expect(point.y).to.roughlyEqual(52.4827802220782, 1e-9);
expect(point[0]).to.roughlyEqual(-5.625, 1e-9);
expect(point[1]).to.roughlyEqual(52.4827802220782, 1e-9);
});
it('allows new Proj4js projections to be defined', function() {
@@ -138,11 +138,11 @@ describe('ol.projection', function() {
'+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 point = ol.projection.transform(
new ol.Coordinate(7.439583333333333, 46.95240555555556),
[7.439583333333333, 46.95240555555556],
'EPSG:4326',
'EPSG:21781');
expect(point.x).to.roughlyEqual(600072.300, 1);
expect(point.y).to.roughlyEqual(200146.976, 1);
expect(point[0]).to.roughlyEqual(600072.300, 1);
expect(point[1]).to.roughlyEqual(200146.976, 1);
});
it('caches the new Proj4js projections given their srsCode', function() {
@@ -163,7 +163,7 @@ describe('ol.projection', function() {
it('numerically estimates point scale at the equator', function() {
var googleProjection = ol.projection.get('GOOGLE');
expect(googleProjection.getPointResolution(1, new ol.Coordinate(0, 0))).
expect(googleProjection.getPointResolution(1, [0, 0])).
to.roughlyEqual(1, 1e-1);
});
@@ -172,7 +172,7 @@ describe('ol.projection', function() {
var googleProjection = ol.projection.get('GOOGLE');
var point, y;
for (y = -20; y <= 20; ++y) {
point = new ol.Coordinate(0, 1000000 * y);
point = [0, 1000000 * y];
expect(googleProjection.getPointResolution(1, point)).to.roughlyEqual(
epsg3857Projection.getPointResolution(1, point), 1e-1);
}
@@ -184,7 +184,7 @@ describe('ol.projection', function() {
var point, x, y;
for (x = -20; x <= 20; ++x) {
for (y = -20; y <= 20; ++y) {
point = new ol.Coordinate(1000000 * x, 1000000 * y);
point = [1000000 * x, 1000000 * y];
expect(googleProjection.getPointResolution(1, point)).to.roughlyEqual(
epsg3857Projection.getPointResolution(1, point), 1e-1);
}
@@ -357,7 +357,6 @@ describe('ol.projection', function() {
});
goog.require('goog.array');
goog.require('ol.Coordinate');
goog.require('ol.Extent');
goog.require('ol.Projection');
goog.require('ol.ProjectionUnits');

View File

@@ -6,8 +6,8 @@ describe('ol.Rectangle', function() {
it('returns the expected center', function() {
var rectangle = new ol.Rectangle(1, 2, 3, 4);
var center = rectangle.getCenter();
expect(center.x).to.eql(2);
expect(center.y).to.eql(3);
expect(center[0]).to.eql(2);
expect(center[1]).to.eql(3);
});
});
@@ -80,25 +80,25 @@ describe('ol.Rectangle', function() {
var rectangle = new ol.Rectangle(0, 1, 2, 3);
var coordinate;
coordinate = rectangle.normalize(new ol.Coordinate(1, 2));
expect(coordinate.x).to.eql(0.5);
expect(coordinate.y).to.eql(0.5);
coordinate = rectangle.normalize([1, 2]);
expect(coordinate[0]).to.eql(0.5);
expect(coordinate[1]).to.eql(0.5);
coordinate = rectangle.normalize(new ol.Coordinate(0, 3));
expect(coordinate.x).to.eql(0);
expect(coordinate.y).to.eql(1);
coordinate = rectangle.normalize([0, 3]);
expect(coordinate[0]).to.eql(0);
expect(coordinate[1]).to.eql(1);
coordinate = rectangle.normalize(new ol.Coordinate(2, 1));
expect(coordinate.x).to.eql(1);
expect(coordinate.y).to.eql(0);
coordinate = rectangle.normalize([2, 1]);
expect(coordinate[0]).to.eql(1);
expect(coordinate[1]).to.eql(0);
coordinate = rectangle.normalize(new ol.Coordinate(0, 0));
expect(coordinate.x).to.eql(0);
expect(coordinate.y).to.eql(-0.5);
coordinate = rectangle.normalize([0, 0]);
expect(coordinate[0]).to.eql(0);
expect(coordinate[1]).to.eql(-0.5);
coordinate = rectangle.normalize(new ol.Coordinate(-1, 1));
expect(coordinate.x).to.eql(-0.5);
expect(coordinate.y).to.eql(0);
coordinate = rectangle.normalize([-1, 1]);
expect(coordinate[0]).to.eql(-0.5);
expect(coordinate[1]).to.eql(0);
});
});
@@ -122,5 +122,4 @@ describe('ol.Rectangle', function() {
});
goog.require('ol.Coordinate');
goog.require('ol.Rectangle');

View File

@@ -28,7 +28,7 @@ describe('ol.renderer.webgl.ImageLayer', function() {
canvasHeight = 256;
viewResolution = 10;
viewRotation = 0;
viewCenter = new ol.Coordinate(7680, 3840);
viewCenter = [7680, 3840];
// view extent is 512O, 2560, 10240, 5120
// image size is 1024, 768
@@ -79,7 +79,6 @@ describe('ol.renderer.webgl.ImageLayer', function() {
goog.require('goog.vec.Mat4');
goog.require('goog.vec.Vec4');
goog.require('ol.Coordinate');
goog.require('ol.Extent');
goog.require('ol.Map');
goog.require('ol.layer.ImageLayer');

View File

@@ -196,7 +196,7 @@ ol.test.source.MockTileSource = function(loaded) {
var tileGrid = new ol.tilegrid.TileGrid({
resolutions: [360 / 256, 180 / 256, 90 / 256, 45 / 256],
extent: extent,
origin: new ol.Coordinate(-180, -180),
origin: [-180, -180],
tileSize: new ol.Size(256, 256)
});
@@ -265,7 +265,6 @@ describe('ol.test.source.MockTileSource', function() {
});
goog.require('goog.object');
goog.require('ol.Coordinate');
goog.require('ol.Extent');
goog.require('ol.Size');
goog.require('ol.Tile');

View File

@@ -17,7 +17,7 @@ describe('ol.source.XYZ', function() {
it('return the expected URL', function() {
var coordinate = new ol.Coordinate(829330.2064098881, 5933916.615134273);
var coordinate = [829330.2064098881, 5933916.615134273];
var tileUrl;
tileUrl = xyzTileSource.tileUrlFunction(
@@ -86,6 +86,5 @@ describe('ol.source.XYZ', function() {
});
goog.require('ol.Coordinate');
goog.require('ol.TileCoord');
goog.require('ol.source.XYZ');

View File

@@ -11,454 +11,454 @@ describe('ol.Sphere', function() {
var sphere = new ol.Sphere(6371);
var expected = [
{
c1: new ol.Coordinate(0, 0),
c2: new ol.Coordinate(0, 0),
c1: [0, 0],
c2: [0, 0],
cosineDistance: 0,
equirectangularDistance: 0,
finalBearing: 180,
haversineDistance: 0,
initialBearing: 0,
midpoint: new ol.Coordinate(0, 0)
midpoint: [0, 0]
},
{
c1: new ol.Coordinate(0, 0),
c2: new ol.Coordinate(45, 45),
c1: [0, 0],
c2: [45, 45],
cosineDistance: 6671.695598673524,
equirectangularDistance: 6812.398372654371,
finalBearing: 54.735610317245346,
haversineDistance: 6671.695598673525,
initialBearing: 35.264389682754654,
midpoint: new ol.Coordinate(18.434948822922006, 24.0948425521107)
midpoint: [18.434948822922006, 24.0948425521107]
},
{
c1: new ol.Coordinate(0, 0),
c2: new ol.Coordinate(-45, 45),
c1: [0, 0],
c2: [-45, 45],
cosineDistance: 6671.695598673524,
equirectangularDistance: 6812.398372654371,
finalBearing: 305.26438968275465,
haversineDistance: 6671.695598673525,
initialBearing: -35.264389682754654,
midpoint: new ol.Coordinate(-18.434948822922006, 24.0948425521107)
midpoint: [-18.434948822922006, 24.0948425521107]
},
{
c1: new ol.Coordinate(0, 0),
c2: new ol.Coordinate(-45, -45),
c1: [0, 0],
c2: [-45, -45],
cosineDistance: 6671.695598673524,
equirectangularDistance: 6812.398372654371,
finalBearing: 234.73561031724535,
haversineDistance: 6671.695598673525,
initialBearing: -144.73561031724535,
midpoint: new ol.Coordinate(-18.434948822922006, -24.0948425521107)
midpoint: [-18.434948822922006, -24.0948425521107]
},
{
c1: new ol.Coordinate(0, 0),
c2: new ol.Coordinate(45, -45),
c1: [0, 0],
c2: [45, -45],
cosineDistance: 6671.695598673524,
equirectangularDistance: 6812.398372654371,
finalBearing: 125.26438968275465,
haversineDistance: 6671.695598673525,
initialBearing: 144.73561031724535,
midpoint: new ol.Coordinate(18.434948822922006, -24.0948425521107)
midpoint: [18.434948822922006, -24.0948425521107]
},
{
c1: new ol.Coordinate(0, 0),
c2: new ol.Coordinate(90, 180),
c1: [0, 0],
c2: [90, 180],
cosineDistance: 10007.543398010286,
equirectangularDistance: 20015.086796020572,
finalBearing: 90,
haversineDistance: 10007.543398010288,
initialBearing: -90,
midpoint: new ol.Coordinate(-45.00000000000005, 4.961398865471767e-15)
midpoint: [-45.00000000000005, 4.961398865471767e-15]
},
{
c1: new ol.Coordinate(0, 0),
c2: new ol.Coordinate(-90, 180),
c1: [0, 0],
c2: [-90, 180],
cosineDistance: 10007.543398010286,
equirectangularDistance: 20015.086796020572,
finalBearing: 270,
haversineDistance: 10007.543398010288,
initialBearing: 90,
midpoint: new ol.Coordinate(45.00000000000005, 4.961398865471767e-15)
midpoint: [45.00000000000005, 4.961398865471767e-15]
},
{
c1: new ol.Coordinate(0, 0),
c2: new ol.Coordinate(90, -180),
c1: [0, 0],
c2: [90, -180],
cosineDistance: 10007.543398010286,
equirectangularDistance: 20015.086796020572,
finalBearing: 90,
haversineDistance: 10007.543398010288,
initialBearing: -90.00000000000001,
midpoint: new ol.Coordinate(-45.00000000000005, -4.961398865471767e-15)
midpoint: [-45.00000000000005, -4.961398865471767e-15]
},
{
c1: new ol.Coordinate(0, 0),
c2: new ol.Coordinate(90, -180),
c1: [0, 0],
c2: [90, -180],
cosineDistance: 10007.543398010286,
equirectangularDistance: 20015.086796020572,
finalBearing: 90,
haversineDistance: 10007.543398010288,
initialBearing: -90.00000000000001,
midpoint: new ol.Coordinate(-45.00000000000005, -4.961398865471767e-15)
midpoint: [-45.00000000000005, -4.961398865471767e-15]
},
{
c1: new ol.Coordinate(45, 45),
c2: new ol.Coordinate(45, 45),
c1: [45, 45],
c2: [45, 45],
cosineDistance: 0,
equirectangularDistance: 0,
finalBearing: 180,
haversineDistance: 0,
initialBearing: 0,
midpoint: new ol.Coordinate(45.00000000000005, 45)
midpoint: [45.00000000000005, 45]
},
{
c1: new ol.Coordinate(45, 45),
c2: new ol.Coordinate(-45, 45),
c1: [45, 45],
c2: [-45, 45],
cosineDistance: 6671.695598673525,
equirectangularDistance: 7076.401799751738,
finalBearing: 234.73561031724535,
haversineDistance: 6671.695598673525,
initialBearing: -54.73561031724535,
midpoint: new ol.Coordinate(0, 54.735610317245346)
midpoint: [0, 54.735610317245346]
},
{
c1: new ol.Coordinate(45, 45),
c2: new ol.Coordinate(-45, -45),
c1: [45, 45],
c2: [-45, -45],
cosineDistance: 13343.391197347048,
equirectangularDistance: 14152.803599503475,
finalBearing: 234.73561031724535,
haversineDistance: 13343.391197347048,
initialBearing: -125.26438968275465,
midpoint: new ol.Coordinate(0, 0)
midpoint: [0, 0]
},
{
c1: new ol.Coordinate(45, 45),
c2: new ol.Coordinate(45, -45),
c1: [45, 45],
c2: [45, -45],
cosineDistance: 10007.543398010284,
equirectangularDistance: 10007.543398010286,
finalBearing: 180,
haversineDistance: 10007.543398010286,
initialBearing: 180,
midpoint: new ol.Coordinate(45.00000000000005, 0)
midpoint: [45.00000000000005, 0]
},
{
c1: new ol.Coordinate(45, 45),
c2: new ol.Coordinate(90, 180),
c1: [45, 45],
c2: [90, 180],
cosineDistance: 13343.39119734705,
equirectangularDistance: 15132.953174634127,
finalBearing: 35.264389682754654,
haversineDistance: 13343.391197347048,
initialBearing: -54.735610317245346,
midpoint: new ol.Coordinate(-45.00000000000005, 45.00000000000001)
midpoint: [-45.00000000000005, 45.00000000000001]
},
{
c1: new ol.Coordinate(45, 45),
c2: new ol.Coordinate(-90, 180),
c1: [45, 45],
c2: [-90, 180],
cosineDistance: 6671.695598673524,
equirectangularDistance: 16072.9523901477,
finalBearing: 324.73561031724535,
haversineDistance: 6671.695598673525,
initialBearing: 125.26438968275465,
midpoint: new ol.Coordinate(71.56505117707799, 24.094842552110702)
midpoint: [71.56505117707799, 24.094842552110702]
},
{
c1: new ol.Coordinate(45, 45),
c2: new ol.Coordinate(90, -180),
c1: [45, 45],
c2: [90, -180],
cosineDistance: 13343.39119734705,
equirectangularDistance: 25092.03003421417,
finalBearing: 35.264389682754654,
haversineDistance: 13343.391197347048,
initialBearing: -54.735610317245346,
midpoint: new ol.Coordinate(-45.00000000000005, 45)
midpoint: [-45.00000000000005, 45]
},
{
c1: new ol.Coordinate(45, 45),
c2: new ol.Coordinate(90, -180),
c1: [45, 45],
c2: [90, -180],
cosineDistance: 13343.39119734705,
equirectangularDistance: 25092.03003421417,
finalBearing: 35.264389682754654,
haversineDistance: 13343.391197347048,
initialBearing: -54.735610317245346,
midpoint: new ol.Coordinate(-45.00000000000005, 45)
midpoint: [-45.00000000000005, 45]
},
{
c1: new ol.Coordinate(-45, 45),
c2: new ol.Coordinate(-45, 45),
c1: [-45, 45],
c2: [-45, 45],
cosineDistance: 0,
equirectangularDistance: 0,
finalBearing: 180,
haversineDistance: 0,
initialBearing: 0,
midpoint: new ol.Coordinate(-45.00000000000005, 45)
midpoint: [-45.00000000000005, 45]
},
{
c1: new ol.Coordinate(-45, 45),
c2: new ol.Coordinate(-45, -45),
c1: [-45, 45],
c2: [-45, -45],
cosineDistance: 10007.543398010284,
equirectangularDistance: 10007.543398010286,
finalBearing: 180,
haversineDistance: 10007.543398010286,
initialBearing: 180,
midpoint: new ol.Coordinate(-45.00000000000005, 0)
midpoint: [-45.00000000000005, 0]
},
{
c1: new ol.Coordinate(-45, 45),
c2: new ol.Coordinate(45, -45),
c1: [-45, 45],
c2: [45, -45],
cosineDistance: 13343.391197347048,
equirectangularDistance: 14152.803599503475,
finalBearing: 125.26438968275465,
haversineDistance: 13343.391197347048,
initialBearing: 125.26438968275465,
midpoint: new ol.Coordinate(0, 0)
midpoint: [0, 0]
},
{
c1: new ol.Coordinate(-45, 45),
c2: new ol.Coordinate(90, 180),
c1: [-45, 45],
c2: [90, 180],
cosineDistance: 6671.695598673524,
equirectangularDistance: 16072.9523901477,
finalBearing: 35.264389682754654,
haversineDistance: 6671.695598673525,
initialBearing: -125.26438968275465,
midpoint: new ol.Coordinate(-71.56505117707799, 24.094842552110702)
midpoint: [-71.56505117707799, 24.094842552110702]
},
{
c1: new ol.Coordinate(-45, 45),
c2: new ol.Coordinate(-90, 180),
c1: [-45, 45],
c2: [-90, 180],
cosineDistance: 13343.39119734705,
equirectangularDistance: 15132.953174634127,
finalBearing: 324.73561031724535,
haversineDistance: 13343.391197347048,
initialBearing: 54.735610317245346,
midpoint: new ol.Coordinate(45.00000000000005, 45.00000000000001)
midpoint: [45.00000000000005, 45.00000000000001]
},
{
c1: new ol.Coordinate(-45, 45),
c2: new ol.Coordinate(90, -180),
c1: [-45, 45],
c2: [90, -180],
cosineDistance: 6671.695598673525,
equirectangularDistance: 25669.894779453065,
finalBearing: 35.264389682754654,
haversineDistance: 6671.695598673525,
initialBearing: -125.26438968275465,
midpoint: new ol.Coordinate(-71.56505117707799, 24.0948425521107)
midpoint: [-71.56505117707799, 24.0948425521107]
},
{
c1: new ol.Coordinate(-45, 45),
c2: new ol.Coordinate(90, -180),
c1: [-45, 45],
c2: [90, -180],
cosineDistance: 6671.695598673525,
equirectangularDistance: 25669.894779453065,
finalBearing: 35.264389682754654,
haversineDistance: 6671.695598673525,
initialBearing: -125.26438968275465,
midpoint: new ol.Coordinate(-71.56505117707799, 24.0948425521107)
midpoint: [-71.56505117707799, 24.0948425521107]
},
{
c1: new ol.Coordinate(-45, -45),
c2: new ol.Coordinate(-45, -45),
c1: [-45, -45],
c2: [-45, -45],
cosineDistance: 0,
equirectangularDistance: 0,
finalBearing: 180,
haversineDistance: 0,
initialBearing: 0,
midpoint: new ol.Coordinate(-45.00000000000005, -45)
midpoint: [-45.00000000000005, -45]
},
{
c1: new ol.Coordinate(-45, -45),
c2: new ol.Coordinate(45, -45),
c1: [-45, -45],
c2: [45, -45],
cosineDistance: 6671.695598673525,
equirectangularDistance: 7076.401799751738,
finalBearing: 54.735610317245346,
haversineDistance: 6671.695598673525,
initialBearing: 125.26438968275465,
midpoint: new ol.Coordinate(0, -54.735610317245346)
midpoint: [0, -54.735610317245346]
},
{
c1: new ol.Coordinate(-45, -45),
c2: new ol.Coordinate(90, 180),
c1: [-45, -45],
c2: [90, 180],
cosineDistance: 6671.695598673525,
equirectangularDistance: 25669.894779453065,
finalBearing: 144.73561031724535,
haversineDistance: 6671.695598673525,
initialBearing: -54.735610317245346,
midpoint: new ol.Coordinate(-71.56505117707799, -24.0948425521107)
midpoint: [-71.56505117707799, -24.0948425521107]
},
{
c1: new ol.Coordinate(-45, -45),
c2: new ol.Coordinate(-90, 180),
c1: [-45, -45],
c2: [-90, 180],
cosineDistance: 13343.39119734705,
equirectangularDistance: 25092.03003421417,
finalBearing: 215.26438968275465,
haversineDistance: 13343.391197347048,
initialBearing: 125.26438968275465,
midpoint: new ol.Coordinate(45.00000000000005, -45)
midpoint: [45.00000000000005, -45]
},
{
c1: new ol.Coordinate(-45, -45),
c2: new ol.Coordinate(90, -180),
c1: [-45, -45],
c2: [90, -180],
cosineDistance: 6671.695598673524,
equirectangularDistance: 16072.9523901477,
finalBearing: 144.73561031724535,
haversineDistance: 6671.695598673525,
initialBearing: -54.73561031724536,
midpoint: new ol.Coordinate(-71.56505117707799, -24.094842552110702)
midpoint: [-71.56505117707799, -24.094842552110702]
},
{
c1: new ol.Coordinate(-45, -45),
c2: new ol.Coordinate(90, -180),
c1: [-45, -45],
c2: [90, -180],
cosineDistance: 6671.695598673524,
equirectangularDistance: 16072.9523901477,
finalBearing: 144.73561031724535,
haversineDistance: 6671.695598673525,
initialBearing: -54.73561031724536,
midpoint: new ol.Coordinate(-71.56505117707799, -24.094842552110702)
midpoint: [-71.56505117707799, -24.094842552110702]
},
{
c1: new ol.Coordinate(45, -45),
c2: new ol.Coordinate(45, -45),
c1: [45, -45],
c2: [45, -45],
cosineDistance: 0,
equirectangularDistance: 0,
finalBearing: 180,
haversineDistance: 0,
initialBearing: 0,
midpoint: new ol.Coordinate(45.00000000000005, -45)
midpoint: [45.00000000000005, -45]
},
{
c1: new ol.Coordinate(45, -45),
c2: new ol.Coordinate(90, 180),
c1: [45, -45],
c2: [90, 180],
cosineDistance: 13343.39119734705,
equirectangularDistance: 25092.03003421417,
finalBearing: 144.73561031724535,
haversineDistance: 13343.391197347048,
initialBearing: -125.26438968275465,
midpoint: new ol.Coordinate(-45.00000000000005, -45)
midpoint: [-45.00000000000005, -45]
},
{
c1: new ol.Coordinate(45, -45),
c2: new ol.Coordinate(-90, 180),
c1: [45, -45],
c2: [-90, 180],
cosineDistance: 6671.695598673525,
equirectangularDistance: 25669.894779453065,
finalBearing: 215.26438968275465,
haversineDistance: 6671.695598673525,
initialBearing: 54.735610317245346,
midpoint: new ol.Coordinate(71.56505117707799, -24.0948425521107)
midpoint: [71.56505117707799, -24.0948425521107]
},
{
c1: new ol.Coordinate(45, -45),
c2: new ol.Coordinate(90, -180),
c1: [45, -45],
c2: [90, -180],
cosineDistance: 13343.39119734705,
equirectangularDistance: 15132.953174634127,
finalBearing: 144.73561031724535,
haversineDistance: 13343.391197347048,
initialBearing: -125.26438968275465,
midpoint: new ol.Coordinate(-45.00000000000005, -45.00000000000001)
midpoint: [-45.00000000000005, -45.00000000000001]
},
{
c1: new ol.Coordinate(45, -45),
c2: new ol.Coordinate(90, -180),
c1: [45, -45],
c2: [90, -180],
cosineDistance: 13343.39119734705,
equirectangularDistance: 15132.953174634127,
finalBearing: 144.73561031724535,
haversineDistance: 13343.391197347048,
initialBearing: -125.26438968275465,
midpoint: new ol.Coordinate(-45.00000000000005, -45.00000000000001)
midpoint: [-45.00000000000005, -45.00000000000001]
},
{
c1: new ol.Coordinate(90, 180),
c2: new ol.Coordinate(90, 180),
c1: [90, 180],
c2: [90, 180],
cosineDistance: 0,
equirectangularDistance: 0,
finalBearing: 180,
haversineDistance: 0,
initialBearing: 0,
midpoint: new ol.Coordinate(-90, 7.0164775638926606e-15)
midpoint: [-90, 7.0164775638926606e-15]
},
{
c1: new ol.Coordinate(90, 180),
c2: new ol.Coordinate(-90, 180),
c1: [90, 180],
c2: [-90, 180],
cosineDistance: 20015.086796020572,
equirectangularDistance: 20015.086796020572,
finalBearing: 26.565051177077976,
haversineDistance: 20015.086796020572,
initialBearing: 153.43494882292202,
midpoint: new ol.Coordinate(-180, 63.43494882292201)
midpoint: [-180, 63.43494882292201]
},
{
c1: new ol.Coordinate(90, 180),
c2: new ol.Coordinate(90, -180),
c1: [90, 180],
c2: [90, -180],
cosineDistance: 0,
equirectangularDistance: 40030.173592041145,
finalBearing: 0,
haversineDistance: 1.5603934160404731e-12,
initialBearing: 0,
midpoint: new ol.Coordinate(-90, 0)
midpoint: [-90, 0]
},
{
c1: new ol.Coordinate(90, 180),
c2: new ol.Coordinate(90, -180),
c1: [90, 180],
c2: [90, -180],
cosineDistance: 0,
equirectangularDistance: 40030.173592041145,
finalBearing: 0,
haversineDistance: 1.5603934160404731e-12,
initialBearing: 0,
midpoint: new ol.Coordinate(-90, 0)
midpoint: [-90, 0]
},
{
c1: new ol.Coordinate(-90, 180),
c2: new ol.Coordinate(-90, 180),
c1: [-90, 180],
c2: [-90, 180],
cosineDistance: 0,
equirectangularDistance: 0,
finalBearing: 180,
haversineDistance: 0,
initialBearing: 0,
midpoint: new ol.Coordinate(90, 7.0164775638926606e-15)
midpoint: [90, 7.0164775638926606e-15]
},
{
c1: new ol.Coordinate(-90, 180),
c2: new ol.Coordinate(90, -180),
c1: [-90, 180],
c2: [90, -180],
cosineDistance: 20015.086796020572,
equirectangularDistance: 44755.09465146047,
finalBearing: 270,
haversineDistance: 20015.086796020572,
initialBearing: -90,
midpoint: new ol.Coordinate(-180, 0)
midpoint: [-180, 0]
},
{
c1: new ol.Coordinate(-90, 180),
c2: new ol.Coordinate(90, -180),
c1: [-90, 180],
c2: [90, -180],
cosineDistance: 20015.086796020572,
equirectangularDistance: 44755.09465146047,
finalBearing: 270,
haversineDistance: 20015.086796020572,
initialBearing: -90,
midpoint: new ol.Coordinate(-180, 0)
midpoint: [-180, 0]
},
{
c1: new ol.Coordinate(90, -180),
c2: new ol.Coordinate(90, -180),
c1: [90, -180],
c2: [90, -180],
cosineDistance: 0,
equirectangularDistance: 0,
finalBearing: 180,
haversineDistance: 0,
initialBearing: 0,
midpoint: new ol.Coordinate(-90, -7.0164775638926606e-15)
midpoint: [-90, -7.0164775638926606e-15]
},
{
c1: new ol.Coordinate(90, -180),
c2: new ol.Coordinate(90, -180),
c1: [90, -180],
c2: [90, -180],
cosineDistance: 0,
equirectangularDistance: 0,
finalBearing: 180,
haversineDistance: 0,
initialBearing: 0,
midpoint: new ol.Coordinate(-90, -7.0164775638926606e-15)
midpoint: [-90, -7.0164775638926606e-15]
},
{
c1: new ol.Coordinate(90, -180),
c2: new ol.Coordinate(90, -180),
c1: [90, -180],
c2: [90, -180],
cosineDistance: 0,
equirectangularDistance: 0,
finalBearing: 180,
haversineDistance: 0,
initialBearing: 0,
midpoint: new ol.Coordinate(-90, -7.0164775638926606e-15)
midpoint: [-90, -7.0164775638926606e-15]
}
];
@@ -536,9 +536,9 @@ describe('ol.Sphere', function() {
midpoint = sphere.midpoint(e.c1, e.c2);
// Test modulo 360 to avoid unnecessary expensive modulo operations
// in our implementation.
expect(goog.math.modulo(midpoint.x, 360)).to.roughlyEqual(
goog.math.modulo(e.midpoint.x, 360), 1e-9);
expect(midpoint.y).to.roughlyEqual(e.midpoint.y, 1e-9);
expect(goog.math.modulo(midpoint[0], 360)).to.roughlyEqual(
goog.math.modulo(e.midpoint[0], 360), 1e-9);
expect(midpoint[1]).to.roughlyEqual(e.midpoint[1], 1e-9);
}
});
@@ -547,5 +547,4 @@ describe('ol.Sphere', function() {
});
goog.require('ol.Coordinate');
goog.require('ol.Sphere');

View File

@@ -10,7 +10,7 @@ describe('ol.tilegrid.TileGrid', function() {
beforeEach(function() {
resolutions = [1000, 500, 250, 100];
extent = new ol.Extent(0, 0, 100000, 100000);
origin = new ol.Coordinate(0, 0);
origin = [0, 0];
origins = [];
tileSize = new ol.Size(100, 100);
});
@@ -218,7 +218,7 @@ describe('ol.tilegrid.TileGrid', function() {
describe('Y North, X East', function() {
it('returns the expected TileCoord', function() {
origin = new ol.Coordinate(0, 0);
origin = [0, 0];
var tileGrid = new ol.tilegrid.TileGrid({
resolutions: resolutions,
extent: extent,
@@ -227,26 +227,22 @@ describe('ol.tilegrid.TileGrid', function() {
});
var tileCoord;
tileCoord = tileGrid.getTileCoordForCoordAndZ(
new ol.Coordinate(0, 0), 3);
tileCoord = tileGrid.getTileCoordForCoordAndZ([0, 0], 3);
expect(tileCoord.z).to.eql(3);
expect(tileCoord.x).to.eql(0);
expect(tileCoord.y).to.eql(0);
tileCoord = tileGrid.getTileCoordForCoordAndZ(
new ol.Coordinate(0, 100000), 3);
tileCoord = tileGrid.getTileCoordForCoordAndZ([0, 100000], 3);
expect(tileCoord.z).to.eql(3);
expect(tileCoord.x).to.eql(0);
expect(tileCoord.y).to.eql(10);
tileCoord = tileGrid.getTileCoordForCoordAndZ(
new ol.Coordinate(100000, 0), 3);
tileCoord = tileGrid.getTileCoordForCoordAndZ([100000, 0], 3);
expect(tileCoord.z).to.eql(3);
expect(tileCoord.x).to.eql(10);
expect(tileCoord.y).to.eql(0);
tileCoord = tileGrid.getTileCoordForCoordAndZ(
new ol.Coordinate(100000, 100000), 3);
tileCoord = tileGrid.getTileCoordForCoordAndZ([100000, 100000], 3);
expect(tileCoord.z).to.eql(3);
expect(tileCoord.x).to.eql(10);
expect(tileCoord.y).to.eql(10);
@@ -255,7 +251,7 @@ describe('ol.tilegrid.TileGrid', function() {
describe('Y South, X East', function() {
it('returns the expected TileCoord', function() {
origin = new ol.Coordinate(0, 100000);
origin = [0, 100000];
var tileGrid = new ol.tilegrid.TileGrid({
resolutions: resolutions,
extent: extent,
@@ -264,26 +260,22 @@ describe('ol.tilegrid.TileGrid', function() {
});
var tileCoord;
tileCoord = tileGrid.getTileCoordForCoordAndZ(
new ol.Coordinate(0, 0), 3);
tileCoord = tileGrid.getTileCoordForCoordAndZ([0, 0], 3);
expect(tileCoord.z).to.eql(3);
expect(tileCoord.x).to.eql(0);
expect(tileCoord.y).to.eql(-10);
tileCoord = tileGrid.getTileCoordForCoordAndZ(
new ol.Coordinate(0, 100000), 3);
tileCoord = tileGrid.getTileCoordForCoordAndZ([0, 100000], 3);
expect(tileCoord.z).to.eql(3);
expect(tileCoord.x).to.eql(0);
expect(tileCoord.y).to.eql(0);
tileCoord = tileGrid.getTileCoordForCoordAndZ(
new ol.Coordinate(100000, 0), 3);
tileCoord = tileGrid.getTileCoordForCoordAndZ([100000, 0], 3);
expect(tileCoord.z).to.eql(3);
expect(tileCoord.x).to.eql(10);
expect(tileCoord.y).to.eql(-10);
tileCoord = tileGrid.getTileCoordForCoordAndZ(
new ol.Coordinate(100000, 100000), 3);
tileCoord = tileGrid.getTileCoordForCoordAndZ([100000, 100000], 3);
expect(tileCoord.z).to.eql(3);
expect(tileCoord.x).to.eql(10);
expect(tileCoord.y).to.eql(0);
@@ -305,73 +297,64 @@ describe('ol.tilegrid.TileGrid', function() {
var tileCoord;
// gets the first tile at the origin
coordinate = new ol.Coordinate(0, 0);
tileCoord = tileGrid.getTileCoordForCoordAndResolution(
coordinate, 10);
coordinate = [0, 0];
tileCoord = tileGrid.getTileCoordForCoordAndResolution(coordinate, 10);
expect(tileCoord.z).to.eql(0);
expect(tileCoord.x).to.eql(0);
expect(tileCoord.y).to.eql(0);
// gets one tile northwest of the origin
coordinate = new ol.Coordinate(-1280, 1280);
tileCoord = tileGrid.getTileCoordForCoordAndResolution(
coordinate, 10);
coordinate = [-1280, 1280];
tileCoord = tileGrid.getTileCoordForCoordAndResolution(coordinate, 10);
expect(tileCoord.z).to.eql(0);
expect(tileCoord.x).to.eql(-1);
expect(tileCoord.y).to.eql(0);
// gets one tile northeast of the origin
coordinate = new ol.Coordinate(1280, 1280);
tileCoord = tileGrid.getTileCoordForCoordAndResolution(
coordinate, 10);
coordinate = [1280, 1280];
tileCoord = tileGrid.getTileCoordForCoordAndResolution(coordinate, 10);
expect(tileCoord.z).to.eql(0);
expect(tileCoord.x).to.eql(0);
expect(tileCoord.y).to.eql(0);
// gets one tile southeast of the origin
coordinate = new ol.Coordinate(1280, -1280);
tileCoord = tileGrid.getTileCoordForCoordAndResolution(
coordinate, 10);
coordinate = [1280, -1280];
tileCoord = tileGrid.getTileCoordForCoordAndResolution(coordinate, 10);
expect(tileCoord.z).to.eql(0);
expect(tileCoord.x).to.eql(0);
expect(tileCoord.y).to.eql(-1);
// gets one tile southwest of the origin
coordinate = new ol.Coordinate(-1280, -1280);
tileCoord = tileGrid.getTileCoordForCoordAndResolution(
coordinate, 10);
coordinate = [-1280, -1280];
tileCoord = tileGrid.getTileCoordForCoordAndResolution(coordinate, 10);
expect(tileCoord.z).to.eql(0);
expect(tileCoord.x).to.eql(-1);
expect(tileCoord.y).to.eql(-1);
// gets the tile to the east when on the edge
coordinate = new ol.Coordinate(2560, -1280);
tileCoord = tileGrid.getTileCoordForCoordAndResolution(
coordinate, 10);
coordinate = [2560, -1280];
tileCoord = tileGrid.getTileCoordForCoordAndResolution(coordinate, 10);
expect(tileCoord.z).to.eql(0);
expect(tileCoord.x).to.eql(1);
expect(tileCoord.y).to.eql(-1);
// gets the tile to the north when on the edge
coordinate = new ol.Coordinate(1280, -2560);
tileCoord = tileGrid.getTileCoordForCoordAndResolution(
coordinate, 10);
coordinate = [1280, -2560];
tileCoord = tileGrid.getTileCoordForCoordAndResolution(coordinate, 10);
expect(tileCoord.z).to.eql(0);
expect(tileCoord.x).to.eql(0);
expect(tileCoord.y).to.eql(-1);
// pixels are top aligned to the origin
coordinate = new ol.Coordinate(1280, -2559.999);
tileCoord = tileGrid.getTileCoordForCoordAndResolution(
coordinate, 10);
coordinate = [1280, -2559.999];
tileCoord = tileGrid.getTileCoordForCoordAndResolution(coordinate, 10);
expect(tileCoord.z).to.eql(0);
expect(tileCoord.x).to.eql(0);
expect(tileCoord.y).to.eql(-1);
// pixels are left aligned to the origin
coordinate = new ol.Coordinate(2559.999, -1280);
tileCoord = tileGrid.getTileCoordForCoordAndResolution(
coordinate, 10);
coordinate = [2559.999, -1280];
tileCoord = tileGrid.getTileCoordForCoordAndResolution(coordinate, 10);
expect(tileCoord.z).to.eql(0);
expect(tileCoord.x).to.eql(0);
expect(tileCoord.y).to.eql(-1);
@@ -445,16 +428,16 @@ describe('ol.tilegrid.TileGrid', function() {
var center;
center = tileGrid.getTileCoordCenter(new ol.TileCoord(0, 0, 0));
expect(center.x).to.eql(50000);
expect(center.y).to.eql(50000);
expect(center[0]).to.eql(50000);
expect(center[1]).to.eql(50000);
center = tileGrid.getTileCoordCenter(new ol.TileCoord(3, 0, 0));
expect(center.x).to.eql(5000);
expect(center.y).to.eql(5000);
expect(center[0]).to.eql(5000);
expect(center[1]).to.eql(5000);
center = tileGrid.getTileCoordCenter(new ol.TileCoord(3, 9, 9));
expect(center.x).to.eql(95000);
expect(center.y).to.eql(95000);
expect(center[0]).to.eql(95000);
expect(center[1]).to.eql(95000);
});
});

View File

@@ -7,7 +7,7 @@ describe('ol.TileQueue', function() {
for (i = 0; i < num; i++) {
tile = new ol.Tile();
priority = Math.floor(Math.random() * 100);
tq.elements_.push([tile, '', new ol.Coordinate(0, 0)]);
tq.elements_.push([tile, '', [0, 0]]);
tq.priorities_.push(priority);
tq.queuedElements_[tile.getKey()] = true;
}
@@ -56,7 +56,6 @@ describe('ol.TileQueue', function() {
});
});
goog.require('ol.Coordinate');
goog.require('ol.Tile');
goog.require('ol.TileQueue');
goog.require('ol.structs.PriorityQueue');