You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
775 B
38 lines
775 B
/**
|
|
* @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;
|
|
}
|