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:
@@ -64,8 +64,6 @@ export const PROJECTIONS = [
|
|||||||
new EPSG3857Projection('EPSG:102100'),
|
new EPSG3857Projection('EPSG:102100'),
|
||||||
new EPSG3857Projection('EPSG:102113'),
|
new EPSG3857Projection('EPSG:102113'),
|
||||||
new EPSG3857Projection('EPSG:900913'),
|
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'),
|
new EPSG3857Projection('http://www.opengis.net/gml/srs/epsg.xml#3857'),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -61,11 +61,7 @@ class EPSG4326Projection extends Projection {
|
|||||||
export const PROJECTIONS = [
|
export const PROJECTIONS = [
|
||||||
new EPSG4326Projection('CRS:84'),
|
new EPSG4326Projection('CRS:84'),
|
||||||
new EPSG4326Projection('EPSG:4326', 'neu'),
|
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:1.3:CRS84'),
|
||||||
new EPSG4326Projection('urn:ogc:def:crs:OGC:2:84'),
|
new EPSG4326Projection('urn:ogc:def:crs:OGC:2:84'),
|
||||||
new EPSG4326Projection('http://www.opengis.net/gml/srs/epsg.xml#4326', 'neu'),
|
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'),
|
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -20,7 +20,11 @@ export function clear() {
|
|||||||
* @return {import("./Projection.js").default} The projection (if cached).
|
* @return {import("./Projection.js").default} The projection (if cached).
|
||||||
*/
|
*/
|
||||||
export function get(code) {
|
export function get(code) {
|
||||||
return cache[code] || null;
|
return (
|
||||||
|
cache[code] ||
|
||||||
|
cache[code.replace(/urn:(x-)?ogc:def:crs:EPSG:(.*:)?(\w+)$/, 'EPSG:$3')] ||
|
||||||
|
null
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -369,10 +369,7 @@ export function optionsFromCapabilities(wmtsCap, config) {
|
|||||||
return el['Identifier'] == elt['TileMatrixSet'];
|
return el['Identifier'] == elt['TileMatrixSet'];
|
||||||
});
|
});
|
||||||
const supportedCRS = tileMatrixSet['SupportedCRS'];
|
const supportedCRS = tileMatrixSet['SupportedCRS'];
|
||||||
const proj1 =
|
const proj1 = getProjection(supportedCRS);
|
||||||
getProjection(
|
|
||||||
supportedCRS.replace(/urn:ogc:def:crs:(\w+):(.*:)?(\w+)$/, '$1:$3')
|
|
||||||
) || getProjection(supportedCRS);
|
|
||||||
const proj2 = getProjection(config['projection']);
|
const proj2 = getProjection(config['projection']);
|
||||||
if (proj1 && proj2) {
|
if (proj1 && proj2) {
|
||||||
return equivalent(proj1, proj2);
|
return equivalent(proj1, proj2);
|
||||||
@@ -434,10 +431,7 @@ export function optionsFromCapabilities(wmtsCap, config) {
|
|||||||
let projection;
|
let projection;
|
||||||
const code = matrixSetObj['SupportedCRS'];
|
const code = matrixSetObj['SupportedCRS'];
|
||||||
if (code) {
|
if (code) {
|
||||||
projection =
|
projection = getProjection(code);
|
||||||
getProjection(
|
|
||||||
code.replace(/urn:ogc:def:crs:(\w+):(.*:)?(\w+)$/, '$1:$3')
|
|
||||||
) || getProjection(code);
|
|
||||||
}
|
}
|
||||||
if ('projection' in config) {
|
if ('projection' in config) {
|
||||||
const projConfig = getProjection(config['projection']);
|
const projConfig = getProjection(config['projection']);
|
||||||
|
|||||||
@@ -124,10 +124,7 @@ export function createFromCapabilitiesMatrixSet(
|
|||||||
const tileHeightPropName = 'TileHeight';
|
const tileHeightPropName = 'TileHeight';
|
||||||
|
|
||||||
const code = matrixSet[supportedCRSPropName];
|
const code = matrixSet[supportedCRSPropName];
|
||||||
const projection =
|
const projection = getProjection(code);
|
||||||
getProjection(
|
|
||||||
code.replace(/urn:ogc:def:crs:(\w+):(.*:)?(\w+)$/, '$1:$3')
|
|
||||||
) || getProjection(code);
|
|
||||||
const metersPerUnit = projection.getMetersPerUnit();
|
const metersPerUnit = projection.getMetersPerUnit();
|
||||||
// swap origin x and y coordinates if axis orientation is lat/long
|
// swap origin x and y coordinates if axis orientation is lat/long
|
||||||
const switchOriginXY = projection.getAxisOrientation().substr(0, 2) == 'ne';
|
const switchOriginXY = projection.getAxisOrientation().substr(0, 2) == 'ne';
|
||||||
|
|||||||
Reference in New Issue
Block a user