-
Notifications
You must be signed in to change notification settings - Fork 75
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
Conversation
@matthewma7 Would this be useful as a stand-alone function in utils? It could be named something like |
@manthey Yes, I think this could be useful, at this moment I have a use case for it. |
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.
Add more tests.
42d552f
to
bff9e1a
Compare
This removes the burden on binding events to the class instance.
* @returns {geo.geoPosition|undefined} The position for the center, or | ||
* `undefined` if no such position exists. | ||
*/ | ||
centerFromPerimeter: function (coor) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGMT 👍
Shift many references in annotations code of this to m_this.
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.