-
Notifications
You must be signed in to change notification settings - Fork 303
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
refacto: migrate Crs to typescript #2436
base: master
Are you sure you want to change the base?
Conversation
54c4243
to
54d3317
Compare
54d3317
to
b6e923f
Compare
06fa1e1
to
33c57e4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks :) Nice to see that we are moving forward on this migration 👍
While we're at it, I would be down for renaming some functions to make their name clearer:
toUnit
->getUnit
reasonnableEpsilon
->reasonableEpsilon
formatToEPSG
->formatToEpsg
(to be consistent with capital letters in other methods). Or use capitals in all methods with EPSG and TMS.
I would also make private is4326
.
Also, we could add a isDegreeUnit
since we expose a isMetricUnit
.
/** | ||
* A projection as a CRS identifier string. | ||
*/ | ||
export type ProjectionLike = string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we export it in the doc ? Also, the comment is not complete as it can either be a crs identifier or a wkt string describing the projection and passed directly to proj4 (in isGeocentric for instance)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, we should export it in the documentation since this is the type of the argument of some functions of the CRS
module.
I think the documentation is complete, this is an identifier referencing an already defined projection (I should maybe add this to the documentation). In isGeocentric
, the call to proj4.defs
is only for retrieving an already defined projection as an object of type proj4.ProjectionDefinition
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moreover, I added such type alias since we'll surely want in a near future to have a ProjectionLike
either as an identifier or an proj4.ProjectionDefinition
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh ok thanks, proj4.defs
is quite misleading 😅
I just checked and it is not exported in the doc though, you may need to add a @typedef tag like for CameraTransformOptions? : @typedef {Object} CameraTransformOptions
Also, I'm wandering if it should appear in the Crs doc page or have its own page or be in a Types
page, WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The equivalent of typedef in typescript or either an interface
or a type
. Instead of being in the documentation, we can write the types directly.
553960b
to
7d3138b
Compare
@jailln I fixed all issues listed in your review. I added an
Done, shall I mark it as breaking change though?
I chose to kept the old name since we'll surely remove it due to the reasons above.
|
7d3138b
to
ca2f245
Compare
Thanks for the changes :)
I would be clearer to only use the EPSG naming scheme yes.
I'm not sure it is used but we might add a breaking change to the commit message just in case. |
ca2f245
to
e275eac
Compare
Okay, I went a little bit further and removed the two naming schemes (which were not needed since #2412). This means that all I don't think they are used outside of the codebase IMO. As for the documentation, |
Description
This PR includes:
Crs
from javascript to typescriptProjectionLike
type alias for named CRS which could be later extended as either a string or aproj4
definition object (à la OpenLayer)Motivation and Context
As described in proposal #2396, we aim to gradually migrate our entire codebase (with the exception of deprecated modules) from javascript to typescript. We choose to start with modules with no-dependency and move up in the dependency tree.
This PR is the first step of Migrate geographic modules, migrating the base module
Crs
. Follow-up steps includes migration of dependent modulesCoordinates/Ellipsoid
andExtent
.