Skip to content
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

Merged
merged 2 commits into from
Jul 27, 2018
Merged

Update to the latest proj4. #873

merged 2 commits into from
Jul 27, 2018

Conversation

manthey
Copy link
Contributor

@manthey manthey commented Jul 24, 2018

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 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$/);
Copy link
Member

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});
Copy link
Member

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?

Copy link
Member

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?

Copy link
Contributor Author

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>).

Copy link
Contributor Author

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.

@manthey manthey merged commit 733388b into master Jul 27, 2018
@manthey manthey deleted the proj4-2.4 branch July 27, 2018 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants