@@ -17,6 +17,7 @@ goog.require('ol.style.Fill');
|
||||
goog.require('ol.style.Icon');
|
||||
goog.require('ol.proj');
|
||||
goog.require('ol.proj.Projection');
|
||||
goog.require('ol.proj.transforms');
|
||||
goog.require('ol.style.Stroke');
|
||||
goog.require('ol.style.Style');
|
||||
goog.require('ol.style.Text');
|
||||
@@ -358,9 +359,9 @@ describe('ol.format.KML', function() {
|
||||
'</kml>';
|
||||
expect(node).to.xmleql(ol.xml.parse(text));
|
||||
|
||||
ol.proj.removeTransform(
|
||||
ol.proj.transforms.remove(
|
||||
ol.proj.get('EPSG:4326'), ol.proj.get('double'));
|
||||
ol.proj.removeTransform(
|
||||
ol.proj.transforms.remove(
|
||||
ol.proj.get('double'), ol.proj.get('EPSG:4326'));
|
||||
});
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ describe('ol.proj.EPSG3857', function() {
|
||||
var epsg3857 = ol.proj.get('EPSG:3857');
|
||||
var resolution = 19.11;
|
||||
var point = [0, 0];
|
||||
expect(epsg3857.getPointResolution(resolution, point)).
|
||||
expect(ol.proj.getPointResolution(epsg3857, resolution, point)).
|
||||
to.roughlyEqual(19.11, 1e-1);
|
||||
});
|
||||
|
||||
@@ -60,7 +60,7 @@ describe('ol.proj.EPSG3857', function() {
|
||||
var epsg4326 = ol.proj.get('EPSG:4326');
|
||||
var resolution = 19.11;
|
||||
var point = ol.proj.transform([0, 43.65], epsg4326, epsg3857);
|
||||
expect(epsg3857.getPointResolution(resolution, point)).
|
||||
expect(ol.proj.getPointResolution(epsg3857, resolution, point)).
|
||||
to.roughlyEqual(19.11 * Math.cos(Math.PI * 43.65 / 180), 1e-9);
|
||||
});
|
||||
|
||||
@@ -72,7 +72,7 @@ describe('ol.proj.EPSG3857', function() {
|
||||
var latitude;
|
||||
for (latitude = 0; latitude <= 85; ++latitude) {
|
||||
var point = ol.proj.transform([0, latitude], epsg4326, epsg3857);
|
||||
expect(epsg3857.getPointResolution(resolution, point)).
|
||||
expect(ol.proj.getPointResolution(epsg3857, resolution, point)).
|
||||
to.roughlyEqual(19.11 * Math.cos(Math.PI * latitude / 180), 1e-9);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -310,7 +310,7 @@ describe('ol.proj', function() {
|
||||
|
||||
it('numerically estimates point scale at the equator', function() {
|
||||
var googleProjection = ol.proj.get('GOOGLE');
|
||||
expect(googleProjection.getPointResolution(1, [0, 0])).
|
||||
expect(ol.proj.getPointResolution(googleProjection, 1, [0, 0])).
|
||||
to.roughlyEqual(1, 1e-1);
|
||||
});
|
||||
|
||||
@@ -320,8 +320,8 @@ describe('ol.proj', function() {
|
||||
var point, y;
|
||||
for (y = -20; y <= 20; ++y) {
|
||||
point = [0, 1000000 * y];
|
||||
expect(googleProjection.getPointResolution(1, point)).to.roughlyEqual(
|
||||
epsg3857Projection.getPointResolution(1, point), 1e-1);
|
||||
expect(ol.proj.getPointResolution(googleProjection, 1, point)).to.roughlyEqual(
|
||||
ol.proj.getPointResolution(epsg3857Projection, 1, point), 1e-1);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -332,8 +332,8 @@ describe('ol.proj', function() {
|
||||
for (x = -20; x <= 20; x += 2) {
|
||||
for (y = -20; y <= 20; y += 2) {
|
||||
point = [1000000 * x, 1000000 * y];
|
||||
expect(googleProjection.getPointResolution(1, point)).to.roughlyEqual(
|
||||
epsg3857Projection.getPointResolution(1, point), 1e-1);
|
||||
expect(ol.proj.getPointResolution(googleProjection, 1, point)).to.roughlyEqual(
|
||||
ol.proj.getPointResolution(epsg3857Projection, 1, point), 1e-1);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -451,37 +451,6 @@ describe('ol.proj', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('ol.proj.removeTransform()', function() {
|
||||
|
||||
var extent = [180, -90, 180, 90];
|
||||
var units = 'degrees';
|
||||
|
||||
it('removes functions cached by addTransform', function() {
|
||||
var foo = new ol.proj.Projection({
|
||||
code: 'foo',
|
||||
units: units,
|
||||
extent: extent
|
||||
});
|
||||
var bar = new ol.proj.Projection({
|
||||
code: 'bar',
|
||||
units: units,
|
||||
extent: extent
|
||||
});
|
||||
var transform = function(input, output, dimension) {
|
||||
return input;
|
||||
};
|
||||
ol.proj.addTransform(foo, bar, transform);
|
||||
expect(ol.proj.transforms_).not.to.be(undefined);
|
||||
expect(ol.proj.transforms_.foo).not.to.be(undefined);
|
||||
expect(ol.proj.transforms_.foo.bar).to.be(transform);
|
||||
|
||||
var removed = ol.proj.removeTransform(foo, bar);
|
||||
expect(removed).to.be(transform);
|
||||
expect(ol.proj.transforms_.foo).to.be(undefined);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('ol.proj.transform()', function() {
|
||||
|
||||
it('transforms a 2d coordinate', function() {
|
||||
|
||||
36
test/spec/ol/proj/transforms.test.js
Normal file
36
test/spec/ol/proj/transforms.test.js
Normal file
@@ -0,0 +1,36 @@
|
||||
goog.provide('ol.test.proj.transforms');
|
||||
|
||||
goog.require('ol.proj.Projection');
|
||||
goog.require('ol.proj.transforms');
|
||||
|
||||
|
||||
describe('ol.proj.transforms.remove()', function() {
|
||||
|
||||
var extent = [180, -90, 180, 90];
|
||||
var units = 'degrees';
|
||||
|
||||
it('removes functions cached by ol.proj.transforms.add()', function() {
|
||||
var foo = new ol.proj.Projection({
|
||||
code: 'foo',
|
||||
units: units,
|
||||
extent: extent
|
||||
});
|
||||
var bar = new ol.proj.Projection({
|
||||
code: 'bar',
|
||||
units: units,
|
||||
extent: extent
|
||||
});
|
||||
var transform = function(input, output, dimension) {
|
||||
return input;
|
||||
};
|
||||
ol.proj.transforms.add(foo, bar, transform);
|
||||
expect(ol.proj.transforms.cache_).not.to.be(undefined);
|
||||
expect(ol.proj.transforms.cache_.foo).not.to.be(undefined);
|
||||
expect(ol.proj.transforms.cache_.foo.bar).to.be(transform);
|
||||
|
||||
var removed = ol.proj.transforms.remove(foo, bar);
|
||||
expect(removed).to.be(transform);
|
||||
expect(ol.proj.transforms.cache_.foo).to.be(undefined);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -5,7 +5,6 @@ goog.require('ol.TileRange');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.proj');
|
||||
goog.require('ol.proj.EPSG3857');
|
||||
goog.require('ol.proj.METERS_PER_UNIT');
|
||||
goog.require('ol.proj.Projection');
|
||||
goog.require('ol.tilegrid');
|
||||
goog.require('ol.tilegrid.TileGrid');
|
||||
|
||||
Reference in New Issue
Block a user