Skip to content
Merged
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
a87035b
Fix some small issues that were flagged by upcoming lint checks.
rsned Apr 2, 2025
ed507ae
replace the swap edges, newEdges which left a dangling value with _
rsned Apr 2, 2025
39caea7
Add todo on this //nolint.
rsned Apr 2, 2025
69704c9
Add linter/formatter/govet github action.
rsned Apr 2, 2025
12554af
Merge branch 'golang:master' into master
rsned Apr 3, 2025
55902bd
Fix OSSF detected go.mod toolchain version issue.
rsned Apr 3, 2025
4f7483f
update to use git hashes instead of @v5 style.
rsned Apr 4, 2025
e141dbf
Use dependabot compatible version comments
alan-strohm Apr 4, 2025
c597829
Add comments on disabled checks. Add a few more entries.
rsned Apr 8, 2025
5836f6f
Merge branch 'golang:master' into master
rsned Apr 8, 2025
7c7e52c
Merge remote-tracking branch 'refs/remotes/origin/master'
rsned Apr 8, 2025
6df2625
Update some comments and add in reference to related issue number for…
rsned Apr 8, 2025
0f45e9d
Remove govet from enabled. Drop exclusions. Clarify some comments.
rsned Apr 8, 2025
6937d18
Fix some typos
alan-strohm Apr 9, 2025
aeac25e
Set gofmt formatter to keep the default -s (simplify option)
rsned Apr 10, 2025
6570bb0
Re-disable simplify until existing files are fixed.
rsned Apr 10, 2025
46b2465
Update permissions to read-all
rsned Apr 10, 2025
c8d0c06
Remove simply: false from format checks.
rsned Apr 10, 2025
a09abef
Merge branch 'golang:master' into master
rsned Apr 10, 2025
cc51d8b
read-all should be on permissions, not the specific sub element.
rsned Apr 10, 2025
61272a9
Merge remote-tracking branch 'refs/remotes/origin/master'
rsned Apr 10, 2025
f996d29
Merge branch 'golang:master' into master
rsned Apr 12, 2025
63e5133
drop comment on pull requests.
rsned Apr 14, 2025
9a1faa3
Merge remote-tracking branch 'refs/remotes/origin/master'
rsned Apr 14, 2025
05836a2
Merge branch 'golang:master' into master
rsned Apr 14, 2025
86e764d
Merge branch 'golang:master' into master
rsned Apr 17, 2025
b8bbe24
Merge branch 'golang:master' into master
rsned Apr 23, 2025
f162306
Add missing methods on Edge.
rsned Apr 25, 2025
bbcd8f2
shape.go: fix typo comment
alan-strohm Apr 29, 2025
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
33 changes: 31 additions & 2 deletions s2/shape.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import (
"sort"
)

// Edge represents a geodesic edge consisting of two vertices. Zero-length edges are
// allowed, and can be used to represent points.
// Edge represents a geodesic edge consisting of two vertices. Zero-length
// edges are allowed, and can be used to represent points.
type Edge struct {
V0, V1 Point
}
Expand All @@ -38,6 +38,27 @@ func (e Edge) Cmp(other Edge) int {
return e.V1.Cmp(other.V1.Vector)
}

// TODO(rsned): Add helpers for <=, >=

// Reversed returns a new edge with the vertices reversed.
func (e Edge) Reversed() Edge {
return Edge{V0: e.V1, V1: e.V0}
}

// IsDegenerate reports if the edge is degenerate.
func (e Edge) IsDegenerate() bool { return e.V0 == e.V1 }

// Incoming reports if point equals v1, indicating this edge is arriving.
func (e Edge) Incoming(point Point) bool { return e.V1 == point }

// Outgoing reports if point equals v0, indicating this edge is leaving.
func (e Edge) Outgoing(point Point) bool { return e.V0 == point }

// IncidentOn reports if point is one of the vertices of this edge.
func (e Edge) IncidentOn(point Point) bool {
return e.Incoming(point) || e.Outgoing(point)
}

// sortEdges sorts the slice of Edges in place.
func sortEdges(e []Edge) {
sort.Sort(edges(e))
Expand All @@ -50,6 +71,8 @@ func (e edges) Len() int { return len(e) }
func (e edges) Swap(i, j int) { e[i], e[j] = e[j], e[i] }
func (e edges) Less(i, j int) bool { return e[i].Cmp(e[j]) == -1 }

// TODO(rsned): Implement the slices.SortFunc interface.

// ShapeEdgeID is a unique identifier for an Edge within an ShapeIndex,
// consisting of a (shapeID, edgeID) pair.
type ShapeEdgeID struct {
Expand Down Expand Up @@ -261,3 +284,9 @@ var (
_ Shape = &Polygon{}
_ Shape = &Polyline{}
)

// TODO(rsned): Remaining methods and types from C++
// ChainVertexIterator
// ChainVertexRange
// ChainIterator
// ChainRange