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

booleanEqual() sometimes outputs false by internal cleanCoords() #2406

Open
naoak opened this issue Mar 2, 2023 · 1 comment · May be fixed by #2771
Open

booleanEqual() sometimes outputs false by internal cleanCoords() #2406

naoak opened this issue Mar 2, 2023 · 1 comment · May be fixed by #2771
Assignees

Comments

@naoak
Copy link

naoak commented Mar 2, 2023

Both of these polygons have the same shape and are in the same location. The length of the coordinates is also the same. The only difference is the order of the coordinates.

A:

{
  "type": "Feature", 
  "properties": {},
  "geometry": {
    "type": "Polygon",
    "coordinates": [
      [
        [1, 3], [3, 3], [3, 1], [3, -3], [-3, -3], [-3, 3], [1, 3]
      ]
    ]
  }
}

B:

{
  "type": "Feature",
  "properties": {},
  "geometry": {
    "type": "Polygon",
    "coordinates": [
      [
        [-3, -3], [-3, 3], [1, 3], [3, 3], [3, 1], [3, -3], [-3, -3]
      ]
    ]
  }
}

cleanCoords() drops [3,1] from A, whereas it does [1,3] and [3,1] from B. Therefore, the lengths of the coordinates are different and the result of booleanEqual is false. In polygon A, [1,3] is at the starting point, so it seems to make that difference.

@smallsaucepan
Copy link
Member

This is an interesting case. cleanCoords effectively refuses to clean a redundant point if it's the start or end point of a polygon.

Taking example A above as polygon a-b-c-d-e-f-a and running cleanCoords:

clean-coords

Giving us a-b-d-e-f-a. Technically though, that polygon is really only defined by b-d-e-f-b, so a is still a redundant point.

On paper I would say this is a bug in cleanCoords. There shouldn't be any protected status offered to the start or end point of a polygon.

@smallsaucepan smallsaucepan self-assigned this Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants