Add method to compute a polygon centroid, for label placement

Authored by vkrause on May 23 2020, 1:43 PM.

Description

Add method to compute a polygon centroid, for label placement

While fairly simple math as such, the challenge is to get this numerically
stable for coordinates with sub-meter precision on a world-scale.
Appropriate scaling of the input polygon and 64bit arithmetic on temporary
values seem to help sufficiently for our use-case.

Placing area labels using this brings a significant improvement over
the current way of using the bounding box center, e.g. for curved
platforms. It's still not ideal for more complex shapes, or for shapes
where the centroid is not actually on the polygon itself. For this we
need a full "pole of inaccessibility" algorithm, but that internally
also needs centroid computation, so this is a useful intermediate step
either way.

Details

Committed
vkrauseMay 23 2020, 1:43 PM
Parents
R1032:312dd0607e22: Ignore layers when their value matches the current level
Branches
Unknown
Tags
Unknown