apache / apache/sedona

ST_MakeValid changes the order of points in a polygon

Open
#1,754 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
2.4k
Forks
784
Avg merge
1d 12h
Merged PRs (30d)
58

Description

I think that all polygons in OSM and other datasets are supposed to be ordered in such a way that the points in the polygon are listed in counter clockwise direction.

Here is an example. I gave it this polygon:
POLYGON ((10.947076 45.9679118, 10.9471748 45.967871, 10.9472574 45.9679588, 10.9471571 45.9680032, 10.947076 45.9679118))

And asked it to apply ST_MakeValid on it and it gave me this:
POLYGON ((10.947076 45.9679118, 10.9471571 45.9680032, 10.9472574 45.9679588, 10.9471748 45.967871, 10.947076 45.9679118))

Here is a picture of that polygon with the first (and last) node highlited.
![Image](https://github.com/user-attachments/assets/2b642675-0061-4fcb-8422-763f61485fc7)

Here is a picture of that same polygon with the first and second point of the original polygon highlighted showing that the order indicates that it is counter-clockwise - This is correct!
![Image](https://github.com/user-attachments/assets/72178994-6e7e-426c-9a39-3bfc257053bf)

Here is a picture of that same polygon with the first and second point of the polygon that was created with ST_MakeValid highlighted showing that the order indicates that it is clockwise - This is Wrong!
![Image](https://github.com/user-attachments/assets/0a04119e-caeb-4d58-8325-e6384fa462b3)

Contributor guide

Open the contributing guide

Research direction

Start by locating the ST_MakeValid entry point in Apache Sedona and reproduce the issue with the polygon WKT in the report. Compare the input and output point ordering; done means valid polygons retain the expected counter-clockwise ordering.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
data
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.