-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #627 from peterstace/separate_twkb_unmarshal_funcs
Refactor TWKB unmarshal interface
- Loading branch information
Showing
5 changed files
with
227 additions
and
182 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package geom | ||
|
||
// Interval represents the interval bound by two float64 values. The interval | ||
// is closed, i.e. its endpoints are included. An interval typically has | ||
// distinct endpoints (i.e. is non-degenerate). It may also be degenerate and | ||
// contain no elements, or degenerate and contain a single element (i.e. the | ||
// min and max bounds are the same). The zero value of Interval is the | ||
// degenerate interval that contains no elements. | ||
type Interval struct { | ||
min, max float64 | ||
nonEmpty bool | ||
} | ||
|
||
// NewInterval returns a new non-empty Interval with the given bounds (which | ||
// may be the same). | ||
func NewInterval(boundA, boundB float64) Interval { | ||
if boundB < boundA { | ||
boundA, boundB = boundB, boundA | ||
} | ||
return Interval{boundA, boundB, true} | ||
} | ||
|
||
// MinMax returns the minimum and maximum bounds of the interval. The boolean | ||
// return value indicates if the interval is non-empty (the minimum and maximum | ||
// bounds should be ignored if false). | ||
func (i Interval) MinMax() (float64, float64, bool) { | ||
return i.min, i.max, i.nonEmpty | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.