Separate ol.projection module from ol.Projection class
This commit is contained in:
@@ -71,7 +71,7 @@ describe('ol.Extent', function() {
|
||||
|
||||
it('does transform', function() {
|
||||
var transformFn =
|
||||
ol.Projection.getTransformFromCodes('EPSG:4326', 'EPSG:3857');
|
||||
ol.projection.getTransformFromCodes('EPSG:4326', 'EPSG:3857');
|
||||
var sourceExtent = new ol.Extent(-15, -30, 45, 60);
|
||||
var destinationExtent = sourceExtent.transform(transformFn);
|
||||
expect(destinationExtent).not.toBeUndefined();
|
||||
@@ -101,4 +101,4 @@ describe('ol.Extent', function() {
|
||||
});
|
||||
|
||||
goog.require('ol.Extent');
|
||||
goog.require('ol.Projection');
|
||||
goog.require('ol.projection');
|
||||
|
||||
@@ -9,7 +9,7 @@ describe('ol.layer.Layer', function() {
|
||||
beforeEach(function() {
|
||||
layer = new ol.layer.Layer({
|
||||
source: new ol.source.Source({
|
||||
projection: ol.Projection.getFromCode('EPSG:4326')
|
||||
projection: ol.projection.getFromCode('EPSG:4326')
|
||||
})
|
||||
});
|
||||
});
|
||||
@@ -53,7 +53,7 @@ describe('ol.layer.Layer', function() {
|
||||
it('accepts options', function() {
|
||||
var layer = new ol.layer.Layer({
|
||||
source: new ol.source.Source({
|
||||
projection: ol.Projection.getFromCode('EPSG:4326')
|
||||
projection: ol.projection.getFromCode('EPSG:4326')
|
||||
}),
|
||||
brightness: 0.5,
|
||||
contrast: 10,
|
||||
@@ -82,7 +82,7 @@ describe('ol.layer.Layer', function() {
|
||||
beforeEach(function() {
|
||||
layer = new ol.layer.Layer({
|
||||
source: new ol.source.Source({
|
||||
projection: ol.Projection.getFromCode('EPSG:4326')
|
||||
projection: ol.projection.getFromCode('EPSG:4326')
|
||||
})
|
||||
});
|
||||
});
|
||||
@@ -120,7 +120,7 @@ describe('ol.layer.Layer', function() {
|
||||
beforeEach(function() {
|
||||
layer = new ol.layer.Layer({
|
||||
source: new ol.source.Source({
|
||||
projection: ol.Projection.getFromCode('EPSG:4326')
|
||||
projection: ol.projection.getFromCode('EPSG:4326')
|
||||
})
|
||||
});
|
||||
});
|
||||
@@ -154,7 +154,7 @@ describe('ol.layer.Layer', function() {
|
||||
beforeEach(function() {
|
||||
layer = new ol.layer.Layer({
|
||||
source: new ol.source.Source({
|
||||
projection: ol.Projection.getFromCode('EPSG:4326')
|
||||
projection: ol.projection.getFromCode('EPSG:4326')
|
||||
})
|
||||
});
|
||||
});
|
||||
@@ -193,7 +193,7 @@ describe('ol.layer.Layer', function() {
|
||||
beforeEach(function() {
|
||||
layer = new ol.layer.Layer({
|
||||
source: new ol.source.Source({
|
||||
projection: ol.Projection.getFromCode('EPSG:4326')
|
||||
projection: ol.projection.getFromCode('EPSG:4326')
|
||||
})
|
||||
});
|
||||
});
|
||||
@@ -227,7 +227,7 @@ describe('ol.layer.Layer', function() {
|
||||
beforeEach(function() {
|
||||
layer = new ol.layer.Layer({
|
||||
source: new ol.source.Source({
|
||||
projection: ol.Projection.getFromCode('EPSG:4326')
|
||||
projection: ol.projection.getFromCode('EPSG:4326')
|
||||
})
|
||||
});
|
||||
});
|
||||
@@ -259,7 +259,7 @@ describe('ol.layer.Layer', function() {
|
||||
it('sets visible property', function() {
|
||||
var layer = new ol.layer.Layer({
|
||||
source: new ol.source.Source({
|
||||
projection: ol.Projection.getFromCode('EPSG:4326')
|
||||
projection: ol.projection.getFromCode('EPSG:4326')
|
||||
})
|
||||
});
|
||||
|
||||
@@ -275,3 +275,5 @@ describe('ol.layer.Layer', function() {
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
goog.require('ol.projection');
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
goog.provide('ol.test.Projection');
|
||||
|
||||
describe('ol.Projection', function() {
|
||||
describe('ol.projection', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
spyOn(ol.Projection, 'addTransform').andCallThrough();
|
||||
spyOn(ol.projection, 'addTransform').andCallThrough();
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
var argsForCall = ol.Projection.addTransform.argsForCall;
|
||||
var argsForCall = ol.projection.addTransform.argsForCall;
|
||||
for (var i = 0, ii = argsForCall.length; i < ii; ++i) {
|
||||
try {
|
||||
ol.Projection.removeTransform.apply(
|
||||
ol.Projection, argsForCall[i].splice(0, 2));
|
||||
ol.projection.removeTransform.apply(
|
||||
ol.projection, argsForCall[i].splice(0, 2));
|
||||
} catch (error) {
|
||||
if (error instanceof goog.asserts.AssertionError) {
|
||||
// The removeTransform function may have been called explicitly by the
|
||||
@@ -26,10 +26,10 @@ describe('ol.Projection', function() {
|
||||
describe('projection equivalence', function() {
|
||||
|
||||
function _testAllEquivalent(codes) {
|
||||
var projections = goog.array.map(codes, ol.Projection.getFromCode);
|
||||
var projections = goog.array.map(codes, ol.projection.getFromCode);
|
||||
goog.array.forEach(projections, function(source) {
|
||||
goog.array.forEach(projections, function(destination) {
|
||||
expect(ol.Projection.equivalent(source, destination)).toBeTruthy();
|
||||
expect(ol.projection.equivalent(source, destination)).toBeTruthy();
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -56,10 +56,10 @@ describe('ol.Projection', function() {
|
||||
describe('identify transform', function() {
|
||||
|
||||
it('returns a new object, with same coord values', function() {
|
||||
var epsg4326 = ol.Projection.getFromCode('EPSG:4326');
|
||||
var epsg4326 = ol.projection.getFromCode('EPSG:4326');
|
||||
var uniqueObject = {};
|
||||
var sourcePoint = new ol.Coordinate(uniqueObject, uniqueObject);
|
||||
var destinationPoint = ol.Projection.transform(
|
||||
var destinationPoint = ol.projection.transform(
|
||||
sourcePoint, epsg4326, epsg4326);
|
||||
expect(sourcePoint === destinationPoint).toBeFalsy();
|
||||
expect(destinationPoint.x === sourcePoint.x).toBeTruthy();
|
||||
@@ -70,7 +70,7 @@ describe('ol.Projection', function() {
|
||||
describe('transform 0,0 from 4326 to 3857', function() {
|
||||
|
||||
it('returns expected value', function() {
|
||||
var point = ol.Projection.transformWithCodes(
|
||||
var point = ol.projection.transformWithCodes(
|
||||
new ol.Coordinate(0, 0), 'EPSG:4326', 'EPSG:3857');
|
||||
expect(point).not.toBeUndefined();
|
||||
expect(point).not.toBeNull();
|
||||
@@ -81,7 +81,7 @@ describe('ol.Projection', function() {
|
||||
describe('transform 0,0 from 3857 to 4326', function() {
|
||||
|
||||
it('returns expected value', function() {
|
||||
var point = ol.Projection.transformWithCodes(
|
||||
var point = ol.projection.transformWithCodes(
|
||||
new ol.Coordinate(0, 0), 'EPSG:3857', 'EPSG:4326');
|
||||
expect(point).not.toBeUndefined();
|
||||
expect(point).not.toBeNull();
|
||||
@@ -94,7 +94,7 @@ describe('ol.Projection', function() {
|
||||
// http://alastaira.wordpress.com/2011/01/23/the-google-maps-bing-maps-spherical-mercator-projection/
|
||||
|
||||
it('returns expected value', function() {
|
||||
var point = ol.Projection.transformWithCodes(
|
||||
var point = ol.projection.transformWithCodes(
|
||||
new ol.Coordinate(-5.625, 52.4827802220782),
|
||||
'EPSG:4326',
|
||||
'EPSG:900913');
|
||||
@@ -109,7 +109,7 @@ describe('ol.Projection', function() {
|
||||
// http://alastaira.wordpress.com/2011/01/23/the-google-maps-bing-maps-spherical-mercator-projection/
|
||||
|
||||
it('returns expected value', function() {
|
||||
var point = ol.Projection.transformWithCodes(
|
||||
var point = ol.projection.transformWithCodes(
|
||||
new ol.Coordinate(-626172.13571216376, 6887893.4928337997),
|
||||
'EPSG:900913',
|
||||
'EPSG:4326');
|
||||
@@ -123,7 +123,7 @@ describe('ol.Projection', function() {
|
||||
describe('Proj4js integration', function() {
|
||||
|
||||
it('allows Proj4js projections to be used transparently', function() {
|
||||
var point = ol.Projection.transformWithCodes(
|
||||
var point = ol.projection.transformWithCodes(
|
||||
new ol.Coordinate(-626172.13571216376, 6887893.4928337997),
|
||||
'GOOGLE',
|
||||
'WGS84');
|
||||
@@ -136,7 +136,7 @@ describe('ol.Projection', function() {
|
||||
'+proj=somerc +lat_0=46.95240555555556 +lon_0=7.439583333333333 ' +
|
||||
'+k_0=1 +x_0=600000 +y_0=200000 +ellps=bessel ' +
|
||||
'+towgs84=674.374,15.056,405.346,0,0,0,0 +units=m +no_defs';
|
||||
var point = ol.Projection.transformWithCodes(
|
||||
var point = ol.projection.transformWithCodes(
|
||||
new ol.Coordinate(7.439583333333333, 46.95240555555556),
|
||||
'EPSG:4326',
|
||||
'EPSG:21781');
|
||||
@@ -146,13 +146,13 @@ describe('ol.Projection', function() {
|
||||
|
||||
});
|
||||
|
||||
describe('ol.Projection.getTransform()', function() {
|
||||
describe('ol.projection.getTransform()', function() {
|
||||
|
||||
var sm = ol.Projection.getFromCode('GOOGLE');
|
||||
var gg = ol.Projection.getFromCode('EPSG:4326');
|
||||
var sm = ol.projection.getFromCode('GOOGLE');
|
||||
var gg = ol.projection.getFromCode('EPSG:4326');
|
||||
|
||||
it('returns a transform function', function() {
|
||||
var transform = ol.Projection.getTransform(sm, gg);
|
||||
var transform = ol.projection.getTransform(sm, gg);
|
||||
expect(typeof transform).toBe('function');
|
||||
|
||||
var coordinate = transform(new ol.Coordinate(-12000000, 5000000));
|
||||
@@ -164,16 +164,16 @@ describe('ol.Projection', function() {
|
||||
});
|
||||
|
||||
|
||||
describe('ol.Projection.getTransformFromCodes()', function() {
|
||||
describe('ol.projection.getTransformFromCodes()', function() {
|
||||
|
||||
it('returns a function', function() {
|
||||
var transform = ol.Projection.getTransformFromCodes(
|
||||
var transform = ol.projection.getTransformFromCodes(
|
||||
'GOOGLE', 'EPSG:4326');
|
||||
expect(typeof transform).toBe('function');
|
||||
});
|
||||
|
||||
it('returns a transform function', function() {
|
||||
var transform = ol.Projection.getTransformFromCodes(
|
||||
var transform = ol.projection.getTransformFromCodes(
|
||||
'GOOGLE', 'EPSG:4326');
|
||||
expect(typeof transform).toBe('function');
|
||||
|
||||
@@ -187,7 +187,7 @@ describe('ol.Projection', function() {
|
||||
|
||||
});
|
||||
|
||||
describe('ol.Projection.removeTransform()', function() {
|
||||
describe('ol.projection.removeTransform()', function() {
|
||||
|
||||
var extent = new ol.Extent(-180, -90, 180, 90);
|
||||
var units = ol.ProjectionUnits.DEGREES;
|
||||
@@ -196,14 +196,14 @@ describe('ol.Projection', function() {
|
||||
var foo = new ol.Projection('foo', units, extent);
|
||||
var bar = new ol.Projection('bar', units, extent);
|
||||
var transform = function() {};
|
||||
ol.Projection.addTransform(foo, bar, transform);
|
||||
expect(ol.Projection.transforms_).not.toBeUndefined();
|
||||
expect(ol.Projection.transforms_.foo).not.toBeUndefined();
|
||||
expect(ol.Projection.transforms_.foo.bar).toBe(transform);
|
||||
ol.projection.addTransform(foo, bar, transform);
|
||||
expect(ol.projection.transforms_).not.toBeUndefined();
|
||||
expect(ol.projection.transforms_.foo).not.toBeUndefined();
|
||||
expect(ol.projection.transforms_.foo.bar).toBe(transform);
|
||||
|
||||
var removed = ol.Projection.removeTransform(foo, bar);
|
||||
var removed = ol.projection.removeTransform(foo, bar);
|
||||
expect(removed).toBe(transform);
|
||||
expect(ol.Projection.transforms_.foo).toBeUndefined();
|
||||
expect(ol.projection.transforms_.foo).toBeUndefined();
|
||||
});
|
||||
|
||||
});
|
||||
@@ -215,3 +215,4 @@ goog.require('ol.Coordinate');
|
||||
goog.require('ol.Extent');
|
||||
goog.require('ol.Projection');
|
||||
goog.require('ol.ProjectionUnits');
|
||||
goog.require('ol.projection');
|
||||
|
||||
@@ -5,7 +5,7 @@ describe('ol.source.TileSource', function() {
|
||||
describe('constructor', function() {
|
||||
it('returns a tile source', function() {
|
||||
var source = new ol.source.TileSource({
|
||||
projection: ol.Projection.getFromCode('EPSG:4326')
|
||||
projection: ol.projection.getFromCode('EPSG:4326')
|
||||
});
|
||||
expect(source).toBeA(ol.source.Source);
|
||||
expect(source).toBeA(ol.source.TileSource);
|
||||
@@ -161,7 +161,7 @@ ol.test.source.MockTileSource = function(loaded) {
|
||||
|
||||
goog.base(this, {
|
||||
extent: extent,
|
||||
projection: ol.Projection.getFromCode('EPSG:4326'),
|
||||
projection: ol.projection.getFromCode('EPSG:4326'),
|
||||
tileGrid: tileGrid
|
||||
});
|
||||
|
||||
@@ -230,9 +230,9 @@ goog.require('goog.object');
|
||||
|
||||
goog.require('ol.Coordinate');
|
||||
goog.require('ol.Extent');
|
||||
goog.require('ol.Projection');
|
||||
goog.require('ol.Tile');
|
||||
goog.require('ol.TileCoord');
|
||||
goog.require('ol.TileState');
|
||||
goog.require('ol.projection');
|
||||
goog.require('ol.source.TileSource');
|
||||
goog.require('ol.tilegrid.TileGrid');
|
||||
|
||||
@@ -97,7 +97,7 @@ describe('ol.tilegrid.TileGrid', function() {
|
||||
describe('createForProjection', function() {
|
||||
|
||||
it('allows easier creation of a tile grid', function() {
|
||||
var projection = ol.Projection.getFromCode('EPSG:3857');
|
||||
var projection = ol.projection.getFromCode('EPSG:3857');
|
||||
var grid = ol.tilegrid.createForProjection(projection);
|
||||
expect(grid).toBeA(ol.tilegrid.TileGrid);
|
||||
|
||||
@@ -106,7 +106,7 @@ describe('ol.tilegrid.TileGrid', function() {
|
||||
});
|
||||
|
||||
it('accepts a number of zoom levels', function() {
|
||||
var projection = ol.Projection.getFromCode('EPSG:3857');
|
||||
var projection = ol.projection.getFromCode('EPSG:3857');
|
||||
var grid = ol.tilegrid.createForProjection(projection, 22);
|
||||
expect(grid).toBeA(ol.tilegrid.TileGrid);
|
||||
|
||||
@@ -115,7 +115,7 @@ describe('ol.tilegrid.TileGrid', function() {
|
||||
});
|
||||
|
||||
it('accepts a big number of zoom levels', function() {
|
||||
var projection = ol.Projection.getFromCode('EPSG:3857');
|
||||
var projection = ol.projection.getFromCode('EPSG:3857');
|
||||
var grid = ol.tilegrid.createForProjection(projection, 23);
|
||||
expect(grid).toBeA(ol.tilegrid.TileGrid);
|
||||
|
||||
@@ -570,4 +570,5 @@ goog.require('ol.Coordinate');
|
||||
goog.require('ol.Extent');
|
||||
goog.require('ol.Size');
|
||||
goog.require('ol.TileCoord');
|
||||
goog.require('ol.projection');
|
||||
goog.require('ol.tilegrid.TileGrid');
|
||||
|
||||
@@ -69,7 +69,7 @@ describe('ol.TileUrlFunction', function() {
|
||||
});
|
||||
});
|
||||
it('creates expected URL', function() {
|
||||
var epsg3857 = ol.Projection.getFromCode('EPSG:3857');
|
||||
var epsg3857 = ol.projection.getFromCode('EPSG:3857');
|
||||
var tileUrlFunction = ol.TileUrlFunction.createBboxParam(
|
||||
'http://wms?foo=bar', tileGrid, epsg3857.getAxisOrientation());
|
||||
var tileCoord = new ol.TileCoord(1, 0, 0);
|
||||
@@ -79,7 +79,7 @@ describe('ol.TileUrlFunction', function() {
|
||||
expect(tileUrl).toEqual(expected);
|
||||
});
|
||||
it('creates expected URL respecting axis orientation', function() {
|
||||
var epsg4326 = ol.Projection.getFromCode('EPSG:4326');
|
||||
var epsg4326 = ol.projection.getFromCode('EPSG:4326');
|
||||
var tileUrlFunction = ol.TileUrlFunction.createBboxParam(
|
||||
'http://wms?foo=bar', tileGrid, epsg4326.getAxisOrientation());
|
||||
var tileCoord = new ol.TileCoord(1, 0, 0);
|
||||
@@ -93,4 +93,5 @@ describe('ol.TileUrlFunction', function() {
|
||||
|
||||
goog.require('ol.TileCoord');
|
||||
goog.require('ol.TileUrlFunction');
|
||||
goog.require('ol.projection');
|
||||
goog.require('ol.tilegrid.XYZ');
|
||||
|
||||
Reference in New Issue
Block a user