Named exports from ol/proj/epsg4326
This commit is contained in:
@@ -5,7 +5,7 @@ import {getDistance} from './sphere.js';
|
|||||||
import {applyTransform} from './extent.js';
|
import {applyTransform} from './extent.js';
|
||||||
import {modulo} from './math.js';
|
import {modulo} from './math.js';
|
||||||
import {toEPSG4326, fromEPSG4326, PROJECTIONS as EPSG3857_PROJECTIONS} from './proj/epsg3857.js';
|
import {toEPSG4326, fromEPSG4326, PROJECTIONS as EPSG3857_PROJECTIONS} from './proj/epsg3857.js';
|
||||||
import EPSG4326 from './proj/EPSG4326.js';
|
import {PROJECTIONS as EPSG4326_PROJECTIONS} from './proj/epsg4326.js';
|
||||||
import Projection from './proj/Projection.js';
|
import Projection from './proj/Projection.js';
|
||||||
import Units from './proj/Units.js';
|
import Units from './proj/Units.js';
|
||||||
import * as projections from './proj/projections.js';
|
import * as projections from './proj/projections.js';
|
||||||
@@ -439,14 +439,10 @@ export function addCommon() {
|
|||||||
// Add transformations that don't alter coordinates to convert within set of
|
// Add transformations that don't alter coordinates to convert within set of
|
||||||
// projections with equal meaning.
|
// projections with equal meaning.
|
||||||
addEquivalentProjections(EPSG3857_PROJECTIONS);
|
addEquivalentProjections(EPSG3857_PROJECTIONS);
|
||||||
addEquivalentProjections(EPSG4326.PROJECTIONS);
|
addEquivalentProjections(EPSG4326_PROJECTIONS);
|
||||||
// Add transformations to convert EPSG:4326 like coordinates to EPSG:3857 like
|
// Add transformations to convert EPSG:4326 like coordinates to EPSG:3857 like
|
||||||
// coordinates and back.
|
// coordinates and back.
|
||||||
addEquivalentTransforms(
|
addEquivalentTransforms(EPSG4326_PROJECTIONS, EPSG3857_PROJECTIONS, fromEPSG4326, toEPSG4326);
|
||||||
EPSG4326.PROJECTIONS,
|
|
||||||
EPSG3857_PROJECTIONS,
|
|
||||||
fromEPSG4326,
|
|
||||||
toEPSG4326);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
addCommon();
|
addCommon();
|
||||||
|
|||||||
@@ -1,79 +0,0 @@
|
|||||||
/**
|
|
||||||
* @module ol/proj/EPSG4326
|
|
||||||
*/
|
|
||||||
import {inherits} from '../index.js';
|
|
||||||
import Projection from '../proj/Projection.js';
|
|
||||||
import Units from '../proj/Units.js';
|
|
||||||
const _ol_proj_EPSG4326_ = {};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @classdesc
|
|
||||||
* Projection object for WGS84 geographic coordinates (EPSG:4326).
|
|
||||||
*
|
|
||||||
* Note that OpenLayers does not strictly comply with the EPSG definition.
|
|
||||||
* The EPSG registry defines 4326 as a CRS for Latitude,Longitude (y,x).
|
|
||||||
* OpenLayers treats EPSG:4326 as a pseudo-projection, with x,y coordinates.
|
|
||||||
*
|
|
||||||
* @constructor
|
|
||||||
* @extends {ol.proj.Projection}
|
|
||||||
* @param {string} code Code.
|
|
||||||
* @param {string=} opt_axisOrientation Axis orientation.
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
_ol_proj_EPSG4326_.Projection_ = function(code, opt_axisOrientation) {
|
|
||||||
Projection.call(this, {
|
|
||||||
code: code,
|
|
||||||
units: Units.DEGREES,
|
|
||||||
extent: _ol_proj_EPSG4326_.EXTENT,
|
|
||||||
axisOrientation: opt_axisOrientation,
|
|
||||||
global: true,
|
|
||||||
metersPerUnit: _ol_proj_EPSG4326_.METERS_PER_UNIT,
|
|
||||||
worldExtent: _ol_proj_EPSG4326_.EXTENT
|
|
||||||
});
|
|
||||||
};
|
|
||||||
inherits(_ol_proj_EPSG4326_.Projection_, Projection);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Radius of WGS84 sphere
|
|
||||||
*
|
|
||||||
* @const
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
_ol_proj_EPSG4326_.RADIUS = 6378137;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Extent of the EPSG:4326 projection which is the whole world.
|
|
||||||
*
|
|
||||||
* @const
|
|
||||||
* @type {ol.Extent}
|
|
||||||
*/
|
|
||||||
_ol_proj_EPSG4326_.EXTENT = [-180, -90, 180, 90];
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @const
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
_ol_proj_EPSG4326_.METERS_PER_UNIT = Math.PI * _ol_proj_EPSG4326_.RADIUS / 180;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Projections equal to EPSG:4326.
|
|
||||||
*
|
|
||||||
* @const
|
|
||||||
* @type {Array.<ol.proj.Projection>}
|
|
||||||
*/
|
|
||||||
_ol_proj_EPSG4326_.PROJECTIONS = [
|
|
||||||
new _ol_proj_EPSG4326_.Projection_('CRS:84'),
|
|
||||||
new _ol_proj_EPSG4326_.Projection_('EPSG:4326', 'neu'),
|
|
||||||
new _ol_proj_EPSG4326_.Projection_('urn:ogc:def:crs:EPSG::4326', 'neu'),
|
|
||||||
new _ol_proj_EPSG4326_.Projection_('urn:ogc:def:crs:EPSG:6.6:4326', 'neu'),
|
|
||||||
new _ol_proj_EPSG4326_.Projection_('urn:ogc:def:crs:OGC:1.3:CRS84'),
|
|
||||||
new _ol_proj_EPSG4326_.Projection_('urn:ogc:def:crs:OGC:2:84'),
|
|
||||||
new _ol_proj_EPSG4326_.Projection_('http://www.opengis.net/gml/srs/epsg.xml#4326', 'neu'),
|
|
||||||
new _ol_proj_EPSG4326_.Projection_('urn:x-ogc:def:crs:EPSG:4326', 'neu')
|
|
||||||
];
|
|
||||||
export default _ol_proj_EPSG4326_;
|
|
||||||
76
src/ol/proj/epsg4326.js
Normal file
76
src/ol/proj/epsg4326.js
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
/**
|
||||||
|
* @module ol/proj/epsg4326
|
||||||
|
*/
|
||||||
|
import {inherits} from '../index.js';
|
||||||
|
import Projection from '../proj/Projection.js';
|
||||||
|
import Units from '../proj/Units.js';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Semi-major radius of the WGS84 ellipsoid.
|
||||||
|
*
|
||||||
|
* @const
|
||||||
|
* @type {number}
|
||||||
|
*/
|
||||||
|
export const RADIUS = 6378137;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extent of the EPSG:4326 projection which is the whole world.
|
||||||
|
*
|
||||||
|
* @const
|
||||||
|
* @type {ol.Extent}
|
||||||
|
*/
|
||||||
|
export const EXTENT = [-180, -90, 180, 90];
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @const
|
||||||
|
* @type {number}
|
||||||
|
*/
|
||||||
|
export const METERS_PER_UNIT = Math.PI * RADIUS / 180;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @classdesc
|
||||||
|
* Projection object for WGS84 geographic coordinates (EPSG:4326).
|
||||||
|
*
|
||||||
|
* Note that OpenLayers does not strictly comply with the EPSG definition.
|
||||||
|
* The EPSG registry defines 4326 as a CRS for Latitude,Longitude (y,x).
|
||||||
|
* OpenLayers treats EPSG:4326 as a pseudo-projection, with x,y coordinates.
|
||||||
|
*
|
||||||
|
* @constructor
|
||||||
|
* @extends {ol.proj.Projection}
|
||||||
|
* @param {string} code Code.
|
||||||
|
* @param {string=} opt_axisOrientation Axis orientation.
|
||||||
|
*/
|
||||||
|
function EPSG4326Projection(code, opt_axisOrientation) {
|
||||||
|
Projection.call(this, {
|
||||||
|
code: code,
|
||||||
|
units: Units.DEGREES,
|
||||||
|
extent: EXTENT,
|
||||||
|
axisOrientation: opt_axisOrientation,
|
||||||
|
global: true,
|
||||||
|
metersPerUnit: METERS_PER_UNIT,
|
||||||
|
worldExtent: EXTENT
|
||||||
|
});
|
||||||
|
}
|
||||||
|
inherits(EPSG4326Projection, Projection);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Projections equal to EPSG:4326.
|
||||||
|
*
|
||||||
|
* @const
|
||||||
|
* @type {Array.<ol.proj.Projection>}
|
||||||
|
*/
|
||||||
|
export const PROJECTIONS = [
|
||||||
|
new EPSG4326Projection('CRS:84'),
|
||||||
|
new EPSG4326Projection('EPSG:4326', 'neu'),
|
||||||
|
new EPSG4326Projection('urn:ogc:def:crs:EPSG::4326', 'neu'),
|
||||||
|
new EPSG4326Projection('urn:ogc:def:crs:EPSG:6.6:4326', 'neu'),
|
||||||
|
new EPSG4326Projection('urn:ogc:def:crs:OGC:1.3:CRS84'),
|
||||||
|
new EPSG4326Projection('urn:ogc:def:crs:OGC:2:84'),
|
||||||
|
new EPSG4326Projection('http://www.opengis.net/gml/srs/epsg.xml#4326', 'neu'),
|
||||||
|
new EPSG4326Projection('urn:x-ogc:def:crs:EPSG:4326', 'neu')
|
||||||
|
];
|
||||||
@@ -13,7 +13,7 @@ import {
|
|||||||
} from '../../../src/ol/proj.js';
|
} from '../../../src/ol/proj.js';
|
||||||
import {register} from '../../../src/ol/proj/proj4.js';
|
import {register} from '../../../src/ol/proj/proj4.js';
|
||||||
import {HALF_SIZE} from '../../../src/ol/proj/epsg3857.js';
|
import {HALF_SIZE} from '../../../src/ol/proj/epsg3857.js';
|
||||||
import _ol_proj_EPSG4326_ from '../../../src/ol/proj/EPSG4326.js';
|
import {METERS_PER_UNIT} from '../../../src/ol/proj/epsg4326.js';
|
||||||
import Projection from '../../../src/ol/proj/Projection.js';
|
import Projection from '../../../src/ol/proj/Projection.js';
|
||||||
|
|
||||||
|
|
||||||
@@ -600,8 +600,7 @@ describe('ol.proj', function() {
|
|||||||
|
|
||||||
it('returns value in meters', function() {
|
it('returns value in meters', function() {
|
||||||
const epsg4326 = getProjection('EPSG:4326');
|
const epsg4326 = getProjection('EPSG:4326');
|
||||||
expect(epsg4326.getMetersPerUnit()).to.eql(
|
expect(epsg4326.getMetersPerUnit()).to.eql(METERS_PER_UNIT);
|
||||||
_ol_proj_EPSG4326_.METERS_PER_UNIT);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works for proj4js projections without units', function() {
|
it('works for proj4js projections without units', function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user