Skip to content

Commit

Permalink
Better support for either 4326 and CRS:84 distinctly
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex-NRCan committed Dec 18, 2024
1 parent 654878e commit e897be1
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions packages/geoview-core/src/geo/utils/projection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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',
};
Expand Down Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -469,6 +476,7 @@ function init102190Projection(): void {

// Initialize the supported projections
initCRS84Projection();
init4326Projection();
initWMProjection();
initLCCProjection();
initCSRSProjection();
Expand Down

0 comments on commit e897be1

Please sign in to comment.