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

Block clockwise WKT polygons from searches and downloads #340

Open
MattBlissett opened this issue Feb 16, 2024 · 4 comments
Open

Block clockwise WKT polygons from searches and downloads #340

MattBlissett opened this issue Feb 16, 2024 · 4 comments

Comments

@MattBlissett
Copy link
Member

MattBlissett commented Feb 16, 2024

We currently have different behaviour regarding WKT polygons between ElasticSearch (search and small downloads) and Hive (large downloads).

The WKT specification requires a normal polygon to be counterclockwise. A clockwise polygon represents a hole, i.e. the whole world except that polygon.

A few tools generate clockwise polygons. We've had problems with this before. It is presumably a rare requirement to have the whole world except some polygon, and if that is required it can be specified by

  • providing multiple, smaller polygons
  • providing a whole-world polygon with a hole
  • lat/long greater/lessthan comparisons

I suggest we reject queries where the outer polygon is clockwise as 400 Bad Request, ideally with a suitable error message explaining the problem. (Could even give the reversed polygon...)

Some earlier issues:

@MattBlissett
Copy link
Member Author

See also https://codepen.io/GBIFS/pen/mdgdrrJ

@jhnwllr
Copy link

jhnwllr commented Mar 4, 2024

I get this error message now from rgbif when trying to do clockwise downloads. Is this expected now?

Error: Polygon with clockwise exterior ring: POLYGON ((8.64152 66.10075, 20.24262 63.18351, 24.24534 58.63805, 19.49635 52.6679, 10.74464 53.54985, 5.11369 60.53765, 8.64152 66.10075)). Did you mean these coordinates? (Note this is only part of the polygon or multipolygon you provided.) LINEARRING (8.64152 66.10075, 5.11369 60.53765, 10.74464 53.54985, 19.49635 52.6679, 24.24534 58.63805, 20.24262 63.18351, 8.64152 66.10075)

@MortenHofft
Copy link
Member

MortenHofft commented Mar 4, 2024

Yes. A clockwise wkt polygon is a hole and not supported. Unless inside a enclosing polygon (counter clockwise winding)

@MattBlissett
Copy link
Member Author

Clockwise rectangles are still accepted.

@MattBlissett MattBlissett reopened this Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants