Skip to content

Algorithm generates wrong results due to limits on double type #119

@davideder

Description

@davideder

If you try to find the polylabel for the following polygon, it fails to find a good point.

-111.1815838, 45.7768091
-111.1816944, 45.7766950
-111.1812484, 45.7764847
-111.1811378, 45.7765988

It does not matter what precision you use. It does drill down to a point, but it is not right.

This is due to limitations in the double type.

The solution is to subtract the min of the bounding box before doing the remaining calculations, and then add it back at the end. This does seem to fix the problem in my tests, and shouldn't add much in execution time.

Also, it would also be best to calculate the bounding box for all rings to better avoid this problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions