Use regexp replacements in ol.proj.get

This avoids to have to many redundant identifier definitions for each projection and ensure to cover most of the existing srsNames
This commit is contained in:
Florent gravin
2020-09-07 17:06:44 +02:00
parent 8eb5ac900d
commit 5d8aa85caa
5 changed files with 8 additions and 19 deletions

View File

@@ -64,8 +64,6 @@ export const PROJECTIONS = [
new EPSG3857Projection('EPSG:102100'),
new EPSG3857Projection('EPSG:102113'),
new EPSG3857Projection('EPSG:900913'),
new EPSG3857Projection('urn:ogc:def:crs:EPSG:6.18:3:3857'),
new EPSG3857Projection('urn:ogc:def:crs:EPSG::3857'),
new EPSG3857Projection('http://www.opengis.net/gml/srs/epsg.xml#3857'),
];

View File

@@ -61,11 +61,7 @@ class EPSG4326Projection extends 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'),
new EPSG4326Projection('urn:x-ogc:def:crs:EPSG:6.6:4326', 'neu'),
];

View File

@@ -20,7 +20,11 @@ export function clear() {
* @return {import("./Projection.js").default} The projection (if cached).
*/
export function get(code) {
return cache[code] || null;
return (
cache[code] ||
cache[code.replace(/urn:(x-)?ogc:def:crs:EPSG:(.*:)?(\w+)$/, 'EPSG:$3')] ||
null
);
}
/**