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

Make IgnoreOrder a func rather than a variable #485

Merged
merged 2 commits into from
Jan 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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