Skip to content

Commit 07c3f63

Browse files
ftoromanoffDesplandis
authored andcommitted
fix(crs): fix proj4 unit 'meter' and add 'foot'
1 parent b81e8e9 commit 07c3f63

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/Core/Geographic/Crs.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ export const UNIT = {
4141
* Distance unit in meter.
4242
*/
4343
METER: 2,
44+
/**
45+
* Distance unit in foot.
46+
*/
47+
FOOT: 3,
4448
} as const;
4549

4650
/**
@@ -56,8 +60,10 @@ export function is4326(crs: ProjectionLike) {
5660
function unitFromProj4Unit(proj: ProjectionDefinition) {
5761
if (proj.units === 'degrees') {
5862
return UNIT.DEGREE;
59-
} else if (proj.units === 'm') {
63+
} else if (proj.units === 'm' || proj.units === 'meter') {
6064
return UNIT.METER;
65+
} else if (proj.units === 'foot') {
66+
return UNIT.FOOT;
6167
} else if (proj.units === undefined && proj.to_meter === undefined) {
6268
// See https://proj.org/en/9.4/usage/projections.html [17/10/2024]
6369
// > The default unit for projected coordinates is the meter.
@@ -71,7 +77,7 @@ function unitFromProj4Unit(proj: ProjectionDefinition) {
7177
* Returns the horizontal coordinates system units associated with this CRS.
7278
*
7379
* @param crs - The CRS to extract the unit from.
74-
* @returns Either `UNIT.METER`, `UNIT.DEGREE` or `undefined`.
80+
* @returns Either `UNIT.METER`, `UNIT.DEGREE`, `UNIT.FOOT` or `undefined`.
7581
*/
7682
export function getUnit(crs: ProjectionLike) {
7783
mustBeString(crs);

0 commit comments

Comments
 (0)