Skip to content

Commit

Permalink
fix(crs): fix proj4 unit 'meter' and add 'foot'
Browse files Browse the repository at this point in the history
  • Loading branch information
ftoromanoff authored and Desplandis committed Dec 20, 2024
1 parent b81e8e9 commit 07c3f63
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Core/Geographic/Crs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ export const UNIT = {
* Distance unit in meter.
*/
METER: 2,
/**
* Distance unit in foot.
*/
FOOT: 3,
} as const;

/**
Expand All @@ -56,8 +60,10 @@ export function is4326(crs: ProjectionLike) {
function unitFromProj4Unit(proj: ProjectionDefinition) {
if (proj.units === 'degrees') {
return UNIT.DEGREE;
} else if (proj.units === 'm') {
} else if (proj.units === 'm' || proj.units === 'meter') {
return UNIT.METER;
} else if (proj.units === 'foot') {
return UNIT.FOOT;
} else if (proj.units === undefined && proj.to_meter === undefined) {
// See https://proj.org/en/9.4/usage/projections.html [17/10/2024]
// > The default unit for projected coordinates is the meter.
Expand All @@ -71,7 +77,7 @@ function unitFromProj4Unit(proj: ProjectionDefinition) {
* Returns the horizontal coordinates system units associated with this CRS.
*
* @param crs - The CRS to extract the unit from.
* @returns Either `UNIT.METER`, `UNIT.DEGREE` or `undefined`.
* @returns Either `UNIT.METER`, `UNIT.DEGREE`, `UNIT.FOOT` or `undefined`.
*/
export function getUnit(crs: ProjectionLike) {
mustBeString(crs);
Expand Down

0 comments on commit 07c3f63

Please sign in to comment.