peterstace / simplefeatures

Simple Features is a pure Go Implementation of the OpenGIS Simple Feature Access Specification
MIT License
129 stars 19 forks source link

Make DCEL geometry extraction ordering deterministic #480

Closed peterstace closed 1 year ago

peterstace commented 1 year ago

Description

commit 9c7dfea5f505ff5488334bc1e397c970703659f4 Author: Peter Stace peterstace@gmail.com Date: Sun Nov 13 05:45:29 2022 +1100

Make DCEL geometry extraction ordering deterministic

https://github.com/peterstace/simplefeatures/pull/472 introduced some
fixes for `GeometryCollection` inputs for DCEL operations. This change
modified the DCEL data structure to store most state in maps rather than
slices.

The geometry extraction phase of the DCEL algorithm iterates over all of
the DCEL state, building up the output `Geometry`. Map iteration order
in Go is non-deterministic, resulting in the ordering within the output
`Geometry` also being non-deterministic.

Specifically:

- `Points` within `MultiPoint`s could occur in any order.

- Each `LineString` could be in one of two orders (forward and
  reverse variants).

- The `LineString` constituents in a `MultiLineString` could occur in
  any order.

- `Polygon` inner rings could occur in any order.

- `Polygon` rings (inner or outer) could start at any arbitrary point.

- The `Polygon` constituents in a `MultiPolygon` could occur in any
  order.

This PR makes the ordering of all geometry components mentioned above
arbitrary but deterministic.

Check List

Have you:

Related Issue

Benchmark Results

Click to expand ``` PASTE BENCHMARKS HERE ```
peterstace commented 1 year ago

Thanks for the review! 😁