id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
28,000
golang/geo
s2/cap.go
IsValid
func (c Cap) IsValid() bool { return c.center.Vector.IsUnit() && c.radius <= s1.StraightChordAngle }
go
func (c Cap) IsValid() bool { return c.center.Vector.IsUnit() && c.radius <= s1.StraightChordAngle }
[ "func", "(", "c", "Cap", ")", "IsValid", "(", ")", "bool", "{", "return", "c", ".", "center", ".", "Vector", ".", "IsUnit", "(", ")", "&&", "c", ".", "radius", "<=", "s1", ".", "StraightChordAngle", "\n", "}" ]
// IsValid reports whether the Cap is considered valid.
[ "IsValid", "reports", "whether", "the", "Cap", "is", "considered", "valid", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cap.go#L111-L113
28,001
golang/geo
s2/cap.go
Equal
func (c Cap) Equal(other Cap) bool { return (c.radius == other.radius && c.center == other.center) || (c.IsEmpty() && other.IsEmpty()) || (c.IsFull() && other.IsFull()) }
go
func (c Cap) Equal(other Cap) bool { return (c.radius == other.radius && c.center == other.center) || (c.IsEmpty() && other.IsEmpty()) || (c.IsFull() && other.IsFull()) }
[ "func", "(", "c", "Cap", ")", "Equal", "(", "other", "Cap", ")", "bool", "{", "return", "(", "c", ".", "radius", "==", "other", ".", "radius", "&&", "c", ".", "center", "==", "other", ".", "center", ")", "||", "(", "c", ".", "IsEmpty", "(", ")"...
// Equal reports whether this cap is equal to the other cap.
[ "Equal", "reports", "whether", "this", "cap", "is", "equal", "to", "the", "other", "cap", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cap.go#L259-L263
28,002
golang/geo
s2/cap.go
ApproxEqual
func (c Cap) ApproxEqual(other Cap) bool { const epsilon = 1e-14 r2 := float64(c.radius) otherR2 := float64(other.radius) return c.center.ApproxEqual(other.center) && math.Abs(r2-otherR2) <= epsilon || c.IsEmpty() && otherR2 <= epsilon || other.IsEmpty() && r2 <= epsilon || c.IsFull() && otherR2 >= 2-epsilo...
go
func (c Cap) ApproxEqual(other Cap) bool { const epsilon = 1e-14 r2 := float64(c.radius) otherR2 := float64(other.radius) return c.center.ApproxEqual(other.center) && math.Abs(r2-otherR2) <= epsilon || c.IsEmpty() && otherR2 <= epsilon || other.IsEmpty() && r2 <= epsilon || c.IsFull() && otherR2 >= 2-epsilo...
[ "func", "(", "c", "Cap", ")", "ApproxEqual", "(", "other", "Cap", ")", "bool", "{", "const", "epsilon", "=", "1e-14", "\n", "r2", ":=", "float64", "(", "c", ".", "radius", ")", "\n", "otherR2", ":=", "float64", "(", "other", ".", "radius", ")", "\n...
// ApproxEqual reports whether this cap is equal to the other cap within the given tolerance.
[ "ApproxEqual", "reports", "whether", "this", "cap", "is", "equal", "to", "the", "other", "cap", "within", "the", "given", "tolerance", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cap.go#L266-L276
28,003
golang/geo
s2/cap.go
AddPoint
func (c Cap) AddPoint(p Point) Cap { if c.IsEmpty() { c.center = p c.radius = 0 return c } // After calling cap.AddPoint(p), cap.Contains(p) must be true. However // we don't need to do anything special to achieve this because Contains() // does exactly the same distance calculation that we do here. if new...
go
func (c Cap) AddPoint(p Point) Cap { if c.IsEmpty() { c.center = p c.radius = 0 return c } // After calling cap.AddPoint(p), cap.Contains(p) must be true. However // we don't need to do anything special to achieve this because Contains() // does exactly the same distance calculation that we do here. if new...
[ "func", "(", "c", "Cap", ")", "AddPoint", "(", "p", "Point", ")", "Cap", "{", "if", "c", ".", "IsEmpty", "(", ")", "{", "c", ".", "center", "=", "p", "\n", "c", ".", "radius", "=", "0", "\n", "return", "c", "\n", "}", "\n\n", "// After calling ...
// AddPoint increases the cap if necessary to include the given point. If this cap is empty, // then the center is set to the point with a zero height. p must be unit-length.
[ "AddPoint", "increases", "the", "cap", "if", "necessary", "to", "include", "the", "given", "point", ".", "If", "this", "cap", "is", "empty", "then", "the", "center", "is", "set", "to", "the", "point", "with", "a", "zero", "height", ".", "p", "must", "b...
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cap.go#L280-L294
28,004
golang/geo
s2/cap.go
AddCap
func (c Cap) AddCap(other Cap) Cap { if c.IsEmpty() { return other } if other.IsEmpty() { return c } // We round up the distance to ensure that the cap is actually contained. // TODO(roberts): Do some error analysis in order to guarantee this. dist := ChordAngleBetweenPoints(c.center, other.center).Add(othe...
go
func (c Cap) AddCap(other Cap) Cap { if c.IsEmpty() { return other } if other.IsEmpty() { return c } // We round up the distance to ensure that the cap is actually contained. // TODO(roberts): Do some error analysis in order to guarantee this. dist := ChordAngleBetweenPoints(c.center, other.center).Add(othe...
[ "func", "(", "c", "Cap", ")", "AddCap", "(", "other", "Cap", ")", "Cap", "{", "if", "c", ".", "IsEmpty", "(", ")", "{", "return", "other", "\n", "}", "\n", "if", "other", ".", "IsEmpty", "(", ")", "{", "return", "c", "\n", "}", "\n\n", "// We r...
// AddCap increases the cap height if necessary to include the other cap. If this cap is empty, // it is set to the other cap.
[ "AddCap", "increases", "the", "cap", "height", "if", "necessary", "to", "include", "the", "other", "cap", ".", "If", "this", "cap", "is", "empty", "it", "is", "set", "to", "the", "other", "cap", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cap.go#L298-L313
28,005
golang/geo
s2/cap.go
ContainsCell
func (c Cap) ContainsCell(cell Cell) bool { // If the cap does not contain all cell vertices, return false. var vertices [4]Point for k := 0; k < 4; k++ { vertices[k] = cell.Vertex(k) if !c.ContainsPoint(vertices[k]) { return false } } // Otherwise, return true if the complement of the cap does not inters...
go
func (c Cap) ContainsCell(cell Cell) bool { // If the cap does not contain all cell vertices, return false. var vertices [4]Point for k := 0; k < 4; k++ { vertices[k] = cell.Vertex(k) if !c.ContainsPoint(vertices[k]) { return false } } // Otherwise, return true if the complement of the cap does not inters...
[ "func", "(", "c", "Cap", ")", "ContainsCell", "(", "cell", "Cell", ")", "bool", "{", "// If the cap does not contain all cell vertices, return false.", "var", "vertices", "[", "4", "]", "Point", "\n", "for", "k", ":=", "0", ";", "k", "<", "4", ";", "k", "+...
// ContainsCell reports whether the cap contains the given cell.
[ "ContainsCell", "reports", "whether", "the", "cap", "contains", "the", "given", "cell", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cap.go#L341-L352
28,006
golang/geo
s2/cap.go
IntersectsCell
func (c Cap) IntersectsCell(cell Cell) bool { // If the cap contains any cell vertex, return true. var vertices [4]Point for k := 0; k < 4; k++ { vertices[k] = cell.Vertex(k) if c.ContainsPoint(vertices[k]) { return true } } return c.intersects(cell, vertices) }
go
func (c Cap) IntersectsCell(cell Cell) bool { // If the cap contains any cell vertex, return true. var vertices [4]Point for k := 0; k < 4; k++ { vertices[k] = cell.Vertex(k) if c.ContainsPoint(vertices[k]) { return true } } return c.intersects(cell, vertices) }
[ "func", "(", "c", "Cap", ")", "IntersectsCell", "(", "cell", "Cell", ")", "bool", "{", "// If the cap contains any cell vertex, return true.", "var", "vertices", "[", "4", "]", "Point", "\n", "for", "k", ":=", "0", ";", "k", "<", "4", ";", "k", "++", "{"...
// IntersectsCell reports whether the cap intersects the cell.
[ "IntersectsCell", "reports", "whether", "the", "cap", "intersects", "the", "cell", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cap.go#L355-L365
28,007
golang/geo
s2/cap.go
CellUnionBound
func (c Cap) CellUnionBound() []CellID { // TODO(roberts): The covering could be made quite a bit tighter by mapping // the cap to a rectangle in (i,j)-space and finding a covering for that. // Find the maximum level such that the cap contains at most one cell vertex // and such that CellID.AppendVertexNeighbors()...
go
func (c Cap) CellUnionBound() []CellID { // TODO(roberts): The covering could be made quite a bit tighter by mapping // the cap to a rectangle in (i,j)-space and finding a covering for that. // Find the maximum level such that the cap contains at most one cell vertex // and such that CellID.AppendVertexNeighbors()...
[ "func", "(", "c", "Cap", ")", "CellUnionBound", "(", ")", "[", "]", "CellID", "{", "// TODO(roberts): The covering could be made quite a bit tighter by mapping", "// the cap to a rectangle in (i,j)-space and finding a covering for that.", "// Find the maximum level such that the cap cont...
// CellUnionBound computes a covering of the Cap. In general the covering // consists of at most 4 cells except for very large caps, which may need // up to 6 cells. The output is not sorted.
[ "CellUnionBound", "computes", "a", "covering", "of", "the", "Cap", ".", "In", "general", "the", "covering", "consists", "of", "at", "most", "4", "cells", "except", "for", "very", "large", "caps", "which", "may", "need", "up", "to", "6", "cells", ".", "Th...
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cap.go#L421-L440
28,008
golang/geo
s2/cap.go
Union
func (c Cap) Union(other Cap) Cap { // If the other cap is larger, swap c and other for the rest of the computations. if c.radius < other.radius { c, other = other, c } if c.IsFull() || other.IsEmpty() { return c } // TODO: This calculation would be more efficient using s1.ChordAngles. cRadius := c.Radius(...
go
func (c Cap) Union(other Cap) Cap { // If the other cap is larger, swap c and other for the rest of the computations. if c.radius < other.radius { c, other = other, c } if c.IsFull() || other.IsEmpty() { return c } // TODO: This calculation would be more efficient using s1.ChordAngles. cRadius := c.Radius(...
[ "func", "(", "c", "Cap", ")", "Union", "(", "other", "Cap", ")", "Cap", "{", "// If the other cap is larger, swap c and other for the rest of the computations.", "if", "c", ".", "radius", "<", "other", ".", "radius", "{", "c", ",", "other", "=", "other", ",", ...
// Union returns the smallest cap which encloses this cap and other.
[ "Union", "returns", "the", "smallest", "cap", "which", "encloses", "this", "cap", "and", "other", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cap.go#L470-L491
28,009
golang/geo
s2/cap.go
Encode
func (c Cap) Encode(w io.Writer) error { e := &encoder{w: w} c.encode(e) return e.err }
go
func (c Cap) Encode(w io.Writer) error { e := &encoder{w: w} c.encode(e) return e.err }
[ "func", "(", "c", "Cap", ")", "Encode", "(", "w", "io", ".", "Writer", ")", "error", "{", "e", ":=", "&", "encoder", "{", "w", ":", "w", "}", "\n", "c", ".", "encode", "(", "e", ")", "\n", "return", "e", ".", "err", "\n", "}" ]
// Encode encodes the Cap.
[ "Encode", "encodes", "the", "Cap", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cap.go#L494-L498
28,010
golang/geo
s2/cap.go
Decode
func (c *Cap) Decode(r io.Reader) error { d := &decoder{r: asByteReader(r)} c.decode(d) return d.err }
go
func (c *Cap) Decode(r io.Reader) error { d := &decoder{r: asByteReader(r)} c.decode(d) return d.err }
[ "func", "(", "c", "*", "Cap", ")", "Decode", "(", "r", "io", ".", "Reader", ")", "error", "{", "d", ":=", "&", "decoder", "{", "r", ":", "asByteReader", "(", "r", ")", "}", "\n", "c", ".", "decode", "(", "d", ")", "\n", "return", "d", ".", ...
// Decode decodes the Cap.
[ "Decode", "decodes", "the", "Cap", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cap.go#L508-L512
28,011
golang/geo
r1/interval.go
Equal
func (i Interval) Equal(oi Interval) bool { return i == oi || i.IsEmpty() && oi.IsEmpty() }
go
func (i Interval) Equal(oi Interval) bool { return i == oi || i.IsEmpty() && oi.IsEmpty() }
[ "func", "(", "i", "Interval", ")", "Equal", "(", "oi", "Interval", ")", "bool", "{", "return", "i", "==", "oi", "||", "i", ".", "IsEmpty", "(", ")", "&&", "oi", ".", "IsEmpty", "(", ")", "\n", "}" ]
// Equal returns true iff the interval contains the same points as oi.
[ "Equal", "returns", "true", "iff", "the", "interval", "contains", "the", "same", "points", "as", "oi", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/r1/interval.go#L39-L41
28,012
golang/geo
r1/interval.go
InteriorContains
func (i Interval) InteriorContains(p float64) bool { return i.Lo < p && p < i.Hi }
go
func (i Interval) InteriorContains(p float64) bool { return i.Lo < p && p < i.Hi }
[ "func", "(", "i", "Interval", ")", "InteriorContains", "(", "p", "float64", ")", "bool", "{", "return", "i", ".", "Lo", "<", "p", "&&", "p", "<", "i", ".", "Hi", "\n", "}" ]
// InteriorContains returns true iff the interval strictly contains p.
[ "InteriorContains", "returns", "true", "iff", "the", "interval", "strictly", "contains", "p", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/r1/interval.go#L63-L65
28,013
golang/geo
r1/interval.go
Intersection
func (i Interval) Intersection(j Interval) Interval { // Empty intervals do not need to be special-cased. return Interval{ Lo: math.Max(i.Lo, j.Lo), Hi: math.Min(i.Hi, j.Hi), } }
go
func (i Interval) Intersection(j Interval) Interval { // Empty intervals do not need to be special-cased. return Interval{ Lo: math.Max(i.Lo, j.Lo), Hi: math.Min(i.Hi, j.Hi), } }
[ "func", "(", "i", "Interval", ")", "Intersection", "(", "j", "Interval", ")", "Interval", "{", "// Empty intervals do not need to be special-cased.", "return", "Interval", "{", "Lo", ":", "math", ".", "Max", "(", "i", ".", "Lo", ",", "j", ".", "Lo", ")", "...
// Intersection returns the interval containing all points common to i and j.
[ "Intersection", "returns", "the", "interval", "containing", "all", "points", "common", "to", "i", "and", "j", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/r1/interval.go#L89-L95
28,014
golang/geo
r1/interval.go
AddPoint
func (i Interval) AddPoint(p float64) Interval { if i.IsEmpty() { return Interval{p, p} } if p < i.Lo { return Interval{p, i.Hi} } if p > i.Hi { return Interval{i.Lo, p} } return i }
go
func (i Interval) AddPoint(p float64) Interval { if i.IsEmpty() { return Interval{p, p} } if p < i.Lo { return Interval{p, i.Hi} } if p > i.Hi { return Interval{i.Lo, p} } return i }
[ "func", "(", "i", "Interval", ")", "AddPoint", "(", "p", "float64", ")", "Interval", "{", "if", "i", ".", "IsEmpty", "(", ")", "{", "return", "Interval", "{", "p", ",", "p", "}", "\n", "}", "\n", "if", "p", "<", "i", ".", "Lo", "{", "return", ...
// AddPoint returns the interval expanded so that it contains the given point.
[ "AddPoint", "returns", "the", "interval", "expanded", "so", "that", "it", "contains", "the", "given", "point", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/r1/interval.go#L98-L109
28,015
golang/geo
r1/interval.go
ClampPoint
func (i Interval) ClampPoint(p float64) float64 { return math.Max(i.Lo, math.Min(i.Hi, p)) }
go
func (i Interval) ClampPoint(p float64) float64 { return math.Max(i.Lo, math.Min(i.Hi, p)) }
[ "func", "(", "i", "Interval", ")", "ClampPoint", "(", "p", "float64", ")", "float64", "{", "return", "math", ".", "Max", "(", "i", ".", "Lo", ",", "math", ".", "Min", "(", "i", ".", "Hi", ",", "p", ")", ")", "\n", "}" ]
// ClampPoint returns the closest point in the interval to the given point "p". // The interval must be non-empty.
[ "ClampPoint", "returns", "the", "closest", "point", "in", "the", "interval", "to", "the", "given", "point", "p", ".", "The", "interval", "must", "be", "non", "-", "empty", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/r1/interval.go#L113-L115
28,016
golang/geo
r1/interval.go
Expanded
func (i Interval) Expanded(margin float64) Interval { if i.IsEmpty() { return i } return Interval{i.Lo - margin, i.Hi + margin} }
go
func (i Interval) Expanded(margin float64) Interval { if i.IsEmpty() { return i } return Interval{i.Lo - margin, i.Hi + margin} }
[ "func", "(", "i", "Interval", ")", "Expanded", "(", "margin", "float64", ")", "Interval", "{", "if", "i", ".", "IsEmpty", "(", ")", "{", "return", "i", "\n", "}", "\n", "return", "Interval", "{", "i", ".", "Lo", "-", "margin", ",", "i", ".", "Hi"...
// Expanded returns an interval that has been expanded on each side by margin. // If margin is negative, then the function shrinks the interval on // each side by margin instead. The resulting interval may be empty. Any // expansion of an empty interval remains empty.
[ "Expanded", "returns", "an", "interval", "that", "has", "been", "expanded", "on", "each", "side", "by", "margin", ".", "If", "margin", "is", "negative", "then", "the", "function", "shrinks", "the", "interval", "on", "each", "side", "by", "margin", "instead",...
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/r1/interval.go#L121-L126
28,017
golang/geo
r1/interval.go
Union
func (i Interval) Union(other Interval) Interval { if i.IsEmpty() { return other } if other.IsEmpty() { return i } return Interval{math.Min(i.Lo, other.Lo), math.Max(i.Hi, other.Hi)} }
go
func (i Interval) Union(other Interval) Interval { if i.IsEmpty() { return other } if other.IsEmpty() { return i } return Interval{math.Min(i.Lo, other.Lo), math.Max(i.Hi, other.Hi)} }
[ "func", "(", "i", "Interval", ")", "Union", "(", "other", "Interval", ")", "Interval", "{", "if", "i", ".", "IsEmpty", "(", ")", "{", "return", "other", "\n", "}", "\n", "if", "other", ".", "IsEmpty", "(", ")", "{", "return", "i", "\n", "}", "\n"...
// Union returns the smallest interval that contains this interval and the given interval.
[ "Union", "returns", "the", "smallest", "interval", "that", "contains", "this", "interval", "and", "the", "given", "interval", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/r1/interval.go#L129-L137
28,018
golang/geo
r1/interval.go
ApproxEqual
func (i Interval) ApproxEqual(other Interval) bool { if i.IsEmpty() { return other.Length() <= 2*epsilon } if other.IsEmpty() { return i.Length() <= 2*epsilon } return math.Abs(other.Lo-i.Lo) <= epsilon && math.Abs(other.Hi-i.Hi) <= epsilon }
go
func (i Interval) ApproxEqual(other Interval) bool { if i.IsEmpty() { return other.Length() <= 2*epsilon } if other.IsEmpty() { return i.Length() <= 2*epsilon } return math.Abs(other.Lo-i.Lo) <= epsilon && math.Abs(other.Hi-i.Hi) <= epsilon }
[ "func", "(", "i", "Interval", ")", "ApproxEqual", "(", "other", "Interval", ")", "bool", "{", "if", "i", ".", "IsEmpty", "(", ")", "{", "return", "other", ".", "Length", "(", ")", "<=", "2", "*", "epsilon", "\n", "}", "\n", "if", "other", ".", "I...
// ApproxEqual reports whether the interval can be transformed into the // given interval by moving each endpoint a small distance. // The empty interval is considered to be positioned arbitrarily on the // real line, so any interval with a small enough length will match // the empty interval.
[ "ApproxEqual", "reports", "whether", "the", "interval", "can", "be", "transformed", "into", "the", "given", "interval", "by", "moving", "each", "endpoint", "a", "small", "distance", ".", "The", "empty", "interval", "is", "considered", "to", "be", "positioned", ...
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/r1/interval.go#L155-L164
28,019
golang/geo
s2/convex_hull_query.go
AddPoint
func (q *ConvexHullQuery) AddPoint(p Point) { q.bound = q.bound.AddPoint(LatLngFromPoint(p)) q.points = append(q.points, p) }
go
func (q *ConvexHullQuery) AddPoint(p Point) { q.bound = q.bound.AddPoint(LatLngFromPoint(p)) q.points = append(q.points, p) }
[ "func", "(", "q", "*", "ConvexHullQuery", ")", "AddPoint", "(", "p", "Point", ")", "{", "q", ".", "bound", "=", "q", ".", "bound", ".", "AddPoint", "(", "LatLngFromPoint", "(", "p", ")", ")", "\n", "q", ".", "points", "=", "append", "(", "q", "."...
// AddPoint adds the given point to the input geometry.
[ "AddPoint", "adds", "the", "given", "point", "to", "the", "input", "geometry", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/convex_hull_query.go#L71-L74
28,020
golang/geo
s2/convex_hull_query.go
AddPolyline
func (q *ConvexHullQuery) AddPolyline(p *Polyline) { q.bound = q.bound.Union(p.RectBound()) q.points = append(q.points, (*p)...) }
go
func (q *ConvexHullQuery) AddPolyline(p *Polyline) { q.bound = q.bound.Union(p.RectBound()) q.points = append(q.points, (*p)...) }
[ "func", "(", "q", "*", "ConvexHullQuery", ")", "AddPolyline", "(", "p", "*", "Polyline", ")", "{", "q", ".", "bound", "=", "q", ".", "bound", ".", "Union", "(", "p", ".", "RectBound", "(", ")", ")", "\n", "q", ".", "points", "=", "append", "(", ...
// AddPolyline adds the given polyline to the input geometry.
[ "AddPolyline", "adds", "the", "given", "polyline", "to", "the", "input", "geometry", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/convex_hull_query.go#L77-L80
28,021
golang/geo
s2/convex_hull_query.go
AddLoop
func (q *ConvexHullQuery) AddLoop(l *Loop) { q.bound = q.bound.Union(l.RectBound()) if l.isEmptyOrFull() { return } q.points = append(q.points, l.vertices...) }
go
func (q *ConvexHullQuery) AddLoop(l *Loop) { q.bound = q.bound.Union(l.RectBound()) if l.isEmptyOrFull() { return } q.points = append(q.points, l.vertices...) }
[ "func", "(", "q", "*", "ConvexHullQuery", ")", "AddLoop", "(", "l", "*", "Loop", ")", "{", "q", ".", "bound", "=", "q", ".", "bound", ".", "Union", "(", "l", ".", "RectBound", "(", ")", ")", "\n", "if", "l", ".", "isEmptyOrFull", "(", ")", "{",...
// AddLoop adds the given loop to the input geometry.
[ "AddLoop", "adds", "the", "given", "loop", "to", "the", "input", "geometry", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/convex_hull_query.go#L83-L89
28,022
golang/geo
s2/convex_hull_query.go
AddPolygon
func (q *ConvexHullQuery) AddPolygon(p *Polygon) { q.bound = q.bound.Union(p.RectBound()) for _, l := range p.loops { // Only loops at depth 0 can contribute to the convex hull. if l.depth == 0 { q.AddLoop(l) } } }
go
func (q *ConvexHullQuery) AddPolygon(p *Polygon) { q.bound = q.bound.Union(p.RectBound()) for _, l := range p.loops { // Only loops at depth 0 can contribute to the convex hull. if l.depth == 0 { q.AddLoop(l) } } }
[ "func", "(", "q", "*", "ConvexHullQuery", ")", "AddPolygon", "(", "p", "*", "Polygon", ")", "{", "q", ".", "bound", "=", "q", ".", "bound", ".", "Union", "(", "p", ".", "RectBound", "(", ")", ")", "\n", "for", "_", ",", "l", ":=", "range", "p",...
// AddPolygon adds the given polygon to the input geometry.
[ "AddPolygon", "adds", "the", "given", "polygon", "to", "the", "input", "geometry", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/convex_hull_query.go#L92-L100
28,023
golang/geo
s2/convex_hull_query.go
singleEdgeLoop
func singleEdgeLoop(a, b Point) *Loop { vertices := []Point{a, b, Point{a.Add(b.Vector).Normalize()}} loop := LoopFromPoints(vertices) // The resulting loop may be clockwise, so invert it if necessary. loop.Normalize() return loop }
go
func singleEdgeLoop(a, b Point) *Loop { vertices := []Point{a, b, Point{a.Add(b.Vector).Normalize()}} loop := LoopFromPoints(vertices) // The resulting loop may be clockwise, so invert it if necessary. loop.Normalize() return loop }
[ "func", "singleEdgeLoop", "(", "a", ",", "b", "Point", ")", "*", "Loop", "{", "vertices", ":=", "[", "]", "Point", "{", "a", ",", "b", ",", "Point", "{", "a", ".", "Add", "(", "b", ".", "Vector", ")", ".", "Normalize", "(", ")", "}", "}", "\n...
// singleEdgeLoop constructs a loop consisting of the two vertices and their midpoint.
[ "singleEdgeLoop", "constructs", "a", "loop", "consisting", "of", "the", "two", "vertices", "and", "their", "midpoint", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/convex_hull_query.go#L233-L239
28,024
golang/geo
s1/chordangle.go
ChordAngleFromAngle
func ChordAngleFromAngle(a Angle) ChordAngle { if a < 0 { return NegativeChordAngle } if a.isInf() { return InfChordAngle() } l := 2 * math.Sin(0.5*math.Min(math.Pi, a.Radians())) return ChordAngle(l * l) }
go
func ChordAngleFromAngle(a Angle) ChordAngle { if a < 0 { return NegativeChordAngle } if a.isInf() { return InfChordAngle() } l := 2 * math.Sin(0.5*math.Min(math.Pi, a.Radians())) return ChordAngle(l * l) }
[ "func", "ChordAngleFromAngle", "(", "a", "Angle", ")", "ChordAngle", "{", "if", "a", "<", "0", "{", "return", "NegativeChordAngle", "\n", "}", "\n", "if", "a", ".", "isInf", "(", ")", "{", "return", "InfChordAngle", "(", ")", "\n", "}", "\n", "l", ":...
// ChordAngleFromAngle returns a ChordAngle from the given Angle.
[ "ChordAngleFromAngle", "returns", "a", "ChordAngle", "from", "the", "given", "Angle", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s1/chordangle.go#L57-L66
28,025
golang/geo
s1/chordangle.go
Angle
func (c ChordAngle) Angle() Angle { if c < 0 { return -1 * Radian } if c.isInf() { return InfAngle() } return Angle(2 * math.Asin(0.5*math.Sqrt(float64(c)))) }
go
func (c ChordAngle) Angle() Angle { if c < 0 { return -1 * Radian } if c.isInf() { return InfAngle() } return Angle(2 * math.Asin(0.5*math.Sqrt(float64(c)))) }
[ "func", "(", "c", "ChordAngle", ")", "Angle", "(", ")", "Angle", "{", "if", "c", "<", "0", "{", "return", "-", "1", "*", "Radian", "\n", "}", "\n", "if", "c", ".", "isInf", "(", ")", "{", "return", "InfAngle", "(", ")", "\n", "}", "\n", "retu...
// Angle converts this ChordAngle to an Angle.
[ "Angle", "converts", "this", "ChordAngle", "to", "an", "Angle", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s1/chordangle.go#L92-L100
28,026
golang/geo
s1/chordangle.go
Add
func (c ChordAngle) Add(other ChordAngle) ChordAngle { // Note that this method (and Sub) is much more efficient than converting // the ChordAngle to an Angle and adding those and converting back. It // requires only one square root plus a few additions and multiplications. // Optimization for the common case wher...
go
func (c ChordAngle) Add(other ChordAngle) ChordAngle { // Note that this method (and Sub) is much more efficient than converting // the ChordAngle to an Angle and adding those and converting back. It // requires only one square root plus a few additions and multiplications. // Optimization for the common case wher...
[ "func", "(", "c", "ChordAngle", ")", "Add", "(", "other", "ChordAngle", ")", "ChordAngle", "{", "// Note that this method (and Sub) is much more efficient than converting", "// the ChordAngle to an Angle and adding those and converting back. It", "// requires only one square root plus a ...
// Add adds the other ChordAngle to this one and returns the resulting value. // This method assumes the ChordAngles are not special.
[ "Add", "adds", "the", "other", "ChordAngle", "to", "this", "one", "and", "returns", "the", "resulting", "value", ".", "This", "method", "assumes", "the", "ChordAngles", "are", "not", "special", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s1/chordangle.go#L178-L202
28,027
golang/geo
s1/chordangle.go
Sub
func (c ChordAngle) Sub(other ChordAngle) ChordAngle { if other == 0 { return c } if c <= other { return 0 } x := float64(c * (1 - 0.25*other)) y := float64(other * (1 - 0.25*c)) return ChordAngle(math.Max(0.0, x+y-2*math.Sqrt(x*y))) }
go
func (c ChordAngle) Sub(other ChordAngle) ChordAngle { if other == 0 { return c } if c <= other { return 0 } x := float64(c * (1 - 0.25*other)) y := float64(other * (1 - 0.25*c)) return ChordAngle(math.Max(0.0, x+y-2*math.Sqrt(x*y))) }
[ "func", "(", "c", "ChordAngle", ")", "Sub", "(", "other", "ChordAngle", ")", "ChordAngle", "{", "if", "other", "==", "0", "{", "return", "c", "\n", "}", "\n", "if", "c", "<=", "other", "{", "return", "0", "\n", "}", "\n", "x", ":=", "float64", "(...
// Sub subtracts the other ChordAngle from this one and returns the resulting // value. This method assumes the ChordAngles are not special.
[ "Sub", "subtracts", "the", "other", "ChordAngle", "from", "this", "one", "and", "returns", "the", "resulting", "value", ".", "This", "method", "assumes", "the", "ChordAngles", "are", "not", "special", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s1/chordangle.go#L206-L216
28,028
golang/geo
s2/edge_clipping.go
ClipEdge
func ClipEdge(a, b r2.Point, clip r2.Rect) (aClip, bClip r2.Point, intersects bool) { // Compute the bounding rectangle of AB, clip it, and then extract the new // endpoints from the clipped bound. bound := r2.RectFromPoints(a, b) if bound, intersects = clipEdgeBound(a, b, clip, bound); !intersects { return aClip...
go
func ClipEdge(a, b r2.Point, clip r2.Rect) (aClip, bClip r2.Point, intersects bool) { // Compute the bounding rectangle of AB, clip it, and then extract the new // endpoints from the clipped bound. bound := r2.RectFromPoints(a, b) if bound, intersects = clipEdgeBound(a, b, clip, bound); !intersects { return aClip...
[ "func", "ClipEdge", "(", "a", ",", "b", "r2", ".", "Point", ",", "clip", "r2", ".", "Rect", ")", "(", "aClip", ",", "bClip", "r2", ".", "Point", ",", "intersects", "bool", ")", "{", "// Compute the bounding rectangle of AB, clip it, and then extract the new", ...
// ClipEdge returns the portion of the edge defined by AB that is contained by the // given rectangle. If there is no intersection, false is returned and aClip and bClip // are undefined.
[ "ClipEdge", "returns", "the", "portion", "of", "the", "edge", "defined", "by", "AB", "that", "is", "contained", "by", "the", "given", "rectangle", ".", "If", "there", "is", "no", "intersection", "false", "is", "returned", "and", "aClip", "and", "bClip", "a...
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/edge_clipping.go#L140-L157
28,029
golang/geo
s2/edge_clipping.go
updateEndpoint
func updateEndpoint(bound r1.Interval, highEndpoint bool, value float64) (r1.Interval, bool) { if !highEndpoint { if bound.Hi < value { return bound, false } if bound.Lo < value { bound.Lo = value } return bound, true } if bound.Lo > value { return bound, false } if bound.Hi > value { bound.Hi...
go
func updateEndpoint(bound r1.Interval, highEndpoint bool, value float64) (r1.Interval, bool) { if !highEndpoint { if bound.Hi < value { return bound, false } if bound.Lo < value { bound.Lo = value } return bound, true } if bound.Lo > value { return bound, false } if bound.Hi > value { bound.Hi...
[ "func", "updateEndpoint", "(", "bound", "r1", ".", "Interval", ",", "highEndpoint", "bool", ",", "value", "float64", ")", "(", "r1", ".", "Interval", ",", "bool", ")", "{", "if", "!", "highEndpoint", "{", "if", "bound", ".", "Hi", "<", "value", "{", ...
// updateEndpoint returns the interval with the specified endpoint updated to // the given value. If the value lies beyond the opposite endpoint, nothing is // changed and false is returned.
[ "updateEndpoint", "returns", "the", "interval", "with", "the", "specified", "endpoint", "updated", "to", "the", "given", "value", ".", "If", "the", "value", "lies", "beyond", "the", "opposite", "endpoint", "nothing", "is", "changed", "and", "false", "is", "ret...
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/edge_clipping.go#L364-L382
28,030
golang/geo
s2/edge_clipping.go
edgeIntersectsRect
func edgeIntersectsRect(a, b r2.Point, r r2.Rect) bool { // First check whether the bounds of a Rect around AB intersects the given rect. if !r.Intersects(r2.RectFromPoints(a, b)) { return false } // Otherwise AB intersects the rect if and only if all four vertices of rect // do not lie on the same side of the ...
go
func edgeIntersectsRect(a, b r2.Point, r r2.Rect) bool { // First check whether the bounds of a Rect around AB intersects the given rect. if !r.Intersects(r2.RectFromPoints(a, b)) { return false } // Otherwise AB intersects the rect if and only if all four vertices of rect // do not lie on the same side of the ...
[ "func", "edgeIntersectsRect", "(", "a", ",", "b", "r2", ".", "Point", ",", "r", "r2", ".", "Rect", ")", "bool", "{", "// First check whether the bounds of a Rect around AB intersects the given rect.", "if", "!", "r", ".", "Intersects", "(", "r2", ".", "RectFromPoi...
// edgeIntersectsRect reports whether the edge defined by AB intersects the // given closed rectangle to within the error bound.
[ "edgeIntersectsRect", "reports", "whether", "the", "edge", "defined", "by", "AB", "intersects", "the", "given", "closed", "rectangle", "to", "within", "the", "error", "bound", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/edge_clipping.go#L421-L446
28,031
golang/geo
s2/edge_clipping.go
clippedEdgeBound
func clippedEdgeBound(a, b r2.Point, clip r2.Rect) r2.Rect { bound := r2.RectFromPoints(a, b) if b1, intersects := clipEdgeBound(a, b, clip, bound); intersects { return b1 } return r2.EmptyRect() }
go
func clippedEdgeBound(a, b r2.Point, clip r2.Rect) r2.Rect { bound := r2.RectFromPoints(a, b) if b1, intersects := clipEdgeBound(a, b, clip, bound); intersects { return b1 } return r2.EmptyRect() }
[ "func", "clippedEdgeBound", "(", "a", ",", "b", "r2", ".", "Point", ",", "clip", "r2", ".", "Rect", ")", "r2", ".", "Rect", "{", "bound", ":=", "r2", ".", "RectFromPoints", "(", "a", ",", "b", ")", "\n", "if", "b1", ",", "intersects", ":=", "clip...
// clippedEdgeBound returns the bounding rectangle of the portion of the edge defined // by AB intersected by clip. The resulting bound may be empty. This is a convenience // function built on top of clipEdgeBound.
[ "clippedEdgeBound", "returns", "the", "bounding", "rectangle", "of", "the", "portion", "of", "the", "edge", "defined", "by", "AB", "intersected", "by", "clip", ".", "The", "resulting", "bound", "may", "be", "empty", ".", "This", "is", "a", "convenience", "fu...
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/edge_clipping.go#L451-L457
28,032
golang/geo
s2/edge_clipping.go
clipEdgeBound
func clipEdgeBound(a, b r2.Point, clip, bound r2.Rect) (r2.Rect, bool) { // negSlope indicates which diagonal of the bounding box is spanned by AB: it // is false if AB has positive slope, and true if AB has negative slope. This is // used to determine which interval endpoints need to be updated each time // the ed...
go
func clipEdgeBound(a, b r2.Point, clip, bound r2.Rect) (r2.Rect, bool) { // negSlope indicates which diagonal of the bounding box is spanned by AB: it // is false if AB has positive slope, and true if AB has negative slope. This is // used to determine which interval endpoints need to be updated each time // the ed...
[ "func", "clipEdgeBound", "(", "a", ",", "b", "r2", ".", "Point", ",", "clip", ",", "bound", "r2", ".", "Rect", ")", "(", "r2", ".", "Rect", ",", "bool", ")", "{", "// negSlope indicates which diagonal of the bounding box is spanned by AB: it", "// is false if AB h...
// clipEdgeBound clips an edge AB to sequence of rectangles efficiently. // It represents the clipped edges by their bounding boxes rather than as a pair of // endpoints. Specifically, let A'B' be some portion of an edge AB, and let bound be // a tight bound of A'B'. This function returns the bound that is a tight boun...
[ "clipEdgeBound", "clips", "an", "edge", "AB", "to", "sequence", "of", "rectangles", "efficiently", ".", "It", "represents", "the", "clipped", "edges", "by", "their", "bounding", "boxes", "rather", "than", "as", "a", "pair", "of", "endpoints", ".", "Specificall...
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/edge_clipping.go#L465-L481
28,033
golang/geo
s2/predicates.go
stableSign
func stableSign(a, b, c Point) Direction { ab := b.Sub(a.Vector) ab2 := ab.Norm2() bc := c.Sub(b.Vector) bc2 := bc.Norm2() ca := a.Sub(c.Vector) ca2 := ca.Norm2() // Now compute the determinant ((A-C)x(B-C)).C, where the vertices have been // cyclically permuted if necessary so that AB is the longest edge. (Th...
go
func stableSign(a, b, c Point) Direction { ab := b.Sub(a.Vector) ab2 := ab.Norm2() bc := c.Sub(b.Vector) bc2 := bc.Norm2() ca := a.Sub(c.Vector) ca2 := ca.Norm2() // Now compute the determinant ((A-C)x(B-C)).C, where the vertices have been // cyclically permuted if necessary so that AB is the longest edge. (Th...
[ "func", "stableSign", "(", "a", ",", "b", ",", "c", "Point", ")", "Direction", "{", "ab", ":=", "b", ".", "Sub", "(", "a", ".", "Vector", ")", "\n", "ab2", ":=", "ab", ".", "Norm2", "(", ")", "\n", "bc", ":=", "c", ".", "Sub", "(", "b", "."...
// stableSign reports the direction sign of the points in a numerically stable way. // Unlike triageSign, this method can usually compute the correct determinant sign // even when all three points are as collinear as possible. For example if three // points are spaced 1km apart along a random line on the Earth's surfac...
[ "stableSign", "reports", "the", "direction", "sign", "of", "the", "points", "in", "a", "numerically", "stable", "way", ".", "Unlike", "triageSign", "this", "method", "can", "usually", "compute", "the", "correct", "determinant", "sign", "even", "when", "all", "...
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/predicates.go#L156-L193
28,034
golang/geo
s2/predicates.go
triageSign
func triageSign(a, b, c Point) Direction { det := a.Cross(b.Vector).Dot(c.Vector) if det > maxDeterminantError { return CounterClockwise } if det < -maxDeterminantError { return Clockwise } return Indeterminate }
go
func triageSign(a, b, c Point) Direction { det := a.Cross(b.Vector).Dot(c.Vector) if det > maxDeterminantError { return CounterClockwise } if det < -maxDeterminantError { return Clockwise } return Indeterminate }
[ "func", "triageSign", "(", "a", ",", "b", ",", "c", "Point", ")", "Direction", "{", "det", ":=", "a", ".", "Cross", "(", "b", ".", "Vector", ")", ".", "Dot", "(", "c", ".", "Vector", ")", "\n", "if", "det", ">", "maxDeterminantError", "{", "retur...
// triageSign returns the direction sign of the points. It returns Indeterminate if two // points are identical or the result is uncertain. Uncertain cases can be resolved, if // desired, by calling expensiveSign. // // The purpose of this method is to allow additional cheap tests to be done without // calling expensiv...
[ "triageSign", "returns", "the", "direction", "sign", "of", "the", "points", ".", "It", "returns", "Indeterminate", "if", "two", "points", "are", "identical", "or", "the", "result", "is", "uncertain", ".", "Uncertain", "cases", "can", "be", "resolved", "if", ...
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/predicates.go#L201-L210
28,035
golang/geo
s2/predicates.go
expensiveSign
func expensiveSign(a, b, c Point) Direction { // Return Indeterminate if and only if two points are the same. // This ensures RobustSign(a,b,c) == Indeterminate if and only if a == b, b == c, or c == a. // ie. Property 1 of RobustSign. if a == b || b == c || c == a { return Indeterminate } // Next we try recom...
go
func expensiveSign(a, b, c Point) Direction { // Return Indeterminate if and only if two points are the same. // This ensures RobustSign(a,b,c) == Indeterminate if and only if a == b, b == c, or c == a. // ie. Property 1 of RobustSign. if a == b || b == c || c == a { return Indeterminate } // Next we try recom...
[ "func", "expensiveSign", "(", "a", ",", "b", ",", "c", "Point", ")", "Direction", "{", "// Return Indeterminate if and only if two points are the same.", "// This ensures RobustSign(a,b,c) == Indeterminate if and only if a == b, b == c, or c == a.", "// ie. Property 1 of RobustSign.", ...
// expensiveSign reports the direction sign of the points. It returns Indeterminate // if two of the input points are the same. It uses multiple-precision arithmetic // to ensure that its results are always self-consistent.
[ "expensiveSign", "reports", "the", "direction", "sign", "of", "the", "points", ".", "It", "returns", "Indeterminate", "if", "two", "of", "the", "input", "points", "are", "the", "same", ".", "It", "uses", "multiple", "-", "precision", "arithmetic", "to", "ens...
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/predicates.go#L215-L236
28,036
golang/geo
s2/predicates.go
exactCompareDistances
func exactCompareDistances(x, a, b r3.PreciseVector) int { // This code produces the same result as though all points were reprojected // to lie exactly on the surface of the unit sphere. It is based on testing // whether x.Dot(a.Normalize()) < x.Dot(b.Normalize()), reformulated // so that it can be evaluated using...
go
func exactCompareDistances(x, a, b r3.PreciseVector) int { // This code produces the same result as though all points were reprojected // to lie exactly on the surface of the unit sphere. It is based on testing // whether x.Dot(a.Normalize()) < x.Dot(b.Normalize()), reformulated // so that it can be evaluated using...
[ "func", "exactCompareDistances", "(", "x", ",", "a", ",", "b", "r3", ".", "PreciseVector", ")", "int", "{", "// This code produces the same result as though all points were reprojected", "// to lie exactly on the surface of the unit sphere. It is based on testing", "// whether x.Dot(...
// exactCompareDistances returns -1, 0, or 1 after comparing using the values as // PreciseVectors.
[ "exactCompareDistances", "returns", "-", "1", "0", "or", "1", "after", "comparing", "using", "the", "values", "as", "PreciseVectors", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/predicates.go#L527-L550
28,037
golang/geo
s2/predicates.go
CompareDistance
func CompareDistance(x, y Point, r s1.ChordAngle) int { // As with CompareDistances, we start by comparing dot products because // the sin^2 method is only valid when the distance XY and the limit "r" are // both less than 90 degrees. sign := triageCompareCosDistance(x, y, float64(r)) if sign != 0 { return sign ...
go
func CompareDistance(x, y Point, r s1.ChordAngle) int { // As with CompareDistances, we start by comparing dot products because // the sin^2 method is only valid when the distance XY and the limit "r" are // both less than 90 degrees. sign := triageCompareCosDistance(x, y, float64(r)) if sign != 0 { return sign ...
[ "func", "CompareDistance", "(", "x", ",", "y", "Point", ",", "r", "s1", ".", "ChordAngle", ")", "int", "{", "// As with CompareDistances, we start by comparing dot products because", "// the sin^2 method is only valid when the distance XY and the limit \"r\" are", "// both less tha...
// CompareDistance returns -1, 0, or +1 according to whether the distance XY is // respectively less than, equal to, or greater than the provided chord angle. Distances are measured // with respect to the positions of all points as though they are projected to lie // exactly on the surface of the unit sphere.
[ "CompareDistance", "returns", "-", "1", "0", "or", "+", "1", "according", "to", "whether", "the", "distance", "XY", "is", "respectively", "less", "than", "equal", "to", "or", "greater", "than", "the", "provided", "chord", "angle", ".", "Distances", "are", ...
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/predicates.go#L592-L612
28,038
golang/geo
s2/predicates.go
triageCompareCosDistance
func triageCompareCosDistance(x, y Point, r2 float64) int { cosXY, cosXYError := cosDistance(x, y) cosR := 1.0 - 0.5*r2 cosRError := 2.0 * dblError * cosR diff := cosXY - cosR err := cosXYError + cosRError if diff > err { return -1 } if diff < -err { return 1 } return 0 }
go
func triageCompareCosDistance(x, y Point, r2 float64) int { cosXY, cosXYError := cosDistance(x, y) cosR := 1.0 - 0.5*r2 cosRError := 2.0 * dblError * cosR diff := cosXY - cosR err := cosXYError + cosRError if diff > err { return -1 } if diff < -err { return 1 } return 0 }
[ "func", "triageCompareCosDistance", "(", "x", ",", "y", "Point", ",", "r2", "float64", ")", "int", "{", "cosXY", ",", "cosXYError", ":=", "cosDistance", "(", "x", ",", "y", ")", "\n", "cosR", ":=", "1.0", "-", "0.5", "*", "r2", "\n", "cosRError", ":=...
// triageCompareCosDistance returns -1, 0, or +1 according to whether the distance XY is // less than, equal to, or greater than r2 respectively using cos distance.
[ "triageCompareCosDistance", "returns", "-", "1", "0", "or", "+", "1", "according", "to", "whether", "the", "distance", "XY", "is", "less", "than", "equal", "to", "or", "greater", "than", "r2", "respectively", "using", "cos", "distance", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/predicates.go#L616-L629
28,039
golang/geo
s2/predicates.go
triageCompareSin2Distance
func triageCompareSin2Distance(x, y Point, r2 float64) int { // Only valid for distance limits < 90 degrees. sin2XY, sin2XYError := sin2Distance(x, y) sin2R := r2 * (1.0 - 0.25*r2) sin2RError := 3.0 * dblError * sin2R diff := sin2XY - sin2R err := sin2XYError + sin2RError if diff > err { return 1 } if diff <...
go
func triageCompareSin2Distance(x, y Point, r2 float64) int { // Only valid for distance limits < 90 degrees. sin2XY, sin2XYError := sin2Distance(x, y) sin2R := r2 * (1.0 - 0.25*r2) sin2RError := 3.0 * dblError * sin2R diff := sin2XY - sin2R err := sin2XYError + sin2RError if diff > err { return 1 } if diff <...
[ "func", "triageCompareSin2Distance", "(", "x", ",", "y", "Point", ",", "r2", "float64", ")", "int", "{", "// Only valid for distance limits < 90 degrees.", "sin2XY", ",", "sin2XYError", ":=", "sin2Distance", "(", "x", ",", "y", ")", "\n", "sin2R", ":=", "r2", ...
// triageCompareSin2Distance returns -1, 0, or +1 according to whether the distance XY is // less than, equal to, or greater than r2 respectively using sin^2 distance.
[ "triageCompareSin2Distance", "returns", "-", "1", "0", "or", "+", "1", "according", "to", "whether", "the", "distance", "XY", "is", "less", "than", "equal", "to", "or", "greater", "than", "r2", "respectively", "using", "sin^2", "distance", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/predicates.go#L633-L647
28,040
golang/geo
s2/predicates.go
exactCompareDistance
func exactCompareDistance(x, y r3.PreciseVector, r2 *big.Float) int { // This code produces the same result as though all points were reprojected // to lie exactly on the surface of the unit sphere. It is based on // comparing the cosine of the angle XY (when both points are projected to // lie exactly on the sphe...
go
func exactCompareDistance(x, y r3.PreciseVector, r2 *big.Float) int { // This code produces the same result as though all points were reprojected // to lie exactly on the surface of the unit sphere. It is based on // comparing the cosine of the angle XY (when both points are projected to // lie exactly on the sphe...
[ "func", "exactCompareDistance", "(", "x", ",", "y", "r3", ".", "PreciseVector", ",", "r2", "*", "big", ".", "Float", ")", "int", "{", "// This code produces the same result as though all points were reprojected", "// to lie exactly on the surface of the unit sphere. It is base...
// exactCompareDistance returns -1, 0, or +1 after comparing using PreciseVectors.
[ "exactCompareDistance", "returns", "-", "1", "0", "or", "+", "1", "after", "comparing", "using", "PreciseVectors", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/predicates.go#L655-L678
28,041
golang/geo
s2/rect_bounder.go
RectBound
func (r *RectBounder) RectBound() Rect { return r.bound.expanded(LatLng{s1.Angle(2 * dblEpsilon), 0}).PolarClosure() }
go
func (r *RectBounder) RectBound() Rect { return r.bound.expanded(LatLng{s1.Angle(2 * dblEpsilon), 0}).PolarClosure() }
[ "func", "(", "r", "*", "RectBounder", ")", "RectBound", "(", ")", "Rect", "{", "return", "r", ".", "bound", ".", "expanded", "(", "LatLng", "{", "s1", ".", "Angle", "(", "2", "*", "dblEpsilon", ")", ",", "0", "}", ")", ".", "PolarClosure", "(", "...
// RectBound returns the bounding rectangle of the edge chain that connects the // vertices defined so far. This bound satisfies the guarantee made // above, i.e. if the edge chain defines a Loop, then the bound contains // the LatLng coordinates of all Points contained by the loop.
[ "RectBound", "returns", "the", "bounding", "rectangle", "of", "the", "edge", "chain", "that", "connects", "the", "vertices", "defined", "so", "far", ".", "This", "bound", "satisfies", "the", "guarantee", "made", "above", "i", ".", "e", ".", "if", "the", "e...
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/rect_bounder.go#L202-L204
28,042
golang/geo
s2/edge_distances.go
UpdateMaxDistance
func UpdateMaxDistance(x, a, b Point, maxDist s1.ChordAngle) (s1.ChordAngle, bool) { dist := maxChordAngle(ChordAngleBetweenPoints(x, a), ChordAngleBetweenPoints(x, b)) if dist > s1.RightChordAngle { dist, _ = updateMinDistance(Point{x.Mul(-1)}, a, b, dist, true) dist = s1.StraightChordAngle - dist } if maxDist...
go
func UpdateMaxDistance(x, a, b Point, maxDist s1.ChordAngle) (s1.ChordAngle, bool) { dist := maxChordAngle(ChordAngleBetweenPoints(x, a), ChordAngleBetweenPoints(x, b)) if dist > s1.RightChordAngle { dist, _ = updateMinDistance(Point{x.Mul(-1)}, a, b, dist, true) dist = s1.StraightChordAngle - dist } if maxDist...
[ "func", "UpdateMaxDistance", "(", "x", ",", "a", ",", "b", "Point", ",", "maxDist", "s1", ".", "ChordAngle", ")", "(", "s1", ".", "ChordAngle", ",", "bool", ")", "{", "dist", ":=", "maxChordAngle", "(", "ChordAngleBetweenPoints", "(", "x", ",", "a", ")...
// UpdateMaxDistance checks if the distance from X to the edge AB is greater // than maxDist, and if so, returns the updated value and true. // Otherwise it returns false. The case A == B is handled correctly.
[ "UpdateMaxDistance", "checks", "if", "the", "distance", "from", "X", "to", "the", "edge", "AB", "is", "greater", "than", "maxDist", "and", "if", "so", "returns", "the", "updated", "value", "and", "true", ".", "Otherwise", "it", "returns", "false", ".", "Th...
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/edge_distances.go#L62-L73
28,043
golang/geo
s2/edge_distances.go
Project
func Project(x, a, b Point) Point { aXb := a.PointCross(b) // Find the closest point to X along the great circle through AB. p := x.Sub(aXb.Mul(x.Dot(aXb.Vector) / aXb.Vector.Norm2())) // If this point is on the edge AB, then it's the closest point. if Sign(aXb, a, Point{p}) && Sign(Point{p}, b, aXb) { return P...
go
func Project(x, a, b Point) Point { aXb := a.PointCross(b) // Find the closest point to X along the great circle through AB. p := x.Sub(aXb.Mul(x.Dot(aXb.Vector) / aXb.Vector.Norm2())) // If this point is on the edge AB, then it's the closest point. if Sign(aXb, a, Point{p}) && Sign(Point{p}, b, aXb) { return P...
[ "func", "Project", "(", "x", ",", "a", ",", "b", "Point", ")", "Point", "{", "aXb", ":=", "a", ".", "PointCross", "(", "b", ")", "\n", "// Find the closest point to X along the great circle through AB.", "p", ":=", "x", ".", "Sub", "(", "aXb", ".", "Mul", ...
// Project returns the point along the edge AB that is closest to the point X. // The fractional distance of this point along the edge AB can be obtained // using DistanceFraction. // // This requires that all points are unit length.
[ "Project", "returns", "the", "point", "along", "the", "edge", "AB", "that", "is", "closest", "to", "the", "point", "X", ".", "The", "fractional", "distance", "of", "this", "point", "along", "the", "edge", "AB", "can", "be", "obtained", "using", "DistanceFr...
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/edge_distances.go#L96-L111
28,044
golang/geo
s2/edge_distances.go
InterpolateAtDistance
func InterpolateAtDistance(ax s1.Angle, a, b Point) Point { aRad := ax.Radians() // Use PointCross to compute the tangent vector at A towards B. The // result is always perpendicular to A, even if A=B or A=-B, but it is not // necessarily unit length. (We effectively normalize it below.) normal := a.PointCross(b)...
go
func InterpolateAtDistance(ax s1.Angle, a, b Point) Point { aRad := ax.Radians() // Use PointCross to compute the tangent vector at A towards B. The // result is always perpendicular to A, even if A=B or A=-B, but it is not // necessarily unit length. (We effectively normalize it below.) normal := a.PointCross(b)...
[ "func", "InterpolateAtDistance", "(", "ax", "s1", ".", "Angle", ",", "a", ",", "b", "Point", ")", "Point", "{", "aRad", ":=", "ax", ".", "Radians", "(", ")", "\n\n", "// Use PointCross to compute the tangent vector at A towards B. The", "// result is always perpendicu...
// InterpolateAtDistance returns the point X along the line segment AB whose // distance from A is the angle ax.
[ "InterpolateAtDistance", "returns", "the", "point", "X", "along", "the", "line", "segment", "AB", "whose", "distance", "from", "A", "is", "the", "angle", "ax", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/edge_distances.go#L142-L157
28,045
golang/geo
s2/edge_distances.go
updateMinDistance
func updateMinDistance(x, a, b Point, minDist s1.ChordAngle, alwaysUpdate bool) (s1.ChordAngle, bool) { if d, ok := interiorDist(x, a, b, minDist, alwaysUpdate); ok { // Minimum distance is attained along the edge interior. return d, true } // Otherwise the minimum distance is to one of the endpoints. xa2, xb2...
go
func updateMinDistance(x, a, b Point, minDist s1.ChordAngle, alwaysUpdate bool) (s1.ChordAngle, bool) { if d, ok := interiorDist(x, a, b, minDist, alwaysUpdate); ok { // Minimum distance is attained along the edge interior. return d, true } // Otherwise the minimum distance is to one of the endpoints. xa2, xb2...
[ "func", "updateMinDistance", "(", "x", ",", "a", ",", "b", "Point", ",", "minDist", "s1", ".", "ChordAngle", ",", "alwaysUpdate", "bool", ")", "(", "s1", ".", "ChordAngle", ",", "bool", ")", "{", "if", "d", ",", "ok", ":=", "interiorDist", "(", "x", ...
// updateMinDistance computes the distance from a point X to a line segment AB, // and if either the distance was less than the given minDist, or alwaysUpdate is // true, the value and whether it was updated are returned.
[ "updateMinDistance", "computes", "the", "distance", "from", "a", "point", "X", "to", "a", "line", "segment", "AB", "and", "if", "either", "the", "distance", "was", "less", "than", "the", "given", "minDist", "or", "alwaysUpdate", "is", "true", "the", "value",...
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/edge_distances.go#L207-L220
28,046
golang/geo
s2/edge_distances.go
updateEdgePairMinDistance
func updateEdgePairMinDistance(a0, a1, b0, b1 Point, minDist s1.ChordAngle) (s1.ChordAngle, bool) { if minDist == 0 { return 0, false } if CrossingSign(a0, a1, b0, b1) == Cross { minDist = 0 return 0, true } // Otherwise, the minimum distance is achieved at an endpoint of at least // one of the two edges. ...
go
func updateEdgePairMinDistance(a0, a1, b0, b1 Point, minDist s1.ChordAngle) (s1.ChordAngle, bool) { if minDist == 0 { return 0, false } if CrossingSign(a0, a1, b0, b1) == Cross { minDist = 0 return 0, true } // Otherwise, the minimum distance is achieved at an endpoint of at least // one of the two edges. ...
[ "func", "updateEdgePairMinDistance", "(", "a0", ",", "a1", ",", "b0", ",", "b1", "Point", ",", "minDist", "s1", ".", "ChordAngle", ")", "(", "s1", ".", "ChordAngle", ",", "bool", ")", "{", "if", "minDist", "==", "0", "{", "return", "0", ",", "false",...
// updateEdgePairMinDistance computes the minimum distance between the given // pair of edges. If the two edges cross, the distance is zero. The cases // a0 == a1 and b0 == b1 are handled correctly.
[ "updateEdgePairMinDistance", "computes", "the", "minimum", "distance", "between", "the", "given", "pair", "of", "edges", ".", "If", "the", "two", "edges", "cross", "the", "distance", "is", "zero", ".", "The", "cases", "a0", "==", "a1", "and", "b0", "==", "...
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/edge_distances.go#L300-L320
28,047
golang/geo
s2/edge_distances.go
updateEdgePairMaxDistance
func updateEdgePairMaxDistance(a0, a1, b0, b1 Point, maxDist s1.ChordAngle) (s1.ChordAngle, bool) { if maxDist == s1.StraightChordAngle { return s1.StraightChordAngle, false } if CrossingSign(a0, a1, Point{b0.Mul(-1)}, Point{b1.Mul(-1)}) == Cross { return s1.StraightChordAngle, true } // Otherwise, the maximu...
go
func updateEdgePairMaxDistance(a0, a1, b0, b1 Point, maxDist s1.ChordAngle) (s1.ChordAngle, bool) { if maxDist == s1.StraightChordAngle { return s1.StraightChordAngle, false } if CrossingSign(a0, a1, Point{b0.Mul(-1)}, Point{b1.Mul(-1)}) == Cross { return s1.StraightChordAngle, true } // Otherwise, the maximu...
[ "func", "updateEdgePairMaxDistance", "(", "a0", ",", "a1", ",", "b0", ",", "b1", "Point", ",", "maxDist", "s1", ".", "ChordAngle", ")", "(", "s1", ".", "ChordAngle", ",", "bool", ")", "{", "if", "maxDist", "==", "s1", ".", "StraightChordAngle", "{", "r...
// updateEdgePairMaxDistance reports the minimum distance between the given pair of edges. // If one edge crosses the antipodal reflection of the other, the distance is pi.
[ "updateEdgePairMaxDistance", "reports", "the", "minimum", "distance", "between", "the", "given", "pair", "of", "edges", ".", "If", "one", "edge", "crosses", "the", "antipodal", "reflection", "of", "the", "other", "the", "distance", "is", "pi", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/edge_distances.go#L324-L343
28,048
golang/geo
s2/contains_point_query.go
NewContainsPointQuery
func NewContainsPointQuery(index *ShapeIndex, model VertexModel) *ContainsPointQuery { return &ContainsPointQuery{ index: index, model: model, iter: index.Iterator(), } }
go
func NewContainsPointQuery(index *ShapeIndex, model VertexModel) *ContainsPointQuery { return &ContainsPointQuery{ index: index, model: model, iter: index.Iterator(), } }
[ "func", "NewContainsPointQuery", "(", "index", "*", "ShapeIndex", ",", "model", "VertexModel", ")", "*", "ContainsPointQuery", "{", "return", "&", "ContainsPointQuery", "{", "index", ":", "index", ",", "model", ":", "model", ",", "iter", ":", "index", ".", "...
// NewContainsPointQuery creates a new instance of the ContainsPointQuery for the index // and given vertex model choice.
[ "NewContainsPointQuery", "creates", "a", "new", "instance", "of", "the", "ContainsPointQuery", "for", "the", "index", "and", "given", "vertex", "model", "choice", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/contains_point_query.go#L61-L67
28,049
golang/geo
s2/contains_point_query.go
shapeContains
func (q *ContainsPointQuery) shapeContains(clipped *clippedShape, center, p Point) bool { inside := clipped.containsCenter numEdges := clipped.numEdges() if numEdges <= 0 { return inside } shape := q.index.Shape(clipped.shapeID) if shape.Dimension() != 2 { // Points and polylines can be ignored unless the ve...
go
func (q *ContainsPointQuery) shapeContains(clipped *clippedShape, center, p Point) bool { inside := clipped.containsCenter numEdges := clipped.numEdges() if numEdges <= 0 { return inside } shape := q.index.Shape(clipped.shapeID) if shape.Dimension() != 2 { // Points and polylines can be ignored unless the ve...
[ "func", "(", "q", "*", "ContainsPointQuery", ")", "shapeContains", "(", "clipped", "*", "clippedShape", ",", "center", ",", "p", "Point", ")", "bool", "{", "inside", ":=", "clipped", ".", "containsCenter", "\n", "numEdges", ":=", "clipped", ".", "numEdges", ...
// shapeContains reports whether the clippedShape from the iterator's center position contains // the given point.
[ "shapeContains", "reports", "whether", "the", "clippedShape", "from", "the", "iterator", "s", "center", "position", "contains", "the", "given", "point", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/contains_point_query.go#L87-L136
28,050
golang/geo
s2/contains_point_query.go
visitContainingShapes
func (q *ContainsPointQuery) visitContainingShapes(p Point, f shapeVisitorFunc) bool { // This function returns false only if the algorithm terminates early // because the visitor function returned false. if !q.iter.LocatePoint(p) { return true } cell := q.iter.IndexCell() for _, clipped := range cell.shapes {...
go
func (q *ContainsPointQuery) visitContainingShapes(p Point, f shapeVisitorFunc) bool { // This function returns false only if the algorithm terminates early // because the visitor function returned false. if !q.iter.LocatePoint(p) { return true } cell := q.iter.IndexCell() for _, clipped := range cell.shapes {...
[ "func", "(", "q", "*", "ContainsPointQuery", ")", "visitContainingShapes", "(", "p", "Point", ",", "f", "shapeVisitorFunc", ")", "bool", "{", "// This function returns false only if the algorithm terminates early", "// because the visitor function returned false.", "if", "!", ...
// visitContainingShapes visits all shapes in the given index that contain the // given point p, terminating early if the given visitor function returns false, // in which case visitContainingShapes returns false. Each shape is // visited at most once.
[ "visitContainingShapes", "visits", "all", "shapes", "in", "the", "given", "index", "that", "contain", "the", "given", "point", "p", "terminating", "early", "if", "the", "given", "visitor", "function", "returns", "false", "in", "which", "case", "visitContainingShap...
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/contains_point_query.go#L161-L176
28,051
golang/geo
s2/contains_point_query.go
ContainingShapes
func (q *ContainsPointQuery) ContainingShapes(p Point) []Shape { var shapes []Shape q.visitContainingShapes(p, func(shape Shape) bool { shapes = append(shapes, shape) return true }) return shapes }
go
func (q *ContainsPointQuery) ContainingShapes(p Point) []Shape { var shapes []Shape q.visitContainingShapes(p, func(shape Shape) bool { shapes = append(shapes, shape) return true }) return shapes }
[ "func", "(", "q", "*", "ContainsPointQuery", ")", "ContainingShapes", "(", "p", "Point", ")", "[", "]", "Shape", "{", "var", "shapes", "[", "]", "Shape", "\n", "q", ".", "visitContainingShapes", "(", "p", ",", "func", "(", "shape", "Shape", ")", "bool"...
// ContainingShapes returns a slice of all shapes that contain the given point.
[ "ContainingShapes", "returns", "a", "slice", "of", "all", "shapes", "that", "contain", "the", "given", "point", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/contains_point_query.go#L179-L186
28,052
golang/geo
s2/cellid.go
CellIDFromToken
func CellIDFromToken(s string) CellID { if len(s) > 16 { return CellID(0) } n, err := strconv.ParseUint(s, 16, 64) if err != nil { return CellID(0) } // Equivalent to right-padding string with zeros to 16 characters. if len(s) < 16 { n = n << (4 * uint(16-len(s))) } return CellID(n) }
go
func CellIDFromToken(s string) CellID { if len(s) > 16 { return CellID(0) } n, err := strconv.ParseUint(s, 16, 64) if err != nil { return CellID(0) } // Equivalent to right-padding string with zeros to 16 characters. if len(s) < 16 { n = n << (4 * uint(16-len(s))) } return CellID(n) }
[ "func", "CellIDFromToken", "(", "s", "string", ")", "CellID", "{", "if", "len", "(", "s", ")", ">", "16", "{", "return", "CellID", "(", "0", ")", "\n", "}", "\n", "n", ",", "err", ":=", "strconv", ".", "ParseUint", "(", "s", ",", "16", ",", "64...
// CellIDFromToken returns a cell given a hex-encoded string of its uint64 ID.
[ "CellIDFromToken", "returns", "a", "cell", "given", "a", "hex", "-", "encoded", "string", "of", "its", "uint64", "ID", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellid.go#L116-L129
28,053
golang/geo
s2/cellid.go
ToToken
func (ci CellID) ToToken() string { s := strings.TrimRight(fmt.Sprintf("%016x", uint64(ci)), "0") if len(s) == 0 { return "X" } return s }
go
func (ci CellID) ToToken() string { s := strings.TrimRight(fmt.Sprintf("%016x", uint64(ci)), "0") if len(s) == 0 { return "X" } return s }
[ "func", "(", "ci", "CellID", ")", "ToToken", "(", ")", "string", "{", "s", ":=", "strings", ".", "TrimRight", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "uint64", "(", "ci", ")", ")", ",", "\"", "\"", ")", "\n", "if", "len", "(", "s", ...
// ToToken returns a hex-encoded string of the uint64 cell id, with leading // zeros included but trailing zeros stripped.
[ "ToToken", "returns", "a", "hex", "-", "encoded", "string", "of", "the", "uint64", "cell", "id", "with", "leading", "zeros", "included", "but", "trailing", "zeros", "stripped", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellid.go#L133-L139
28,054
golang/geo
s2/cellid.go
Parent
func (ci CellID) Parent(level int) CellID { lsb := lsbForLevel(level) return CellID((uint64(ci) & -lsb) | lsb) }
go
func (ci CellID) Parent(level int) CellID { lsb := lsbForLevel(level) return CellID((uint64(ci) & -lsb) | lsb) }
[ "func", "(", "ci", "CellID", ")", "Parent", "(", "level", "int", ")", "CellID", "{", "lsb", ":=", "lsbForLevel", "(", "level", ")", "\n", "return", "CellID", "(", "(", "uint64", "(", "ci", ")", "&", "-", "lsb", ")", "|", "lsb", ")", "\n", "}" ]
// Parent returns the cell at the given level, which must be no greater than the current level.
[ "Parent", "returns", "the", "cell", "at", "the", "given", "level", "which", "must", "be", "no", "greater", "than", "the", "current", "level", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellid.go#L174-L177
28,055
golang/geo
s2/cellid.go
Children
func (ci CellID) Children() [4]CellID { var ch [4]CellID lsb := CellID(ci.lsb()) ch[0] = ci - lsb + lsb>>2 lsb >>= 1 ch[1] = ch[0] + lsb ch[2] = ch[1] + lsb ch[3] = ch[2] + lsb return ch }
go
func (ci CellID) Children() [4]CellID { var ch [4]CellID lsb := CellID(ci.lsb()) ch[0] = ci - lsb + lsb>>2 lsb >>= 1 ch[1] = ch[0] + lsb ch[2] = ch[1] + lsb ch[3] = ch[2] + lsb return ch }
[ "func", "(", "ci", "CellID", ")", "Children", "(", ")", "[", "4", "]", "CellID", "{", "var", "ch", "[", "4", "]", "CellID", "\n", "lsb", ":=", "CellID", "(", "ci", ".", "lsb", "(", ")", ")", "\n", "ch", "[", "0", "]", "=", "ci", "-", "lsb",...
// Children returns the four immediate children of this cell. // If ci is a leaf cell, it returns four identical cells that are not the children.
[ "Children", "returns", "the", "four", "immediate", "children", "of", "this", "cell", ".", "If", "ci", "is", "a", "leaf", "cell", "it", "returns", "four", "identical", "cells", "that", "are", "not", "the", "children", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellid.go#L193-L202
28,056
golang/geo
s2/cellid.go
EdgeNeighbors
func (ci CellID) EdgeNeighbors() [4]CellID { level := ci.Level() size := sizeIJ(level) f, i, j, _ := ci.faceIJOrientation() return [4]CellID{ cellIDFromFaceIJWrap(f, i, j-size).Parent(level), cellIDFromFaceIJWrap(f, i+size, j).Parent(level), cellIDFromFaceIJWrap(f, i, j+size).Parent(level), cellIDFromFaceIJ...
go
func (ci CellID) EdgeNeighbors() [4]CellID { level := ci.Level() size := sizeIJ(level) f, i, j, _ := ci.faceIJOrientation() return [4]CellID{ cellIDFromFaceIJWrap(f, i, j-size).Parent(level), cellIDFromFaceIJWrap(f, i+size, j).Parent(level), cellIDFromFaceIJWrap(f, i, j+size).Parent(level), cellIDFromFaceIJ...
[ "func", "(", "ci", "CellID", ")", "EdgeNeighbors", "(", ")", "[", "4", "]", "CellID", "{", "level", ":=", "ci", ".", "Level", "(", ")", "\n", "size", ":=", "sizeIJ", "(", "level", ")", "\n", "f", ",", "i", ",", "j", ",", "_", ":=", "ci", ".",...
// EdgeNeighbors returns the four cells that are adjacent across the cell's four edges. // Edges 0, 1, 2, 3 are in the down, right, up, left directions in the face space. // All neighbors are guaranteed to be distinct.
[ "EdgeNeighbors", "returns", "the", "four", "cells", "that", "are", "adjacent", "across", "the", "cell", "s", "four", "edges", ".", "Edges", "0", "1", "2", "3", "are", "in", "the", "down", "right", "up", "left", "directions", "in", "the", "face", "space",...
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellid.go#L211-L221
28,057
golang/geo
s2/cellid.go
Contains
func (ci CellID) Contains(oci CellID) bool { return uint64(ci.RangeMin()) <= uint64(oci) && uint64(oci) <= uint64(ci.RangeMax()) }
go
func (ci CellID) Contains(oci CellID) bool { return uint64(ci.RangeMin()) <= uint64(oci) && uint64(oci) <= uint64(ci.RangeMax()) }
[ "func", "(", "ci", "CellID", ")", "Contains", "(", "oci", "CellID", ")", "bool", "{", "return", "uint64", "(", "ci", ".", "RangeMin", "(", ")", ")", "<=", "uint64", "(", "oci", ")", "&&", "uint64", "(", "oci", ")", "<=", "uint64", "(", "ci", ".",...
// Contains returns true iff the CellID contains oci.
[ "Contains", "returns", "true", "iff", "the", "CellID", "contains", "oci", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellid.go#L321-L323
28,058
golang/geo
s2/cellid.go
Intersects
func (ci CellID) Intersects(oci CellID) bool { return uint64(oci.RangeMin()) <= uint64(ci.RangeMax()) && uint64(oci.RangeMax()) >= uint64(ci.RangeMin()) }
go
func (ci CellID) Intersects(oci CellID) bool { return uint64(oci.RangeMin()) <= uint64(ci.RangeMax()) && uint64(oci.RangeMax()) >= uint64(ci.RangeMin()) }
[ "func", "(", "ci", "CellID", ")", "Intersects", "(", "oci", "CellID", ")", "bool", "{", "return", "uint64", "(", "oci", ".", "RangeMin", "(", ")", ")", "<=", "uint64", "(", "ci", ".", "RangeMax", "(", ")", ")", "&&", "uint64", "(", "oci", ".", "R...
// Intersects returns true iff the CellID intersects oci.
[ "Intersects", "returns", "true", "iff", "the", "CellID", "intersects", "oci", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellid.go#L326-L328
28,059
golang/geo
s2/cellid.go
ChildBeginAtLevel
func (ci CellID) ChildBeginAtLevel(level int) CellID { return CellID(uint64(ci) - ci.lsb() + lsbForLevel(level)) }
go
func (ci CellID) ChildBeginAtLevel(level int) CellID { return CellID(uint64(ci) - ci.lsb() + lsbForLevel(level)) }
[ "func", "(", "ci", "CellID", ")", "ChildBeginAtLevel", "(", "level", "int", ")", "CellID", "{", "return", "CellID", "(", "uint64", "(", "ci", ")", "-", "ci", ".", "lsb", "(", ")", "+", "lsbForLevel", "(", "level", ")", ")", "\n", "}" ]
// ChildBeginAtLevel returns the first cell in a traversal of children a given level deeper than this cell, in // Hilbert curve order. The given level must be no smaller than the cell's level. // See ChildBegin for example use.
[ "ChildBeginAtLevel", "returns", "the", "first", "cell", "in", "a", "traversal", "of", "children", "a", "given", "level", "deeper", "than", "this", "cell", "in", "Hilbert", "curve", "order", ".", "The", "given", "level", "must", "be", "no", "smaller", "than",...
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellid.go#L366-L368
28,060
golang/geo
s2/cellid.go
ChildEnd
func (ci CellID) ChildEnd() CellID { ol := ci.lsb() return CellID(uint64(ci) + ol + ol>>2) }
go
func (ci CellID) ChildEnd() CellID { ol := ci.lsb() return CellID(uint64(ci) + ol + ol>>2) }
[ "func", "(", "ci", "CellID", ")", "ChildEnd", "(", ")", "CellID", "{", "ol", ":=", "ci", ".", "lsb", "(", ")", "\n", "return", "CellID", "(", "uint64", "(", "ci", ")", "+", "ol", "+", "ol", ">>", "2", ")", "\n", "}" ]
// ChildEnd returns the first cell after a traversal of the children of this cell in Hilbert curve order. // The returned cell may be invalid.
[ "ChildEnd", "returns", "the", "first", "cell", "after", "a", "traversal", "of", "the", "children", "of", "this", "cell", "in", "Hilbert", "curve", "order", ".", "The", "returned", "cell", "may", "be", "invalid", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellid.go#L372-L375
28,061
golang/geo
s2/cellid.go
ChildEndAtLevel
func (ci CellID) ChildEndAtLevel(level int) CellID { return CellID(uint64(ci) + ci.lsb() + lsbForLevel(level)) }
go
func (ci CellID) ChildEndAtLevel(level int) CellID { return CellID(uint64(ci) + ci.lsb() + lsbForLevel(level)) }
[ "func", "(", "ci", "CellID", ")", "ChildEndAtLevel", "(", "level", "int", ")", "CellID", "{", "return", "CellID", "(", "uint64", "(", "ci", ")", "+", "ci", ".", "lsb", "(", ")", "+", "lsbForLevel", "(", "level", ")", ")", "\n", "}" ]
// ChildEndAtLevel returns the first cell after the last child in a traversal of children a given level deeper // than this cell, in Hilbert curve order. // The given level must be no smaller than the cell's level. // The returned cell may be invalid.
[ "ChildEndAtLevel", "returns", "the", "first", "cell", "after", "the", "last", "child", "in", "a", "traversal", "of", "children", "a", "given", "level", "deeper", "than", "this", "cell", "in", "Hilbert", "curve", "order", ".", "The", "given", "level", "must",...
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellid.go#L381-L383
28,062
golang/geo
s2/cellid.go
NextWrap
func (ci CellID) NextWrap() CellID { n := ci.Next() if uint64(n) < wrapOffset { return n } return CellID(uint64(n) - wrapOffset) }
go
func (ci CellID) NextWrap() CellID { n := ci.Next() if uint64(n) < wrapOffset { return n } return CellID(uint64(n) - wrapOffset) }
[ "func", "(", "ci", "CellID", ")", "NextWrap", "(", ")", "CellID", "{", "n", ":=", "ci", ".", "Next", "(", ")", "\n", "if", "uint64", "(", "n", ")", "<", "wrapOffset", "{", "return", "n", "\n", "}", "\n", "return", "CellID", "(", "uint64", "(", ...
// NextWrap returns the next cell along the Hilbert curve, wrapping from last to // first as necessary. This should not be used with ChildBegin and ChildEnd.
[ "NextWrap", "returns", "the", "next", "cell", "along", "the", "Hilbert", "curve", "wrapping", "from", "last", "to", "first", "as", "necessary", ".", "This", "should", "not", "be", "used", "with", "ChildBegin", "and", "ChildEnd", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellid.go#L399-L405
28,063
golang/geo
s2/cellid.go
PrevWrap
func (ci CellID) PrevWrap() CellID { p := ci.Prev() if uint64(p) < wrapOffset { return p } return CellID(uint64(p) + wrapOffset) }
go
func (ci CellID) PrevWrap() CellID { p := ci.Prev() if uint64(p) < wrapOffset { return p } return CellID(uint64(p) + wrapOffset) }
[ "func", "(", "ci", "CellID", ")", "PrevWrap", "(", ")", "CellID", "{", "p", ":=", "ci", ".", "Prev", "(", ")", "\n", "if", "uint64", "(", "p", ")", "<", "wrapOffset", "{", "return", "p", "\n", "}", "\n", "return", "CellID", "(", "uint64", "(", ...
// PrevWrap returns the previous cell along the Hilbert curve, wrapping around from // first to last as necessary. This should not be used with ChildBegin and ChildEnd.
[ "PrevWrap", "returns", "the", "previous", "cell", "along", "the", "Hilbert", "curve", "wrapping", "around", "from", "first", "to", "last", "as", "necessary", ".", "This", "should", "not", "be", "used", "with", "ChildBegin", "and", "ChildEnd", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellid.go#L409-L415
28,064
golang/geo
s2/cellid.go
AdvanceWrap
func (ci CellID) AdvanceWrap(steps int64) CellID { if steps == 0 { return ci } // We clamp the number of steps if necessary to ensure that we do not // advance past the End() or before the Begin() of this level. shift := uint(2*(maxLevel-ci.Level()) + 1) if steps < 0 { if min := -int64(uint64(ci) >> shift); ...
go
func (ci CellID) AdvanceWrap(steps int64) CellID { if steps == 0 { return ci } // We clamp the number of steps if necessary to ensure that we do not // advance past the End() or before the Begin() of this level. shift := uint(2*(maxLevel-ci.Level()) + 1) if steps < 0 { if min := -int64(uint64(ci) >> shift); ...
[ "func", "(", "ci", "CellID", ")", "AdvanceWrap", "(", "steps", "int64", ")", "CellID", "{", "if", "steps", "==", "0", "{", "return", "ci", "\n", "}", "\n\n", "// We clamp the number of steps if necessary to ensure that we do not", "// advance past the End() or before th...
// AdvanceWrap advances or retreats the indicated number of steps along the // Hilbert curve at the current level and returns the new position. The // position wraps between the first and last faces as necessary.
[ "AdvanceWrap", "advances", "or", "retreats", "the", "indicated", "number", "of", "steps", "along", "the", "Hilbert", "curve", "at", "the", "current", "level", "and", "returns", "the", "new", "position", ".", "The", "position", "wraps", "between", "the", "first...
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellid.go#L420-L450
28,065
golang/geo
s2/cellid.go
Encode
func (ci CellID) Encode(w io.Writer) error { e := &encoder{w: w} ci.encode(e) return e.err }
go
func (ci CellID) Encode(w io.Writer) error { e := &encoder{w: w} ci.encode(e) return e.err }
[ "func", "(", "ci", "CellID", ")", "Encode", "(", "w", "io", ".", "Writer", ")", "error", "{", "e", ":=", "&", "encoder", "{", "w", ":", "w", "}", "\n", "ci", ".", "encode", "(", "e", ")", "\n", "return", "e", ".", "err", "\n", "}" ]
// Encode encodes the CellID.
[ "Encode", "encodes", "the", "CellID", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellid.go#L453-L457
28,066
golang/geo
s2/cellid.go
Decode
func (ci *CellID) Decode(r io.Reader) error { d := &decoder{r: asByteReader(r)} ci.decode(d) return d.err }
go
func (ci *CellID) Decode(r io.Reader) error { d := &decoder{r: asByteReader(r)} ci.decode(d) return d.err }
[ "func", "(", "ci", "*", "CellID", ")", "Decode", "(", "r", "io", ".", "Reader", ")", "error", "{", "d", ":=", "&", "decoder", "{", "r", ":", "asByteReader", "(", "r", ")", "}", "\n", "ci", ".", "decode", "(", "d", ")", "\n", "return", "d", "....
// Decode encodes the CellID.
[ "Decode", "encodes", "the", "CellID", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellid.go#L464-L468
28,067
golang/geo
s2/cellid.go
rawPoint
func (ci CellID) rawPoint() r3.Vector { face, si, ti := ci.faceSiTi() return faceUVToXYZ(face, stToUV((0.5/maxSize)*float64(si)), stToUV((0.5/maxSize)*float64(ti))) }
go
func (ci CellID) rawPoint() r3.Vector { face, si, ti := ci.faceSiTi() return faceUVToXYZ(face, stToUV((0.5/maxSize)*float64(si)), stToUV((0.5/maxSize)*float64(ti))) }
[ "func", "(", "ci", "CellID", ")", "rawPoint", "(", ")", "r3", ".", "Vector", "{", "face", ",", "si", ",", "ti", ":=", "ci", ".", "faceSiTi", "(", ")", "\n", "return", "faceUVToXYZ", "(", "face", ",", "stToUV", "(", "(", "0.5", "/", "maxSize", ")"...
// rawPoint returns an unnormalized r3 vector from the origin through the center // of the s2 cell on the sphere.
[ "rawPoint", "returns", "an", "unnormalized", "r3", "vector", "from", "the", "origin", "through", "the", "center", "of", "the", "s2", "cell", "on", "the", "sphere", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellid.go#L486-L489
28,068
golang/geo
s2/cellid.go
faceIJOrientation
func (ci CellID) faceIJOrientation() (f, i, j, orientation int) { f = ci.Face() orientation = f & swapMask nbits := maxLevel - 7*lookupBits // first iteration // Each iteration maps 8 bits of the Hilbert curve position into // 4 bits of "i" and "j". The lookup table transforms a key of the // form "ppppppppoo" t...
go
func (ci CellID) faceIJOrientation() (f, i, j, orientation int) { f = ci.Face() orientation = f & swapMask nbits := maxLevel - 7*lookupBits // first iteration // Each iteration maps 8 bits of the Hilbert curve position into // 4 bits of "i" and "j". The lookup table transforms a key of the // form "ppppppppoo" t...
[ "func", "(", "ci", "CellID", ")", "faceIJOrientation", "(", ")", "(", "f", ",", "i", ",", "j", ",", "orientation", "int", ")", "{", "f", "=", "ci", ".", "Face", "(", ")", "\n", "orientation", "=", "f", "&", "swapMask", "\n", "nbits", ":=", "maxLe...
// faceIJOrientation uses the global lookupIJ table to unfiddle the bits of ci.
[ "faceIJOrientation", "uses", "the", "global", "lookupIJ", "table", "to", "unfiddle", "the", "bits", "of", "ci", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellid.go#L506-L540
28,069
golang/geo
s2/cellid.go
initLookupCell
func initLookupCell(level, i, j, origOrientation, pos, orientation int) { if level == lookupBits { ij := (i << lookupBits) + j lookupPos[(ij<<2)+origOrientation] = (pos << 2) + orientation lookupIJ[(pos<<2)+origOrientation] = (ij << 2) + orientation return } level++ i <<= 1 j <<= 1 pos <<= 2 r := posToI...
go
func initLookupCell(level, i, j, origOrientation, pos, orientation int) { if level == lookupBits { ij := (i << lookupBits) + j lookupPos[(ij<<2)+origOrientation] = (pos << 2) + orientation lookupIJ[(pos<<2)+origOrientation] = (ij << 2) + orientation return } level++ i <<= 1 j <<= 1 pos <<= 2 r := posToI...
[ "func", "initLookupCell", "(", "level", ",", "i", ",", "j", ",", "origOrientation", ",", "pos", ",", "orientation", "int", ")", "{", "if", "level", "==", "lookupBits", "{", "ij", ":=", "(", "i", "<<", "lookupBits", ")", "+", "j", "\n", "lookupPos", "...
// initLookupCell initializes the lookupIJ table at init time.
[ "initLookupCell", "initializes", "the", "lookupIJ", "table", "at", "init", "time", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellid.go#L701-L718
28,070
golang/geo
s2/cellid.go
CommonAncestorLevel
func (ci CellID) CommonAncestorLevel(other CellID) (level int, ok bool) { bits := uint64(ci ^ other) if bits < ci.lsb() { bits = ci.lsb() } if bits < other.lsb() { bits = other.lsb() } msbPos := findMSBSetNonZero64(bits) if msbPos > 60 { return 0, false } return (60 - msbPos) >> 1, true }
go
func (ci CellID) CommonAncestorLevel(other CellID) (level int, ok bool) { bits := uint64(ci ^ other) if bits < ci.lsb() { bits = ci.lsb() } if bits < other.lsb() { bits = other.lsb() } msbPos := findMSBSetNonZero64(bits) if msbPos > 60 { return 0, false } return (60 - msbPos) >> 1, true }
[ "func", "(", "ci", "CellID", ")", "CommonAncestorLevel", "(", "other", "CellID", ")", "(", "level", "int", ",", "ok", "bool", ")", "{", "bits", ":=", "uint64", "(", "ci", "^", "other", ")", "\n", "if", "bits", "<", "ci", ".", "lsb", "(", ")", "{"...
// CommonAncestorLevel returns the level of the common ancestor of the two S2 CellIDs.
[ "CommonAncestorLevel", "returns", "the", "level", "of", "the", "common", "ancestor", "of", "the", "two", "S2", "CellIDs", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellid.go#L721-L735
28,071
golang/geo
s2/metric.go
Value
func (m Metric) Value(level int) float64 { return math.Ldexp(m.Deriv, -m.Dim*level) }
go
func (m Metric) Value(level int) float64 { return math.Ldexp(m.Deriv, -m.Dim*level) }
[ "func", "(", "m", "Metric", ")", "Value", "(", "level", "int", ")", "float64", "{", "return", "math", ".", "Ldexp", "(", "m", ".", "Deriv", ",", "-", "m", ".", "Dim", "*", "level", ")", "\n", "}" ]
// Value returns the value of the metric at the given level.
[ "Value", "returns", "the", "value", "of", "the", "metric", "at", "the", "given", "level", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/metric.go#L106-L108
28,072
golang/geo
s2/util.go
roundAngle
func roundAngle(val s1.Angle) int32 { if val < 0 { return int32(val - 0.5) } return int32(val + 0.5) }
go
func roundAngle(val s1.Angle) int32 { if val < 0 { return int32(val - 0.5) } return int32(val + 0.5) }
[ "func", "roundAngle", "(", "val", "s1", ".", "Angle", ")", "int32", "{", "if", "val", "<", "0", "{", "return", "int32", "(", "val", "-", "0.5", ")", "\n", "}", "\n", "return", "int32", "(", "val", "+", "0.5", ")", "\n", "}" ]
// roundAngle returns the value rounded to nearest as an int32. // This does not match C++ exactly for the case of x.5.
[ "roundAngle", "returns", "the", "value", "rounded", "to", "nearest", "as", "an", "int32", ".", "This", "does", "not", "match", "C", "++", "exactly", "for", "the", "case", "of", "x", ".", "5", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/util.go#L21-L26
28,073
golang/geo
s2/util.go
minAngle
func minAngle(x s1.Angle, others ...s1.Angle) s1.Angle { min := x for _, y := range others { if y < min { min = y } } return min }
go
func minAngle(x s1.Angle, others ...s1.Angle) s1.Angle { min := x for _, y := range others { if y < min { min = y } } return min }
[ "func", "minAngle", "(", "x", "s1", ".", "Angle", ",", "others", "...", "s1", ".", "Angle", ")", "s1", ".", "Angle", "{", "min", ":=", "x", "\n", "for", "_", ",", "y", ":=", "range", "others", "{", "if", "y", "<", "min", "{", "min", "=", "y",...
// minAngle returns the smallest of the given values.
[ "minAngle", "returns", "the", "smallest", "of", "the", "given", "values", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/util.go#L29-L37
28,074
golang/geo
s2/util.go
maxAngle
func maxAngle(x s1.Angle, others ...s1.Angle) s1.Angle { max := x for _, y := range others { if y > max { max = y } } return max }
go
func maxAngle(x s1.Angle, others ...s1.Angle) s1.Angle { max := x for _, y := range others { if y > max { max = y } } return max }
[ "func", "maxAngle", "(", "x", "s1", ".", "Angle", ",", "others", "...", "s1", ".", "Angle", ")", "s1", ".", "Angle", "{", "max", ":=", "x", "\n", "for", "_", ",", "y", ":=", "range", "others", "{", "if", "y", ">", "max", "{", "max", "=", "y",...
// maxAngle returns the largest of the given values.
[ "maxAngle", "returns", "the", "largest", "of", "the", "given", "values", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/util.go#L40-L48
28,075
golang/geo
s2/util.go
minChordAngle
func minChordAngle(x s1.ChordAngle, others ...s1.ChordAngle) s1.ChordAngle { min := x for _, y := range others { if y < min { min = y } } return min }
go
func minChordAngle(x s1.ChordAngle, others ...s1.ChordAngle) s1.ChordAngle { min := x for _, y := range others { if y < min { min = y } } return min }
[ "func", "minChordAngle", "(", "x", "s1", ".", "ChordAngle", ",", "others", "...", "s1", ".", "ChordAngle", ")", "s1", ".", "ChordAngle", "{", "min", ":=", "x", "\n", "for", "_", ",", "y", ":=", "range", "others", "{", "if", "y", "<", "min", "{", ...
// minChordAngle returns the smallest of the given values.
[ "minChordAngle", "returns", "the", "smallest", "of", "the", "given", "values", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/util.go#L51-L59
28,076
golang/geo
s2/util.go
maxChordAngle
func maxChordAngle(x s1.ChordAngle, others ...s1.ChordAngle) s1.ChordAngle { max := x for _, y := range others { if y > max { max = y } } return max }
go
func maxChordAngle(x s1.ChordAngle, others ...s1.ChordAngle) s1.ChordAngle { max := x for _, y := range others { if y > max { max = y } } return max }
[ "func", "maxChordAngle", "(", "x", "s1", ".", "ChordAngle", ",", "others", "...", "s1", ".", "ChordAngle", ")", "s1", ".", "ChordAngle", "{", "max", ":=", "x", "\n", "for", "_", ",", "y", ":=", "range", "others", "{", "if", "y", ">", "max", "{", ...
// maxChordAngle returns the largest of the given values.
[ "maxChordAngle", "returns", "the", "largest", "of", "the", "given", "values", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/util.go#L62-L70
28,077
golang/geo
s2/util.go
minFloat64
func minFloat64(x float64, others ...float64) float64 { min := x for _, y := range others { if y < min { min = y } } return min }
go
func minFloat64(x float64, others ...float64) float64 { min := x for _, y := range others { if y < min { min = y } } return min }
[ "func", "minFloat64", "(", "x", "float64", ",", "others", "...", "float64", ")", "float64", "{", "min", ":=", "x", "\n", "for", "_", ",", "y", ":=", "range", "others", "{", "if", "y", "<", "min", "{", "min", "=", "y", "\n", "}", "\n", "}", "\n"...
// minFloat64 returns the smallest of the given values.
[ "minFloat64", "returns", "the", "smallest", "of", "the", "given", "values", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/util.go#L73-L81
28,078
golang/geo
s2/util.go
maxFloat64
func maxFloat64(x float64, others ...float64) float64 { max := x for _, y := range others { if y > max { max = y } } return max }
go
func maxFloat64(x float64, others ...float64) float64 { max := x for _, y := range others { if y > max { max = y } } return max }
[ "func", "maxFloat64", "(", "x", "float64", ",", "others", "...", "float64", ")", "float64", "{", "max", ":=", "x", "\n", "for", "_", ",", "y", ":=", "range", "others", "{", "if", "y", ">", "max", "{", "max", "=", "y", "\n", "}", "\n", "}", "\n"...
// maxFloat64 returns the largest of the given values.
[ "maxFloat64", "returns", "the", "largest", "of", "the", "given", "values", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/util.go#L84-L92
28,079
golang/geo
s2/util.go
minInt
func minInt(x int, others ...int) int { min := x for _, y := range others { if y < min { min = y } } return min }
go
func minInt(x int, others ...int) int { min := x for _, y := range others { if y < min { min = y } } return min }
[ "func", "minInt", "(", "x", "int", ",", "others", "...", "int", ")", "int", "{", "min", ":=", "x", "\n", "for", "_", ",", "y", ":=", "range", "others", "{", "if", "y", "<", "min", "{", "min", "=", "y", "\n", "}", "\n", "}", "\n", "return", ...
// minInt returns the smallest of the given values.
[ "minInt", "returns", "the", "smallest", "of", "the", "given", "values", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/util.go#L95-L103
28,080
golang/geo
s2/util.go
maxInt
func maxInt(x int, others ...int) int { max := x for _, y := range others { if y > max { max = y } } return max }
go
func maxInt(x int, others ...int) int { max := x for _, y := range others { if y > max { max = y } } return max }
[ "func", "maxInt", "(", "x", "int", ",", "others", "...", "int", ")", "int", "{", "max", ":=", "x", "\n", "for", "_", ",", "y", ":=", "range", "others", "{", "if", "y", ">", "max", "{", "max", "=", "y", "\n", "}", "\n", "}", "\n", "return", ...
// maxInt returns the largest of the given values.
[ "maxInt", "returns", "the", "largest", "of", "the", "given", "values", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/util.go#L106-L114
28,081
golang/geo
s2/util.go
clampInt
func clampInt(x, min, max int) int { if x < min { return min } if x > max { return max } return x }
go
func clampInt(x, min, max int) int { if x < min { return min } if x > max { return max } return x }
[ "func", "clampInt", "(", "x", ",", "min", ",", "max", "int", ")", "int", "{", "if", "x", "<", "min", "{", "return", "min", "\n", "}", "\n", "if", "x", ">", "max", "{", "return", "max", "\n", "}", "\n", "return", "x", "\n", "}" ]
// clampInt returns the number closest to x within the range min..max.
[ "clampInt", "returns", "the", "number", "closest", "to", "x", "within", "the", "range", "min", "..", "max", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/util.go#L117-L125
28,082
golang/geo
s2/regioncoverer.go
newCandidate
func (c *coverer) newCandidate(cell Cell) *candidate { if !c.region.IntersectsCell(cell) { return nil } cand := &candidate{cell: cell} level := int(cell.level) if level >= c.minLevel { if c.interiorCovering { if c.region.ContainsCell(cell) { cand.terminal = true } else if level+c.levelMod > c.maxLeve...
go
func (c *coverer) newCandidate(cell Cell) *candidate { if !c.region.IntersectsCell(cell) { return nil } cand := &candidate{cell: cell} level := int(cell.level) if level >= c.minLevel { if c.interiorCovering { if c.region.ContainsCell(cell) { cand.terminal = true } else if level+c.levelMod > c.maxLeve...
[ "func", "(", "c", "*", "coverer", ")", "newCandidate", "(", "cell", "Cell", ")", "*", "candidate", "{", "if", "!", "c", ".", "region", ".", "IntersectsCell", "(", "cell", ")", "{", "return", "nil", "\n", "}", "\n", "cand", ":=", "&", "candidate", "...
// newCandidate returns a new candidate with no children if the cell intersects the given region. // The candidate is marked as terminal if it should not be expanded further.
[ "newCandidate", "returns", "a", "new", "candidate", "with", "no", "children", "if", "the", "cell", "intersects", "the", "given", "region", ".", "The", "candidate", "is", "marked", "as", "terminal", "if", "it", "should", "not", "be", "expanded", "further", "....
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/regioncoverer.go#L132-L150
28,083
golang/geo
s2/regioncoverer.go
expandChildren
func (c *coverer) expandChildren(cand *candidate, cell Cell, numLevels int) int { numLevels-- var numTerminals int last := cell.id.ChildEnd() for ci := cell.id.ChildBegin(); ci != last; ci = ci.Next() { childCell := CellFromCellID(ci) if numLevels > 0 { if c.region.IntersectsCell(childCell) { numTerminal...
go
func (c *coverer) expandChildren(cand *candidate, cell Cell, numLevels int) int { numLevels-- var numTerminals int last := cell.id.ChildEnd() for ci := cell.id.ChildBegin(); ci != last; ci = ci.Next() { childCell := CellFromCellID(ci) if numLevels > 0 { if c.region.IntersectsCell(childCell) { numTerminal...
[ "func", "(", "c", "*", "coverer", ")", "expandChildren", "(", "cand", "*", "candidate", ",", "cell", "Cell", ",", "numLevels", "int", ")", "int", "{", "numLevels", "--", "\n", "var", "numTerminals", "int", "\n", "last", ":=", "cell", ".", "id", ".", ...
// expandChildren populates the children of the candidate by expanding the given number of // levels from the given cell. Returns the number of children that were marked "terminal".
[ "expandChildren", "populates", "the", "children", "of", "the", "candidate", "by", "expanding", "the", "given", "number", "of", "levels", "from", "the", "given", "cell", ".", "Returns", "the", "number", "of", "children", "that", "were", "marked", "terminal", "....
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/regioncoverer.go#L154-L175
28,084
golang/geo
s2/regioncoverer.go
addCandidate
func (c *coverer) addCandidate(cand *candidate) { if cand == nil { return } if cand.terminal { c.result = append(c.result, cand.cell.id) return } // Expand one level at a time until we hit minLevel to ensure that we don't skip over it. numLevels := c.levelMod level := int(cand.cell.level) if level < c.m...
go
func (c *coverer) addCandidate(cand *candidate) { if cand == nil { return } if cand.terminal { c.result = append(c.result, cand.cell.id) return } // Expand one level at a time until we hit minLevel to ensure that we don't skip over it. numLevels := c.levelMod level := int(cand.cell.level) if level < c.m...
[ "func", "(", "c", "*", "coverer", ")", "addCandidate", "(", "cand", "*", "candidate", ")", "{", "if", "cand", "==", "nil", "{", "return", "\n", "}", "\n\n", "if", "cand", ".", "terminal", "{", "c", ".", "result", "=", "append", "(", "c", ".", "re...
// addCandidate adds the given candidate to the result if it is marked as "terminal", // otherwise expands its children and inserts it into the priority queue. // Passing an argument of nil does nothing.
[ "addCandidate", "adds", "the", "given", "candidate", "to", "the", "result", "if", "it", "is", "marked", "as", "terminal", "otherwise", "expands", "its", "children", "and", "inserts", "it", "into", "the", "priority", "queue", ".", "Passing", "an", "argument", ...
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/regioncoverer.go#L180-L218
28,085
golang/geo
s2/regioncoverer.go
initialCandidates
func (c *coverer) initialCandidates() { // Optimization: start with a small (usually 4 cell) covering of the region's bounding cap. temp := &RegionCoverer{MaxLevel: c.maxLevel, LevelMod: 1, MaxCells: minInt(4, c.maxCells)} cells := temp.FastCovering(c.region) c.adjustCellLevels(&cells) for _, ci := range cells { ...
go
func (c *coverer) initialCandidates() { // Optimization: start with a small (usually 4 cell) covering of the region's bounding cap. temp := &RegionCoverer{MaxLevel: c.maxLevel, LevelMod: 1, MaxCells: minInt(4, c.maxCells)} cells := temp.FastCovering(c.region) c.adjustCellLevels(&cells) for _, ci := range cells { ...
[ "func", "(", "c", "*", "coverer", ")", "initialCandidates", "(", ")", "{", "// Optimization: start with a small (usually 4 cell) covering of the region's bounding cap.", "temp", ":=", "&", "RegionCoverer", "{", "MaxLevel", ":", "c", ".", "maxLevel", ",", "LevelMod", ":"...
// initialCandidates computes a set of initial candidates that cover the given region.
[ "initialCandidates", "computes", "a", "set", "of", "initial", "candidates", "that", "cover", "the", "given", "region", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/regioncoverer.go#L258-L267
28,086
golang/geo
s2/regioncoverer.go
newCoverer
func (rc *RegionCoverer) newCoverer() *coverer { return &coverer{ minLevel: maxInt(0, minInt(maxLevel, rc.MinLevel)), maxLevel: maxInt(0, minInt(maxLevel, rc.MaxLevel)), levelMod: maxInt(1, minInt(3, rc.LevelMod)), maxCells: rc.MaxCells, } }
go
func (rc *RegionCoverer) newCoverer() *coverer { return &coverer{ minLevel: maxInt(0, minInt(maxLevel, rc.MinLevel)), maxLevel: maxInt(0, minInt(maxLevel, rc.MaxLevel)), levelMod: maxInt(1, minInt(3, rc.LevelMod)), maxCells: rc.MaxCells, } }
[ "func", "(", "rc", "*", "RegionCoverer", ")", "newCoverer", "(", ")", "*", "coverer", "{", "return", "&", "coverer", "{", "minLevel", ":", "maxInt", "(", "0", ",", "minInt", "(", "maxLevel", ",", "rc", ".", "MinLevel", ")", ")", ",", "maxLevel", ":",...
// newCoverer returns an instance of coverer.
[ "newCoverer", "returns", "an", "instance", "of", "coverer", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/regioncoverer.go#L314-L321
28,087
golang/geo
s2/regioncoverer.go
Covering
func (rc *RegionCoverer) Covering(region Region) CellUnion { covering := rc.CellUnion(region) covering.Denormalize(maxInt(0, minInt(maxLevel, rc.MinLevel)), maxInt(1, minInt(3, rc.LevelMod))) return covering }
go
func (rc *RegionCoverer) Covering(region Region) CellUnion { covering := rc.CellUnion(region) covering.Denormalize(maxInt(0, minInt(maxLevel, rc.MinLevel)), maxInt(1, minInt(3, rc.LevelMod))) return covering }
[ "func", "(", "rc", "*", "RegionCoverer", ")", "Covering", "(", "region", "Region", ")", "CellUnion", "{", "covering", ":=", "rc", ".", "CellUnion", "(", "region", ")", "\n", "covering", ".", "Denormalize", "(", "maxInt", "(", "0", ",", "minInt", "(", "...
// Covering returns a CellUnion that covers the given region and satisfies the various restrictions.
[ "Covering", "returns", "a", "CellUnion", "that", "covers", "the", "given", "region", "and", "satisfies", "the", "various", "restrictions", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/regioncoverer.go#L324-L328
28,088
golang/geo
s2/regioncoverer.go
InteriorCovering
func (rc *RegionCoverer) InteriorCovering(region Region) CellUnion { intCovering := rc.InteriorCellUnion(region) intCovering.Denormalize(maxInt(0, minInt(maxLevel, rc.MinLevel)), maxInt(1, minInt(3, rc.LevelMod))) return intCovering }
go
func (rc *RegionCoverer) InteriorCovering(region Region) CellUnion { intCovering := rc.InteriorCellUnion(region) intCovering.Denormalize(maxInt(0, minInt(maxLevel, rc.MinLevel)), maxInt(1, minInt(3, rc.LevelMod))) return intCovering }
[ "func", "(", "rc", "*", "RegionCoverer", ")", "InteriorCovering", "(", "region", "Region", ")", "CellUnion", "{", "intCovering", ":=", "rc", ".", "InteriorCellUnion", "(", "region", ")", "\n", "intCovering", ".", "Denormalize", "(", "maxInt", "(", "0", ",", ...
// InteriorCovering returns a CellUnion that is contained within the given region and satisfies the various restrictions.
[ "InteriorCovering", "returns", "a", "CellUnion", "that", "is", "contained", "within", "the", "given", "region", "and", "satisfies", "the", "various", "restrictions", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/regioncoverer.go#L331-L335
28,089
golang/geo
s2/regioncoverer.go
SimpleRegionCovering
func SimpleRegionCovering(region Region, start Point, level int) []CellID { return FloodFillRegionCovering(region, cellIDFromPoint(start).Parent(level)) }
go
func SimpleRegionCovering(region Region, start Point, level int) []CellID { return FloodFillRegionCovering(region, cellIDFromPoint(start).Parent(level)) }
[ "func", "SimpleRegionCovering", "(", "region", "Region", ",", "start", "Point", ",", "level", "int", ")", "[", "]", "CellID", "{", "return", "FloodFillRegionCovering", "(", "region", ",", "cellIDFromPoint", "(", "start", ")", ".", "Parent", "(", "level", ")"...
// SimpleRegionCovering returns a set of cells at the given level that cover // the connected region and a starting point on the boundary or inside the // region. The cells are returned in arbitrary order. // // Note that this method is not faster than the regular Covering // method for most region types, such as Cap o...
[ "SimpleRegionCovering", "returns", "a", "set", "of", "cells", "at", "the", "given", "level", "that", "cover", "the", "connected", "region", "and", "a", "starting", "point", "on", "the", "boundary", "or", "inside", "the", "region", ".", "The", "cells", "are",...
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/regioncoverer.go#L442-L444
28,090
golang/geo
s2/regioncoverer.go
FloodFillRegionCovering
func FloodFillRegionCovering(region Region, start CellID) []CellID { var output []CellID all := map[CellID]bool{ start: true, } frontier := []CellID{start} for len(frontier) > 0 { id := frontier[len(frontier)-1] frontier = frontier[:len(frontier)-1] if !region.IntersectsCell(CellFromCellID(id)) { contin...
go
func FloodFillRegionCovering(region Region, start CellID) []CellID { var output []CellID all := map[CellID]bool{ start: true, } frontier := []CellID{start} for len(frontier) > 0 { id := frontier[len(frontier)-1] frontier = frontier[:len(frontier)-1] if !region.IntersectsCell(CellFromCellID(id)) { contin...
[ "func", "FloodFillRegionCovering", "(", "region", "Region", ",", "start", "CellID", ")", "[", "]", "CellID", "{", "var", "output", "[", "]", "CellID", "\n", "all", ":=", "map", "[", "CellID", "]", "bool", "{", "start", ":", "true", ",", "}", "\n", "f...
// FloodFillRegionCovering returns all edge-connected cells at the same level as // the given CellID that intersect the given region, in arbitrary order.
[ "FloodFillRegionCovering", "returns", "all", "edge", "-", "connected", "cells", "at", "the", "same", "level", "as", "the", "given", "CellID", "that", "intersect", "the", "given", "region", "in", "arbitrary", "order", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/regioncoverer.go#L448-L470
28,091
golang/geo
s2/pointcompression.go
encodePointsCompressed
func encodePointsCompressed(e *encoder, vertices []xyzFaceSiTi, level int) { var faces []faceRun for _, v := range vertices { faces = appendFace(faces, v.face) } encodeFaces(e, faces) type piQi struct { pi, qi uint32 } verticesPiQi := make([]piQi, len(vertices)) for i, v := range vertices { verticesPiQi[...
go
func encodePointsCompressed(e *encoder, vertices []xyzFaceSiTi, level int) { var faces []faceRun for _, v := range vertices { faces = appendFace(faces, v.face) } encodeFaces(e, faces) type piQi struct { pi, qi uint32 } verticesPiQi := make([]piQi, len(vertices)) for i, v := range vertices { verticesPiQi[...
[ "func", "encodePointsCompressed", "(", "e", "*", "encoder", ",", "vertices", "[", "]", "xyzFaceSiTi", ",", "level", "int", ")", "{", "var", "faces", "[", "]", "faceRun", "\n", "for", "_", ",", "v", ":=", "range", "vertices", "{", "faces", "=", "appendF...
// encodePointsCompressed uses an optimized compressed format to encode the given values.
[ "encodePointsCompressed", "uses", "an", "optimized", "compressed", "format", "to", "encode", "the", "given", "values", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/pointcompression.go#L50-L90
28,092
golang/geo
s2/pointcompression.go
piQiToST
func piQiToST(pi uint32, level int) float64 { // We want to recover the position at the center of the cell. If the point // was snapped to the center of the cell, then math.Modf(s * 2^level) == 0.5. // Inverting STtoPiQi gives: // s = (pi + 0.5) / 2^level. return (float64(pi) + 0.5) / float64(int(1)<<uint(level)) ...
go
func piQiToST(pi uint32, level int) float64 { // We want to recover the position at the center of the cell. If the point // was snapped to the center of the cell, then math.Modf(s * 2^level) == 0.5. // Inverting STtoPiQi gives: // s = (pi + 0.5) / 2^level. return (float64(pi) + 0.5) / float64(int(1)<<uint(level)) ...
[ "func", "piQiToST", "(", "pi", "uint32", ",", "level", "int", ")", "float64", "{", "// We want to recover the position at the center of the cell. If the point", "// was snapped to the center of the cell, then math.Modf(s * 2^level) == 0.5.", "// Inverting STtoPiQi gives:", "// s = (pi + ...
// piQiToST returns the value transformed to ST space.
[ "piQiToST", "returns", "the", "value", "transformed", "to", "ST", "space", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/pointcompression.go#L309-L315
28,093
golang/geo
s2/cellunion.go
CellUnionFromUnion
func CellUnionFromUnion(cellUnions ...CellUnion) CellUnion { var cu CellUnion for _, cellUnion := range cellUnions { cu = append(cu, cellUnion...) } cu.Normalize() return cu }
go
func CellUnionFromUnion(cellUnions ...CellUnion) CellUnion { var cu CellUnion for _, cellUnion := range cellUnions { cu = append(cu, cellUnion...) } cu.Normalize() return cu }
[ "func", "CellUnionFromUnion", "(", "cellUnions", "...", "CellUnion", ")", "CellUnion", "{", "var", "cu", "CellUnion", "\n", "for", "_", ",", "cellUnion", ":=", "range", "cellUnions", "{", "cu", "=", "append", "(", "cu", ",", "cellUnion", "...", ")", "\n", ...
// CellUnionFromUnion creates a CellUnion from the union of the given CellUnions.
[ "CellUnionFromUnion", "creates", "a", "CellUnion", "from", "the", "union", "of", "the", "given", "CellUnions", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellunion.go#L51-L58
28,094
golang/geo
s2/cellunion.go
CellUnionFromIntersection
func CellUnionFromIntersection(x, y CellUnion) CellUnion { var cu CellUnion // This is a fairly efficient calculation that uses binary search to skip // over sections of both input vectors. It takes constant time if all the // cells of x come before or after all the cells of y in CellID order. var i, j int for i...
go
func CellUnionFromIntersection(x, y CellUnion) CellUnion { var cu CellUnion // This is a fairly efficient calculation that uses binary search to skip // over sections of both input vectors. It takes constant time if all the // cells of x come before or after all the cells of y in CellID order. var i, j int for i...
[ "func", "CellUnionFromIntersection", "(", "x", ",", "y", "CellUnion", ")", "CellUnion", "{", "var", "cu", "CellUnion", "\n\n", "// This is a fairly efficient calculation that uses binary search to skip", "// over sections of both input vectors. It takes constant time if all the", "//...
// CellUnionFromIntersection creates a CellUnion from the intersection of the given CellUnions.
[ "CellUnionFromIntersection", "creates", "a", "CellUnion", "from", "the", "intersection", "of", "the", "given", "CellUnions", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellunion.go#L61-L110
28,095
golang/geo
s2/cellunion.go
CellUnionFromIntersectionWithCellID
func CellUnionFromIntersectionWithCellID(x CellUnion, id CellID) CellUnion { var cu CellUnion if x.ContainsCellID(id) { cu = append(cu, id) cu.Normalize() return cu } idmax := id.RangeMax() for i := x.lowerBound(0, len(x), id.RangeMin()); i < len(x) && x[i] <= idmax; i++ { cu = append(cu, x[i]) } cu.No...
go
func CellUnionFromIntersectionWithCellID(x CellUnion, id CellID) CellUnion { var cu CellUnion if x.ContainsCellID(id) { cu = append(cu, id) cu.Normalize() return cu } idmax := id.RangeMax() for i := x.lowerBound(0, len(x), id.RangeMin()); i < len(x) && x[i] <= idmax; i++ { cu = append(cu, x[i]) } cu.No...
[ "func", "CellUnionFromIntersectionWithCellID", "(", "x", "CellUnion", ",", "id", "CellID", ")", "CellUnion", "{", "var", "cu", "CellUnion", "\n", "if", "x", ".", "ContainsCellID", "(", "id", ")", "{", "cu", "=", "append", "(", "cu", ",", "id", ")", "\n",...
// CellUnionFromIntersectionWithCellID creates a CellUnion from the intersection // of a CellUnion with the given CellID. This can be useful for splitting a // CellUnion into chunks.
[ "CellUnionFromIntersectionWithCellID", "creates", "a", "CellUnion", "from", "the", "intersection", "of", "a", "CellUnion", "with", "the", "given", "CellID", ".", "This", "can", "be", "useful", "for", "splitting", "a", "CellUnion", "into", "chunks", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellunion.go#L115-L130
28,096
golang/geo
s2/cellunion.go
IsValid
func (cu *CellUnion) IsValid() bool { for i, cid := range *cu { if !cid.IsValid() { return false } if i == 0 { continue } if (*cu)[i-1].RangeMax() >= cid.RangeMin() { return false } } return true }
go
func (cu *CellUnion) IsValid() bool { for i, cid := range *cu { if !cid.IsValid() { return false } if i == 0 { continue } if (*cu)[i-1].RangeMax() >= cid.RangeMin() { return false } } return true }
[ "func", "(", "cu", "*", "CellUnion", ")", "IsValid", "(", ")", "bool", "{", "for", "i", ",", "cid", ":=", "range", "*", "cu", "{", "if", "!", "cid", ".", "IsValid", "(", ")", "{", "return", "false", "\n", "}", "\n", "if", "i", "==", "0", "{",...
// The C++ constructor methods FromNormalized and FromVerbatim are not necessary // since they don't call Normalize, and just set the CellIDs directly on the object, // so straight casting is sufficient in Go to replicate this behavior. // IsValid reports whether the cell union is valid, meaning that the CellIDs are //...
[ "The", "C", "++", "constructor", "methods", "FromNormalized", "and", "FromVerbatim", "are", "not", "necessary", "since", "they", "don", "t", "call", "Normalize", "and", "just", "set", "the", "CellIDs", "directly", "on", "the", "object", "so", "straight", "cast...
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellunion.go#L154-L167
28,097
golang/geo
s2/cellunion.go
IsNormalized
func (cu *CellUnion) IsNormalized() bool { for i, cid := range *cu { if !cid.IsValid() { return false } if i == 0 { continue } if (*cu)[i-1].RangeMax() >= cid.RangeMin() { return false } if i < 3 { continue } if areSiblings((*cu)[i-3], (*cu)[i-2], (*cu)[i-1], cid) { return false } }...
go
func (cu *CellUnion) IsNormalized() bool { for i, cid := range *cu { if !cid.IsValid() { return false } if i == 0 { continue } if (*cu)[i-1].RangeMax() >= cid.RangeMin() { return false } if i < 3 { continue } if areSiblings((*cu)[i-3], (*cu)[i-2], (*cu)[i-1], cid) { return false } }...
[ "func", "(", "cu", "*", "CellUnion", ")", "IsNormalized", "(", ")", "bool", "{", "for", "i", ",", "cid", ":=", "range", "*", "cu", "{", "if", "!", "cid", ".", "IsValid", "(", ")", "{", "return", "false", "\n", "}", "\n", "if", "i", "==", "0", ...
// IsNormalized reports whether the cell union is normalized, meaning that it is // satisfies IsValid and that no four cells have a common parent. // Certain operations such as Contains will return a different // result if the cell union is not normalized.
[ "IsNormalized", "reports", "whether", "the", "cell", "union", "is", "normalized", "meaning", "that", "it", "is", "satisfies", "IsValid", "and", "that", "no", "four", "cells", "have", "a", "common", "parent", ".", "Certain", "operations", "such", "as", "Contain...
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellunion.go#L173-L192
28,098
golang/geo
s2/cellunion.go
IntersectsCellID
func (cu *CellUnion) IntersectsCellID(id CellID) bool { // Find index of array item that occurs directly after our probe cell: i := sort.Search(len(*cu), func(i int) bool { return id < (*cu)[i] }) if i != len(*cu) && (*cu)[i].RangeMin() <= id.RangeMax() { return true } return i != 0 && (*cu)[i-1].RangeMax() >= ...
go
func (cu *CellUnion) IntersectsCellID(id CellID) bool { // Find index of array item that occurs directly after our probe cell: i := sort.Search(len(*cu), func(i int) bool { return id < (*cu)[i] }) if i != len(*cu) && (*cu)[i].RangeMin() <= id.RangeMax() { return true } return i != 0 && (*cu)[i-1].RangeMax() >= ...
[ "func", "(", "cu", "*", "CellUnion", ")", "IntersectsCellID", "(", "id", "CellID", ")", "bool", "{", "// Find index of array item that occurs directly after our probe cell:", "i", ":=", "sort", ".", "Search", "(", "len", "(", "*", "cu", ")", ",", "func", "(", ...
// IntersectsCellID reports whether this CellUnion intersects the given cell ID.
[ "IntersectsCellID", "reports", "whether", "this", "CellUnion", "intersects", "the", "given", "cell", "ID", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellunion.go#L240-L248
28,099
golang/geo
s2/cellunion.go
RectBound
func (cu *CellUnion) RectBound() Rect { bound := EmptyRect() for _, c := range *cu { bound = bound.Union(CellFromCellID(c).RectBound()) } return bound }
go
func (cu *CellUnion) RectBound() Rect { bound := EmptyRect() for _, c := range *cu { bound = bound.Union(CellFromCellID(c).RectBound()) } return bound }
[ "func", "(", "cu", "*", "CellUnion", ")", "RectBound", "(", ")", "Rect", "{", "bound", ":=", "EmptyRect", "(", ")", "\n", "for", "_", ",", "c", ":=", "range", "*", "cu", "{", "bound", "=", "bound", ".", "Union", "(", "CellFromCellID", "(", "c", "...
// RectBound returns a Rect that bounds this entity.
[ "RectBound", "returns", "a", "Rect", "that", "bounds", "this", "entity", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellunion.go#L298-L304