From e897be116a51d47cf1b73c64d4651e40d11f8338 Mon Sep 17 00:00:00 2001 From: AlexNRCan Date: Wed, 18 Dec 2024 10:46:32 -0500 Subject: [PATCH] Better support for either 4326 and CRS:84 distinctly --- .../geoview-core/src/geo/utils/projection.ts | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/packages/geoview-core/src/geo/utils/projection.ts b/packages/geoview-core/src/geo/utils/projection.ts index cacad26bfc6..0f55d2be8dd 100644 --- a/packages/geoview-core/src/geo/utils/projection.ts +++ b/packages/geoview-core/src/geo/utils/projection.ts @@ -22,10 +22,6 @@ import { TypeJsonObject } from '@/core/types/global-types'; * @class Projection */ export abstract class Projection { - /** - * constant for the CRS84 URL - */ - static CRS_84_URL = 'http://www.opengis.net/def/crs/OGC/1.3/CRS84'; /** * constant used for the available projection names @@ -40,6 +36,7 @@ export abstract class Projection { WM: 'EPSG:3857', 4269: 'EPSG:4269', LNGLAT: 'EPSG:4326', + CRS84: 'CRS:84', // Supporting CRS:84 which is equivalent to 4326 except it's long-lat, whereas the 4326 standard is lat-long. CSRS: 'EPSG:4617', CSRS98: 'EPSG:4140', }; @@ -323,13 +320,23 @@ export abstract class Projection { * Initializes the CRS84 Projection */ function initCRS84Projection(): void { - const newDefinition = proj4.defs(Projection.PROJECTION_NAMES.LNGLAT); - newDefinition.axis = 'neu'; - proj4.defs(Projection.CRS_84_URL, newDefinition); + // define 3978 projection + proj4.defs(Projection.PROJECTION_NAMES.CRS84, '+proj=longlat +datum=WGS84 +no_defs +type=crs'); + register(proj4); - const projection = olGetProjection(Projection.CRS_84_URL); + const projection = olGetProjection(Projection.PROJECTION_NAMES.CRS84); + if (projection) Projection.PROJECTIONS['CRS:84'] = projection; +} + +/** + * Initializes the 4326 Projection + */ +function init4326Projection(): void { + proj4.defs(Projection.PROJECTION_NAMES.LNGLAT, '+proj=longlat +datum=WGS84 +no_defs +type=crs'); + register(proj4); - if (projection) Projection.PROJECTIONS[Projection.CRS_84_URL] = projection; + const projection = olGetProjection(Projection.PROJECTION_NAMES.LNGLAT); + if (projection) Projection.PROJECTIONS['4326'] = projection; } /** @@ -469,6 +476,7 @@ function init102190Projection(): void { // Initialize the supported projections initCRS84Projection(); +init4326Projection(); initWMProjection(); initLCCProjection(); initCSRSProjection();