Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(layer-projection) Added support for the CRS:84 projection #2667

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions packages/geoview-core/src/geo/utils/projection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +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 +35,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 +319,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 +475,7 @@ function init102190Projection(): void {

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