Merge pull request #6643 from tschaub/proj-common
Add common transforms by default
This commit is contained in:
@@ -30,7 +30,6 @@ goog.require('ol.has');
|
|||||||
goog.require('ol.interaction');
|
goog.require('ol.interaction');
|
||||||
goog.require('ol.layer.Group');
|
goog.require('ol.layer.Group');
|
||||||
goog.require('ol.obj');
|
goog.require('ol.obj');
|
||||||
goog.require('ol.proj.common');
|
|
||||||
goog.require('ol.renderer.Map');
|
goog.require('ol.renderer.Map');
|
||||||
goog.require('ol.renderer.Type');
|
goog.require('ol.renderer.Type');
|
||||||
goog.require('ol.renderer.canvas.Map');
|
goog.require('ol.renderer.canvas.Map');
|
||||||
@@ -1501,5 +1500,3 @@ ol.Map.createOptionsInternal = function(options) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
ol.proj.common.add();
|
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ goog.provide('ol.proj');
|
|||||||
|
|
||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
goog.require('ol.extent');
|
goog.require('ol.extent');
|
||||||
|
goog.require('ol.proj.EPSG3857');
|
||||||
|
goog.require('ol.proj.EPSG4326');
|
||||||
goog.require('ol.proj.Projection');
|
goog.require('ol.proj.Projection');
|
||||||
goog.require('ol.proj.Units');
|
goog.require('ol.proj.Units');
|
||||||
goog.require('ol.proj.proj4');
|
goog.require('ol.proj.proj4');
|
||||||
@@ -467,3 +469,24 @@ ol.proj.transformWithProjections = function(point, sourceProjection, destination
|
|||||||
sourceProjection, destinationProjection);
|
sourceProjection, destinationProjection);
|
||||||
return transformFn(point);
|
return transformFn(point);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add transforms to and from EPSG:4326 and EPSG:3857. This function is called
|
||||||
|
* by when this module is executed and should only need to be called again after
|
||||||
|
* `ol.proj.clearAllProjections()` is called (e.g. in tests).
|
||||||
|
*/
|
||||||
|
ol.proj.addCommon = function() {
|
||||||
|
// Add transformations that don't alter coordinates to convert within set of
|
||||||
|
// projections with equal meaning.
|
||||||
|
ol.proj.addEquivalentProjections(ol.proj.EPSG3857.PROJECTIONS);
|
||||||
|
ol.proj.addEquivalentProjections(ol.proj.EPSG4326.PROJECTIONS);
|
||||||
|
// Add transformations to convert EPSG:4326 like coordinates to EPSG:3857 like
|
||||||
|
// coordinates and back.
|
||||||
|
ol.proj.addEquivalentTransforms(
|
||||||
|
ol.proj.EPSG4326.PROJECTIONS,
|
||||||
|
ol.proj.EPSG3857.PROJECTIONS,
|
||||||
|
ol.proj.EPSG3857.fromEPSG4326,
|
||||||
|
ol.proj.EPSG3857.toEPSG4326);
|
||||||
|
};
|
||||||
|
|
||||||
|
ol.proj.addCommon();
|
||||||
|
|||||||
+5
-16
@@ -1,24 +1,13 @@
|
|||||||
goog.provide('ol.proj.common');
|
goog.provide('ol.proj.common');
|
||||||
|
|
||||||
goog.require('ol.proj');
|
goog.require('ol.proj');
|
||||||
goog.require('ol.proj.EPSG3857');
|
|
||||||
goog.require('ol.proj.EPSG4326');
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FIXME empty description for jsdoc
|
* Deprecated. Transforms between EPSG:4326 and EPSG:3857 are now included by
|
||||||
|
* default. There is no need to call this function in application code and it
|
||||||
|
* will be removed in a future major release.
|
||||||
|
* @deprecated This function is no longer necessary.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
ol.proj.common.add = function() {
|
ol.proj.common.add = ol.proj.addCommon;
|
||||||
// Add transformations that don't alter coordinates to convert within set of
|
|
||||||
// projections with equal meaning.
|
|
||||||
ol.proj.addEquivalentProjections(ol.proj.EPSG3857.PROJECTIONS);
|
|
||||||
ol.proj.addEquivalentProjections(ol.proj.EPSG4326.PROJECTIONS);
|
|
||||||
// Add transformations to convert EPSG:4326 like coordinates to EPSG:3857 like
|
|
||||||
// coordinates and back.
|
|
||||||
ol.proj.addEquivalentTransforms(
|
|
||||||
ol.proj.EPSG4326.PROJECTIONS,
|
|
||||||
ol.proj.EPSG3857.PROJECTIONS,
|
|
||||||
ol.proj.EPSG3857.fromEPSG4326,
|
|
||||||
ol.proj.EPSG3857.toEPSG4326);
|
|
||||||
};
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ goog.provide('ol.proj.EPSG3857');
|
|||||||
|
|
||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
goog.require('ol.math');
|
goog.require('ol.math');
|
||||||
goog.require('ol.proj');
|
|
||||||
goog.require('ol.proj.Projection');
|
goog.require('ol.proj.Projection');
|
||||||
goog.require('ol.proj.Units');
|
goog.require('ol.proj.Units');
|
||||||
|
|
||||||
@@ -16,7 +15,7 @@ goog.require('ol.proj.Units');
|
|||||||
* @param {string} code Code.
|
* @param {string} code Code.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.proj.EPSG3857_ = function(code) {
|
ol.proj.EPSG3857.Projection_ = function(code) {
|
||||||
ol.proj.Projection.call(this, {
|
ol.proj.Projection.call(this, {
|
||||||
code: code,
|
code: code,
|
||||||
units: ol.proj.Units.METERS,
|
units: ol.proj.Units.METERS,
|
||||||
@@ -28,7 +27,7 @@ ol.proj.EPSG3857_ = function(code) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
ol.inherits(ol.proj.EPSG3857_, ol.proj.Projection);
|
ol.inherits(ol.proj.EPSG3857.Projection_, ol.proj.Projection);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -85,7 +84,7 @@ ol.proj.EPSG3857.CODES = [
|
|||||||
* @type {Array.<ol.proj.Projection>}
|
* @type {Array.<ol.proj.Projection>}
|
||||||
*/
|
*/
|
||||||
ol.proj.EPSG3857.PROJECTIONS = ol.proj.EPSG3857.CODES.map(function(code) {
|
ol.proj.EPSG3857.PROJECTIONS = ol.proj.EPSG3857.CODES.map(function(code) {
|
||||||
return new ol.proj.EPSG3857_(code);
|
return new ol.proj.EPSG3857.Projection_(code);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+10
-11
@@ -1,7 +1,6 @@
|
|||||||
goog.provide('ol.proj.EPSG4326');
|
goog.provide('ol.proj.EPSG4326');
|
||||||
|
|
||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
goog.require('ol.proj');
|
|
||||||
goog.require('ol.proj.Projection');
|
goog.require('ol.proj.Projection');
|
||||||
goog.require('ol.proj.Units');
|
goog.require('ol.proj.Units');
|
||||||
goog.require('ol.sphere.WGS84');
|
goog.require('ol.sphere.WGS84');
|
||||||
@@ -21,7 +20,7 @@ goog.require('ol.sphere.WGS84');
|
|||||||
* @param {string=} opt_axisOrientation Axis orientation.
|
* @param {string=} opt_axisOrientation Axis orientation.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.proj.EPSG4326_ = function(code, opt_axisOrientation) {
|
ol.proj.EPSG4326.Projection_ = function(code, opt_axisOrientation) {
|
||||||
ol.proj.Projection.call(this, {
|
ol.proj.Projection.call(this, {
|
||||||
code: code,
|
code: code,
|
||||||
units: ol.proj.Units.DEGREES,
|
units: ol.proj.Units.DEGREES,
|
||||||
@@ -32,7 +31,7 @@ ol.proj.EPSG4326_ = function(code, opt_axisOrientation) {
|
|||||||
worldExtent: ol.proj.EPSG4326.EXTENT
|
worldExtent: ol.proj.EPSG4326.EXTENT
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
ol.inherits(ol.proj.EPSG4326_, ol.proj.Projection);
|
ol.inherits(ol.proj.EPSG4326.Projection_, ol.proj.Projection);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -58,12 +57,12 @@ ol.proj.EPSG4326.METERS_PER_UNIT = Math.PI * ol.sphere.WGS84.radius / 180;
|
|||||||
* @type {Array.<ol.proj.Projection>}
|
* @type {Array.<ol.proj.Projection>}
|
||||||
*/
|
*/
|
||||||
ol.proj.EPSG4326.PROJECTIONS = [
|
ol.proj.EPSG4326.PROJECTIONS = [
|
||||||
new ol.proj.EPSG4326_('CRS:84'),
|
new ol.proj.EPSG4326.Projection_('CRS:84'),
|
||||||
new ol.proj.EPSG4326_('EPSG:4326', 'neu'),
|
new ol.proj.EPSG4326.Projection_('EPSG:4326', 'neu'),
|
||||||
new ol.proj.EPSG4326_('urn:ogc:def:crs:EPSG::4326', 'neu'),
|
new ol.proj.EPSG4326.Projection_('urn:ogc:def:crs:EPSG::4326', 'neu'),
|
||||||
new ol.proj.EPSG4326_('urn:ogc:def:crs:EPSG:6.6:4326', 'neu'),
|
new ol.proj.EPSG4326.Projection_('urn:ogc:def:crs:EPSG:6.6:4326', 'neu'),
|
||||||
new ol.proj.EPSG4326_('urn:ogc:def:crs:OGC:1.3:CRS84'),
|
new ol.proj.EPSG4326.Projection_('urn:ogc:def:crs:OGC:1.3:CRS84'),
|
||||||
new ol.proj.EPSG4326_('urn:ogc:def:crs:OGC:2:84'),
|
new ol.proj.EPSG4326.Projection_('urn:ogc:def:crs:OGC:2:84'),
|
||||||
new ol.proj.EPSG4326_('http://www.opengis.net/gml/srs/epsg.xml#4326', 'neu'),
|
new ol.proj.EPSG4326.Projection_('http://www.opengis.net/gml/srs/epsg.xml#4326', 'neu'),
|
||||||
new ol.proj.EPSG4326_('urn:x-ogc:def:crs:EPSG:4326', 'neu')
|
new ol.proj.EPSG4326.Projection_('urn:x-ogc:def:crs:EPSG:4326', 'neu')
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
goog.provide('ol.test.proj.EPSG3857');
|
goog.provide('ol.test.proj.EPSG3857');
|
||||||
|
|
||||||
goog.require('ol.proj');
|
goog.require('ol.proj');
|
||||||
goog.require('ol.proj.common');
|
|
||||||
|
|
||||||
describe('ol.proj.EPSG3857', function() {
|
describe('ol.proj.EPSG3857', function() {
|
||||||
|
|
||||||
afterEach(function() {
|
afterEach(function() {
|
||||||
ol.proj.clearAllProjections();
|
ol.proj.clearAllProjections();
|
||||||
ol.proj.common.add();
|
ol.proj.addCommon();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('fromEPSG4326()', function() {
|
describe('fromEPSG4326()', function() {
|
||||||
|
|||||||
@@ -3,14 +3,13 @@ goog.provide('ol.test.proj');
|
|||||||
goog.require('ol.proj');
|
goog.require('ol.proj');
|
||||||
goog.require('ol.proj.EPSG4326');
|
goog.require('ol.proj.EPSG4326');
|
||||||
goog.require('ol.proj.Projection');
|
goog.require('ol.proj.Projection');
|
||||||
goog.require('ol.proj.common');
|
|
||||||
|
|
||||||
|
|
||||||
describe('ol.proj', function() {
|
describe('ol.proj', function() {
|
||||||
|
|
||||||
afterEach(function() {
|
afterEach(function() {
|
||||||
ol.proj.clearAllProjections();
|
ol.proj.clearAllProjections();
|
||||||
ol.proj.common.add();
|
ol.proj.addCommon();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('projection equivalence', function() {
|
describe('projection equivalence', function() {
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ goog.provide('ol.test.renderer.webgl.ImageLayer');
|
|||||||
|
|
||||||
goog.require('ol.transform');
|
goog.require('ol.transform');
|
||||||
goog.require('ol.Map');
|
goog.require('ol.Map');
|
||||||
goog.require('ol.proj.common');
|
|
||||||
goog.require('ol.layer.Image');
|
goog.require('ol.layer.Image');
|
||||||
goog.require('ol.source.Image');
|
goog.require('ol.source.Image');
|
||||||
goog.require('ol.renderer.webgl.ImageLayer');
|
goog.require('ol.renderer.webgl.ImageLayer');
|
||||||
@@ -21,8 +20,6 @@ describe('ol.renderer.webgl.ImageLayer', function() {
|
|||||||
var imageExtent;
|
var imageExtent;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
ol.proj.common.add();
|
|
||||||
|
|
||||||
map = new ol.Map({
|
map = new ol.Map({
|
||||||
target: document.createElement('div')
|
target: document.createElement('div')
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user