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

Fix centroid calculation. Bump turf to v6.5 #7115

Merged
merged 15 commits into from
Aug 19, 2024
Merged

Conversation

birkskyum
Copy link
Contributor

@birkskyum birkskyum commented Aug 19, 2024

Update turf to v6.5.

This fixes a bug where the centroid calculation erroneously would include the first point of a polygon twice, thus giving it double weight. Single- and Multi-polygon tests are updates

Changelog

@archmoj
Copy link
Contributor

archmoj commented Aug 19, 2024

Thanks for the PR.
Please add a change log entry in draftlogs for this one.
I expect some jasmine tests to fail which you could help debug and adjust.

@birkskyum
Copy link
Contributor Author

birkskyum commented Aug 19, 2024

Found a bug in the centroid tests, that I've fixed (both single and multipolygon tests affected). In geojson, the first and last vertex of a polygon has the same coordinates, so the first or last element should be ignored in the centroid math.

draftlogs/7115_change.md Outdated Show resolved Hide resolved
@archmoj
Copy link
Contributor

archmoj commented Aug 19, 2024

Please update the PR title and description to mention the bug fix.
Thank you.

@birkskyum birkskyum changed the title Bump turf v6 -> v7 Fix centroid calculation. Bump turf v6 -> v7 Aug 19, 2024
var turfArea = require('@turf/area');
var turfCentroid = require('@turf/centroid');
var turfBbox = require('@turf/bbox');
var { area: turfArea } = require('@turf/area');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering how these imports are transpiled in to the dist?
May I ask you to test the dist from CI on the plotly.py side?

Copy link
Contributor Author

@birkskyum birkskyum Aug 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless minified will they be kept as a destructuring assignment (plotly-geo.js bundle):

var {
  area: turfArea
} = __webpack_require__(9532);

Not sure how to run it in python

@archmoj
Copy link
Contributor

archmoj commented Aug 19, 2024

How about just fixing the bug in this PR and bump to latest v6 packages and then make the move from v6 to v7 in a separate PR (which may require additional testing)?

@birkskyum birkskyum changed the title Fix centroid calculation. Bump turf v6 -> v7 Fix centroid calculation. Bump turf 6.5 Aug 19, 2024
@birkskyum
Copy link
Contributor Author

It's rolled back to 6.5 now with the bugfix

@birkskyum birkskyum changed the title Fix centroid calculation. Bump turf 6.5 Fix centroid calculation. Bump turf to 6.5 Aug 19, 2024
@birkskyum birkskyum changed the title Fix centroid calculation. Bump turf to 6.5 Fix centroid calculation. Bump turf to v6.5 Aug 19, 2024
@birkskyum
Copy link
Contributor Author

birkskyum commented Aug 19, 2024

Only the usual suspects break, so I consider it CI Green

@archmoj archmoj merged commit 634293a into plotly:master Aug 19, 2024
1 check failed
@archmoj
Copy link
Contributor

archmoj commented Aug 19, 2024

Please open your new PR for v7.
Thank you.

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