-
Notifications
You must be signed in to change notification settings - Fork 75
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
Update to the latest proj4. #873
Conversation
proj4 now uses rollup, which changes how it gets imported. proj4 is now pickier about coordinates. Before it accepted a string and cast it to a float. Now it must be cast before hand.
proj4.Proj.projections.add(require('proj4/projections/ortho')); | ||
proj4 = proj4.__esModule ? proj4.default : proj4; | ||
/* Ensure all projections in proj4 are included. */ | ||
var projections = require.context('proj4/projections', true, /.*\.js$/); |
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.
👍
@@ -254,7 +255,7 @@ transform.transformCoordinates = function ( | |||
|
|||
var trans = transform({source: srcPrj, target: tgtPrj}), output; | |||
if (util.isObject(coordinates) && 'x' in coordinates && 'y' in coordinates) { | |||
output = trans.forward({x: coordinates.x, y: coordinates.y, z: coordinates.z || 0}); | |||
output = trans.forward({x: +coordinates.x, y: +coordinates.y, z: +coordinates.z || 0}); |
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.
curious ..what does plus do here?
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.
@manthey the reason I did not approve it earlier, as I had a question on the signs. I approve it now, but still curious. is that because of the notation that is now enforced?
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.
+
casts a string to a float but does nothing to a float. It is cheaper than Number(<string or number>)
.
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.
A quick test shows the +
takes 60% of the time of Number
.
proj4 now uses rollup, which changes how it gets imported.
proj4 is now pickier about coordinates. Before it accepted a string and cast it to a float. Now it must be cast before hand.