-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: support xy and yx ordering when generating tile matrixes
- Loading branch information
Showing
4 changed files
with
22 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,26 @@ | ||
import { Epsg } from './epsg.js'; | ||
import { Epsg, EpsgCode } from './epsg.js'; | ||
|
||
/** | ||
* Order of X & Y coordinates when defined as a array | ||
* | ||
* `[x,y]` vs `[y,x]` | ||
*/ | ||
export enum XyOrder { | ||
/** [x, y] */ | ||
Xy, | ||
/** [y, x] */ | ||
Yx, | ||
} | ||
export type XyOrder = 'xy' | 'yx'; | ||
|
||
/** | ||
* Get the X & Y coordinate order for a given EPSG | ||
* @param epsg EPSG to lookup | ||
*/ | ||
export function getXyOrder(epsg: Epsg): XyOrder { | ||
export function getXyOrder(epsg: Epsg | EpsgCode): XyOrder { | ||
const code = typeof epsg === 'number' ? epsg : epsg.code; | ||
/** | ||
* [EPSG:2193](https://www.opengis.net/def/crs/EPSG/0/2193) (NZTM) is defined in [y, x] | ||
* - [EPSG:2193](https://www.opengis.net/def/crs/EPSG/0/2193) (NZTM) is defined in [y, x] | ||
* - [EPSG:3793](https://www.opengis.net/def/crs/EPSG/0/3793) (CITM) is defined in [y, x] | ||
* specified by the coordinate system [cs:4500](https://www.opengis.net/def/cs/EPSG/0/4500) | ||
*/ | ||
if (epsg === Epsg.Nztm2000) { | ||
return XyOrder.Yx; | ||
} | ||
if (code === EpsgCode.Nztm2000 || code === EpsgCode.Citm2000) return 'yx'; | ||
|
||
// TODO there are other projections that are YX | ||
return XyOrder.Xy; | ||
// TODO there are other projections that are YX, | ||
// TileMatrixSet v2 specification includes Xy ordering, https://docs.ogc.org/is/17-083r4/21-066r1.html#_adding_optional_orderedaxes_to_highlight_crs_axis_ordering | ||
return 'xy'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters