Skip to content

Commit

Permalink
Merge pull request #485 from peterstace/make_ignore_order_a_func
Browse files Browse the repository at this point in the history
Make IgnoreOrder a func rather than a variable
  • Loading branch information
peterstace committed Jan 6, 2023
2 parents 62ebc9e + c681b33 commit 8e2f45d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## Unreleased

- Make `IgnoreOrder` a function rather than a global variable to prevent
consumers from erroneously altering its behaviour.

## v0.41.0

2022-11-15
Expand Down
15 changes: 7 additions & 8 deletions geom/alg_exact_equals.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ func (c exactEqualsComparator) eq(a, b Coordinates) bool {
return true
}

// IgnoreOrder modifies the behaviour of the ExactEquals method by ignoring
// ordering that doesn't have a material impact on geometries.
// IgnoreOrder is an ExactEqualsOption that modifies the behaviour of the
// ExactEquals method by ignoring ordering that doesn't have a material impact
// on geometries.
//
// For Points, there is no ordering, so this option does nothing.
//
Expand All @@ -59,12 +60,10 @@ func (c exactEqualsComparator) eq(a, b Coordinates) bool {
// For collections (MultiPoint, MultiLineString, MultiPolygon, and
// GeometryCollection), the ordering of constituent elements in the collection
// are ignored.
var IgnoreOrder = ExactEqualsOption(
func(c exactEqualsComparator) exactEqualsComparator {
c.ignoreOrder = true
return c
},
)
func IgnoreOrder(c exactEqualsComparator) exactEqualsComparator {
c.ignoreOrder = true
return c
}

// ExactEquals checks if two geometries are equal from a structural pointwise
// equality perspective. Geometries that are structurally equal are defined by
Expand Down

0 comments on commit 8e2f45d

Please sign in to comment.