Sitelet https://web.archive.org/web/20210124124617/https://github.com/Turfjs/turf/issues/1539
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

Wrong centroid calculation #1539

Closed
raviqqe opened this issue Nov 30, 2018 · 3 comments
Closed

Wrong centroid calculation #1539

raviqqe opened this issue Nov 30, 2018 · 3 comments
Assignees

Comments

@raviqqe
Copy link

@raviqqe raviqqe commented Nov 30, 2018 •

import { centroid, polygon } from "@turf/turf";

console.log(centroid(polygon([[[-1, -1], [1, -1], [1, 1], [-1, 1], [-1, -1]]])));

The result should be a point at (0, 0) but is actually (-0.2, -0.2). The algorithm is using the enclosing point twice.

@rowanwins
Copy link
Member

@rowanwins rowanwins commented Dec 3, 2018

Great pickup thanks @raviqqe

I'll get a fix for this within the v7 branch and add a test.

@rowanwins rowanwins self-assigned this Dec 3, 2018
rowanwins pushed a commit that referenced this issue Dec 4, 2018
@vomc
Copy link

@vomc vomc commented Jul 29, 2019

This is probably in development, but I just made a Fiddle using 7.0.0-alpha.1 and the centroid still seems off: https://jsfiddle.net/9z37srjb/3/

@rowanwins
Copy link
Member

@rowanwins rowanwins commented Jul 30, 2019

Yeah the change hasn't been released yet @vomc , it was added after the 7.0.0-alpha.1 release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

3 participants