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,100
golang/geo
s2/cellunion.go
CapBound
func (cu *CellUnion) CapBound() Cap { if len(*cu) == 0 { return EmptyCap() } // Compute the approximate centroid of the region. This won't produce the // bounding cap of minimal area, but it should be close enough. var centroid Point for _, ci := range *cu { area := AvgAreaMetric.Value(ci.Level()) centroi...
go
func (cu *CellUnion) CapBound() Cap { if len(*cu) == 0 { return EmptyCap() } // Compute the approximate centroid of the region. This won't produce the // bounding cap of minimal area, but it should be close enough. var centroid Point for _, ci := range *cu { area := AvgAreaMetric.Value(ci.Level()) centroi...
[ "func", "(", "cu", "*", "CellUnion", ")", "CapBound", "(", ")", "Cap", "{", "if", "len", "(", "*", "cu", ")", "==", "0", "{", "return", "EmptyCap", "(", ")", "\n", "}", "\n\n", "// Compute the approximate centroid of the region. This won't produce the", "// bo...
// CapBound returns a Cap that bounds this entity.
[ "CapBound", "returns", "a", "Cap", "that", "bounds", "this", "entity", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellunion.go#L307-L337
28,101
golang/geo
s2/cellunion.go
ContainsCell
func (cu *CellUnion) ContainsCell(c Cell) bool { return cu.ContainsCellID(c.id) }
go
func (cu *CellUnion) ContainsCell(c Cell) bool { return cu.ContainsCellID(c.id) }
[ "func", "(", "cu", "*", "CellUnion", ")", "ContainsCell", "(", "c", "Cell", ")", "bool", "{", "return", "cu", ".", "ContainsCellID", "(", "c", ".", "id", ")", "\n", "}" ]
// ContainsCell reports whether this cell union contains the given cell.
[ "ContainsCell", "reports", "whether", "this", "cell", "union", "contains", "the", "given", "cell", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellunion.go#L340-L342
28,102
golang/geo
s2/cellunion.go
IntersectsCell
func (cu *CellUnion) IntersectsCell(c Cell) bool { return cu.IntersectsCellID(c.id) }
go
func (cu *CellUnion) IntersectsCell(c Cell) bool { return cu.IntersectsCellID(c.id) }
[ "func", "(", "cu", "*", "CellUnion", ")", "IntersectsCell", "(", "c", "Cell", ")", "bool", "{", "return", "cu", ".", "IntersectsCellID", "(", "c", ".", "id", ")", "\n", "}" ]
// IntersectsCell reports whether this cell union intersects the given cell.
[ "IntersectsCell", "reports", "whether", "this", "cell", "union", "intersects", "the", "given", "cell", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellunion.go#L345-L347
28,103
golang/geo
s2/cellunion.go
ContainsPoint
func (cu *CellUnion) ContainsPoint(p Point) bool { return cu.ContainsCell(CellFromPoint(p)) }
go
func (cu *CellUnion) ContainsPoint(p Point) bool { return cu.ContainsCell(CellFromPoint(p)) }
[ "func", "(", "cu", "*", "CellUnion", ")", "ContainsPoint", "(", "p", "Point", ")", "bool", "{", "return", "cu", ".", "ContainsCell", "(", "CellFromPoint", "(", "p", ")", ")", "\n", "}" ]
// ContainsPoint reports whether this cell union contains the given point.
[ "ContainsPoint", "reports", "whether", "this", "cell", "union", "contains", "the", "given", "point", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellunion.go#L350-L352
28,104
golang/geo
s2/cellunion.go
areSiblings
func areSiblings(a, b, c, d CellID) bool { // A necessary (but not sufficient) condition is that the XOR of the // four cell IDs must be zero. This is also very fast to test. if (a ^ b ^ c) != d { return false } // Now we do a slightly more expensive but exact test. First, compute a // mask that blocks out the...
go
func areSiblings(a, b, c, d CellID) bool { // A necessary (but not sufficient) condition is that the XOR of the // four cell IDs must be zero. This is also very fast to test. if (a ^ b ^ c) != d { return false } // Now we do a slightly more expensive but exact test. First, compute a // mask that blocks out the...
[ "func", "areSiblings", "(", "a", ",", "b", ",", "c", ",", "d", "CellID", ")", "bool", "{", "// A necessary (but not sufficient) condition is that the XOR of the", "// four cell IDs must be zero. This is also very fast to test.", "if", "(", "a", "^", "b", "^", "c", ")", ...
// Returns true if the given four cells have a common parent. // This requires that the four CellIDs are distinct.
[ "Returns", "true", "if", "the", "given", "four", "cells", "have", "a", "common", "parent", ".", "This", "requires", "that", "the", "four", "CellIDs", "are", "distinct", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellunion.go#L371-L389
28,105
golang/geo
s2/cellunion.go
Contains
func (cu *CellUnion) Contains(o CellUnion) bool { // TODO(roberts): Investigate alternatives such as divide-and-conquer // or alternating-skip-search that may be significantly faster in both // the average and worst case. This applies to Intersects as well. for _, id := range o { if !cu.ContainsCellID(id) { re...
go
func (cu *CellUnion) Contains(o CellUnion) bool { // TODO(roberts): Investigate alternatives such as divide-and-conquer // or alternating-skip-search that may be significantly faster in both // the average and worst case. This applies to Intersects as well. for _, id := range o { if !cu.ContainsCellID(id) { re...
[ "func", "(", "cu", "*", "CellUnion", ")", "Contains", "(", "o", "CellUnion", ")", "bool", "{", "// TODO(roberts): Investigate alternatives such as divide-and-conquer", "// or alternating-skip-search that may be significantly faster in both", "// the average and worst case. This applies...
// Contains reports whether this CellUnion contains all of the CellIDs of the given CellUnion.
[ "Contains", "reports", "whether", "this", "CellUnion", "contains", "all", "of", "the", "CellIDs", "of", "the", "given", "CellUnion", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellunion.go#L392-L403
28,106
golang/geo
s2/cellunion.go
Intersects
func (cu *CellUnion) Intersects(o CellUnion) bool { for _, c := range *cu { if o.IntersectsCellID(c) { return true } } return false }
go
func (cu *CellUnion) Intersects(o CellUnion) bool { for _, c := range *cu { if o.IntersectsCellID(c) { return true } } return false }
[ "func", "(", "cu", "*", "CellUnion", ")", "Intersects", "(", "o", "CellUnion", ")", "bool", "{", "for", "_", ",", "c", ":=", "range", "*", "cu", "{", "if", "o", ".", "IntersectsCellID", "(", "c", ")", "{", "return", "true", "\n", "}", "\n", "}", ...
// Intersects reports whether this CellUnion intersects any of the CellIDs of the given CellUnion.
[ "Intersects", "reports", "whether", "this", "CellUnion", "intersects", "any", "of", "the", "CellIDs", "of", "the", "given", "CellUnion", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellunion.go#L406-L414
28,107
golang/geo
s2/cellunion.go
cellUnionDifferenceInternal
func (cu *CellUnion) cellUnionDifferenceInternal(id CellID, other *CellUnion) { if !other.IntersectsCellID(id) { (*cu) = append((*cu), id) return } if !other.ContainsCellID(id) { for _, child := range id.Children() { cu.cellUnionDifferenceInternal(child, other) } } }
go
func (cu *CellUnion) cellUnionDifferenceInternal(id CellID, other *CellUnion) { if !other.IntersectsCellID(id) { (*cu) = append((*cu), id) return } if !other.ContainsCellID(id) { for _, child := range id.Children() { cu.cellUnionDifferenceInternal(child, other) } } }
[ "func", "(", "cu", "*", "CellUnion", ")", "cellUnionDifferenceInternal", "(", "id", "CellID", ",", "other", "*", "CellUnion", ")", "{", "if", "!", "other", ".", "IntersectsCellID", "(", "id", ")", "{", "(", "*", "cu", ")", "=", "append", "(", "(", "*...
// cellUnionDifferenceInternal adds the difference between the CellID and the union to // the result CellUnion. If they intersect but the difference is non-empty, it divides // and conquers.
[ "cellUnionDifferenceInternal", "adds", "the", "difference", "between", "the", "CellID", "and", "the", "union", "to", "the", "result", "CellUnion", ".", "If", "they", "intersect", "but", "the", "difference", "is", "non", "-", "empty", "it", "divides", "and", "c...
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellunion.go#L432-L443
28,108
golang/geo
s2/cellunion.go
Equal
func (cu CellUnion) Equal(o CellUnion) bool { if len(cu) != len(o) { return false } for i := 0; i < len(cu); i++ { if cu[i] != o[i] { return false } } return true }
go
func (cu CellUnion) Equal(o CellUnion) bool { if len(cu) != len(o) { return false } for i := 0; i < len(cu); i++ { if cu[i] != o[i] { return false } } return true }
[ "func", "(", "cu", "CellUnion", ")", "Equal", "(", "o", "CellUnion", ")", "bool", "{", "if", "len", "(", "cu", ")", "!=", "len", "(", "o", ")", "{", "return", "false", "\n", "}", "\n", "for", "i", ":=", "0", ";", "i", "<", "len", "(", "cu", ...
// Equal reports whether the two CellUnions are equal.
[ "Equal", "reports", "whether", "the", "two", "CellUnions", "are", "equal", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellunion.go#L508-L518
28,109
golang/geo
s2/cellunion.go
AverageArea
func (cu *CellUnion) AverageArea() float64 { return AvgAreaMetric.Value(maxLevel) * float64(cu.LeafCellsCovered()) }
go
func (cu *CellUnion) AverageArea() float64 { return AvgAreaMetric.Value(maxLevel) * float64(cu.LeafCellsCovered()) }
[ "func", "(", "cu", "*", "CellUnion", ")", "AverageArea", "(", ")", "float64", "{", "return", "AvgAreaMetric", ".", "Value", "(", "maxLevel", ")", "*", "float64", "(", "cu", ".", "LeafCellsCovered", "(", ")", ")", "\n", "}" ]
// AverageArea returns the average area of this CellUnion. // This is accurate to within a factor of 1.7.
[ "AverageArea", "returns", "the", "average", "area", "of", "this", "CellUnion", ".", "This", "is", "accurate", "to", "within", "a", "factor", "of", "1", ".", "7", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellunion.go#L522-L524
28,110
golang/geo
s2/cellunion.go
ApproxArea
func (cu *CellUnion) ApproxArea() float64 { var area float64 for _, id := range *cu { area += CellFromCellID(id).ApproxArea() } return area }
go
func (cu *CellUnion) ApproxArea() float64 { var area float64 for _, id := range *cu { area += CellFromCellID(id).ApproxArea() } return area }
[ "func", "(", "cu", "*", "CellUnion", ")", "ApproxArea", "(", ")", "float64", "{", "var", "area", "float64", "\n", "for", "_", ",", "id", ":=", "range", "*", "cu", "{", "area", "+=", "CellFromCellID", "(", "id", ")", ".", "ApproxArea", "(", ")", "\n...
// ApproxArea returns the approximate area of this CellUnion. This method is accurate // to within 3% percent for all cell sizes and accurate to within 0.1% for cells // at level 5 or higher within the union.
[ "ApproxArea", "returns", "the", "approximate", "area", "of", "this", "CellUnion", ".", "This", "method", "is", "accurate", "to", "within", "3%", "percent", "for", "all", "cell", "sizes", "and", "accurate", "to", "within", "0", ".", "1%", "for", "cells", "a...
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellunion.go#L529-L535
28,111
golang/geo
s2/cellunion.go
ExactArea
func (cu *CellUnion) ExactArea() float64 { var area float64 for _, id := range *cu { area += CellFromCellID(id).ExactArea() } return area }
go
func (cu *CellUnion) ExactArea() float64 { var area float64 for _, id := range *cu { area += CellFromCellID(id).ExactArea() } return area }
[ "func", "(", "cu", "*", "CellUnion", ")", "ExactArea", "(", ")", "float64", "{", "var", "area", "float64", "\n", "for", "_", ",", "id", ":=", "range", "*", "cu", "{", "area", "+=", "CellFromCellID", "(", "id", ")", ".", "ExactArea", "(", ")", "\n",...
// ExactArea returns the area of this CellUnion as accurately as possible.
[ "ExactArea", "returns", "the", "area", "of", "this", "CellUnion", "as", "accurately", "as", "possible", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellunion.go#L538-L544
28,112
golang/geo
s2/cellunion.go
Encode
func (cu *CellUnion) Encode(w io.Writer) error { e := &encoder{w: w} cu.encode(e) return e.err }
go
func (cu *CellUnion) Encode(w io.Writer) error { e := &encoder{w: w} cu.encode(e) return e.err }
[ "func", "(", "cu", "*", "CellUnion", ")", "Encode", "(", "w", "io", ".", "Writer", ")", "error", "{", "e", ":=", "&", "encoder", "{", "w", ":", "w", "}", "\n", "cu", ".", "encode", "(", "e", ")", "\n", "return", "e", ".", "err", "\n", "}" ]
// Encode encodes the CellUnion.
[ "Encode", "encodes", "the", "CellUnion", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellunion.go#L547-L551
28,113
golang/geo
s2/cellunion.go
Decode
func (cu *CellUnion) Decode(r io.Reader) error { d := &decoder{r: asByteReader(r)} cu.decode(d) return d.err }
go
func (cu *CellUnion) Decode(r io.Reader) error { d := &decoder{r: asByteReader(r)} cu.decode(d) return d.err }
[ "func", "(", "cu", "*", "CellUnion", ")", "Decode", "(", "r", "io", ".", "Reader", ")", "error", "{", "d", ":=", "&", "decoder", "{", "r", ":", "asByteReader", "(", "r", ")", "}", "\n", "cu", ".", "decode", "(", "d", ")", "\n", "return", "d", ...
// Decode decodes the CellUnion.
[ "Decode", "decodes", "the", "CellUnion", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellunion.go#L562-L566
28,114
golang/geo
s2/cell.go
CellFromCellID
func CellFromCellID(id CellID) Cell { c := Cell{} c.id = id f, i, j, o := c.id.faceIJOrientation() c.face = int8(f) c.level = int8(c.id.Level()) c.orientation = int8(o) c.uv = ijLevelToBoundUV(i, j, int(c.level)) return c }
go
func CellFromCellID(id CellID) Cell { c := Cell{} c.id = id f, i, j, o := c.id.faceIJOrientation() c.face = int8(f) c.level = int8(c.id.Level()) c.orientation = int8(o) c.uv = ijLevelToBoundUV(i, j, int(c.level)) return c }
[ "func", "CellFromCellID", "(", "id", "CellID", ")", "Cell", "{", "c", ":=", "Cell", "{", "}", "\n", "c", ".", "id", "=", "id", "\n", "f", ",", "i", ",", "j", ",", "o", ":=", "c", ".", "id", ".", "faceIJOrientation", "(", ")", "\n", "c", ".", ...
// CellFromCellID constructs a Cell corresponding to the given CellID.
[ "CellFromCellID", "constructs", "a", "Cell", "corresponding", "to", "the", "given", "CellID", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cell.go#L39-L48
28,115
golang/geo
s2/cell.go
Children
func (c Cell) Children() ([4]Cell, bool) { var children [4]Cell if c.id.IsLeaf() { return children, false } // Compute the cell midpoint in uv-space. uvMid := c.id.centerUV() // Create four children with the appropriate bounds. cid := c.id.ChildBegin() for pos := 0; pos < 4; pos++ { children[pos] = Cell{...
go
func (c Cell) Children() ([4]Cell, bool) { var children [4]Cell if c.id.IsLeaf() { return children, false } // Compute the cell midpoint in uv-space. uvMid := c.id.centerUV() // Create four children with the appropriate bounds. cid := c.id.ChildBegin() for pos := 0; pos < 4; pos++ { children[pos] = Cell{...
[ "func", "(", "c", "Cell", ")", "Children", "(", ")", "(", "[", "4", "]", "Cell", ",", "bool", ")", "{", "var", "children", "[", "4", "]", "Cell", "\n\n", "if", "c", ".", "id", ".", "IsLeaf", "(", ")", "{", "return", "children", ",", "false", ...
// Children returns the four direct children of this cell in traversal order // and returns true. If this is a leaf cell, or the children could not be created, // false is returned. // The C++ method is called Subdivide.
[ "Children", "returns", "the", "four", "direct", "children", "of", "this", "cell", "in", "traversal", "order", "and", "returns", "true", ".", "If", "this", "is", "a", "leaf", "cell", "or", "the", "children", "could", "not", "be", "created", "false", "is", ...
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cell.go#L133-L176
28,116
golang/geo
s2/cell.go
ExactArea
func (c Cell) ExactArea() float64 { v0, v1, v2, v3 := c.Vertex(0), c.Vertex(1), c.Vertex(2), c.Vertex(3) return PointArea(v0, v1, v2) + PointArea(v0, v2, v3) }
go
func (c Cell) ExactArea() float64 { v0, v1, v2, v3 := c.Vertex(0), c.Vertex(1), c.Vertex(2), c.Vertex(3) return PointArea(v0, v1, v2) + PointArea(v0, v2, v3) }
[ "func", "(", "c", "Cell", ")", "ExactArea", "(", ")", "float64", "{", "v0", ",", "v1", ",", "v2", ",", "v3", ":=", "c", ".", "Vertex", "(", "0", ")", ",", "c", ".", "Vertex", "(", "1", ")", ",", "c", ".", "Vertex", "(", "2", ")", ",", "c"...
// ExactArea returns the area of this cell as accurately as possible.
[ "ExactArea", "returns", "the", "area", "of", "this", "cell", "as", "accurately", "as", "possible", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cell.go#L179-L182
28,117
golang/geo
s2/cell.go
IntersectsCell
func (c Cell) IntersectsCell(oc Cell) bool { return c.id.Intersects(oc.id) }
go
func (c Cell) IntersectsCell(oc Cell) bool { return c.id.Intersects(oc.id) }
[ "func", "(", "c", "Cell", ")", "IntersectsCell", "(", "oc", "Cell", ")", "bool", "{", "return", "c", ".", "id", ".", "Intersects", "(", "oc", ".", "id", ")", "\n", "}" ]
// IntersectsCell reports whether the intersection of this cell and the other cell is not nil.
[ "IntersectsCell", "reports", "whether", "the", "intersection", "of", "this", "cell", "and", "the", "other", "cell", "is", "not", "nil", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cell.go#L216-L218
28,118
golang/geo
s2/cell.go
ContainsCell
func (c Cell) ContainsCell(oc Cell) bool { return c.id.Contains(oc.id) }
go
func (c Cell) ContainsCell(oc Cell) bool { return c.id.Contains(oc.id) }
[ "func", "(", "c", "Cell", ")", "ContainsCell", "(", "oc", "Cell", ")", "bool", "{", "return", "c", ".", "id", ".", "Contains", "(", "oc", ".", "id", ")", "\n", "}" ]
// ContainsCell reports whether this cell contains the other cell.
[ "ContainsCell", "reports", "whether", "this", "cell", "contains", "the", "other", "cell", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cell.go#L221-L223
28,119
golang/geo
s2/cell.go
CapBound
func (c Cell) CapBound() Cap { // We use the cell center in (u,v)-space as the cap axis. This vector is very close // to GetCenter() and faster to compute. Neither one of these vectors yields the // bounding cap with minimal surface area, but they are both pretty close. cap := CapFromPoint(Point{faceUVToXYZ(int(c...
go
func (c Cell) CapBound() Cap { // We use the cell center in (u,v)-space as the cap axis. This vector is very close // to GetCenter() and faster to compute. Neither one of these vectors yields the // bounding cap with minimal surface area, but they are both pretty close. cap := CapFromPoint(Point{faceUVToXYZ(int(c...
[ "func", "(", "c", "Cell", ")", "CapBound", "(", ")", "Cap", "{", "// We use the cell center in (u,v)-space as the cap axis. This vector is very close", "// to GetCenter() and faster to compute. Neither one of these vectors yields the", "// bounding cap with minimal surface area, but they a...
// CapBound returns the bounding cap of this cell.
[ "CapBound", "returns", "the", "bounding", "cap", "of", "this", "cell", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cell.go#L363-L372
28,120
golang/geo
s2/cell.go
vertexChordDist2
func (c Cell) vertexChordDist2(p Point, xHi, yHi bool) s1.ChordAngle { x := c.uv.X.Lo y := c.uv.Y.Lo if xHi { x = c.uv.X.Hi } if yHi { y = c.uv.Y.Hi } return ChordAngleBetweenPoints(p, PointFromCoords(x, y, 1)) }
go
func (c Cell) vertexChordDist2(p Point, xHi, yHi bool) s1.ChordAngle { x := c.uv.X.Lo y := c.uv.Y.Lo if xHi { x = c.uv.X.Hi } if yHi { y = c.uv.Y.Hi } return ChordAngleBetweenPoints(p, PointFromCoords(x, y, 1)) }
[ "func", "(", "c", "Cell", ")", "vertexChordDist2", "(", "p", "Point", ",", "xHi", ",", "yHi", "bool", ")", "s1", ".", "ChordAngle", "{", "x", ":=", "c", ".", "uv", ".", "X", ".", "Lo", "\n", "y", ":=", "c", ".", "uv", ".", "Y", ".", "Lo", "...
// vertexChordDist2 returns the squared chord distance from point P to the // given corner vertex specified by the Hi or Lo values of each.
[ "vertexChordDist2", "returns", "the", "squared", "chord", "distance", "from", "point", "P", "to", "the", "given", "corner", "vertex", "specified", "by", "the", "Hi", "or", "Lo", "values", "of", "each", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cell.go#L423-L434
28,121
golang/geo
s2/cell.go
edgeDistance
func edgeDistance(ij, uv float64) s1.ChordAngle { // Let P by the target point and let R be the closest point on the given // edge AB. The desired distance PR can be expressed as PR^2 = PQ^2 + QR^2 // where Q is the point P projected onto the plane through the great circle // through AB. We can compute the distan...
go
func edgeDistance(ij, uv float64) s1.ChordAngle { // Let P by the target point and let R be the closest point on the given // edge AB. The desired distance PR can be expressed as PR^2 = PQ^2 + QR^2 // where Q is the point P projected onto the plane through the great circle // through AB. We can compute the distan...
[ "func", "edgeDistance", "(", "ij", ",", "uv", "float64", ")", "s1", ".", "ChordAngle", "{", "// Let P by the target point and let R be the closest point on the given", "// edge AB. The desired distance PR can be expressed as PR^2 = PQ^2 + QR^2", "// where Q is the point P projected onto...
// edgeDistance reports the distance from a Point P to a given Cell edge. The point // P is given by its dot product, and the uv edge by its normal in the // given coordinate value.
[ "edgeDistance", "reports", "the", "distance", "from", "a", "Point", "P", "to", "a", "given", "Cell", "edge", ".", "The", "point", "P", "is", "given", "by", "its", "dot", "product", "and", "the", "uv", "edge", "by", "its", "normal", "in", "the", "given"...
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cell.go#L469-L483
28,122
golang/geo
s2/cell.go
distanceInternal
func (c Cell) distanceInternal(targetXYZ Point, toInterior bool) s1.ChordAngle { // All calculations are done in the (u,v,w) coordinates of this cell's face. target := faceXYZtoUVW(int(c.face), targetXYZ) // Compute dot products with all four upward or rightward-facing edge // normals. dirIJ is the dot product for...
go
func (c Cell) distanceInternal(targetXYZ Point, toInterior bool) s1.ChordAngle { // All calculations are done in the (u,v,w) coordinates of this cell's face. target := faceXYZtoUVW(int(c.face), targetXYZ) // Compute dot products with all four upward or rightward-facing edge // normals. dirIJ is the dot product for...
[ "func", "(", "c", "Cell", ")", "distanceInternal", "(", "targetXYZ", "Point", ",", "toInterior", "bool", ")", "s1", ".", "ChordAngle", "{", "// All calculations are done in the (u,v,w) coordinates of this cell's face.", "target", ":=", "faceXYZtoUVW", "(", "int", "(", ...
// distanceInternal reports the distance from the given point to the interior of // the cell if toInterior is true or to the boundary of the cell otherwise.
[ "distanceInternal", "reports", "the", "distance", "from", "the", "given", "point", "to", "the", "interior", "of", "the", "cell", "if", "toInterior", "is", "true", "or", "to", "the", "boundary", "of", "the", "cell", "otherwise", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cell.go#L487-L547
28,123
golang/geo
s2/cell.go
Distance
func (c Cell) Distance(target Point) s1.ChordAngle { return c.distanceInternal(target, true) }
go
func (c Cell) Distance(target Point) s1.ChordAngle { return c.distanceInternal(target, true) }
[ "func", "(", "c", "Cell", ")", "Distance", "(", "target", "Point", ")", "s1", ".", "ChordAngle", "{", "return", "c", ".", "distanceInternal", "(", "target", ",", "true", ")", "\n", "}" ]
// Distance reports the distance from the cell to the given point. Returns zero if // the point is inside the cell.
[ "Distance", "reports", "the", "distance", "from", "the", "cell", "to", "the", "given", "point", ".", "Returns", "zero", "if", "the", "point", "is", "inside", "the", "cell", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cell.go#L551-L553
28,124
golang/geo
s2/cell.go
BoundaryDistance
func (c Cell) BoundaryDistance(target Point) s1.ChordAngle { return c.distanceInternal(target, false) }
go
func (c Cell) BoundaryDistance(target Point) s1.ChordAngle { return c.distanceInternal(target, false) }
[ "func", "(", "c", "Cell", ")", "BoundaryDistance", "(", "target", "Point", ")", "s1", ".", "ChordAngle", "{", "return", "c", ".", "distanceInternal", "(", "target", ",", "false", ")", "\n", "}" ]
// BoundaryDistance reports the distance from the cell boundary to the given point.
[ "BoundaryDistance", "reports", "the", "distance", "from", "the", "cell", "boundary", "to", "the", "given", "point", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cell.go#L576-L578
28,125
golang/geo
s2/cell.go
DistanceToEdge
func (c Cell) DistanceToEdge(a, b Point) s1.ChordAngle { // Possible optimizations: // - Currently the (cell vertex, edge endpoint) distances are computed // twice each, and the length of AB is computed 4 times. // - To fix this, refactor GetDistance(target) so that it skips calculating // the distance to ...
go
func (c Cell) DistanceToEdge(a, b Point) s1.ChordAngle { // Possible optimizations: // - Currently the (cell vertex, edge endpoint) distances are computed // twice each, and the length of AB is computed 4 times. // - To fix this, refactor GetDistance(target) so that it skips calculating // the distance to ...
[ "func", "(", "c", "Cell", ")", "DistanceToEdge", "(", "a", ",", "b", "Point", ")", "s1", ".", "ChordAngle", "{", "// Possible optimizations:", "// - Currently the (cell vertex, edge endpoint) distances are computed", "// twice each, and the length of AB is computed 4 times.",...
// DistanceToEdge returns the minimum distance from the cell to the given edge AB. Returns // zero if the edge intersects the cell interior.
[ "DistanceToEdge", "returns", "the", "minimum", "distance", "from", "the", "cell", "to", "the", "given", "edge", "AB", ".", "Returns", "zero", "if", "the", "edge", "intersects", "the", "cell", "interior", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cell.go#L582-L619
28,126
golang/geo
s2/cell.go
DistanceToCell
func (c Cell) DistanceToCell(target Cell) s1.ChordAngle { // If the cells intersect, the distance is zero. We use the (u,v) ranges // rather than CellID intersects so that cells that share a partial edge or // corner are considered to intersect. if c.face == target.face && c.uv.Intersects(target.uv) { return 0 ...
go
func (c Cell) DistanceToCell(target Cell) s1.ChordAngle { // If the cells intersect, the distance is zero. We use the (u,v) ranges // rather than CellID intersects so that cells that share a partial edge or // corner are considered to intersect. if c.face == target.face && c.uv.Intersects(target.uv) { return 0 ...
[ "func", "(", "c", "Cell", ")", "DistanceToCell", "(", "target", "Cell", ")", "s1", ".", "ChordAngle", "{", "// If the cells intersect, the distance is zero. We use the (u,v) ranges", "// rather than CellID intersects so that cells that share a partial edge or", "// corner are consid...
// DistanceToCell returns the minimum distance from this cell to the given cell. // It returns zero if one cell contains the other.
[ "DistanceToCell", "returns", "the", "minimum", "distance", "from", "this", "cell", "to", "the", "given", "cell", ".", "It", "returns", "zero", "if", "one", "cell", "contains", "the", "other", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cell.go#L637-L665
28,127
golang/geo
s1/interval.go
IsValid
func (i Interval) IsValid() bool { return (math.Abs(i.Lo) <= math.Pi && math.Abs(i.Hi) <= math.Pi && !(i.Lo == -math.Pi && i.Hi != math.Pi) && !(i.Hi == -math.Pi && i.Lo != math.Pi)) }
go
func (i Interval) IsValid() bool { return (math.Abs(i.Lo) <= math.Pi && math.Abs(i.Hi) <= math.Pi && !(i.Lo == -math.Pi && i.Hi != math.Pi) && !(i.Hi == -math.Pi && i.Lo != math.Pi)) }
[ "func", "(", "i", "Interval", ")", "IsValid", "(", ")", "bool", "{", "return", "(", "math", ".", "Abs", "(", "i", ".", "Lo", ")", "<=", "math", ".", "Pi", "&&", "math", ".", "Abs", "(", "i", ".", "Hi", ")", "<=", "math", ".", "Pi", "&&", "!...
// IsValid reports whether the interval is valid.
[ "IsValid", "reports", "whether", "the", "interval", "is", "valid", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s1/interval.go#L71-L75
28,128
golang/geo
s1/interval.go
Center
func (i Interval) Center() float64 { c := 0.5 * (i.Lo + i.Hi) if !i.IsInverted() { return c } if c <= 0 { return c + math.Pi } return c - math.Pi }
go
func (i Interval) Center() float64 { c := 0.5 * (i.Lo + i.Hi) if !i.IsInverted() { return c } if c <= 0 { return c + math.Pi } return c - math.Pi }
[ "func", "(", "i", "Interval", ")", "Center", "(", ")", "float64", "{", "c", ":=", "0.5", "*", "(", "i", ".", "Lo", "+", "i", ".", "Hi", ")", "\n", "if", "!", "i", ".", "IsInverted", "(", ")", "{", "return", "c", "\n", "}", "\n", "if", "c", ...
// Center returns the midpoint of the interval. // It is undefined for full and empty intervals.
[ "Center", "returns", "the", "midpoint", "of", "the", "interval", ".", "It", "is", "undefined", "for", "full", "and", "empty", "intervals", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s1/interval.go#L93-L102
28,129
golang/geo
s1/interval.go
Length
func (i Interval) Length() float64 { l := i.Hi - i.Lo if l >= 0 { return l } l += 2 * math.Pi if l > 0 { return l } return -1 }
go
func (i Interval) Length() float64 { l := i.Hi - i.Lo if l >= 0 { return l } l += 2 * math.Pi if l > 0 { return l } return -1 }
[ "func", "(", "i", "Interval", ")", "Length", "(", ")", "float64", "{", "l", ":=", "i", ".", "Hi", "-", "i", ".", "Lo", "\n", "if", "l", ">=", "0", "{", "return", "l", "\n", "}", "\n", "l", "+=", "2", "*", "math", ".", "Pi", "\n", "if", "l...
// Length returns the length of the interval. // The length of an empty interval is negative.
[ "Length", "returns", "the", "length", "of", "the", "interval", ".", "The", "length", "of", "an", "empty", "interval", "is", "negative", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s1/interval.go#L106-L116
28,130
golang/geo
s1/interval.go
Union
func (i Interval) Union(oi Interval) Interval { if oi.IsEmpty() { return i } if i.fastContains(oi.Lo) { if i.fastContains(oi.Hi) { // Either oi ⊂ i, or i ∪ oi is the full interval. if i.ContainsInterval(oi) { return i } return FullInterval() } return Interval{i.Lo, oi.Hi} } if i.fastContain...
go
func (i Interval) Union(oi Interval) Interval { if oi.IsEmpty() { return i } if i.fastContains(oi.Lo) { if i.fastContains(oi.Hi) { // Either oi ⊂ i, or i ∪ oi is the full interval. if i.ContainsInterval(oi) { return i } return FullInterval() } return Interval{i.Lo, oi.Hi} } if i.fastContain...
[ "func", "(", "i", "Interval", ")", "Union", "(", "oi", "Interval", ")", "Interval", "{", "if", "oi", ".", "IsEmpty", "(", ")", "{", "return", "i", "\n", "}", "\n", "if", "i", ".", "fastContains", "(", "oi", ".", "Lo", ")", "{", "if", "i", ".", ...
// Union returns the smallest interval that contains both the interval and oi.
[ "Union", "returns", "the", "smallest", "interval", "that", "contains", "both", "the", "interval", "and", "oi", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s1/interval.go#L213-L241
28,131
golang/geo
s1/interval.go
Intersection
func (i Interval) Intersection(oi Interval) Interval { if oi.IsEmpty() { return EmptyInterval() } if i.fastContains(oi.Lo) { if i.fastContains(oi.Hi) { // Either oi ⊂ i, or i and oi intersect twice. Neither are empty. // In the first case we want to return i (which is shorter than oi). // In the second ...
go
func (i Interval) Intersection(oi Interval) Interval { if oi.IsEmpty() { return EmptyInterval() } if i.fastContains(oi.Lo) { if i.fastContains(oi.Hi) { // Either oi ⊂ i, or i and oi intersect twice. Neither are empty. // In the first case we want to return i (which is shorter than oi). // In the second ...
[ "func", "(", "i", "Interval", ")", "Intersection", "(", "oi", "Interval", ")", "Interval", "{", "if", "oi", ".", "IsEmpty", "(", ")", "{", "return", "EmptyInterval", "(", ")", "\n", "}", "\n", "if", "i", ".", "fastContains", "(", "oi", ".", "Lo", "...
// Intersection returns the smallest interval that contains the intersection of the interval and oi.
[ "Intersection", "returns", "the", "smallest", "interval", "that", "contains", "the", "intersection", "of", "the", "interval", "and", "oi", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s1/interval.go#L244-L271
28,132
golang/geo
s2/polyline.go
PolylineFromLatLngs
func PolylineFromLatLngs(points []LatLng) *Polyline { p := make(Polyline, len(points)) for k, v := range points { p[k] = PointFromLatLng(v) } return &p }
go
func PolylineFromLatLngs(points []LatLng) *Polyline { p := make(Polyline, len(points)) for k, v := range points { p[k] = PointFromLatLng(v) } return &p }
[ "func", "PolylineFromLatLngs", "(", "points", "[", "]", "LatLng", ")", "*", "Polyline", "{", "p", ":=", "make", "(", "Polyline", ",", "len", "(", "points", ")", ")", "\n", "for", "k", ",", "v", ":=", "range", "points", "{", "p", "[", "k", "]", "=...
// PolylineFromLatLngs creates a new Polyline from the given LatLngs.
[ "PolylineFromLatLngs", "creates", "a", "new", "Polyline", "from", "the", "given", "LatLngs", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/polyline.go#L31-L37
28,133
golang/geo
s2/polyline.go
Reverse
func (p *Polyline) Reverse() { for i := 0; i < len(*p)/2; i++ { (*p)[i], (*p)[len(*p)-i-1] = (*p)[len(*p)-i-1], (*p)[i] } }
go
func (p *Polyline) Reverse() { for i := 0; i < len(*p)/2; i++ { (*p)[i], (*p)[len(*p)-i-1] = (*p)[len(*p)-i-1], (*p)[i] } }
[ "func", "(", "p", "*", "Polyline", ")", "Reverse", "(", ")", "{", "for", "i", ":=", "0", ";", "i", "<", "len", "(", "*", "p", ")", "/", "2", ";", "i", "++", "{", "(", "*", "p", ")", "[", "i", "]", ",", "(", "*", "p", ")", "[", "len", ...
// Reverse reverses the order of the Polyline vertices.
[ "Reverse", "reverses", "the", "order", "of", "the", "Polyline", "vertices", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/polyline.go#L40-L44
28,134
golang/geo
s2/polyline.go
Length
func (p *Polyline) Length() s1.Angle { var length s1.Angle for i := 1; i < len(*p); i++ { length += (*p)[i-1].Distance((*p)[i]) } return length }
go
func (p *Polyline) Length() s1.Angle { var length s1.Angle for i := 1; i < len(*p); i++ { length += (*p)[i-1].Distance((*p)[i]) } return length }
[ "func", "(", "p", "*", "Polyline", ")", "Length", "(", ")", "s1", ".", "Angle", "{", "var", "length", "s1", ".", "Angle", "\n\n", "for", "i", ":=", "1", ";", "i", "<", "len", "(", "*", "p", ")", ";", "i", "++", "{", "length", "+=", "(", "*"...
// Length returns the length of this Polyline.
[ "Length", "returns", "the", "length", "of", "this", "Polyline", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/polyline.go#L47-L54
28,135
golang/geo
s2/polyline.go
Equal
func (p *Polyline) Equal(b *Polyline) bool { if len(*p) != len(*b) { return false } for i, v := range *p { if v != (*b)[i] { return false } } return true }
go
func (p *Polyline) Equal(b *Polyline) bool { if len(*p) != len(*b) { return false } for i, v := range *p { if v != (*b)[i] { return false } } return true }
[ "func", "(", "p", "*", "Polyline", ")", "Equal", "(", "b", "*", "Polyline", ")", "bool", "{", "if", "len", "(", "*", "p", ")", "!=", "len", "(", "*", "b", ")", "{", "return", "false", "\n", "}", "\n", "for", "i", ",", "v", ":=", "range", "*...
// Equal reports whether the given Polyline is exactly the same as this one.
[ "Equal", "reports", "whether", "the", "given", "Polyline", "is", "exactly", "the", "same", "as", "this", "one", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/polyline.go#L77-L88
28,136
golang/geo
s2/polyline.go
RectBound
func (p *Polyline) RectBound() Rect { rb := NewRectBounder() for _, v := range *p { rb.AddPoint(v) } return rb.RectBound() }
go
func (p *Polyline) RectBound() Rect { rb := NewRectBounder() for _, v := range *p { rb.AddPoint(v) } return rb.RectBound() }
[ "func", "(", "p", "*", "Polyline", ")", "RectBound", "(", ")", "Rect", "{", "rb", ":=", "NewRectBounder", "(", ")", "\n", "for", "_", ",", "v", ":=", "range", "*", "p", "{", "rb", ".", "AddPoint", "(", "v", ")", "\n", "}", "\n", "return", "rb",...
// RectBound returns the bounding Rect for this Polyline.
[ "RectBound", "returns", "the", "bounding", "Rect", "for", "this", "Polyline", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/polyline.go#L96-L102
28,137
golang/geo
s2/polyline.go
IntersectsCell
func (p *Polyline) IntersectsCell(cell Cell) bool { if len(*p) == 0 { return false } // We only need to check whether the cell contains vertex 0 for correctness, // but these tests are cheap compared to edge crossings so we might as well // check all the vertices. for _, v := range *p { if cell.ContainsPoint...
go
func (p *Polyline) IntersectsCell(cell Cell) bool { if len(*p) == 0 { return false } // We only need to check whether the cell contains vertex 0 for correctness, // but these tests are cheap compared to edge crossings so we might as well // check all the vertices. for _, v := range *p { if cell.ContainsPoint...
[ "func", "(", "p", "*", "Polyline", ")", "IntersectsCell", "(", "cell", "Cell", ")", "bool", "{", "if", "len", "(", "*", "p", ")", "==", "0", "{", "return", "false", "\n", "}", "\n\n", "// We only need to check whether the cell contains vertex 0 for correctness,"...
// IntersectsCell reports whether this Polyline intersects the given Cell.
[ "IntersectsCell", "reports", "whether", "this", "Polyline", "intersects", "the", "given", "Cell", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/polyline.go#L111-L142
28,138
golang/geo
s2/polyline.go
ChainEdge
func (p *Polyline) ChainEdge(chainID, offset int) Edge { return Edge{(*p)[offset], (*p)[offset+1]} }
go
func (p *Polyline) ChainEdge(chainID, offset int) Edge { return Edge{(*p)[offset], (*p)[offset+1]} }
[ "func", "(", "p", "*", "Polyline", ")", "ChainEdge", "(", "chainID", ",", "offset", "int", ")", "Edge", "{", "return", "Edge", "{", "(", "*", "p", ")", "[", "offset", "]", ",", "(", "*", "p", ")", "[", "offset", "+", "1", "]", "}", "\n", "}" ...
// ChainEdge returns the j-th edge of the i-th edge Chain.
[ "ChainEdge", "returns", "the", "j", "-", "th", "edge", "of", "the", "i", "-", "th", "edge", "Chain", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/polyline.go#L183-L185
28,139
golang/geo
s2/polyline.go
findEndVertex
func findEndVertex(p Polyline, tolerance s1.Angle, index int) int { // The basic idea is to keep track of the "pie wedge" of angles // from the starting vertex such that a ray from the starting // vertex at that angle will pass through the discs of radius // tolerance centered around all vertices processed so far. ...
go
func findEndVertex(p Polyline, tolerance s1.Angle, index int) int { // The basic idea is to keep track of the "pie wedge" of angles // from the starting vertex such that a ray from the starting // vertex at that angle will pass through the discs of radius // tolerance centered around all vertices processed so far. ...
[ "func", "findEndVertex", "(", "p", "Polyline", ",", "tolerance", "s1", ".", "Angle", ",", "index", "int", ")", "int", "{", "// The basic idea is to keep track of the \"pie wedge\" of angles", "// from the starting vertex such that a ray from the starting", "// vertex at that angl...
// findEndVertex reports the maximal end index such that the line segment between // the start index and this one such that the line segment between these two // vertices passes within the given tolerance of all interior vertices, in order.
[ "findEndVertex", "reports", "the", "maximal", "end", "index", "such", "that", "the", "line", "segment", "between", "the", "start", "index", "and", "this", "one", "such", "that", "the", "line", "segment", "between", "these", "two", "vertices", "passes", "within...
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/polyline.go#L206-L290
28,140
golang/geo
s2/polyline.go
Encode
func (p Polyline) Encode(w io.Writer) error { e := &encoder{w: w} p.encode(e) return e.err }
go
func (p Polyline) Encode(w io.Writer) error { e := &encoder{w: w} p.encode(e) return e.err }
[ "func", "(", "p", "Polyline", ")", "Encode", "(", "w", "io", ".", "Writer", ")", "error", "{", "e", ":=", "&", "encoder", "{", "w", ":", "w", "}", "\n", "p", ".", "encode", "(", "e", ")", "\n", "return", "e", ".", "err", "\n", "}" ]
// Encode encodes the Polyline.
[ "Encode", "encodes", "the", "Polyline", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/polyline.go#L336-L340
28,141
golang/geo
s2/polyline.go
Decode
func (p *Polyline) Decode(r io.Reader) error { d := decoder{r: asByteReader(r)} p.decode(d) return d.err }
go
func (p *Polyline) Decode(r io.Reader) error { d := decoder{r: asByteReader(r)} p.decode(d) return d.err }
[ "func", "(", "p", "*", "Polyline", ")", "Decode", "(", "r", "io", ".", "Reader", ")", "error", "{", "d", ":=", "decoder", "{", "r", ":", "asByteReader", "(", "r", ")", "}", "\n", "p", ".", "decode", "(", "d", ")", "\n", "return", "d", ".", "e...
// Decode decodes the polyline.
[ "Decode", "decodes", "the", "polyline", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/polyline.go#L353-L357
28,142
golang/geo
s2/polyline.go
IsOnRight
func (p *Polyline) IsOnRight(point Point) bool { // If the closest point C is an interior vertex of the polyline, let B and D // be the previous and next vertices. The given point P is on the right of // the polyline (locally) if B, P, D are ordered CCW around vertex C. closest, next := p.Project(point) if closest...
go
func (p *Polyline) IsOnRight(point Point) bool { // If the closest point C is an interior vertex of the polyline, let B and D // be the previous and next vertices. The given point P is on the right of // the polyline (locally) if B, P, D are ordered CCW around vertex C. closest, next := p.Project(point) if closest...
[ "func", "(", "p", "*", "Polyline", ")", "IsOnRight", "(", "point", "Point", ")", "bool", "{", "// If the closest point C is an interior vertex of the polyline, let B and D", "// be the previous and next vertices. The given point P is on the right of", "// the polyline (locally) if B, P...
// IsOnRight reports whether the point given is on the right hand side of the // polyline, using a naive definition of "right-hand-sideness" where the point // is on the RHS of the polyline iff the point is on the RHS of the line segment // in the polyline which it is closest to. // The polyline must have at least 2 ve...
[ "IsOnRight", "reports", "whether", "the", "point", "given", "is", "on", "the", "right", "hand", "side", "of", "the", "polyline", "using", "a", "naive", "definition", "of", "right", "-", "hand", "-", "sideness", "where", "the", "point", "is", "on", "the", ...
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/polyline.go#L420-L438
28,143
golang/geo
s2/polyline.go
Validate
func (p *Polyline) Validate() error { // All vertices must be unit length. for i, pt := range *p { if !pt.IsUnit() { return fmt.Errorf("vertex %d is not unit length", i) } } // Adjacent vertices must not be identical or antipodal. for i := 1; i < len(*p); i++ { prev, cur := (*p)[i-1], (*p)[i] if prev =...
go
func (p *Polyline) Validate() error { // All vertices must be unit length. for i, pt := range *p { if !pt.IsUnit() { return fmt.Errorf("vertex %d is not unit length", i) } } // Adjacent vertices must not be identical or antipodal. for i := 1; i < len(*p); i++ { prev, cur := (*p)[i-1], (*p)[i] if prev =...
[ "func", "(", "p", "*", "Polyline", ")", "Validate", "(", ")", "error", "{", "// All vertices must be unit length.", "for", "i", ",", "pt", ":=", "range", "*", "p", "{", "if", "!", "pt", ".", "IsUnit", "(", ")", "{", "return", "fmt", ".", "Errorf", "(...
// Validate checks whether this is a valid polyline or not.
[ "Validate", "checks", "whether", "this", "is", "a", "valid", "polyline", "or", "not", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/polyline.go#L441-L461
28,144
golang/geo
s2/edge_crossings.go
EdgeOrVertexCrossing
func EdgeOrVertexCrossing(a, b, c, d Point) bool { switch CrossingSign(a, b, c, d) { case DoNotCross: return false case Cross: return true default: return VertexCrossing(a, b, c, d) } }
go
func EdgeOrVertexCrossing(a, b, c, d Point) bool { switch CrossingSign(a, b, c, d) { case DoNotCross: return false case Cross: return true default: return VertexCrossing(a, b, c, d) } }
[ "func", "EdgeOrVertexCrossing", "(", "a", ",", "b", ",", "c", ",", "d", "Point", ")", "bool", "{", "switch", "CrossingSign", "(", "a", ",", "b", ",", "c", ",", "d", ")", "{", "case", "DoNotCross", ":", "return", "false", "\n", "case", "Cross", ":",...
// EdgeOrVertexCrossing is a convenience function that calls CrossingSign to // handle cases where all four vertices are distinct, and VertexCrossing to // handle cases where two or more vertices are the same. This defines a crossing // function such that point-in-polygon containment tests can be implemented // by simp...
[ "EdgeOrVertexCrossing", "is", "a", "convenience", "function", "that", "calls", "CrossingSign", "to", "handle", "cases", "where", "all", "four", "vertices", "are", "distinct", "and", "VertexCrossing", "to", "handle", "cases", "where", "two", "or", "more", "vertices...
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/edge_crossings.go#L149-L158
28,145
golang/geo
s2/edge_crossings.go
robustNormalWithLength
func robustNormalWithLength(x, y r3.Vector) (r3.Vector, float64) { var pt r3.Vector // This computes 2 * (x.Cross(y)), but has much better numerical // stability when x and y are unit length. tmp := x.Sub(y).Cross(x.Add(y)) length := tmp.Norm() if length != 0 { pt = tmp.Mul(1 / length) } return pt, 0.5 * leng...
go
func robustNormalWithLength(x, y r3.Vector) (r3.Vector, float64) { var pt r3.Vector // This computes 2 * (x.Cross(y)), but has much better numerical // stability when x and y are unit length. tmp := x.Sub(y).Cross(x.Add(y)) length := tmp.Norm() if length != 0 { pt = tmp.Mul(1 / length) } return pt, 0.5 * leng...
[ "func", "robustNormalWithLength", "(", "x", ",", "y", "r3", ".", "Vector", ")", "(", "r3", ".", "Vector", ",", "float64", ")", "{", "var", "pt", "r3", ".", "Vector", "\n", "// This computes 2 * (x.Cross(y)), but has much better numerical", "// stability when x and y...
// Computes the cross product of two vectors, normalized to be unit length. // Also returns the length of the cross // product before normalization, which is useful for estimating the amount of // error in the result. For numerical stability, the vectors should both be // approximately unit length.
[ "Computes", "the", "cross", "product", "of", "two", "vectors", "normalized", "to", "be", "unit", "length", ".", "Also", "returns", "the", "length", "of", "the", "cross", "product", "before", "normalization", "which", "is", "useful", "for", "estimating", "the",...
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/edge_crossings.go#L211-L221
28,146
golang/geo
s2/stuv.go
siTiToST
func siTiToST(si uint32) float64 { if si > maxSiTi { return 1.0 } return float64(si) / float64(maxSiTi) }
go
func siTiToST(si uint32) float64 { if si > maxSiTi { return 1.0 } return float64(si) / float64(maxSiTi) }
[ "func", "siTiToST", "(", "si", "uint32", ")", "float64", "{", "if", "si", ">", "maxSiTi", "{", "return", "1.0", "\n", "}", "\n", "return", "float64", "(", "si", ")", "/", "float64", "(", "maxSiTi", ")", "\n", "}" ]
// siTiToST converts an si- or ti-value to the corresponding s- or t-value. // Value is capped at 1.0 because there is no DCHECK in Go.
[ "siTiToST", "converts", "an", "si", "-", "or", "ti", "-", "value", "to", "the", "corresponding", "s", "-", "or", "t", "-", "value", ".", "Value", "is", "capped", "at", "1", ".", "0", "because", "there", "is", "no", "DCHECK", "in", "Go", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/stuv.go#L155-L160
28,147
golang/geo
s2/stuv.go
faceUVToXYZ
func faceUVToXYZ(face int, u, v float64) r3.Vector { switch face { case 0: return r3.Vector{1, u, v} case 1: return r3.Vector{-u, 1, v} case 2: return r3.Vector{-u, -v, 1} case 3: return r3.Vector{-1, -v, -u} case 4: return r3.Vector{v, -1, -u} default: return r3.Vector{v, u, -1} } }
go
func faceUVToXYZ(face int, u, v float64) r3.Vector { switch face { case 0: return r3.Vector{1, u, v} case 1: return r3.Vector{-u, 1, v} case 2: return r3.Vector{-u, -v, 1} case 3: return r3.Vector{-1, -v, -u} case 4: return r3.Vector{v, -1, -u} default: return r3.Vector{v, u, -1} } }
[ "func", "faceUVToXYZ", "(", "face", "int", ",", "u", ",", "v", "float64", ")", "r3", ".", "Vector", "{", "switch", "face", "{", "case", "0", ":", "return", "r3", ".", "Vector", "{", "1", ",", "u", ",", "v", "}", "\n", "case", "1", ":", "return"...
// faceUVToXYZ turns face and UV coordinates into an unnormalized 3 vector.
[ "faceUVToXYZ", "turns", "face", "and", "UV", "coordinates", "into", "an", "unnormalized", "3", "vector", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/stuv.go#L236-L251
28,148
golang/geo
s2/centroids.go
PlanarCentroid
func PlanarCentroid(a, b, c Point) Point { return Point{a.Add(b.Vector).Add(c.Vector).Mul(1. / 3)} }
go
func PlanarCentroid(a, b, c Point) Point { return Point{a.Add(b.Vector).Add(c.Vector).Mul(1. / 3)} }
[ "func", "PlanarCentroid", "(", "a", ",", "b", ",", "c", "Point", ")", "Point", "{", "return", "Point", "{", "a", ".", "Add", "(", "b", ".", "Vector", ")", ".", "Add", "(", "c", ".", "Vector", ")", ".", "Mul", "(", "1.", "/", "3", ")", "}", ...
// PlanarCentroid returns the centroid of the planar triangle ABC. This can be // normalized to unit length to obtain the "surface centroid" of the corresponding // spherical triangle, i.e. the intersection of the three medians. However, note // that for large spherical triangles the surface centroid may be nowhere nea...
[ "PlanarCentroid", "returns", "the", "centroid", "of", "the", "planar", "triangle", "ABC", ".", "This", "can", "be", "normalized", "to", "unit", "length", "to", "obtain", "the", "surface", "centroid", "of", "the", "corresponding", "spherical", "triangle", "i", ...
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/centroids.go#L131-L133
28,149
golang/geo
s2/loop.go
LoopFromPoints
func LoopFromPoints(pts []Point) *Loop { l := &Loop{ vertices: pts, } l.initOriginAndBound() return l }
go
func LoopFromPoints(pts []Point) *Loop { l := &Loop{ vertices: pts, } l.initOriginAndBound() return l }
[ "func", "LoopFromPoints", "(", "pts", "[", "]", "Point", ")", "*", "Loop", "{", "l", ":=", "&", "Loop", "{", "vertices", ":", "pts", ",", "}", "\n\n", "l", ".", "initOriginAndBound", "(", ")", "\n", "return", "l", "\n", "}" ]
// LoopFromPoints constructs a loop from the given points.
[ "LoopFromPoints", "constructs", "a", "loop", "from", "the", "given", "points", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/loop.go#L72-L79
28,150
golang/geo
s2/loop.go
initOriginAndBound
func (l *Loop) initOriginAndBound() { if len(l.vertices) < 3 { // Check for the special "empty" and "full" loops (which have one vertex). if !l.isEmptyOrFull() { l.originInside = false return } // This is the special empty or full loop, so the origin depends on if // the vertex is in the southern hemi...
go
func (l *Loop) initOriginAndBound() { if len(l.vertices) < 3 { // Check for the special "empty" and "full" loops (which have one vertex). if !l.isEmptyOrFull() { l.originInside = false return } // This is the special empty or full loop, so the origin depends on if // the vertex is in the southern hemi...
[ "func", "(", "l", "*", "Loop", ")", "initOriginAndBound", "(", ")", "{", "if", "len", "(", "l", ".", "vertices", ")", "<", "3", "{", "// Check for the special \"empty\" and \"full\" loops (which have one vertex).", "if", "!", "l", ".", "isEmptyOrFull", "(", ")",...
// initOriginAndBound sets the origin containment for the given point and then calls // the initialization for the bounds objects and the internal index.
[ "initOriginAndBound", "sets", "the", "origin", "containment", "for", "the", "given", "point", "and", "then", "calls", "the", "initialization", "for", "the", "bounds", "objects", "and", "the", "internal", "index", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/loop.go#L123-L164
28,151
golang/geo
s2/loop.go
initBound
func (l *Loop) initBound() { // Check for the special "empty" and "full" loops. if l.isEmptyOrFull() { if l.IsEmpty() { l.bound = EmptyRect() } else { l.bound = FullRect() } l.subregionBound = l.bound return } // The bounding rectangle of a loop is not necessarily the same as the // bounding recta...
go
func (l *Loop) initBound() { // Check for the special "empty" and "full" loops. if l.isEmptyOrFull() { if l.IsEmpty() { l.bound = EmptyRect() } else { l.bound = FullRect() } l.subregionBound = l.bound return } // The bounding rectangle of a loop is not necessarily the same as the // bounding recta...
[ "func", "(", "l", "*", "Loop", ")", "initBound", "(", ")", "{", "// Check for the special \"empty\" and \"full\" loops.", "if", "l", ".", "isEmptyOrFull", "(", ")", "{", "if", "l", ".", "IsEmpty", "(", ")", "{", "l", ".", "bound", "=", "EmptyRect", "(", ...
// initBound sets up the approximate bounding Rects for this loop.
[ "initBound", "sets", "up", "the", "approximate", "bounding", "Rects", "for", "this", "loop", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/loop.go#L167-L204
28,152
golang/geo
s2/loop.go
Validate
func (l *Loop) Validate() error { if err := l.findValidationErrorNoIndex(); err != nil { return err } // Check for intersections between non-adjacent edges (including at vertices) // TODO(roberts): Once shapeutil gets findAnyCrossing uncomment this. // return findAnyCrossing(l.index) return nil }
go
func (l *Loop) Validate() error { if err := l.findValidationErrorNoIndex(); err != nil { return err } // Check for intersections between non-adjacent edges (including at vertices) // TODO(roberts): Once shapeutil gets findAnyCrossing uncomment this. // return findAnyCrossing(l.index) return nil }
[ "func", "(", "l", "*", "Loop", ")", "Validate", "(", ")", "error", "{", "if", "err", ":=", "l", ".", "findValidationErrorNoIndex", "(", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// Check for intersections between non-adjacent ed...
// Validate checks whether this is a valid loop.
[ "Validate", "checks", "whether", "this", "is", "a", "valid", "loop", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/loop.go#L207-L217
28,153
golang/geo
s2/loop.go
findValidationErrorNoIndex
func (l *Loop) findValidationErrorNoIndex() error { // All vertices must be unit length. for i, v := range l.vertices { if !v.IsUnit() { return fmt.Errorf("vertex %d is not unit length", i) } } // Loops must have at least 3 vertices (except for empty and full). if len(l.vertices) < 3 { if l.isEmptyOrFull...
go
func (l *Loop) findValidationErrorNoIndex() error { // All vertices must be unit length. for i, v := range l.vertices { if !v.IsUnit() { return fmt.Errorf("vertex %d is not unit length", i) } } // Loops must have at least 3 vertices (except for empty and full). if len(l.vertices) < 3 { if l.isEmptyOrFull...
[ "func", "(", "l", "*", "Loop", ")", "findValidationErrorNoIndex", "(", ")", "error", "{", "// All vertices must be unit length.", "for", "i", ",", "v", ":=", "range", "l", ".", "vertices", "{", "if", "!", "v", ".", "IsUnit", "(", ")", "{", "return", "fmt...
// findValidationErrorNoIndex reports whether this is not a valid loop, but // skips checks that would require a ShapeIndex to be built for the loop. This // is primarily used by Polygon to do validation so it doesn't trigger the // creation of unneeded ShapeIndices.
[ "findValidationErrorNoIndex", "reports", "whether", "this", "is", "not", "a", "valid", "loop", "but", "skips", "checks", "that", "would", "require", "a", "ShapeIndex", "to", "be", "built", "for", "the", "loop", ".", "This", "is", "primarily", "used", "by", "...
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/loop.go#L223-L258
28,154
golang/geo
s2/loop.go
Contains
func (l *Loop) Contains(o *Loop) bool { // For a loop A to contain the loop B, all of the following must // be true: // // (1) There are no edge crossings between A and B except at vertices. // // (2) At every vertex that is shared between A and B, the local edge // ordering implies that A contains B. //...
go
func (l *Loop) Contains(o *Loop) bool { // For a loop A to contain the loop B, all of the following must // be true: // // (1) There are no edge crossings between A and B except at vertices. // // (2) At every vertex that is shared between A and B, the local edge // ordering implies that A contains B. //...
[ "func", "(", "l", "*", "Loop", ")", "Contains", "(", "o", "*", "Loop", ")", "bool", "{", "// For a loop A to contain the loop B, all of the following must", "// be true:", "//", "// (1) There are no edge crossings between A and B except at vertices.", "//", "// (2) At every v...
// Contains reports whether the region contained by this loop is a superset of the // region contained by the given other loop.
[ "Contains", "reports", "whether", "the", "region", "contained", "by", "this", "loop", "is", "a", "superset", "of", "the", "region", "contained", "by", "the", "given", "other", "loop", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/loop.go#L262-L314
28,155
golang/geo
s2/loop.go
Intersects
func (l *Loop) Intersects(o *Loop) bool { // Given two loops, A and B, A.Intersects(B) if and only if !A.Complement().Contains(B). // // This code is similar to Contains, but is optimized for the case // where both loops enclose less than half of the sphere. if !l.bound.Intersects(o.bound) { return false } //...
go
func (l *Loop) Intersects(o *Loop) bool { // Given two loops, A and B, A.Intersects(B) if and only if !A.Complement().Contains(B). // // This code is similar to Contains, but is optimized for the case // where both loops enclose less than half of the sphere. if !l.bound.Intersects(o.bound) { return false } //...
[ "func", "(", "l", "*", "Loop", ")", "Intersects", "(", "o", "*", "Loop", ")", "bool", "{", "// Given two loops, A and B, A.Intersects(B) if and only if !A.Complement().Contains(B).", "//", "// This code is similar to Contains, but is optimized for the case", "// where both loops en...
// Intersects reports whether the region contained by this loop intersects the region // contained by the other loop.
[ "Intersects", "reports", "whether", "the", "region", "contained", "by", "this", "loop", "intersects", "the", "region", "contained", "by", "the", "other", "loop", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/loop.go#L318-L357
28,156
golang/geo
s2/loop.go
Edge
func (l *Loop) Edge(i int) Edge { return Edge{l.Vertex(i), l.Vertex(i + 1)} }
go
func (l *Loop) Edge(i int) Edge { return Edge{l.Vertex(i), l.Vertex(i + 1)} }
[ "func", "(", "l", "*", "Loop", ")", "Edge", "(", "i", "int", ")", "Edge", "{", "return", "Edge", "{", "l", ".", "Vertex", "(", "i", ")", ",", "l", ".", "Vertex", "(", "i", "+", "1", ")", "}", "\n", "}" ]
// Edge returns the endpoints for the given edge index.
[ "Edge", "returns", "the", "endpoints", "for", "the", "given", "edge", "index", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/loop.go#L478-L480
28,157
golang/geo
s2/loop.go
ChainEdge
func (l *Loop) ChainEdge(chainID, offset int) Edge { return Edge{l.Vertex(offset), l.Vertex(offset + 1)} }
go
func (l *Loop) ChainEdge(chainID, offset int) Edge { return Edge{l.Vertex(offset), l.Vertex(offset + 1)} }
[ "func", "(", "l", "*", "Loop", ")", "ChainEdge", "(", "chainID", ",", "offset", "int", ")", "Edge", "{", "return", "Edge", "{", "l", ".", "Vertex", "(", "offset", ")", ",", "l", ".", "Vertex", "(", "offset", "+", "1", ")", "}", "\n", "}" ]
// ChainEdge returns the j-th edge of the i-th edge chain.
[ "ChainEdge", "returns", "the", "j", "-", "th", "edge", "of", "the", "i", "-", "th", "edge", "chain", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/loop.go#L496-L498
28,158
golang/geo
s2/loop.go
bruteForceContainsPoint
func (l *Loop) bruteForceContainsPoint(p Point) bool { origin := OriginPoint() inside := l.originInside crosser := NewChainEdgeCrosser(origin, p, l.Vertex(0)) for i := 1; i <= len(l.vertices); i++ { // add vertex 0 twice inside = inside != crosser.EdgeOrVertexChainCrossing(l.Vertex(i)) } return inside }
go
func (l *Loop) bruteForceContainsPoint(p Point) bool { origin := OriginPoint() inside := l.originInside crosser := NewChainEdgeCrosser(origin, p, l.Vertex(0)) for i := 1; i <= len(l.vertices); i++ { // add vertex 0 twice inside = inside != crosser.EdgeOrVertexChainCrossing(l.Vertex(i)) } return inside }
[ "func", "(", "l", "*", "Loop", ")", "bruteForceContainsPoint", "(", "p", "Point", ")", "bool", "{", "origin", ":=", "OriginPoint", "(", ")", "\n", "inside", ":=", "l", ".", "originInside", "\n", "crosser", ":=", "NewChainEdgeCrosser", "(", "origin", ",", ...
// bruteForceContainsPoint reports if the given point is contained by this loop. // This method does not use the ShapeIndex, so it is only preferable below a certain // size of loop.
[ "bruteForceContainsPoint", "reports", "if", "the", "given", "point", "is", "contained", "by", "this", "loop", ".", "This", "method", "does", "not", "use", "the", "ShapeIndex", "so", "it", "is", "only", "preferable", "below", "a", "certain", "size", "of", "lo...
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/loop.go#L576-L584
28,159
golang/geo
s2/loop.go
ContainsPoint
func (l *Loop) ContainsPoint(p Point) bool { // Empty and full loops don't need a special case, but invalid loops with // zero vertices do, so we might as well handle them all at once. if len(l.vertices) < 3 { return l.originInside } // For small loops, and during initial construction, it is faster to just // ...
go
func (l *Loop) ContainsPoint(p Point) bool { // Empty and full loops don't need a special case, but invalid loops with // zero vertices do, so we might as well handle them all at once. if len(l.vertices) < 3 { return l.originInside } // For small loops, and during initial construction, it is faster to just // ...
[ "func", "(", "l", "*", "Loop", ")", "ContainsPoint", "(", "p", "Point", ")", "bool", "{", "// Empty and full loops don't need a special case, but invalid loops with", "// zero vertices do, so we might as well handle them all at once.", "if", "len", "(", "l", ".", "vertices", ...
// ContainsPoint returns true if the loop contains the point.
[ "ContainsPoint", "returns", "true", "if", "the", "loop", "contains", "the", "point", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/loop.go#L587-L607
28,160
golang/geo
s2/loop.go
ContainsCell
func (l *Loop) ContainsCell(target Cell) bool { it := l.index.Iterator() relation := it.LocateCellID(target.ID()) // If "target" is disjoint from all index cells, it is not contained. // Similarly, if "target" is subdivided into one or more index cells then it // is not contained, since index cells are subdivided...
go
func (l *Loop) ContainsCell(target Cell) bool { it := l.index.Iterator() relation := it.LocateCellID(target.ID()) // If "target" is disjoint from all index cells, it is not contained. // Similarly, if "target" is subdivided into one or more index cells then it // is not contained, since index cells are subdivided...
[ "func", "(", "l", "*", "Loop", ")", "ContainsCell", "(", "target", "Cell", ")", "bool", "{", "it", ":=", "l", ".", "index", ".", "Iterator", "(", ")", "\n", "relation", ":=", "it", ".", "LocateCellID", "(", "target", ".", "ID", "(", ")", ")", "\n...
// ContainsCell reports whether the given Cell is contained by this Loop.
[ "ContainsCell", "reports", "whether", "the", "given", "Cell", "is", "contained", "by", "this", "Loop", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/loop.go#L610-L631
28,161
golang/geo
s2/loop.go
IntersectsCell
func (l *Loop) IntersectsCell(target Cell) bool { it := l.index.Iterator() relation := it.LocateCellID(target.ID()) // If target does not overlap any index cell, there is no intersection. if relation == Disjoint { return false } // If target is subdivided into one or more index cells, there is an // intersect...
go
func (l *Loop) IntersectsCell(target Cell) bool { it := l.index.Iterator() relation := it.LocateCellID(target.ID()) // If target does not overlap any index cell, there is no intersection. if relation == Disjoint { return false } // If target is subdivided into one or more index cells, there is an // intersect...
[ "func", "(", "l", "*", "Loop", ")", "IntersectsCell", "(", "target", "Cell", ")", "bool", "{", "it", ":=", "l", ".", "index", ".", "Iterator", "(", ")", "\n", "relation", ":=", "it", ".", "LocateCellID", "(", "target", ".", "ID", "(", ")", ")", "...
// IntersectsCell reports whether this Loop intersects the given cell.
[ "IntersectsCell", "reports", "whether", "this", "Loop", "intersects", "the", "given", "cell", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/loop.go#L634-L659
28,162
golang/geo
s2/loop.go
iteratorContainsPoint
func (l *Loop) iteratorContainsPoint(it *ShapeIndexIterator, p Point) bool { // Test containment by drawing a line segment from the cell center to the // given point and counting edge crossings. aClipped := it.IndexCell().findByShapeID(0) inside := aClipped.containsCenter if len(aClipped.edges) > 0 { center := i...
go
func (l *Loop) iteratorContainsPoint(it *ShapeIndexIterator, p Point) bool { // Test containment by drawing a line segment from the cell center to the // given point and counting edge crossings. aClipped := it.IndexCell().findByShapeID(0) inside := aClipped.containsCenter if len(aClipped.edges) > 0 { center := i...
[ "func", "(", "l", "*", "Loop", ")", "iteratorContainsPoint", "(", "it", "*", "ShapeIndexIterator", ",", "p", "Point", ")", "bool", "{", "// Test containment by drawing a line segment from the cell center to the", "// given point and counting edge crossings.", "aClipped", ":="...
// iteratorContainsPoint reports if the iterator that is positioned at the ShapeIndexCell // that may contain p, contains the point p.
[ "iteratorContainsPoint", "reports", "if", "the", "iterator", "that", "is", "positioned", "at", "the", "ShapeIndexCell", "that", "may", "contain", "p", "contains", "the", "point", "p", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/loop.go#L698-L716
28,163
golang/geo
s2/loop.go
RegularLoop
func RegularLoop(center Point, radius s1.Angle, numVertices int) *Loop { return RegularLoopForFrame(getFrame(center), radius, numVertices) }
go
func RegularLoop(center Point, radius s1.Angle, numVertices int) *Loop { return RegularLoopForFrame(getFrame(center), radius, numVertices) }
[ "func", "RegularLoop", "(", "center", "Point", ",", "radius", "s1", ".", "Angle", ",", "numVertices", "int", ")", "*", "Loop", "{", "return", "RegularLoopForFrame", "(", "getFrame", "(", "center", ")", ",", "radius", ",", "numVertices", ")", "\n", "}" ]
// RegularLoop creates a loop with the given number of vertices, all // located on a circle of the specified radius around the given center.
[ "RegularLoop", "creates", "a", "loop", "with", "the", "given", "number", "of", "vertices", "all", "located", "on", "a", "circle", "of", "the", "specified", "radius", "around", "the", "given", "center", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/loop.go#L720-L722
28,164
golang/geo
s2/loop.go
RegularLoopForFrame
func RegularLoopForFrame(frame matrix3x3, radius s1.Angle, numVertices int) *Loop { return LoopFromPoints(regularPointsForFrame(frame, radius, numVertices)) }
go
func RegularLoopForFrame(frame matrix3x3, radius s1.Angle, numVertices int) *Loop { return LoopFromPoints(regularPointsForFrame(frame, radius, numVertices)) }
[ "func", "RegularLoopForFrame", "(", "frame", "matrix3x3", ",", "radius", "s1", ".", "Angle", ",", "numVertices", "int", ")", "*", "Loop", "{", "return", "LoopFromPoints", "(", "regularPointsForFrame", "(", "frame", ",", "radius", ",", "numVertices", ")", ")", ...
// RegularLoopForFrame creates a loop centered around the z-axis of the given // coordinate frame, with the first vertex in the direction of the positive x-axis.
[ "RegularLoopForFrame", "creates", "a", "loop", "centered", "around", "the", "z", "-", "axis", "of", "the", "given", "coordinate", "frame", "with", "the", "first", "vertex", "in", "the", "direction", "of", "the", "positive", "x", "-", "axis", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/loop.go#L726-L728
28,165
golang/geo
s2/loop.go
turningAngleMaxError
func (l *Loop) turningAngleMaxError() float64 { // The maximum error can be bounded as follows: // 2.24 * dblEpsilon for RobustCrossProd(b, a) // 2.24 * dblEpsilon for RobustCrossProd(c, b) // 3.25 * dblEpsilon for Angle() // 2.00 * dblEpsilon for each addition in the Kahan summation // ----...
go
func (l *Loop) turningAngleMaxError() float64 { // The maximum error can be bounded as follows: // 2.24 * dblEpsilon for RobustCrossProd(b, a) // 2.24 * dblEpsilon for RobustCrossProd(c, b) // 3.25 * dblEpsilon for Angle() // 2.00 * dblEpsilon for each addition in the Kahan summation // ----...
[ "func", "(", "l", "*", "Loop", ")", "turningAngleMaxError", "(", ")", "float64", "{", "// The maximum error can be bounded as follows:", "// 2.24 * dblEpsilon for RobustCrossProd(b, a)", "// 2.24 * dblEpsilon for RobustCrossProd(c, b)", "// 3.25 * dblEpsilon for Angle()", ...
// turningAngleMaxError return the maximum error in TurningAngle. The value is not // constant; it depends on the loop.
[ "turningAngleMaxError", "return", "the", "maximum", "error", "in", "TurningAngle", ".", "The", "value", "is", "not", "constant", ";", "it", "depends", "on", "the", "loop", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/loop.go#L808-L818
28,166
golang/geo
s2/loop.go
findVertex
func (l *Loop) findVertex(p Point) (index int, ok bool) { const notFound = 0 if len(l.vertices) < 10 { // Exhaustive search for loops below a small threshold. for i := 1; i <= len(l.vertices); i++ { if l.Vertex(i) == p { return i, true } } return notFound, false } it := l.index.Iterator() if !it...
go
func (l *Loop) findVertex(p Point) (index int, ok bool) { const notFound = 0 if len(l.vertices) < 10 { // Exhaustive search for loops below a small threshold. for i := 1; i <= len(l.vertices); i++ { if l.Vertex(i) == p { return i, true } } return notFound, false } it := l.index.Iterator() if !it...
[ "func", "(", "l", "*", "Loop", ")", "findVertex", "(", "p", "Point", ")", "(", "index", "int", ",", "ok", "bool", ")", "{", "const", "notFound", "=", "0", "\n", "if", "len", "(", "l", ".", "vertices", ")", "<", "10", "{", "// Exhaustive search for ...
// findVertex returns the index of the vertex at the given Point in the range // 1..numVertices, and a boolean indicating if a vertex was found.
[ "findVertex", "returns", "the", "index", "of", "the", "vertex", "at", "the", "given", "Point", "in", "the", "range", "1", "..", "numVertices", "and", "a", "boolean", "indicating", "if", "a", "vertex", "was", "found", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/loop.go#L892-L924
28,167
golang/geo
s2/loop.go
Encode
func (l Loop) Encode(w io.Writer) error { e := &encoder{w: w} l.encode(e) return e.err }
go
func (l Loop) Encode(w io.Writer) error { e := &encoder{w: w} l.encode(e) return e.err }
[ "func", "(", "l", "Loop", ")", "Encode", "(", "w", "io", ".", "Writer", ")", "error", "{", "e", ":=", "&", "encoder", "{", "w", ":", "w", "}", "\n", "l", ".", "encode", "(", "e", ")", "\n", "return", "e", ".", "err", "\n", "}" ]
// Encode encodes the Loop.
[ "Encode", "encodes", "the", "Loop", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/loop.go#L1220-L1224
28,168
golang/geo
s2/loop.go
Decode
func (l *Loop) Decode(r io.Reader) error { *l = Loop{} d := &decoder{r: asByteReader(r)} l.decode(d) return d.err }
go
func (l *Loop) Decode(r io.Reader) error { *l = Loop{} d := &decoder{r: asByteReader(r)} l.decode(d) return d.err }
[ "func", "(", "l", "*", "Loop", ")", "Decode", "(", "r", "io", ".", "Reader", ")", "error", "{", "*", "l", "=", "Loop", "{", "}", "\n", "d", ":=", "&", "decoder", "{", "r", ":", "asByteReader", "(", "r", ")", "}", "\n", "l", ".", "decode", "...
// Decode decodes a loop.
[ "Decode", "decodes", "a", "loop", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/loop.go#L1243-L1248
28,169
golang/geo
s2/loop.go
startEdge
func (l *loopCrosser) startEdge(aj int) { l.crosser = NewEdgeCrosser(l.a.Vertex(aj), l.a.Vertex(aj+1)) l.aj = aj l.bjPrev = -2 }
go
func (l *loopCrosser) startEdge(aj int) { l.crosser = NewEdgeCrosser(l.a.Vertex(aj), l.a.Vertex(aj+1)) l.aj = aj l.bjPrev = -2 }
[ "func", "(", "l", "*", "loopCrosser", ")", "startEdge", "(", "aj", "int", ")", "{", "l", ".", "crosser", "=", "NewEdgeCrosser", "(", "l", ".", "a", ".", "Vertex", "(", "aj", ")", ",", "l", ".", "a", ".", "Vertex", "(", "aj", "+", "1", ")", ")...
// startEdge sets the crossers state for checking the given edge of loop A.
[ "startEdge", "sets", "the", "crossers", "state", "for", "checking", "the", "given", "edge", "of", "loop", "A", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/loop.go#L1466-L1470
28,170
golang/geo
s2/loop.go
edgeCrossesCell
func (l *loopCrosser) edgeCrossesCell(bClipped *clippedShape) bool { // Test the current edge of A against all edges of bClipped bNumEdges := bClipped.numEdges() for j := 0; j < bNumEdges; j++ { bj := bClipped.edges[j] if bj != l.bjPrev+1 { l.crosser.RestartAt(l.b.Vertex(bj)) } l.bjPrev = bj if crossing...
go
func (l *loopCrosser) edgeCrossesCell(bClipped *clippedShape) bool { // Test the current edge of A against all edges of bClipped bNumEdges := bClipped.numEdges() for j := 0; j < bNumEdges; j++ { bj := bClipped.edges[j] if bj != l.bjPrev+1 { l.crosser.RestartAt(l.b.Vertex(bj)) } l.bjPrev = bj if crossing...
[ "func", "(", "l", "*", "loopCrosser", ")", "edgeCrossesCell", "(", "bClipped", "*", "clippedShape", ")", "bool", "{", "// Test the current edge of A against all edges of bClipped", "bNumEdges", ":=", "bClipped", ".", "numEdges", "(", ")", "\n", "for", "j", ":=", "...
// edgeCrossesCell reports whether the current edge of loop A has any crossings with // edges of the index cell of loop B.
[ "edgeCrossesCell", "reports", "whether", "the", "current", "edge", "of", "loop", "A", "has", "any", "crossings", "with", "edges", "of", "the", "index", "cell", "of", "loop", "B", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/loop.go#L1474-L1505
28,171
golang/geo
s2/loop.go
cellCrossesCell
func (l *loopCrosser) cellCrossesCell(aClipped, bClipped *clippedShape) bool { // Test all edges of aClipped against all edges of bClipped. for _, edge := range aClipped.edges { l.startEdge(edge) if l.edgeCrossesCell(bClipped) { return true } } return false }
go
func (l *loopCrosser) cellCrossesCell(aClipped, bClipped *clippedShape) bool { // Test all edges of aClipped against all edges of bClipped. for _, edge := range aClipped.edges { l.startEdge(edge) if l.edgeCrossesCell(bClipped) { return true } } return false }
[ "func", "(", "l", "*", "loopCrosser", ")", "cellCrossesCell", "(", "aClipped", ",", "bClipped", "*", "clippedShape", ")", "bool", "{", "// Test all edges of aClipped against all edges of bClipped.", "for", "_", ",", "edge", ":=", "range", "aClipped", ".", "edges", ...
// cellCrossesCell reports whether there are any edge crossings or wedge crossings // within the two given cells.
[ "cellCrossesCell", "reports", "whether", "there", "are", "any", "edge", "crossings", "or", "wedge", "crossings", "within", "the", "two", "given", "cells", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/loop.go#L1509-L1519
28,172
golang/geo
s2/loop.go
cellCrossesAnySubcell
func (l *loopCrosser) cellCrossesAnySubcell(aClipped *clippedShape, bID CellID) bool { // Test all edges of aClipped against all edges of B. The relevant B // edges are guaranteed to be children of bID, which lets us find the // correct index cells more efficiently. bRoot := PaddedCellFromCellID(bID, 0) for _, aj ...
go
func (l *loopCrosser) cellCrossesAnySubcell(aClipped *clippedShape, bID CellID) bool { // Test all edges of aClipped against all edges of B. The relevant B // edges are guaranteed to be children of bID, which lets us find the // correct index cells more efficiently. bRoot := PaddedCellFromCellID(bID, 0) for _, aj ...
[ "func", "(", "l", "*", "loopCrosser", ")", "cellCrossesAnySubcell", "(", "aClipped", "*", "clippedShape", ",", "bID", "CellID", ")", "bool", "{", "// Test all edges of aClipped against all edges of B. The relevant B", "// edges are guaranteed to be children of bID, which lets us ...
// cellCrossesAnySubcell reports whether given an index cell of A, if there are any // edge or wedge crossings with any index cell of B contained within bID.
[ "cellCrossesAnySubcell", "reports", "whether", "given", "an", "index", "cell", "of", "A", "if", "there", "are", "any", "edge", "or", "wedge", "crossings", "with", "any", "index", "cell", "of", "B", "contained", "within", "bID", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/loop.go#L1523-L1544
28,173
golang/geo
s2/projections.go
Interpolate
func (p *MercatorProjection) Interpolate(f float64, a, b r2.Point) r2.Point { return a.Mul(1 - f).Add(b.Mul(f)) }
go
func (p *MercatorProjection) Interpolate(f float64, a, b r2.Point) r2.Point { return a.Mul(1 - f).Add(b.Mul(f)) }
[ "func", "(", "p", "*", "MercatorProjection", ")", "Interpolate", "(", "f", "float64", ",", "a", ",", "b", "r2", ".", "Point", ")", "r2", ".", "Point", "{", "return", "a", ".", "Mul", "(", "1", "-", "f", ")", ".", "Add", "(", "b", ".", "Mul", ...
// Interpolate returns the point obtained by interpolating the given // fraction of the distance along the line from A to B.
[ "Interpolate", "returns", "the", "point", "obtained", "by", "interpolating", "the", "given", "fraction", "of", "the", "distance", "along", "the", "line", "from", "A", "to", "B", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/projections.go#L196-L198
28,174
golang/geo
s2/shape.go
defaultShapeIsEmpty
func defaultShapeIsEmpty(s Shape) bool { return s.NumEdges() == 0 && (s.Dimension() != 2 || s.NumChains() == 0) }
go
func defaultShapeIsEmpty(s Shape) bool { return s.NumEdges() == 0 && (s.Dimension() != 2 || s.NumChains() == 0) }
[ "func", "defaultShapeIsEmpty", "(", "s", "Shape", ")", "bool", "{", "return", "s", ".", "NumEdges", "(", ")", "==", "0", "&&", "(", "s", ".", "Dimension", "(", ")", "!=", "2", "||", "s", ".", "NumChains", "(", ")", "==", "0", ")", "\n", "}" ]
// defaultShapeIsEmpty reports whether this shape contains no points.
[ "defaultShapeIsEmpty", "reports", "whether", "this", "shape", "contains", "no", "points", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/shape.go#L228-L230
28,175
golang/geo
s2/shape.go
defaultShapeIsFull
func defaultShapeIsFull(s Shape) bool { return s.NumEdges() == 0 && s.Dimension() == 2 && s.NumChains() > 0 }
go
func defaultShapeIsFull(s Shape) bool { return s.NumEdges() == 0 && s.Dimension() == 2 && s.NumChains() > 0 }
[ "func", "defaultShapeIsFull", "(", "s", "Shape", ")", "bool", "{", "return", "s", ".", "NumEdges", "(", ")", "==", "0", "&&", "s", ".", "Dimension", "(", ")", "==", "2", "&&", "s", ".", "NumChains", "(", ")", ">", "0", "\n", "}" ]
// defaultShapeIsFull reports whether this shape contains all points on the sphere.
[ "defaultShapeIsFull", "reports", "whether", "this", "shape", "contains", "all", "points", "on", "the", "sphere", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/shape.go#L233-L235
28,176
golang/geo
s2/shapeindex.go
newClippedShape
func newClippedShape(id int32, numEdges int) *clippedShape { return &clippedShape{ shapeID: id, edges: make([]int, numEdges), } }
go
func newClippedShape(id int32, numEdges int) *clippedShape { return &clippedShape{ shapeID: id, edges: make([]int, numEdges), } }
[ "func", "newClippedShape", "(", "id", "int32", ",", "numEdges", "int", ")", "*", "clippedShape", "{", "return", "&", "clippedShape", "{", "shapeID", ":", "id", ",", "edges", ":", "make", "(", "[", "]", "int", ",", "numEdges", ")", ",", "}", "\n", "}"...
// newClippedShape returns a new clipped shape for the given shapeID and number of expected edges.
[ "newClippedShape", "returns", "a", "new", "clipped", "shape", "for", "the", "given", "shapeID", "and", "number", "of", "expected", "edges", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/shapeindex.go#L86-L91
28,177
golang/geo
s2/shapeindex.go
containsEdge
func (c *clippedShape) containsEdge(id int) bool { // Linear search is fast because the number of edges per shape is typically // very small (less than 10). for _, e := range c.edges { if e == id { return true } } return false }
go
func (c *clippedShape) containsEdge(id int) bool { // Linear search is fast because the number of edges per shape is typically // very small (less than 10). for _, e := range c.edges { if e == id { return true } } return false }
[ "func", "(", "c", "*", "clippedShape", ")", "containsEdge", "(", "id", "int", ")", "bool", "{", "// Linear search is fast because the number of edges per shape is typically", "// very small (less than 10).", "for", "_", ",", "e", ":=", "range", "c", ".", "edges", "{",...
// containsEdge reports if this clipped shape contains the given edge ID.
[ "containsEdge", "reports", "if", "this", "clipped", "shape", "contains", "the", "given", "edge", "ID", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/shapeindex.go#L99-L108
28,178
golang/geo
s2/shapeindex.go
numEdges
func (s *ShapeIndexCell) numEdges() int { var e int for _, cs := range s.shapes { e += cs.numEdges() } return e }
go
func (s *ShapeIndexCell) numEdges() int { var e int for _, cs := range s.shapes { e += cs.numEdges() } return e }
[ "func", "(", "s", "*", "ShapeIndexCell", ")", "numEdges", "(", ")", "int", "{", "var", "e", "int", "\n", "for", "_", ",", "cs", ":=", "range", "s", ".", "shapes", "{", "e", "+=", "cs", ".", "numEdges", "(", ")", "\n", "}", "\n", "return", "e", ...
// numEdges reports the total number of edges in all clipped shapes in this cell.
[ "numEdges", "reports", "the", "total", "number", "of", "edges", "in", "all", "clipped", "shapes", "in", "this", "cell", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/shapeindex.go#L123-L129
28,179
golang/geo
s2/shapeindex.go
add
func (s *ShapeIndexCell) add(c *clippedShape) { // C++ uses a set, so it's ordered and unique. We don't currently catch // the case when a duplicate value is added. s.shapes = append(s.shapes, c) }
go
func (s *ShapeIndexCell) add(c *clippedShape) { // C++ uses a set, so it's ordered and unique. We don't currently catch // the case when a duplicate value is added. s.shapes = append(s.shapes, c) }
[ "func", "(", "s", "*", "ShapeIndexCell", ")", "add", "(", "c", "*", "clippedShape", ")", "{", "// C++ uses a set, so it's ordered and unique. We don't currently catch", "// the case when a duplicate value is added.", "s", ".", "shapes", "=", "append", "(", "s", ".", "sh...
// add adds the given clipped shape to this index cell.
[ "add", "adds", "the", "given", "clipped", "shape", "to", "this", "index", "cell", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/shapeindex.go#L132-L136
28,180
golang/geo
s2/shapeindex.go
findByShapeID
func (s *ShapeIndexCell) findByShapeID(shapeID int32) *clippedShape { // Linear search is fine because the number of shapes per cell is typically // very small (most often 1), and is large only for pathological inputs // (e.g. very deeply nested loops). for _, clipped := range s.shapes { if clipped.shapeID == sha...
go
func (s *ShapeIndexCell) findByShapeID(shapeID int32) *clippedShape { // Linear search is fine because the number of shapes per cell is typically // very small (most often 1), and is large only for pathological inputs // (e.g. very deeply nested loops). for _, clipped := range s.shapes { if clipped.shapeID == sha...
[ "func", "(", "s", "*", "ShapeIndexCell", ")", "findByShapeID", "(", "shapeID", "int32", ")", "*", "clippedShape", "{", "// Linear search is fine because the number of shapes per cell is typically", "// very small (most often 1), and is large only for pathological inputs", "// (e.g. v...
// findByShapeID returns the clipped shape that contains the given shapeID, // or nil if none of the clipped shapes contain it.
[ "findByShapeID", "returns", "the", "clipped", "shape", "that", "contains", "the", "given", "shapeID", "or", "nil", "if", "none", "of", "the", "clipped", "shapes", "contain", "it", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/shapeindex.go#L140-L150
28,181
golang/geo
s2/shapeindex.go
NewShapeIndexIterator
func NewShapeIndexIterator(index *ShapeIndex, pos ...ShapeIndexIteratorPos) *ShapeIndexIterator { s := &ShapeIndexIterator{ index: index, } if len(pos) > 0 { if len(pos) > 1 { panic("too many ShapeIndexIteratorPos arguments") } switch pos[0] { case IteratorBegin: s.Begin() case IteratorEnd: s.E...
go
func NewShapeIndexIterator(index *ShapeIndex, pos ...ShapeIndexIteratorPos) *ShapeIndexIterator { s := &ShapeIndexIterator{ index: index, } if len(pos) > 0 { if len(pos) > 1 { panic("too many ShapeIndexIteratorPos arguments") } switch pos[0] { case IteratorBegin: s.Begin() case IteratorEnd: s.E...
[ "func", "NewShapeIndexIterator", "(", "index", "*", "ShapeIndex", ",", "pos", "...", "ShapeIndexIteratorPos", ")", "*", "ShapeIndexIterator", "{", "s", ":=", "&", "ShapeIndexIterator", "{", "index", ":", "index", ",", "}", "\n\n", "if", "len", "(", "pos", ")...
// NewShapeIndexIterator creates a new iterator for the given index. If a starting // position is specified, the iterator is positioned at the given spot.
[ "NewShapeIndexIterator", "creates", "a", "new", "iterator", "for", "the", "given", "index", ".", "If", "a", "starting", "position", "is", "specified", "the", "iterator", "is", "positioned", "at", "the", "given", "spot", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/shapeindex.go#L212-L232
28,182
golang/geo
s2/shapeindex.go
Begin
func (s *ShapeIndexIterator) Begin() { if !s.index.IsFresh() { s.index.maybeApplyUpdates() } s.position = 0 s.refresh() }
go
func (s *ShapeIndexIterator) Begin() { if !s.index.IsFresh() { s.index.maybeApplyUpdates() } s.position = 0 s.refresh() }
[ "func", "(", "s", "*", "ShapeIndexIterator", ")", "Begin", "(", ")", "{", "if", "!", "s", ".", "index", ".", "IsFresh", "(", ")", "{", "s", ".", "index", ".", "maybeApplyUpdates", "(", ")", "\n", "}", "\n", "s", ".", "position", "=", "0", "\n", ...
// Begin positions the iterator at the beginning of the index.
[ "Begin", "positions", "the", "iterator", "at", "the", "beginning", "of", "the", "index", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/shapeindex.go#L254-L260
28,183
golang/geo
s2/shapeindex.go
Prev
func (s *ShapeIndexIterator) Prev() bool { if s.position <= 0 { return false } s.position-- s.refresh() return true }
go
func (s *ShapeIndexIterator) Prev() bool { if s.position <= 0 { return false } s.position-- s.refresh() return true }
[ "func", "(", "s", "*", "ShapeIndexIterator", ")", "Prev", "(", ")", "bool", "{", "if", "s", ".", "position", "<=", "0", "{", "return", "false", "\n", "}", "\n\n", "s", ".", "position", "--", "\n", "s", ".", "refresh", "(", ")", "\n", "return", "t...
// Prev advances the iterator to the previous cell in the index and returns true to // indicate it was not yet at the beginning of the index. If the iterator is at the // first cell the call does nothing and returns false.
[ "Prev", "advances", "the", "iterator", "to", "the", "previous", "cell", "in", "the", "index", "and", "returns", "true", "to", "indicate", "it", "was", "not", "yet", "at", "the", "beginning", "of", "the", "index", ".", "If", "the", "iterator", "is", "at",...
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/shapeindex.go#L271-L279
28,184
golang/geo
s2/shapeindex.go
End
func (s *ShapeIndexIterator) End() { s.position = len(s.index.cells) s.refresh() }
go
func (s *ShapeIndexIterator) End() { s.position = len(s.index.cells) s.refresh() }
[ "func", "(", "s", "*", "ShapeIndexIterator", ")", "End", "(", ")", "{", "s", ".", "position", "=", "len", "(", "s", ".", "index", ".", "cells", ")", "\n", "s", ".", "refresh", "(", ")", "\n", "}" ]
// End positions the iterator at the end of the index.
[ "End", "positions", "the", "iterator", "at", "the", "end", "of", "the", "index", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/shapeindex.go#L282-L285
28,185
golang/geo
s2/shapeindex.go
refresh
func (s *ShapeIndexIterator) refresh() { if s.position < len(s.index.cells) { s.id = s.index.cells[s.position] s.cell = s.index.cellMap[s.CellID()] } else { s.id = SentinelCellID s.cell = nil } }
go
func (s *ShapeIndexIterator) refresh() { if s.position < len(s.index.cells) { s.id = s.index.cells[s.position] s.cell = s.index.cellMap[s.CellID()] } else { s.id = SentinelCellID s.cell = nil } }
[ "func", "(", "s", "*", "ShapeIndexIterator", ")", "refresh", "(", ")", "{", "if", "s", ".", "position", "<", "len", "(", "s", ".", "index", ".", "cells", ")", "{", "s", ".", "id", "=", "s", ".", "index", ".", "cells", "[", "s", ".", "position",...
// refresh updates the stored internal iterator values.
[ "refresh", "updates", "the", "stored", "internal", "iterator", "values", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/shapeindex.go#L293-L301
28,186
golang/geo
s2/shapeindex.go
seek
func (s *ShapeIndexIterator) seek(target CellID) { s.position = 0 // In C++, this relies on the lower_bound method of the underlying btree_map. // TODO(roberts): Convert this to a binary search since the list of cells is ordered. for k, v := range s.index.cells { // We've passed the cell that is after us, so we a...
go
func (s *ShapeIndexIterator) seek(target CellID) { s.position = 0 // In C++, this relies on the lower_bound method of the underlying btree_map. // TODO(roberts): Convert this to a binary search since the list of cells is ordered. for k, v := range s.index.cells { // We've passed the cell that is after us, so we a...
[ "func", "(", "s", "*", "ShapeIndexIterator", ")", "seek", "(", "target", "CellID", ")", "{", "s", ".", "position", "=", "0", "\n", "// In C++, this relies on the lower_bound method of the underlying btree_map.", "// TODO(roberts): Convert this to a binary search since the list ...
// seek positions the iterator at the first cell whose ID >= target, or at the // end of the index if no such cell exists.
[ "seek", "positions", "the", "iterator", "at", "the", "first", "cell", "whose", "ID", ">", "=", "target", "or", "at", "the", "end", "of", "the", "index", "if", "no", "such", "cell", "exists", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/shapeindex.go#L305-L319
28,187
golang/geo
s2/shapeindex.go
LocatePoint
func (s *ShapeIndexIterator) LocatePoint(p Point) bool { // Let I = cellMap.LowerBound(T), where T is the leaf cell containing // point P. Then if T is contained by an index cell, then the // containing cell is either I or I'. We test for containment by comparing // the ranges of leaf cells spanned by T, I, and I'....
go
func (s *ShapeIndexIterator) LocatePoint(p Point) bool { // Let I = cellMap.LowerBound(T), where T is the leaf cell containing // point P. Then if T is contained by an index cell, then the // containing cell is either I or I'. We test for containment by comparing // the ranges of leaf cells spanned by T, I, and I'....
[ "func", "(", "s", "*", "ShapeIndexIterator", ")", "LocatePoint", "(", "p", "Point", ")", "bool", "{", "// Let I = cellMap.LowerBound(T), where T is the leaf cell containing", "// point P. Then if T is contained by an index cell, then the", "// containing cell is either I or I'. We test...
// LocatePoint positions the iterator at the cell that contains the given Point. // If no such cell exists, the iterator position is unspecified, and false is returned. // The cell at the matched position is guaranteed to contain all edges that might // intersect the line segment between target and the cell's center.
[ "LocatePoint", "positions", "the", "iterator", "at", "the", "cell", "that", "contains", "the", "given", "Point", ".", "If", "no", "such", "cell", "exists", "the", "iterator", "position", "is", "unspecified", "and", "false", "is", "returned", ".", "The", "cel...
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/shapeindex.go#L325-L340
28,188
golang/geo
s2/shapeindex.go
newTracker
func newTracker() *tracker { // As shapes are added, we compute which ones contain the start of the // CellID space-filling curve by drawing an edge from OriginPoint to this // point and counting how many shape edges cross this edge. t := &tracker{ isActive: false, b: trackerOrigin(), nextCellID: C...
go
func newTracker() *tracker { // As shapes are added, we compute which ones contain the start of the // CellID space-filling curve by drawing an edge from OriginPoint to this // point and counting how many shape edges cross this edge. t := &tracker{ isActive: false, b: trackerOrigin(), nextCellID: C...
[ "func", "newTracker", "(", ")", "*", "tracker", "{", "// As shapes are added, we compute which ones contain the start of the", "// CellID space-filling curve by drawing an edge from OriginPoint to this", "// point and counting how many shape edges cross this edge.", "t", ":=", "&", "tracke...
// newTracker returns a new tracker with the appropriate defaults.
[ "newTracker", "returns", "a", "new", "tracker", "with", "the", "appropriate", "defaults", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/shapeindex.go#L402-L414
28,189
golang/geo
s2/shapeindex.go
drawTo
func (t *tracker) drawTo(b Point) { t.a = t.b t.b = b // TODO: the edge crosser may need an in-place Init method if this gets expensive t.crosser = NewEdgeCrosser(t.a, t.b) }
go
func (t *tracker) drawTo(b Point) { t.a = t.b t.b = b // TODO: the edge crosser may need an in-place Init method if this gets expensive t.crosser = NewEdgeCrosser(t.a, t.b) }
[ "func", "(", "t", "*", "tracker", ")", "drawTo", "(", "b", "Point", ")", "{", "t", ".", "a", "=", "t", ".", "b", "\n", "t", ".", "b", "=", "b", "\n", "// TODO: the edge crosser may need an in-place Init method if this gets expensive", "t", ".", "crosser", ...
// drawTo moves the focus of the tracker to the given point. After this method is // called, testEdge should be called with all edges that may cross the line // segment between the old and new focus locations.
[ "drawTo", "moves", "the", "focus", "of", "the", "tracker", "to", "the", "given", "point", ".", "After", "this", "method", "is", "called", "testEdge", "should", "be", "called", "with", "all", "edges", "that", "may", "cross", "the", "line", "segment", "betwe...
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/shapeindex.go#L449-L454
28,190
golang/geo
s2/shapeindex.go
toggleShape
func (t *tracker) toggleShape(shapeID int32) { // Most shapeIDs slices are small, so special case the common steps. // If there is nothing here, add it. if len(t.shapeIDs) == 0 { t.shapeIDs = append(t.shapeIDs, shapeID) return } // If it's the first element, drop it from the slice. if t.shapeIDs[0] == shape...
go
func (t *tracker) toggleShape(shapeID int32) { // Most shapeIDs slices are small, so special case the common steps. // If there is nothing here, add it. if len(t.shapeIDs) == 0 { t.shapeIDs = append(t.shapeIDs, shapeID) return } // If it's the first element, drop it from the slice. if t.shapeIDs[0] == shape...
[ "func", "(", "t", "*", "tracker", ")", "toggleShape", "(", "shapeID", "int32", ")", "{", "// Most shapeIDs slices are small, so special case the common steps.", "// If there is nothing here, add it.", "if", "len", "(", "t", ".", "shapeIDs", ")", "==", "0", "{", "t", ...
// toggleShape adds or removes the given shapeID from the set of IDs it is tracking.
[ "toggleShape", "adds", "or", "removes", "the", "given", "shapeID", "from", "the", "set", "of", "IDs", "it", "is", "tracking", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/shapeindex.go#L481-L517
28,191
golang/geo
s2/shapeindex.go
restoreStateBefore
func (t *tracker) restoreStateBefore(limitShapeID int32) { limit := t.lowerBound(limitShapeID) t.shapeIDs = append(append([]int32(nil), t.savedIDs...), t.shapeIDs[limit:]...) t.savedIDs = nil }
go
func (t *tracker) restoreStateBefore(limitShapeID int32) { limit := t.lowerBound(limitShapeID) t.shapeIDs = append(append([]int32(nil), t.savedIDs...), t.shapeIDs[limit:]...) t.savedIDs = nil }
[ "func", "(", "t", "*", "tracker", ")", "restoreStateBefore", "(", "limitShapeID", "int32", ")", "{", "limit", ":=", "t", ".", "lowerBound", "(", "limitShapeID", ")", "\n", "t", ".", "shapeIDs", "=", "append", "(", "append", "(", "[", "]", "int32", "(",...
// restoreStateBefore restores the state previously saved by saveAndClearStateBefore. // This only affects the state for shapeIDs below "limitShapeID".
[ "restoreStateBefore", "restores", "the", "state", "previously", "saved", "by", "saveAndClearStateBefore", ".", "This", "only", "affects", "the", "state", "for", "shapeIDs", "below", "limitShapeID", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/shapeindex.go#L530-L534
28,192
golang/geo
s2/shapeindex.go
NewShapeIndex
func NewShapeIndex() *ShapeIndex { return &ShapeIndex{ maxEdgesPerCell: 10, shapes: make(map[int32]Shape), cellMap: make(map[CellID]*ShapeIndexCell), cells: nil, status: fresh, } }
go
func NewShapeIndex() *ShapeIndex { return &ShapeIndex{ maxEdgesPerCell: 10, shapes: make(map[int32]Shape), cellMap: make(map[CellID]*ShapeIndexCell), cells: nil, status: fresh, } }
[ "func", "NewShapeIndex", "(", ")", "*", "ShapeIndex", "{", "return", "&", "ShapeIndex", "{", "maxEdgesPerCell", ":", "10", ",", "shapes", ":", "make", "(", "map", "[", "int32", "]", "Shape", ")", ",", "cellMap", ":", "make", "(", "map", "[", "CellID", ...
// NewShapeIndex creates a new ShapeIndex.
[ "NewShapeIndex", "creates", "a", "new", "ShapeIndex", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/shapeindex.go#L631-L639
28,193
golang/geo
s2/shapeindex.go
Reset
func (s *ShapeIndex) Reset() { s.shapes = make(map[int32]Shape) s.nextID = 0 s.cellMap = make(map[CellID]*ShapeIndexCell) s.cells = nil atomic.StoreInt32(&s.status, fresh) }
go
func (s *ShapeIndex) Reset() { s.shapes = make(map[int32]Shape) s.nextID = 0 s.cellMap = make(map[CellID]*ShapeIndexCell) s.cells = nil atomic.StoreInt32(&s.status, fresh) }
[ "func", "(", "s", "*", "ShapeIndex", ")", "Reset", "(", ")", "{", "s", ".", "shapes", "=", "make", "(", "map", "[", "int32", "]", "Shape", ")", "\n", "s", ".", "nextID", "=", "0", "\n", "s", ".", "cellMap", "=", "make", "(", "map", "[", "Cell...
// Reset resets the index to its original state.
[ "Reset", "resets", "the", "index", "to", "its", "original", "state", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/shapeindex.go#L669-L675
28,194
golang/geo
s2/shapeindex.go
NumEdges
func (s *ShapeIndex) NumEdges() int { numEdges := 0 for _, shape := range s.shapes { numEdges += shape.NumEdges() } return numEdges }
go
func (s *ShapeIndex) NumEdges() int { numEdges := 0 for _, shape := range s.shapes { numEdges += shape.NumEdges() } return numEdges }
[ "func", "(", "s", "*", "ShapeIndex", ")", "NumEdges", "(", ")", "int", "{", "numEdges", ":=", "0", "\n", "for", "_", ",", "shape", ":=", "range", "s", ".", "shapes", "{", "numEdges", "+=", "shape", ".", "NumEdges", "(", ")", "\n", "}", "\n", "ret...
// NumEdges returns the number of edges in this index.
[ "NumEdges", "returns", "the", "number", "of", "edges", "in", "this", "index", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/shapeindex.go#L678-L684
28,195
golang/geo
s2/shapeindex.go
NumEdgesUpTo
func (s *ShapeIndex) NumEdgesUpTo(limit int) int { var numEdges int // We choose to iterate over the shapes in order to match the counting // up behavior in C++ and for test compatibility instead of using a // more idiomatic range over the shape map. for i := int32(0); i <= s.nextID; i++ { s := s.Shape(i) if s...
go
func (s *ShapeIndex) NumEdgesUpTo(limit int) int { var numEdges int // We choose to iterate over the shapes in order to match the counting // up behavior in C++ and for test compatibility instead of using a // more idiomatic range over the shape map. for i := int32(0); i <= s.nextID; i++ { s := s.Shape(i) if s...
[ "func", "(", "s", "*", "ShapeIndex", ")", "NumEdgesUpTo", "(", "limit", "int", ")", "int", "{", "var", "numEdges", "int", "\n", "// We choose to iterate over the shapes in order to match the counting", "// up behavior in C++ and for test compatibility instead of using a", "// m...
// NumEdgesUpTo returns the number of edges in the given index, up to the given // limit. If the limit is encountered, the current running total is returned, // which may be more than the limit.
[ "NumEdgesUpTo", "returns", "the", "number", "of", "edges", "in", "the", "given", "index", "up", "to", "the", "given", "limit", ".", "If", "the", "limit", "is", "encountered", "the", "current", "running", "total", "is", "returned", "which", "may", "be", "mo...
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/shapeindex.go#L689-L706
28,196
golang/geo
s2/shapeindex.go
Add
func (s *ShapeIndex) Add(shape Shape) int32 { s.shapes[s.nextID] = shape s.nextID++ atomic.StoreInt32(&s.status, stale) return s.nextID - 1 }
go
func (s *ShapeIndex) Add(shape Shape) int32 { s.shapes[s.nextID] = shape s.nextID++ atomic.StoreInt32(&s.status, stale) return s.nextID - 1 }
[ "func", "(", "s", "*", "ShapeIndex", ")", "Add", "(", "shape", "Shape", ")", "int32", "{", "s", ".", "shapes", "[", "s", ".", "nextID", "]", "=", "shape", "\n", "s", ".", "nextID", "++", "\n", "atomic", ".", "StoreInt32", "(", "&", "s", ".", "s...
// Add adds the given shape to the index and returns the assigned ID..
[ "Add", "adds", "the", "given", "shape", "to", "the", "index", "and", "returns", "the", "assigned", "ID", ".." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/shapeindex.go#L728-L733
28,197
golang/geo
s2/shapeindex.go
Remove
func (s *ShapeIndex) Remove(shape Shape) { // The index updates itself lazily because it is much more efficient to // process additions and removals in batches. id := s.idForShape(shape) // If the shape wasn't found, it's already been removed or was not in the index. if s.shapes[id] == nil { return } // Remo...
go
func (s *ShapeIndex) Remove(shape Shape) { // The index updates itself lazily because it is much more efficient to // process additions and removals in batches. id := s.idForShape(shape) // If the shape wasn't found, it's already been removed or was not in the index. if s.shapes[id] == nil { return } // Remo...
[ "func", "(", "s", "*", "ShapeIndex", ")", "Remove", "(", "shape", "Shape", ")", "{", "// The index updates itself lazily because it is much more efficient to", "// process additions and removals in batches.", "id", ":=", "s", ".", "idForShape", "(", "shape", ")", "\n\n", ...
// Remove removes the given shape from the index.
[ "Remove", "removes", "the", "given", "shape", "from", "the", "index", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/shapeindex.go#L736-L769
28,198
golang/geo
s2/shapeindex.go
maybeApplyUpdates
func (s *ShapeIndex) maybeApplyUpdates() { // TODO(roberts): To avoid acquiring and releasing the mutex on every // query, we should use atomic operations when testing whether the status // is fresh and when updating the status to be fresh. This guarantees // that any thread that sees a status of fresh will also se...
go
func (s *ShapeIndex) maybeApplyUpdates() { // TODO(roberts): To avoid acquiring and releasing the mutex on every // query, we should use atomic operations when testing whether the status // is fresh and when updating the status to be fresh. This guarantees // that any thread that sees a status of fresh will also se...
[ "func", "(", "s", "*", "ShapeIndex", ")", "maybeApplyUpdates", "(", ")", "{", "// TODO(roberts): To avoid acquiring and releasing the mutex on every", "// query, we should use atomic operations when testing whether the status", "// is fresh and when updating the status to be fresh. This guar...
// maybeApplyUpdates checks if the index pieces have changed, and if so, applies pending updates.
[ "maybeApplyUpdates", "checks", "if", "the", "index", "pieces", "have", "changed", "and", "if", "so", "applies", "pending", "updates", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/shapeindex.go#L797-L809
28,199
golang/geo
s2/shapeindex.go
addShapeInternal
func (s *ShapeIndex) addShapeInternal(shapeID int32, allEdges [][]faceEdge, t *tracker) { shape, ok := s.shapes[shapeID] if !ok { // This shape has already been removed. return } faceEdge := faceEdge{ shapeID: shapeID, hasInterior: shape.Dimension() == 2, } if faceEdge.hasInterior { t.addShape(sha...
go
func (s *ShapeIndex) addShapeInternal(shapeID int32, allEdges [][]faceEdge, t *tracker) { shape, ok := s.shapes[shapeID] if !ok { // This shape has already been removed. return } faceEdge := faceEdge{ shapeID: shapeID, hasInterior: shape.Dimension() == 2, } if faceEdge.hasInterior { t.addShape(sha...
[ "func", "(", "s", "*", "ShapeIndex", ")", "addShapeInternal", "(", "shapeID", "int32", ",", "allEdges", "[", "]", "[", "]", "faceEdge", ",", "t", "*", "tracker", ")", "{", "shape", ",", "ok", ":=", "s", ".", "shapes", "[", "shapeID", "]", "\n", "if...
// addShapeInternal clips all edges of the given shape to the six cube faces, // adds the clipped edges to the set of allEdges, and starts tracking its // interior if necessary.
[ "addShapeInternal", "clips", "all", "edges", "of", "the", "given", "shape", "to", "the", "six", "cube", "faces", "adds", "the", "clipped", "edges", "to", "the", "set", "of", "allEdges", "and", "starts", "tracking", "its", "interior", "if", "necessary", "." ]
476085157cff9aaeef4d4f124649436542d4114a
https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/shapeindex.go#L843-L868