This commit is contained in:
271
node_modules/ol/src/proj/Projection.js
generated
vendored
Normal file
271
node_modules/ol/src/proj/Projection.js
generated
vendored
Normal file
@@ -0,0 +1,271 @@
|
||||
/**
|
||||
* @module ol/proj/Projection
|
||||
*/
|
||||
import {METERS_PER_UNIT} from './Units.js';
|
||||
|
||||
/**
|
||||
* @typedef {Object} Options
|
||||
* @property {string} code The SRS identifier code, e.g. `EPSG:4326`.
|
||||
* @property {import("./Units.js").default|string} [units] Units. Required unless a
|
||||
* proj4 projection is defined for `code`.
|
||||
* @property {import("../extent.js").Extent} [extent] The validity extent for the SRS.
|
||||
* @property {string} [axisOrientation='enu'] The axis orientation as specified in Proj4.
|
||||
* @property {boolean} [global=false] Whether the projection is valid for the whole globe.
|
||||
* @property {number} [metersPerUnit] The meters per unit for the SRS.
|
||||
* If not provided, the `units` are used to get the meters per unit from the {@link module:ol/proj/Units~METERS_PER_UNIT}
|
||||
* lookup table.
|
||||
* @property {import("../extent.js").Extent} [worldExtent] The world extent for the SRS.
|
||||
* @property {function(number, import("../coordinate.js").Coordinate):number} [getPointResolution]
|
||||
* Function to determine resolution at a point. The function is called with a
|
||||
* `number` view resolution and a {@link module:ol/coordinate~Coordinate Coordinate} as arguments, and returns
|
||||
* the `number` resolution in projection units at the passed coordinate. If this is `undefined`,
|
||||
* the default {@link module:ol/proj.getPointResolution getPointResolution()} function will be used.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
* Projection definition class. One of these is created for each projection
|
||||
* supported in the application and stored in the {@link module:ol/proj} namespace.
|
||||
* You can use these in applications, but this is not required, as API params
|
||||
* and options use {@link module:ol/proj~ProjectionLike} which means the simple string
|
||||
* code will suffice.
|
||||
*
|
||||
* You can use {@link module:ol/proj.get} to retrieve the object for a particular
|
||||
* projection.
|
||||
*
|
||||
* The library includes definitions for `EPSG:4326` and `EPSG:3857`, together
|
||||
* with the following aliases:
|
||||
* * `EPSG:4326`: CRS:84, urn:ogc:def:crs:EPSG:6.6:4326,
|
||||
* urn:ogc:def:crs:OGC:1.3:CRS84, urn:ogc:def:crs:OGC:2:84,
|
||||
* http://www.opengis.net/gml/srs/epsg.xml#4326,
|
||||
* urn:x-ogc:def:crs:EPSG:4326
|
||||
* * `EPSG:3857`: EPSG:102100, EPSG:102113, EPSG:900913,
|
||||
* urn:ogc:def:crs:EPSG:6.18:3:3857,
|
||||
* http://www.opengis.net/gml/srs/epsg.xml#3857
|
||||
*
|
||||
* If you use [proj4js](https://github.com/proj4js/proj4js), aliases can
|
||||
* be added using `proj4.defs()`. After all required projection definitions are
|
||||
* added, call the {@link module:ol/proj/proj4.register} function.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
class Projection {
|
||||
/**
|
||||
* @param {Options} options Projection options.
|
||||
*/
|
||||
constructor(options) {
|
||||
/**
|
||||
* @private
|
||||
* @type {string}
|
||||
*/
|
||||
this.code_ = options.code;
|
||||
|
||||
/**
|
||||
* Units of projected coordinates. When set to `TILE_PIXELS`, a
|
||||
* `this.extent_` and `this.worldExtent_` must be configured properly for each
|
||||
* tile.
|
||||
* @private
|
||||
* @type {import("./Units.js").default}
|
||||
*/
|
||||
this.units_ = /** @type {import("./Units.js").default} */ (options.units);
|
||||
|
||||
/**
|
||||
* Validity extent of the projection in projected coordinates. For projections
|
||||
* with `TILE_PIXELS` units, this is the extent of the tile in
|
||||
* tile pixel space.
|
||||
* @private
|
||||
* @type {import("../extent.js").Extent}
|
||||
*/
|
||||
this.extent_ = options.extent !== undefined ? options.extent : null;
|
||||
|
||||
/**
|
||||
* Extent of the world in EPSG:4326. For projections with
|
||||
* `TILE_PIXELS` units, this is the extent of the tile in
|
||||
* projected coordinate space.
|
||||
* @private
|
||||
* @type {import("../extent.js").Extent}
|
||||
*/
|
||||
this.worldExtent_ =
|
||||
options.worldExtent !== undefined ? options.worldExtent : null;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {string}
|
||||
*/
|
||||
this.axisOrientation_ =
|
||||
options.axisOrientation !== undefined ? options.axisOrientation : 'enu';
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.global_ = options.global !== undefined ? options.global : false;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.canWrapX_ = !!(this.global_ && this.extent_);
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {function(number, import("../coordinate.js").Coordinate):number|undefined}
|
||||
*/
|
||||
this.getPointResolutionFunc_ = options.getPointResolution;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {import("../tilegrid/TileGrid.js").default}
|
||||
*/
|
||||
this.defaultTileGrid_ = null;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {number|undefined}
|
||||
*/
|
||||
this.metersPerUnit_ = options.metersPerUnit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {boolean} The projection is suitable for wrapping the x-axis
|
||||
*/
|
||||
canWrapX() {
|
||||
return this.canWrapX_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the code for this projection, e.g. 'EPSG:4326'.
|
||||
* @return {string} Code.
|
||||
* @api
|
||||
*/
|
||||
getCode() {
|
||||
return this.code_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validity extent for this projection.
|
||||
* @return {import("../extent.js").Extent} Extent.
|
||||
* @api
|
||||
*/
|
||||
getExtent() {
|
||||
return this.extent_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the units of this projection.
|
||||
* @return {import("./Units.js").default} Units.
|
||||
* @api
|
||||
*/
|
||||
getUnits() {
|
||||
return this.units_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the amount of meters per unit of this projection. If the projection is
|
||||
* not configured with `metersPerUnit` or a units identifier, the return is
|
||||
* `undefined`.
|
||||
* @return {number|undefined} Meters.
|
||||
* @api
|
||||
*/
|
||||
getMetersPerUnit() {
|
||||
return this.metersPerUnit_ || METERS_PER_UNIT[this.units_];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the world extent for this projection.
|
||||
* @return {import("../extent.js").Extent} Extent.
|
||||
* @api
|
||||
*/
|
||||
getWorldExtent() {
|
||||
return this.worldExtent_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the axis orientation of this projection.
|
||||
* Example values are:
|
||||
* enu - the default easting, northing, elevation.
|
||||
* neu - northing, easting, up - useful for "lat/long" geographic coordinates,
|
||||
* or south orientated transverse mercator.
|
||||
* wnu - westing, northing, up - some planetary coordinate systems have
|
||||
* "west positive" coordinate systems
|
||||
* @return {string} Axis orientation.
|
||||
* @api
|
||||
*/
|
||||
getAxisOrientation() {
|
||||
return this.axisOrientation_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this projection a global projection which spans the whole world?
|
||||
* @return {boolean} Whether the projection is global.
|
||||
* @api
|
||||
*/
|
||||
isGlobal() {
|
||||
return this.global_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set if the projection is a global projection which spans the whole world
|
||||
* @param {boolean} global Whether the projection is global.
|
||||
* @api
|
||||
*/
|
||||
setGlobal(global) {
|
||||
this.global_ = global;
|
||||
this.canWrapX_ = !!(global && this.extent_);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {import("../tilegrid/TileGrid.js").default} The default tile grid.
|
||||
*/
|
||||
getDefaultTileGrid() {
|
||||
return this.defaultTileGrid_;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import("../tilegrid/TileGrid.js").default} tileGrid The default tile grid.
|
||||
*/
|
||||
setDefaultTileGrid(tileGrid) {
|
||||
this.defaultTileGrid_ = tileGrid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the validity extent for this projection.
|
||||
* @param {import("../extent.js").Extent} extent Extent.
|
||||
* @api
|
||||
*/
|
||||
setExtent(extent) {
|
||||
this.extent_ = extent;
|
||||
this.canWrapX_ = !!(this.global_ && extent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the world extent for this projection.
|
||||
* @param {import("../extent.js").Extent} worldExtent World extent
|
||||
* [minlon, minlat, maxlon, maxlat].
|
||||
* @api
|
||||
*/
|
||||
setWorldExtent(worldExtent) {
|
||||
this.worldExtent_ = worldExtent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the getPointResolution function (see {@link module:ol/proj.getPointResolution}
|
||||
* for this projection.
|
||||
* @param {function(number, import("../coordinate.js").Coordinate):number} func Function
|
||||
* @api
|
||||
*/
|
||||
setGetPointResolution(func) {
|
||||
this.getPointResolutionFunc_ = func;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the custom point resolution function for this projection (if set).
|
||||
* @return {function(number, import("../coordinate.js").Coordinate):number|undefined} The custom point
|
||||
* resolution function (if set).
|
||||
*/
|
||||
getPointResolutionFunc() {
|
||||
return this.getPointResolutionFunc_;
|
||||
}
|
||||
}
|
||||
|
||||
export default Projection;
|
||||
82
node_modules/ol/src/proj/Units.js
generated
vendored
Normal file
82
node_modules/ol/src/proj/Units.js
generated
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
/**
|
||||
* @module ol/proj/Units
|
||||
*/
|
||||
|
||||
/**
|
||||
* Projection units: `'degrees'`, `'ft'`, `'m'`, `'pixels'`, `'tile-pixels'` or
|
||||
* `'us-ft'`.
|
||||
* @enum {string}
|
||||
*/
|
||||
const Units = {
|
||||
/**
|
||||
* Radians
|
||||
* @api
|
||||
*/
|
||||
RADIANS: 'radians',
|
||||
/**
|
||||
* Degrees
|
||||
* @api
|
||||
*/
|
||||
DEGREES: 'degrees',
|
||||
/**
|
||||
* Feet
|
||||
* @api
|
||||
*/
|
||||
FEET: 'ft',
|
||||
/**
|
||||
* Meters
|
||||
* @api
|
||||
*/
|
||||
METERS: 'm',
|
||||
/**
|
||||
* Pixels
|
||||
* @api
|
||||
*/
|
||||
PIXELS: 'pixels',
|
||||
/**
|
||||
* Tile Pixels
|
||||
* @api
|
||||
*/
|
||||
TILE_PIXELS: 'tile-pixels',
|
||||
/**
|
||||
* US Feet
|
||||
* @api
|
||||
*/
|
||||
USFEET: 'us-ft',
|
||||
};
|
||||
|
||||
/**
|
||||
* See http://duff.ess.washington.edu/data/raster/drg/docs/geotiff.txt
|
||||
* @type {Object<number, Units>}
|
||||
*/
|
||||
const unitByCode = {
|
||||
'9001': Units.METERS,
|
||||
'9002': Units.FEET,
|
||||
'9003': Units.USFEET,
|
||||
'9101': Units.RADIANS,
|
||||
'9102': Units.DEGREES,
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {number} code Unit code.
|
||||
* @return {Units} Units.
|
||||
*/
|
||||
export function fromCode(code) {
|
||||
return unitByCode[code];
|
||||
}
|
||||
|
||||
/**
|
||||
* Meters per unit lookup table.
|
||||
* @const
|
||||
* @type {Object<Units, number>}
|
||||
* @api
|
||||
*/
|
||||
export const METERS_PER_UNIT = {};
|
||||
// use the radius of the Normal sphere
|
||||
METERS_PER_UNIT[Units.RADIANS] = 6370997 / (2 * Math.PI);
|
||||
METERS_PER_UNIT[Units.DEGREES] = (2 * Math.PI * 6370997) / 360;
|
||||
METERS_PER_UNIT[Units.FEET] = 0.3048;
|
||||
METERS_PER_UNIT[Units.METERS] = 1;
|
||||
METERS_PER_UNIT[Units.USFEET] = 1200 / 3937;
|
||||
|
||||
export default Units;
|
||||
137
node_modules/ol/src/proj/epsg3857.js
generated
vendored
Normal file
137
node_modules/ol/src/proj/epsg3857.js
generated
vendored
Normal file
@@ -0,0 +1,137 @@
|
||||
/**
|
||||
* @module ol/proj/epsg3857
|
||||
*/
|
||||
import Projection from './Projection.js';
|
||||
import Units from './Units.js';
|
||||
import {cosh} from '../math.js';
|
||||
|
||||
/**
|
||||
* Radius of WGS84 sphere
|
||||
*
|
||||
* @const
|
||||
* @type {number}
|
||||
*/
|
||||
export const RADIUS = 6378137;
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {number}
|
||||
*/
|
||||
export const HALF_SIZE = Math.PI * RADIUS;
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {import("../extent.js").Extent}
|
||||
*/
|
||||
export const EXTENT = [-HALF_SIZE, -HALF_SIZE, HALF_SIZE, HALF_SIZE];
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {import("../extent.js").Extent}
|
||||
*/
|
||||
export const WORLD_EXTENT = [-180, -85, 180, 85];
|
||||
|
||||
/**
|
||||
* Maximum safe value in y direction
|
||||
* @const
|
||||
* @type {number}
|
||||
*/
|
||||
export const MAX_SAFE_Y = RADIUS * Math.log(Math.tan(Math.PI / 2));
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
* Projection object for web/spherical Mercator (EPSG:3857).
|
||||
*/
|
||||
class EPSG3857Projection extends Projection {
|
||||
/**
|
||||
* @param {string} code Code.
|
||||
*/
|
||||
constructor(code) {
|
||||
super({
|
||||
code: code,
|
||||
units: Units.METERS,
|
||||
extent: EXTENT,
|
||||
global: true,
|
||||
worldExtent: WORLD_EXTENT,
|
||||
getPointResolution: function (resolution, point) {
|
||||
return resolution / cosh(point[1] / RADIUS);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Projections equal to EPSG:3857.
|
||||
*
|
||||
* @const
|
||||
* @type {Array<import("./Projection.js").default>}
|
||||
*/
|
||||
export const PROJECTIONS = [
|
||||
new EPSG3857Projection('EPSG:3857'),
|
||||
new EPSG3857Projection('EPSG:102100'),
|
||||
new EPSG3857Projection('EPSG:102113'),
|
||||
new EPSG3857Projection('EPSG:900913'),
|
||||
new EPSG3857Projection('http://www.opengis.net/def/crs/EPSG/0/3857'),
|
||||
new EPSG3857Projection('http://www.opengis.net/gml/srs/epsg.xml#3857'),
|
||||
];
|
||||
|
||||
/**
|
||||
* Transformation from EPSG:4326 to EPSG:3857.
|
||||
*
|
||||
* @param {Array<number>} input Input array of coordinate values.
|
||||
* @param {Array<number>} [opt_output] Output array of coordinate values.
|
||||
* @param {number} [opt_dimension] Dimension (default is `2`).
|
||||
* @return {Array<number>} Output array of coordinate values.
|
||||
*/
|
||||
export function fromEPSG4326(input, opt_output, opt_dimension) {
|
||||
const length = input.length;
|
||||
const dimension = opt_dimension > 1 ? opt_dimension : 2;
|
||||
let output = opt_output;
|
||||
if (output === undefined) {
|
||||
if (dimension > 2) {
|
||||
// preserve values beyond second dimension
|
||||
output = input.slice();
|
||||
} else {
|
||||
output = new Array(length);
|
||||
}
|
||||
}
|
||||
for (let i = 0; i < length; i += dimension) {
|
||||
output[i] = (HALF_SIZE * input[i]) / 180;
|
||||
let y = RADIUS * Math.log(Math.tan((Math.PI * (+input[i + 1] + 90)) / 360));
|
||||
if (y > MAX_SAFE_Y) {
|
||||
y = MAX_SAFE_Y;
|
||||
} else if (y < -MAX_SAFE_Y) {
|
||||
y = -MAX_SAFE_Y;
|
||||
}
|
||||
output[i + 1] = y;
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transformation from EPSG:3857 to EPSG:4326.
|
||||
*
|
||||
* @param {Array<number>} input Input array of coordinate values.
|
||||
* @param {Array<number>} [opt_output] Output array of coordinate values.
|
||||
* @param {number} [opt_dimension] Dimension (default is `2`).
|
||||
* @return {Array<number>} Output array of coordinate values.
|
||||
*/
|
||||
export function toEPSG4326(input, opt_output, opt_dimension) {
|
||||
const length = input.length;
|
||||
const dimension = opt_dimension > 1 ? opt_dimension : 2;
|
||||
let output = opt_output;
|
||||
if (output === undefined) {
|
||||
if (dimension > 2) {
|
||||
// preserve values beyond second dimension
|
||||
output = input.slice();
|
||||
} else {
|
||||
output = new Array(length);
|
||||
}
|
||||
}
|
||||
for (let i = 0; i < length; i += dimension) {
|
||||
output[i] = (180 * input[i]) / HALF_SIZE;
|
||||
output[i + 1] =
|
||||
(360 * Math.atan(Math.exp(input[i + 1] / RADIUS))) / Math.PI - 90;
|
||||
}
|
||||
return output;
|
||||
}
|
||||
69
node_modules/ol/src/proj/epsg4326.js
generated
vendored
Normal file
69
node_modules/ol/src/proj/epsg4326.js
generated
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
/**
|
||||
* @module ol/proj/epsg4326
|
||||
*/
|
||||
import Projection from './Projection.js';
|
||||
import Units from './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 {import("../extent.js").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.
|
||||
*/
|
||||
class EPSG4326Projection extends Projection {
|
||||
/**
|
||||
* @param {string} code Code.
|
||||
* @param {string} [opt_axisOrientation] Axis orientation.
|
||||
*/
|
||||
constructor(code, opt_axisOrientation) {
|
||||
super({
|
||||
code: code,
|
||||
units: Units.DEGREES,
|
||||
extent: EXTENT,
|
||||
axisOrientation: opt_axisOrientation,
|
||||
global: true,
|
||||
metersPerUnit: METERS_PER_UNIT,
|
||||
worldExtent: EXTENT,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Projections equal to EPSG:4326.
|
||||
*
|
||||
* @const
|
||||
* @type {Array<import("./Projection.js").default>}
|
||||
*/
|
||||
export const PROJECTIONS = [
|
||||
new EPSG4326Projection('CRS:84'),
|
||||
new EPSG4326Projection('EPSG: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/def/crs/OGC/1.3/CRS84'),
|
||||
new EPSG4326Projection('http://www.opengis.net/gml/srs/epsg.xml#4326', 'neu'),
|
||||
new EPSG4326Projection('http://www.opengis.net/def/crs/EPSG/0/4326', 'neu'),
|
||||
];
|
||||
69
node_modules/ol/src/proj/proj4.js
generated
vendored
Normal file
69
node_modules/ol/src/proj/proj4.js
generated
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
/**
|
||||
* @module ol/proj/proj4
|
||||
*/
|
||||
import Projection from './Projection.js';
|
||||
import Units from './Units.js';
|
||||
import {
|
||||
addCoordinateTransforms,
|
||||
addEquivalentProjections,
|
||||
addProjection,
|
||||
createSafeCoordinateTransform,
|
||||
get,
|
||||
} from '../proj.js';
|
||||
import {get as getTransform} from './transforms.js';
|
||||
|
||||
/**
|
||||
* Make projections defined in proj4 (with `proj4.defs()`) available in
|
||||
* OpenLayers.
|
||||
*
|
||||
* This function should be called whenever changes are made to the proj4
|
||||
* registry, e.g. after calling `proj4.defs()`. Existing transforms will not be
|
||||
* modified by this function.
|
||||
*
|
||||
* @param {?} proj4 Proj4.
|
||||
* @api
|
||||
*/
|
||||
export function register(proj4) {
|
||||
const projCodes = Object.keys(proj4.defs);
|
||||
const len = projCodes.length;
|
||||
let i, j;
|
||||
for (i = 0; i < len; ++i) {
|
||||
const code = projCodes[i];
|
||||
if (!get(code)) {
|
||||
const def = proj4.defs(code);
|
||||
let units = def.units;
|
||||
if (!units && def.projName === 'longlat') {
|
||||
units = Units.DEGREES;
|
||||
}
|
||||
addProjection(
|
||||
new Projection({
|
||||
code: code,
|
||||
axisOrientation: def.axis,
|
||||
metersPerUnit: def.to_meter,
|
||||
units,
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
for (i = 0; i < len; ++i) {
|
||||
const code1 = projCodes[i];
|
||||
const proj1 = get(code1);
|
||||
for (j = 0; j < len; ++j) {
|
||||
const code2 = projCodes[j];
|
||||
const proj2 = get(code2);
|
||||
if (!getTransform(code1, code2)) {
|
||||
if (proj4.defs[code1] === proj4.defs[code2]) {
|
||||
addEquivalentProjections([proj1, proj2]);
|
||||
} else {
|
||||
const transform = proj4(code1, code2);
|
||||
addCoordinateTransforms(
|
||||
proj1,
|
||||
proj2,
|
||||
createSafeCoordinateTransform(proj1, proj2, transform.forward),
|
||||
createSafeCoordinateTransform(proj2, proj1, transform.inverse)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
37
node_modules/ol/src/proj/projections.js
generated
vendored
Normal file
37
node_modules/ol/src/proj/projections.js
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* @module ol/proj/projections
|
||||
*/
|
||||
|
||||
/**
|
||||
* @type {Object<string, import("./Projection.js").default>}
|
||||
*/
|
||||
let cache = {};
|
||||
|
||||
/**
|
||||
* Clear the projections cache.
|
||||
*/
|
||||
export function clear() {
|
||||
cache = {};
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a cached projection by code.
|
||||
* @param {string} code The code for the projection.
|
||||
* @return {import("./Projection.js").default} The projection (if cached).
|
||||
*/
|
||||
export function get(code) {
|
||||
return (
|
||||
cache[code] ||
|
||||
cache[code.replace(/urn:(x-)?ogc:def:crs:EPSG:(.*:)?(\w+)$/, 'EPSG:$3')] ||
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a projection to the cache.
|
||||
* @param {string} code The projection code.
|
||||
* @param {import("./Projection.js").default} projection The projection to cache.
|
||||
*/
|
||||
export function add(code, projection) {
|
||||
cache[code] = projection;
|
||||
}
|
||||
68
node_modules/ol/src/proj/transforms.js
generated
vendored
Normal file
68
node_modules/ol/src/proj/transforms.js
generated
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
/**
|
||||
* @module ol/proj/transforms
|
||||
*/
|
||||
import {isEmpty} from '../obj.js';
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {!Object<string, Object<string, import("../proj.js").TransformFunction>>}
|
||||
*/
|
||||
let transforms = {};
|
||||
|
||||
/**
|
||||
* Clear the transform cache.
|
||||
*/
|
||||
export function clear() {
|
||||
transforms = {};
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a conversion function to convert coordinates from the source
|
||||
* projection to the destination projection.
|
||||
*
|
||||
* @param {import("./Projection.js").default} source Source.
|
||||
* @param {import("./Projection.js").default} destination Destination.
|
||||
* @param {import("../proj.js").TransformFunction} transformFn Transform.
|
||||
*/
|
||||
export function add(source, destination, transformFn) {
|
||||
const sourceCode = source.getCode();
|
||||
const destinationCode = destination.getCode();
|
||||
if (!(sourceCode in transforms)) {
|
||||
transforms[sourceCode] = {};
|
||||
}
|
||||
transforms[sourceCode][destinationCode] = transformFn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters the conversion function to convert coordinates from the source
|
||||
* projection to the destination projection. This method is used to clean up
|
||||
* cached transforms during testing.
|
||||
*
|
||||
* @param {import("./Projection.js").default} source Source projection.
|
||||
* @param {import("./Projection.js").default} destination Destination projection.
|
||||
* @return {import("../proj.js").TransformFunction} transformFn The unregistered transform.
|
||||
*/
|
||||
export function remove(source, destination) {
|
||||
const sourceCode = source.getCode();
|
||||
const destinationCode = destination.getCode();
|
||||
const transform = transforms[sourceCode][destinationCode];
|
||||
delete transforms[sourceCode][destinationCode];
|
||||
if (isEmpty(transforms[sourceCode])) {
|
||||
delete transforms[sourceCode];
|
||||
}
|
||||
return transform;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a transform given a source code and a destination code.
|
||||
* @param {string} sourceCode The code for the source projection.
|
||||
* @param {string} destinationCode The code for the destination projection.
|
||||
* @return {import("../proj.js").TransformFunction|undefined} The transform function (if found).
|
||||
*/
|
||||
export function get(sourceCode, destinationCode) {
|
||||
let transform;
|
||||
if (sourceCode in transforms && destinationCode in transforms[sourceCode]) {
|
||||
transform = transforms[sourceCode][destinationCode];
|
||||
}
|
||||
return transform;
|
||||
}
|
||||
Reference in New Issue
Block a user