gruppe-adler / grad_meh

An Arma 3 Modification built on intercept, which allows exporting data from Arma 3 maps.
MIT License
13 stars 2 forks source link

Make sure poygons comply to geojson spec #25

Closed DerZade closed 4 years ago

DerZade commented 4 years ago

I noticed that some polygons in our GeoJSONs don't comply to the GeoJSON specification. (See GeoJSON specification section 3.1.6)

The spec sates:

[...]For type "Polygon", the "coordinates" member MUST be an array of linear ring coordinate arrays. [...]

A linear ring is further specified:

[...]

  • A linear ring is a closed LineString with four or more positions.

  • The first and last positions are equivalent, and they MUST contain identical values; their representation SHOULD also be identical.

  • A linear ring is the boundary of a surface or the boundary of a hole in a surface.

  • A linear ring MUST follow the right-hand rule with respect to the area it bounds, i.e., exterior rings are counterclockwise, and holes are clockwise.

Note: the [GJ2008] specification did not discuss linear ring winding order. For backwards compatibility, parsers SHOULD NOT reject Polygons that do not follow the right-hand rule. [...]

This PR makes sure our polygons follow all the rules expect the last one. In a perfect world we would make sure that all polygons also follow the the right hand rule, but I think because of the note we can get away with just hoping that they do. ^^ Even if they don't it shouldn't be a big problem, because we don't have any polygons with holes.