gbif / occurrence

Occurrence store, download, search
Apache License 2.0
22 stars 15 forks source link

Block clockwise WKT polygons from searches and downloads #340

Open MattBlissett opened 8 months ago

MattBlissett commented 8 months ago

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

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 commented 7 months ago

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

jhnwllr commented 7 months ago

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 commented 7 months ago

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

MattBlissett commented 4 months ago

Clockwise rectangles are still accepted.