From 8e2125e1bc069f4a010fcc8a49a6f3fde374b01a Mon Sep 17 00:00:00 2001 From: Peter Stace Date: Fri, 6 Jan 2023 15:10:58 +1100 Subject: [PATCH 1/2] Make IgnoreOrder a func rather than a variable The variable was a global variable, and could (theoretically) be changed by any user, altering its behaviour. --- geom/alg_exact_equals.go | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/geom/alg_exact_equals.go b/geom/alg_exact_equals.go index 06ab6f6e..aa3f4c76 100644 --- a/geom/alg_exact_equals.go +++ b/geom/alg_exact_equals.go @@ -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. // @@ -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 From c681b3359388f3985611465249f76f124640946f Mon Sep 17 00:00:00 2001 From: Peter Stace Date: Fri, 6 Jan 2023 15:14:19 +1100 Subject: [PATCH 2/2] Update CHANGELOG --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 71081f3a..78c3a54e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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