Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

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

Merged
merged 15 commits into from
Aug 19, 2024
Prev Previous commit
turf 6.5
  • Loading branch information
birkskyum committed Aug 19, 2024
commit a6e151a67e6a3b184070d1a281c75ef842e60161
2 changes: 1 addition & 1 deletion 2 draftlogs/7115_fix.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
- Fix centroid calculation and update turf.js to v7 [[#7115](https://github.com/plotly/plotly.js/pull/7115)], with thanks to @birkskyum for the contribution!
- Fix centroid calculation in turf [[#7115](https://github.com/plotly/plotly.js/pull/7115)], with thanks to @birkskyum for the contribution!

birkskyum marked this conversation as resolved.
Show resolved Hide resolved
72 changes: 25 additions & 47 deletions 72 package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions 6 package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@
"@plotly/d3-sankey": "0.7.2",
"@plotly/d3-sankey-circular": "0.33.1",
"@plotly/mapbox-gl": "1.13.4",
"@turf/area": "^7.1.0",
"@turf/bbox": "^7.1.0",
"@turf/centroid": "^7.1.0",
"@turf/area": "^6.5.0",
"@turf/bbox": "^6.5.0",
"@turf/centroid": "^6.5.0",
"base64-arraybuffer": "^1.0.2",
"canvas-fit": "^1.5.0",
"color-alpha": "1.0.4",
Expand Down
12 changes: 6 additions & 6 deletions 12 src/lib/geo_location_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

var d3 = require('@plotly/d3');
var countryRegex = require('country-regex');
var { area: turfArea } = require('@turf/area');
var { centroid: turfCentroid } = require('@turf/centroid');
var { bbox: turfBbox } = require('@turf/bbox');
var turfArea = require('@turf/area');
var turfCentroid = require('@turf/centroid');
var turfBbox = require('@turf/bbox');

var identity = require('./identity');
var loggers = require('./loggers');
Expand Down Expand Up @@ -295,7 +295,7 @@ function findCentroid(feature) {

for(var i = 0; i < coords.length; i++) {
var polyi = {type: 'Polygon', coordinates: coords[i]};
var area = turfArea(polyi);
var area = turfArea.default(polyi);
if(area > maxArea) {
maxArea = area;
poly = polyi;
Expand All @@ -305,7 +305,7 @@ function findCentroid(feature) {
poly = geometry;
}

return turfCentroid(poly).geometry.coordinates;
return turfCentroid.default(poly).geometry.coordinates;
}

function fetchTraceGeoData(calcData) {
Expand Down Expand Up @@ -366,7 +366,7 @@ function fetchTraceGeoData(calcData) {
// TODO `turf/bbox` gives wrong result when the input feature/geometry
// crosses the anti-meridian. We should try to implement our own bbox logic.
function computeBbox(d) {
return turfBbox(d);
return turfBbox.default(d);
}

module.exports = {
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.