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

Use the average perimeter as the center of a polygon or line. #761

Merged
merged 7 commits into from
Feb 7, 2018

Conversation

manthey
Copy link
Contributor

@manthey manthey commented Jan 15, 2018

When a polygon has many points near each other in one area and few along the opposite part of the perimeter, this produces a nicer center.

@manthey
Copy link
Contributor Author

manthey commented Jan 16, 2018

@matthewma7 Would this be useful as a stand-alone function in utils? It could be named something like utils.centerFromPerimeter(arrayOfPoints) where the points are objects with x, y values.

@matthewma7
Copy link

@manthey Yes, I think this could be useful, at this moment I have a use case for it.
I think the function signature you suggested looks good.

When a polygon has many points near each other in one area and few along
the opposite part of the perimeter, this produces a nicer center.
This removes the burden on binding events to the class instance.
@manthey manthey mentioned this pull request Jan 25, 2018
* @returns {geo.geoPosition|undefined} The position for the center, or
* `undefined` if no such position exists.
*/
centerFromPerimeter: function (coor) {
Copy link
Member

Choose a reason for hiding this comment

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

@manthey it would be good to describe the math in words to explain what is done in this snippet.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@aashish24 I added a bit more to the function comment.

Copy link
Member

Choose a reason for hiding this comment

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

thanks, I found it useful.

Copy link
Member

@aashish24 aashish24 left a comment

Choose a reason for hiding this comment

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

LGMT 👍

@manthey manthey merged commit 9d03dfd into master Feb 7, 2018
@manthey manthey deleted the center-of-polygon branch February 7, 2018 13:16
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.

3 participants