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 listlengths 21 1.41k | docstring stringlengths 6 2.61k | docstring_tokens listlengths 3 215 | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
150,100 | golang/geo | s2/regioncoverer.go | addCandidate | func (c *coverer) addCandidate(cand *candidate) {
if cand == nil {
return
}
if cand.terminal {
c.result = append(c.result, cand.cell.id)
return
}
// Expand one level at a time until we hit minLevel to ensure that we don't skip over it.
numLevels := c.levelMod
level := int(cand.cell.level)
if level < c.m... | go | func (c *coverer) addCandidate(cand *candidate) {
if cand == nil {
return
}
if cand.terminal {
c.result = append(c.result, cand.cell.id)
return
}
// Expand one level at a time until we hit minLevel to ensure that we don't skip over it.
numLevels := c.levelMod
level := int(cand.cell.level)
if level < c.m... | [
"func",
"(",
"c",
"*",
"coverer",
")",
"addCandidate",
"(",
"cand",
"*",
"candidate",
")",
"{",
"if",
"cand",
"==",
"nil",
"{",
"return",
"\n",
"}",
"\n\n",
"if",
"cand",
".",
"terminal",
"{",
"c",
".",
"result",
"=",
"append",
"(",
"c",
".",
"re... | // addCandidate adds the given candidate to the result if it is marked as "terminal",
// otherwise expands its children and inserts it into the priority queue.
// Passing an argument of nil does nothing. | [
"addCandidate",
"adds",
"the",
"given",
"candidate",
"to",
"the",
"result",
"if",
"it",
"is",
"marked",
"as",
"terminal",
"otherwise",
"expands",
"its",
"children",
"and",
"inserts",
"it",
"into",
"the",
"priority",
"queue",
".",
"Passing",
"an",
"argument",
... | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/regioncoverer.go#L180-L218 |
150,101 | golang/geo | s2/regioncoverer.go | initialCandidates | func (c *coverer) initialCandidates() {
// Optimization: start with a small (usually 4 cell) covering of the region's bounding cap.
temp := &RegionCoverer{MaxLevel: c.maxLevel, LevelMod: 1, MaxCells: minInt(4, c.maxCells)}
cells := temp.FastCovering(c.region)
c.adjustCellLevels(&cells)
for _, ci := range cells {
... | go | func (c *coverer) initialCandidates() {
// Optimization: start with a small (usually 4 cell) covering of the region's bounding cap.
temp := &RegionCoverer{MaxLevel: c.maxLevel, LevelMod: 1, MaxCells: minInt(4, c.maxCells)}
cells := temp.FastCovering(c.region)
c.adjustCellLevels(&cells)
for _, ci := range cells {
... | [
"func",
"(",
"c",
"*",
"coverer",
")",
"initialCandidates",
"(",
")",
"{",
"// Optimization: start with a small (usually 4 cell) covering of the region's bounding cap.",
"temp",
":=",
"&",
"RegionCoverer",
"{",
"MaxLevel",
":",
"c",
".",
"maxLevel",
",",
"LevelMod",
":"... | // initialCandidates computes a set of initial candidates that cover the given region. | [
"initialCandidates",
"computes",
"a",
"set",
"of",
"initial",
"candidates",
"that",
"cover",
"the",
"given",
"region",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/regioncoverer.go#L258-L267 |
150,102 | golang/geo | s2/regioncoverer.go | newCoverer | func (rc *RegionCoverer) newCoverer() *coverer {
return &coverer{
minLevel: maxInt(0, minInt(maxLevel, rc.MinLevel)),
maxLevel: maxInt(0, minInt(maxLevel, rc.MaxLevel)),
levelMod: maxInt(1, minInt(3, rc.LevelMod)),
maxCells: rc.MaxCells,
}
} | go | func (rc *RegionCoverer) newCoverer() *coverer {
return &coverer{
minLevel: maxInt(0, minInt(maxLevel, rc.MinLevel)),
maxLevel: maxInt(0, minInt(maxLevel, rc.MaxLevel)),
levelMod: maxInt(1, minInt(3, rc.LevelMod)),
maxCells: rc.MaxCells,
}
} | [
"func",
"(",
"rc",
"*",
"RegionCoverer",
")",
"newCoverer",
"(",
")",
"*",
"coverer",
"{",
"return",
"&",
"coverer",
"{",
"minLevel",
":",
"maxInt",
"(",
"0",
",",
"minInt",
"(",
"maxLevel",
",",
"rc",
".",
"MinLevel",
")",
")",
",",
"maxLevel",
":",... | // newCoverer returns an instance of coverer. | [
"newCoverer",
"returns",
"an",
"instance",
"of",
"coverer",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/regioncoverer.go#L314-L321 |
150,103 | golang/geo | s2/regioncoverer.go | Covering | func (rc *RegionCoverer) Covering(region Region) CellUnion {
covering := rc.CellUnion(region)
covering.Denormalize(maxInt(0, minInt(maxLevel, rc.MinLevel)), maxInt(1, minInt(3, rc.LevelMod)))
return covering
} | go | func (rc *RegionCoverer) Covering(region Region) CellUnion {
covering := rc.CellUnion(region)
covering.Denormalize(maxInt(0, minInt(maxLevel, rc.MinLevel)), maxInt(1, minInt(3, rc.LevelMod)))
return covering
} | [
"func",
"(",
"rc",
"*",
"RegionCoverer",
")",
"Covering",
"(",
"region",
"Region",
")",
"CellUnion",
"{",
"covering",
":=",
"rc",
".",
"CellUnion",
"(",
"region",
")",
"\n",
"covering",
".",
"Denormalize",
"(",
"maxInt",
"(",
"0",
",",
"minInt",
"(",
"... | // Covering returns a CellUnion that covers the given region and satisfies the various restrictions. | [
"Covering",
"returns",
"a",
"CellUnion",
"that",
"covers",
"the",
"given",
"region",
"and",
"satisfies",
"the",
"various",
"restrictions",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/regioncoverer.go#L324-L328 |
150,104 | golang/geo | s2/regioncoverer.go | InteriorCovering | func (rc *RegionCoverer) InteriorCovering(region Region) CellUnion {
intCovering := rc.InteriorCellUnion(region)
intCovering.Denormalize(maxInt(0, minInt(maxLevel, rc.MinLevel)), maxInt(1, minInt(3, rc.LevelMod)))
return intCovering
} | go | func (rc *RegionCoverer) InteriorCovering(region Region) CellUnion {
intCovering := rc.InteriorCellUnion(region)
intCovering.Denormalize(maxInt(0, minInt(maxLevel, rc.MinLevel)), maxInt(1, minInt(3, rc.LevelMod)))
return intCovering
} | [
"func",
"(",
"rc",
"*",
"RegionCoverer",
")",
"InteriorCovering",
"(",
"region",
"Region",
")",
"CellUnion",
"{",
"intCovering",
":=",
"rc",
".",
"InteriorCellUnion",
"(",
"region",
")",
"\n",
"intCovering",
".",
"Denormalize",
"(",
"maxInt",
"(",
"0",
",",
... | // InteriorCovering returns a CellUnion that is contained within the given region and satisfies the various restrictions. | [
"InteriorCovering",
"returns",
"a",
"CellUnion",
"that",
"is",
"contained",
"within",
"the",
"given",
"region",
"and",
"satisfies",
"the",
"various",
"restrictions",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/regioncoverer.go#L331-L335 |
150,105 | golang/geo | s2/regioncoverer.go | SimpleRegionCovering | func SimpleRegionCovering(region Region, start Point, level int) []CellID {
return FloodFillRegionCovering(region, cellIDFromPoint(start).Parent(level))
} | go | func SimpleRegionCovering(region Region, start Point, level int) []CellID {
return FloodFillRegionCovering(region, cellIDFromPoint(start).Parent(level))
} | [
"func",
"SimpleRegionCovering",
"(",
"region",
"Region",
",",
"start",
"Point",
",",
"level",
"int",
")",
"[",
"]",
"CellID",
"{",
"return",
"FloodFillRegionCovering",
"(",
"region",
",",
"cellIDFromPoint",
"(",
"start",
")",
".",
"Parent",
"(",
"level",
")"... | // SimpleRegionCovering returns a set of cells at the given level that cover
// the connected region and a starting point on the boundary or inside the
// region. The cells are returned in arbitrary order.
//
// Note that this method is not faster than the regular Covering
// method for most region types, such as Cap o... | [
"SimpleRegionCovering",
"returns",
"a",
"set",
"of",
"cells",
"at",
"the",
"given",
"level",
"that",
"cover",
"the",
"connected",
"region",
"and",
"a",
"starting",
"point",
"on",
"the",
"boundary",
"or",
"inside",
"the",
"region",
".",
"The",
"cells",
"are",... | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/regioncoverer.go#L442-L444 |
150,106 | golang/geo | s2/regioncoverer.go | FloodFillRegionCovering | func FloodFillRegionCovering(region Region, start CellID) []CellID {
var output []CellID
all := map[CellID]bool{
start: true,
}
frontier := []CellID{start}
for len(frontier) > 0 {
id := frontier[len(frontier)-1]
frontier = frontier[:len(frontier)-1]
if !region.IntersectsCell(CellFromCellID(id)) {
contin... | go | func FloodFillRegionCovering(region Region, start CellID) []CellID {
var output []CellID
all := map[CellID]bool{
start: true,
}
frontier := []CellID{start}
for len(frontier) > 0 {
id := frontier[len(frontier)-1]
frontier = frontier[:len(frontier)-1]
if !region.IntersectsCell(CellFromCellID(id)) {
contin... | [
"func",
"FloodFillRegionCovering",
"(",
"region",
"Region",
",",
"start",
"CellID",
")",
"[",
"]",
"CellID",
"{",
"var",
"output",
"[",
"]",
"CellID",
"\n",
"all",
":=",
"map",
"[",
"CellID",
"]",
"bool",
"{",
"start",
":",
"true",
",",
"}",
"\n",
"f... | // FloodFillRegionCovering returns all edge-connected cells at the same level as
// the given CellID that intersect the given region, in arbitrary order. | [
"FloodFillRegionCovering",
"returns",
"all",
"edge",
"-",
"connected",
"cells",
"at",
"the",
"same",
"level",
"as",
"the",
"given",
"CellID",
"that",
"intersect",
"the",
"given",
"region",
"in",
"arbitrary",
"order",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/regioncoverer.go#L448-L470 |
150,107 | golang/geo | s2/pointcompression.go | encodePointsCompressed | func encodePointsCompressed(e *encoder, vertices []xyzFaceSiTi, level int) {
var faces []faceRun
for _, v := range vertices {
faces = appendFace(faces, v.face)
}
encodeFaces(e, faces)
type piQi struct {
pi, qi uint32
}
verticesPiQi := make([]piQi, len(vertices))
for i, v := range vertices {
verticesPiQi[... | go | func encodePointsCompressed(e *encoder, vertices []xyzFaceSiTi, level int) {
var faces []faceRun
for _, v := range vertices {
faces = appendFace(faces, v.face)
}
encodeFaces(e, faces)
type piQi struct {
pi, qi uint32
}
verticesPiQi := make([]piQi, len(vertices))
for i, v := range vertices {
verticesPiQi[... | [
"func",
"encodePointsCompressed",
"(",
"e",
"*",
"encoder",
",",
"vertices",
"[",
"]",
"xyzFaceSiTi",
",",
"level",
"int",
")",
"{",
"var",
"faces",
"[",
"]",
"faceRun",
"\n",
"for",
"_",
",",
"v",
":=",
"range",
"vertices",
"{",
"faces",
"=",
"appendF... | // encodePointsCompressed uses an optimized compressed format to encode the given values. | [
"encodePointsCompressed",
"uses",
"an",
"optimized",
"compressed",
"format",
"to",
"encode",
"the",
"given",
"values",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/pointcompression.go#L50-L90 |
150,108 | golang/geo | s2/pointcompression.go | piQiToST | func piQiToST(pi uint32, level int) float64 {
// We want to recover the position at the center of the cell. If the point
// was snapped to the center of the cell, then math.Modf(s * 2^level) == 0.5.
// Inverting STtoPiQi gives:
// s = (pi + 0.5) / 2^level.
return (float64(pi) + 0.5) / float64(int(1)<<uint(level))
... | go | func piQiToST(pi uint32, level int) float64 {
// We want to recover the position at the center of the cell. If the point
// was snapped to the center of the cell, then math.Modf(s * 2^level) == 0.5.
// Inverting STtoPiQi gives:
// s = (pi + 0.5) / 2^level.
return (float64(pi) + 0.5) / float64(int(1)<<uint(level))
... | [
"func",
"piQiToST",
"(",
"pi",
"uint32",
",",
"level",
"int",
")",
"float64",
"{",
"// We want to recover the position at the center of the cell. If the point",
"// was snapped to the center of the cell, then math.Modf(s * 2^level) == 0.5.",
"// Inverting STtoPiQi gives:",
"// s = (pi + ... | // piQiToST returns the value transformed to ST space. | [
"piQiToST",
"returns",
"the",
"value",
"transformed",
"to",
"ST",
"space",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/pointcompression.go#L309-L315 |
150,109 | golang/geo | s2/cellunion.go | CellUnionFromUnion | func CellUnionFromUnion(cellUnions ...CellUnion) CellUnion {
var cu CellUnion
for _, cellUnion := range cellUnions {
cu = append(cu, cellUnion...)
}
cu.Normalize()
return cu
} | go | func CellUnionFromUnion(cellUnions ...CellUnion) CellUnion {
var cu CellUnion
for _, cellUnion := range cellUnions {
cu = append(cu, cellUnion...)
}
cu.Normalize()
return cu
} | [
"func",
"CellUnionFromUnion",
"(",
"cellUnions",
"...",
"CellUnion",
")",
"CellUnion",
"{",
"var",
"cu",
"CellUnion",
"\n",
"for",
"_",
",",
"cellUnion",
":=",
"range",
"cellUnions",
"{",
"cu",
"=",
"append",
"(",
"cu",
",",
"cellUnion",
"...",
")",
"\n",
... | // CellUnionFromUnion creates a CellUnion from the union of the given CellUnions. | [
"CellUnionFromUnion",
"creates",
"a",
"CellUnion",
"from",
"the",
"union",
"of",
"the",
"given",
"CellUnions",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellunion.go#L51-L58 |
150,110 | golang/geo | s2/cellunion.go | CellUnionFromIntersection | func CellUnionFromIntersection(x, y CellUnion) CellUnion {
var cu CellUnion
// This is a fairly efficient calculation that uses binary search to skip
// over sections of both input vectors. It takes constant time if all the
// cells of x come before or after all the cells of y in CellID order.
var i, j int
for i... | go | func CellUnionFromIntersection(x, y CellUnion) CellUnion {
var cu CellUnion
// This is a fairly efficient calculation that uses binary search to skip
// over sections of both input vectors. It takes constant time if all the
// cells of x come before or after all the cells of y in CellID order.
var i, j int
for i... | [
"func",
"CellUnionFromIntersection",
"(",
"x",
",",
"y",
"CellUnion",
")",
"CellUnion",
"{",
"var",
"cu",
"CellUnion",
"\n\n",
"// This is a fairly efficient calculation that uses binary search to skip",
"// over sections of both input vectors. It takes constant time if all the",
"//... | // CellUnionFromIntersection creates a CellUnion from the intersection of the given CellUnions. | [
"CellUnionFromIntersection",
"creates",
"a",
"CellUnion",
"from",
"the",
"intersection",
"of",
"the",
"given",
"CellUnions",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellunion.go#L61-L110 |
150,111 | golang/geo | s2/cellunion.go | CellUnionFromIntersectionWithCellID | func CellUnionFromIntersectionWithCellID(x CellUnion, id CellID) CellUnion {
var cu CellUnion
if x.ContainsCellID(id) {
cu = append(cu, id)
cu.Normalize()
return cu
}
idmax := id.RangeMax()
for i := x.lowerBound(0, len(x), id.RangeMin()); i < len(x) && x[i] <= idmax; i++ {
cu = append(cu, x[i])
}
cu.No... | go | func CellUnionFromIntersectionWithCellID(x CellUnion, id CellID) CellUnion {
var cu CellUnion
if x.ContainsCellID(id) {
cu = append(cu, id)
cu.Normalize()
return cu
}
idmax := id.RangeMax()
for i := x.lowerBound(0, len(x), id.RangeMin()); i < len(x) && x[i] <= idmax; i++ {
cu = append(cu, x[i])
}
cu.No... | [
"func",
"CellUnionFromIntersectionWithCellID",
"(",
"x",
"CellUnion",
",",
"id",
"CellID",
")",
"CellUnion",
"{",
"var",
"cu",
"CellUnion",
"\n",
"if",
"x",
".",
"ContainsCellID",
"(",
"id",
")",
"{",
"cu",
"=",
"append",
"(",
"cu",
",",
"id",
")",
"\n",... | // CellUnionFromIntersectionWithCellID creates a CellUnion from the intersection
// of a CellUnion with the given CellID. This can be useful for splitting a
// CellUnion into chunks. | [
"CellUnionFromIntersectionWithCellID",
"creates",
"a",
"CellUnion",
"from",
"the",
"intersection",
"of",
"a",
"CellUnion",
"with",
"the",
"given",
"CellID",
".",
"This",
"can",
"be",
"useful",
"for",
"splitting",
"a",
"CellUnion",
"into",
"chunks",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellunion.go#L115-L130 |
150,112 | golang/geo | s2/cellunion.go | IsValid | func (cu *CellUnion) IsValid() bool {
for i, cid := range *cu {
if !cid.IsValid() {
return false
}
if i == 0 {
continue
}
if (*cu)[i-1].RangeMax() >= cid.RangeMin() {
return false
}
}
return true
} | go | func (cu *CellUnion) IsValid() bool {
for i, cid := range *cu {
if !cid.IsValid() {
return false
}
if i == 0 {
continue
}
if (*cu)[i-1].RangeMax() >= cid.RangeMin() {
return false
}
}
return true
} | [
"func",
"(",
"cu",
"*",
"CellUnion",
")",
"IsValid",
"(",
")",
"bool",
"{",
"for",
"i",
",",
"cid",
":=",
"range",
"*",
"cu",
"{",
"if",
"!",
"cid",
".",
"IsValid",
"(",
")",
"{",
"return",
"false",
"\n",
"}",
"\n",
"if",
"i",
"==",
"0",
"{",... | // The C++ constructor methods FromNormalized and FromVerbatim are not necessary
// since they don't call Normalize, and just set the CellIDs directly on the object,
// so straight casting is sufficient in Go to replicate this behavior.
// IsValid reports whether the cell union is valid, meaning that the CellIDs are
//... | [
"The",
"C",
"++",
"constructor",
"methods",
"FromNormalized",
"and",
"FromVerbatim",
"are",
"not",
"necessary",
"since",
"they",
"don",
"t",
"call",
"Normalize",
"and",
"just",
"set",
"the",
"CellIDs",
"directly",
"on",
"the",
"object",
"so",
"straight",
"cast... | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellunion.go#L154-L167 |
150,113 | golang/geo | s2/cellunion.go | IsNormalized | func (cu *CellUnion) IsNormalized() bool {
for i, cid := range *cu {
if !cid.IsValid() {
return false
}
if i == 0 {
continue
}
if (*cu)[i-1].RangeMax() >= cid.RangeMin() {
return false
}
if i < 3 {
continue
}
if areSiblings((*cu)[i-3], (*cu)[i-2], (*cu)[i-1], cid) {
return false
}
}... | go | func (cu *CellUnion) IsNormalized() bool {
for i, cid := range *cu {
if !cid.IsValid() {
return false
}
if i == 0 {
continue
}
if (*cu)[i-1].RangeMax() >= cid.RangeMin() {
return false
}
if i < 3 {
continue
}
if areSiblings((*cu)[i-3], (*cu)[i-2], (*cu)[i-1], cid) {
return false
}
}... | [
"func",
"(",
"cu",
"*",
"CellUnion",
")",
"IsNormalized",
"(",
")",
"bool",
"{",
"for",
"i",
",",
"cid",
":=",
"range",
"*",
"cu",
"{",
"if",
"!",
"cid",
".",
"IsValid",
"(",
")",
"{",
"return",
"false",
"\n",
"}",
"\n",
"if",
"i",
"==",
"0",
... | // IsNormalized reports whether the cell union is normalized, meaning that it is
// satisfies IsValid and that no four cells have a common parent.
// Certain operations such as Contains will return a different
// result if the cell union is not normalized. | [
"IsNormalized",
"reports",
"whether",
"the",
"cell",
"union",
"is",
"normalized",
"meaning",
"that",
"it",
"is",
"satisfies",
"IsValid",
"and",
"that",
"no",
"four",
"cells",
"have",
"a",
"common",
"parent",
".",
"Certain",
"operations",
"such",
"as",
"Contain... | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellunion.go#L173-L192 |
150,114 | golang/geo | s2/cellunion.go | IntersectsCellID | func (cu *CellUnion) IntersectsCellID(id CellID) bool {
// Find index of array item that occurs directly after our probe cell:
i := sort.Search(len(*cu), func(i int) bool { return id < (*cu)[i] })
if i != len(*cu) && (*cu)[i].RangeMin() <= id.RangeMax() {
return true
}
return i != 0 && (*cu)[i-1].RangeMax() >= ... | go | func (cu *CellUnion) IntersectsCellID(id CellID) bool {
// Find index of array item that occurs directly after our probe cell:
i := sort.Search(len(*cu), func(i int) bool { return id < (*cu)[i] })
if i != len(*cu) && (*cu)[i].RangeMin() <= id.RangeMax() {
return true
}
return i != 0 && (*cu)[i-1].RangeMax() >= ... | [
"func",
"(",
"cu",
"*",
"CellUnion",
")",
"IntersectsCellID",
"(",
"id",
"CellID",
")",
"bool",
"{",
"// Find index of array item that occurs directly after our probe cell:",
"i",
":=",
"sort",
".",
"Search",
"(",
"len",
"(",
"*",
"cu",
")",
",",
"func",
"(",
... | // IntersectsCellID reports whether this CellUnion intersects the given cell ID. | [
"IntersectsCellID",
"reports",
"whether",
"this",
"CellUnion",
"intersects",
"the",
"given",
"cell",
"ID",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellunion.go#L240-L248 |
150,115 | golang/geo | s2/cellunion.go | RectBound | func (cu *CellUnion) RectBound() Rect {
bound := EmptyRect()
for _, c := range *cu {
bound = bound.Union(CellFromCellID(c).RectBound())
}
return bound
} | go | func (cu *CellUnion) RectBound() Rect {
bound := EmptyRect()
for _, c := range *cu {
bound = bound.Union(CellFromCellID(c).RectBound())
}
return bound
} | [
"func",
"(",
"cu",
"*",
"CellUnion",
")",
"RectBound",
"(",
")",
"Rect",
"{",
"bound",
":=",
"EmptyRect",
"(",
")",
"\n",
"for",
"_",
",",
"c",
":=",
"range",
"*",
"cu",
"{",
"bound",
"=",
"bound",
".",
"Union",
"(",
"CellFromCellID",
"(",
"c",
"... | // RectBound returns a Rect that bounds this entity. | [
"RectBound",
"returns",
"a",
"Rect",
"that",
"bounds",
"this",
"entity",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/cellunion.go#L298-L304 |
150,116 | 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 |
150,117 | 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 |
150,118 | 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 |
150,119 | 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 |
150,120 | 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 |
150,121 | 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 |
150,122 | 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 |
150,123 | 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 |
150,124 | 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 |
150,125 | 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 |
150,126 | 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 |
150,127 | 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 |
150,128 | 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 |
150,129 | 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 |
150,130 | 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 |
150,131 | 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 |
150,132 | 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 |
150,133 | 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 |
150,134 | 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 |
150,135 | 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 |
150,136 | 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 |
150,137 | 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 |
150,138 | 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 |
150,139 | 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 |
150,140 | 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 |
150,141 | 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 |
150,142 | 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 |
150,143 | 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 |
150,144 | 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 |
150,145 | 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 |
150,146 | 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 |
150,147 | 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 |
150,148 | 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 |
150,149 | 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 |
150,150 | 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 |
150,151 | 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 |
150,152 | 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 |
150,153 | 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 |
150,154 | 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 |
150,155 | 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 |
150,156 | 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 |
150,157 | 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 |
150,158 | 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 |
150,159 | 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 |
150,160 | 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 |
150,161 | 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 |
150,162 | 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 |
150,163 | 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 |
150,164 | 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 |
150,165 | 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 |
150,166 | 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 |
150,167 | 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 |
150,168 | 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 |
150,169 | 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 |
150,170 | 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 |
150,171 | 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 |
150,172 | 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 |
150,173 | 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 |
150,174 | 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 |
150,175 | 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 |
150,176 | 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 |
150,177 | 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 |
150,178 | 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 |
150,179 | 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 |
150,180 | 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 |
150,181 | 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 |
150,182 | 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 |
150,183 | 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 |
150,184 | 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 |
150,185 | 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 |
150,186 | 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 |
150,187 | 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 |
150,188 | 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 |
150,189 | 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 |
150,190 | 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 |
150,191 | 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 |
150,192 | 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 |
150,193 | 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 |
150,194 | 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 |
150,195 | 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 |
150,196 | 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 |
150,197 | 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 |
150,198 | 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 |
150,199 | 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 |
Subsets and Splits
SQL Console for google/code_x_glue_ct_code_to_text
This query implements a thoughtful three-tier curation strategy to build a balanced safety dataset, categorizing code by destructive operations, safe I/O operations, and pure computational negatives with subsampling—revealing important patterns about how destructive intent manifests in Python code for model safety research.
SQL Console for google/code_x_glue_ct_code_to_text
This query performs meaningful classification of Python code samples into safety-relevant tiers based on destructive operations, I/O patterns, and pure computation, which could be valuable for building safety classifiers or curating training data, though the output itself is a filtered/ranked dataset rather than revealing novel statistical insights.