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
sequencelengths 21
1.41k
| docstring
stringlengths 6
2.61k
| docstring_tokens
sequencelengths 3
215
| sha
stringlengths 40
40
| url
stringlengths 85
252
|
---|---|---|---|---|---|---|---|---|---|---|---|
151,600 | twpayne/go-geom | xy/angle.go | Normalize | func Normalize(angle float64) float64 {
for angle > math.Pi {
angle -= piTimes2
}
for angle <= -math.Pi {
angle += piTimes2
}
return angle
} | go | func Normalize(angle float64) float64 {
for angle > math.Pi {
angle -= piTimes2
}
for angle <= -math.Pi {
angle += piTimes2
}
return angle
} | [
"func",
"Normalize",
"(",
"angle",
"float64",
")",
"float64",
"{",
"for",
"angle",
">",
"math",
".",
"Pi",
"{",
"angle",
"-=",
"piTimes2",
"\n",
"}",
"\n",
"for",
"angle",
"<=",
"-",
"math",
".",
"Pi",
"{",
"angle",
"+=",
"piTimes2",
"\n",
"}",
"\n",
"return",
"angle",
"\n",
"}"
] | // Normalize computes the normalized value of an angle, which is the
// equivalent angle in the range ( -Pi, Pi ]. | [
"Normalize",
"computes",
"the",
"normalized",
"value",
"of",
"an",
"angle",
"which",
"is",
"the",
"equivalent",
"angle",
"in",
"the",
"range",
"(",
"-",
"Pi",
"Pi",
"]",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/xy/angle.go#L108-L116 |
151,601 | twpayne/go-geom | geom.go | MIndex | func (l Layout) MIndex() int {
switch l {
case NoLayout, XY, XYZ:
return -1
case XYM:
return 2
case XYZM:
return 3
default:
return 3
}
} | go | func (l Layout) MIndex() int {
switch l {
case NoLayout, XY, XYZ:
return -1
case XYM:
return 2
case XYZM:
return 3
default:
return 3
}
} | [
"func",
"(",
"l",
"Layout",
")",
"MIndex",
"(",
")",
"int",
"{",
"switch",
"l",
"{",
"case",
"NoLayout",
",",
"XY",
",",
"XYZ",
":",
"return",
"-",
"1",
"\n",
"case",
"XYM",
":",
"return",
"2",
"\n",
"case",
"XYZM",
":",
"return",
"3",
"\n",
"default",
":",
"return",
"3",
"\n",
"}",
"\n",
"}"
] | // MIndex returns the index of the M dimension, or -1 if the l does not have an
// M dimension. | [
"MIndex",
"returns",
"the",
"index",
"of",
"the",
"M",
"dimension",
"or",
"-",
"1",
"if",
"the",
"l",
"does",
"not",
"have",
"an",
"M",
"dimension",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/geom.go#L135-L146 |
151,602 | twpayne/go-geom | geom.go | Stride | func (l Layout) Stride() int {
switch l {
case NoLayout:
return 0
case XY:
return 2
case XYZ:
return 3
case XYM:
return 3
case XYZM:
return 4
default:
return int(l)
}
} | go | func (l Layout) Stride() int {
switch l {
case NoLayout:
return 0
case XY:
return 2
case XYZ:
return 3
case XYM:
return 3
case XYZM:
return 4
default:
return int(l)
}
} | [
"func",
"(",
"l",
"Layout",
")",
"Stride",
"(",
")",
"int",
"{",
"switch",
"l",
"{",
"case",
"NoLayout",
":",
"return",
"0",
"\n",
"case",
"XY",
":",
"return",
"2",
"\n",
"case",
"XYZ",
":",
"return",
"3",
"\n",
"case",
"XYM",
":",
"return",
"3",
"\n",
"case",
"XYZM",
":",
"return",
"4",
"\n",
"default",
":",
"return",
"int",
"(",
"l",
")",
"\n",
"}",
"\n",
"}"
] | // Stride returns l's number of dimensions. | [
"Stride",
"returns",
"l",
"s",
"number",
"of",
"dimensions",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/geom.go#L149-L164 |
151,603 | twpayne/go-geom | geom.go | String | func (l Layout) String() string {
switch l {
case NoLayout:
return "NoLayout"
case XY:
return "XY"
case XYZ:
return "XYZ"
case XYM:
return "XYM"
case XYZM:
return "XYZM"
default:
return fmt.Sprintf("Layout(%d)", int(l))
}
} | go | func (l Layout) String() string {
switch l {
case NoLayout:
return "NoLayout"
case XY:
return "XY"
case XYZ:
return "XYZ"
case XYM:
return "XYM"
case XYZM:
return "XYZM"
default:
return fmt.Sprintf("Layout(%d)", int(l))
}
} | [
"func",
"(",
"l",
"Layout",
")",
"String",
"(",
")",
"string",
"{",
"switch",
"l",
"{",
"case",
"NoLayout",
":",
"return",
"\"",
"\"",
"\n",
"case",
"XY",
":",
"return",
"\"",
"\"",
"\n",
"case",
"XYZ",
":",
"return",
"\"",
"\"",
"\n",
"case",
"XYM",
":",
"return",
"\"",
"\"",
"\n",
"case",
"XYZM",
":",
"return",
"\"",
"\"",
"\n",
"default",
":",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"int",
"(",
"l",
")",
")",
"\n",
"}",
"\n",
"}"
] | // String returns a human-readable string representing l. | [
"String",
"returns",
"a",
"human",
"-",
"readable",
"string",
"representing",
"l",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/geom.go#L167-L182 |
151,604 | twpayne/go-geom | geom.go | Must | func Must(g T, err error) T {
if err != nil {
panic(err)
}
return g
} | go | func Must(g T, err error) T {
if err != nil {
panic(err)
}
return g
} | [
"func",
"Must",
"(",
"g",
"T",
",",
"err",
"error",
")",
"T",
"{",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}",
"\n",
"return",
"g",
"\n",
"}"
] | // Must panics if err is not nil, otherwise it returns g. | [
"Must",
"panics",
"if",
"err",
"is",
"not",
"nil",
"otherwise",
"it",
"returns",
"g",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/geom.go#L196-L201 |
151,605 | twpayne/go-geom | xy/lineintersection/line_on_line_intersection.go | NewResult | func NewResult(intersectionType Type, intersection []geom.Coord) Result {
return Result{
intersectionType: intersectionType,
intersection: intersection,
}
} | go | func NewResult(intersectionType Type, intersection []geom.Coord) Result {
return Result{
intersectionType: intersectionType,
intersection: intersection,
}
} | [
"func",
"NewResult",
"(",
"intersectionType",
"Type",
",",
"intersection",
"[",
"]",
"geom",
".",
"Coord",
")",
"Result",
"{",
"return",
"Result",
"{",
"intersectionType",
":",
"intersectionType",
",",
"intersection",
":",
"intersection",
",",
"}",
"\n",
"}"
] | // NewResult create a new result object | [
"NewResult",
"create",
"a",
"new",
"result",
"object"
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/xy/lineintersection/line_on_line_intersection.go#L32-L37 |
151,606 | twpayne/go-geom | xy/internal/numbers.go | IsSameSignAndNonZero | func IsSameSignAndNonZero(a, b float64) bool {
if a == 0 || b == 0 {
return false
}
return (a < 0 && b < 0) || (a > 0 && b > 0)
} | go | func IsSameSignAndNonZero(a, b float64) bool {
if a == 0 || b == 0 {
return false
}
return (a < 0 && b < 0) || (a > 0 && b > 0)
} | [
"func",
"IsSameSignAndNonZero",
"(",
"a",
",",
"b",
"float64",
")",
"bool",
"{",
"if",
"a",
"==",
"0",
"||",
"b",
"==",
"0",
"{",
"return",
"false",
"\n",
"}",
"\n",
"return",
"(",
"a",
"<",
"0",
"&&",
"b",
"<",
"0",
")",
"||",
"(",
"a",
">",
"0",
"&&",
"b",
">",
"0",
")",
"\n",
"}"
] | // IsSameSignAndNonZero checks if both a and b are positive or negative. | [
"IsSameSignAndNonZero",
"checks",
"if",
"both",
"a",
"and",
"b",
"are",
"positive",
"or",
"negative",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/xy/internal/numbers.go#L4-L9 |
151,607 | twpayne/go-geom | xy/internal/numbers.go | Min | func Min(v1, v2, v3, v4 float64) float64 {
min := v1
if v2 < min {
min = v2
}
if v3 < min {
min = v3
}
if v4 < min {
min = v4
}
return min
} | go | func Min(v1, v2, v3, v4 float64) float64 {
min := v1
if v2 < min {
min = v2
}
if v3 < min {
min = v3
}
if v4 < min {
min = v4
}
return min
} | [
"func",
"Min",
"(",
"v1",
",",
"v2",
",",
"v3",
",",
"v4",
"float64",
")",
"float64",
"{",
"min",
":=",
"v1",
"\n",
"if",
"v2",
"<",
"min",
"{",
"min",
"=",
"v2",
"\n",
"}",
"\n",
"if",
"v3",
"<",
"min",
"{",
"min",
"=",
"v3",
"\n",
"}",
"\n",
"if",
"v4",
"<",
"min",
"{",
"min",
"=",
"v4",
"\n",
"}",
"\n",
"return",
"min",
"\n",
"}"
] | // Min finds the minimum of the 4 parameters | [
"Min",
"finds",
"the",
"minimum",
"of",
"the",
"4",
"parameters"
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/xy/internal/numbers.go#L12-L24 |
151,608 | twpayne/go-geom | encoding/wkbhex/wkbhex.go | Encode | func Encode(g geom.T, byteOrder binary.ByteOrder) (string, error) {
wkb, err := wkb.Marshal(g, byteOrder)
if err != nil {
return "", err
}
return hex.EncodeToString(wkb), nil
} | go | func Encode(g geom.T, byteOrder binary.ByteOrder) (string, error) {
wkb, err := wkb.Marshal(g, byteOrder)
if err != nil {
return "", err
}
return hex.EncodeToString(wkb), nil
} | [
"func",
"Encode",
"(",
"g",
"geom",
".",
"T",
",",
"byteOrder",
"binary",
".",
"ByteOrder",
")",
"(",
"string",
",",
"error",
")",
"{",
"wkb",
",",
"err",
":=",
"wkb",
".",
"Marshal",
"(",
"g",
",",
"byteOrder",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n",
"return",
"hex",
".",
"EncodeToString",
"(",
"wkb",
")",
",",
"nil",
"\n",
"}"
] | // Encode encodes an arbitrary geometry to a string. | [
"Encode",
"encodes",
"an",
"arbitrary",
"geometry",
"to",
"a",
"string",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/encoding/wkbhex/wkbhex.go#L21-L27 |
151,609 | twpayne/go-geom | encoding/wkbhex/wkbhex.go | Decode | func Decode(s string) (geom.T, error) {
data, err := hex.DecodeString(s)
if err != nil {
return nil, err
}
return wkb.Unmarshal(data)
} | go | func Decode(s string) (geom.T, error) {
data, err := hex.DecodeString(s)
if err != nil {
return nil, err
}
return wkb.Unmarshal(data)
} | [
"func",
"Decode",
"(",
"s",
"string",
")",
"(",
"geom",
".",
"T",
",",
"error",
")",
"{",
"data",
",",
"err",
":=",
"hex",
".",
"DecodeString",
"(",
"s",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"wkb",
".",
"Unmarshal",
"(",
"data",
")",
"\n",
"}"
] | // Decode decodes an arbitrary geometry from a string. | [
"Decode",
"decodes",
"an",
"arbitrary",
"geometry",
"from",
"a",
"string",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/encoding/wkbhex/wkbhex.go#L30-L36 |
151,610 | twpayne/go-geom | polygon.go | NewPolygonFlat | func NewPolygonFlat(layout Layout, flatCoords []float64, ends []int) *Polygon {
g := new(Polygon)
g.layout = layout
g.stride = layout.Stride()
g.flatCoords = flatCoords
g.ends = ends
return g
} | go | func NewPolygonFlat(layout Layout, flatCoords []float64, ends []int) *Polygon {
g := new(Polygon)
g.layout = layout
g.stride = layout.Stride()
g.flatCoords = flatCoords
g.ends = ends
return g
} | [
"func",
"NewPolygonFlat",
"(",
"layout",
"Layout",
",",
"flatCoords",
"[",
"]",
"float64",
",",
"ends",
"[",
"]",
"int",
")",
"*",
"Polygon",
"{",
"g",
":=",
"new",
"(",
"Polygon",
")",
"\n",
"g",
".",
"layout",
"=",
"layout",
"\n",
"g",
".",
"stride",
"=",
"layout",
".",
"Stride",
"(",
")",
"\n",
"g",
".",
"flatCoords",
"=",
"flatCoords",
"\n",
"g",
".",
"ends",
"=",
"ends",
"\n",
"return",
"g",
"\n",
"}"
] | // NewPolygonFlat returns a new Polygon with the given flat coordinates. | [
"NewPolygonFlat",
"returns",
"a",
"new",
"Polygon",
"with",
"the",
"given",
"flat",
"coordinates",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/polygon.go#L16-L23 |
151,611 | twpayne/go-geom | polygon.go | Area | func (g *Polygon) Area() float64 {
return doubleArea2(g.flatCoords, 0, g.ends, g.stride) / 2
} | go | func (g *Polygon) Area() float64 {
return doubleArea2(g.flatCoords, 0, g.ends, g.stride) / 2
} | [
"func",
"(",
"g",
"*",
"Polygon",
")",
"Area",
"(",
")",
"float64",
"{",
"return",
"doubleArea2",
"(",
"g",
".",
"flatCoords",
",",
"0",
",",
"g",
".",
"ends",
",",
"g",
".",
"stride",
")",
"/",
"2",
"\n",
"}"
] | // Area returns the area. | [
"Area",
"returns",
"the",
"area",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/polygon.go#L26-L28 |
151,612 | twpayne/go-geom | polygon.go | Length | func (g *Polygon) Length() float64 {
return length2(g.flatCoords, 0, g.ends, g.stride)
} | go | func (g *Polygon) Length() float64 {
return length2(g.flatCoords, 0, g.ends, g.stride)
} | [
"func",
"(",
"g",
"*",
"Polygon",
")",
"Length",
"(",
")",
"float64",
"{",
"return",
"length2",
"(",
"g",
".",
"flatCoords",
",",
"0",
",",
"g",
".",
"ends",
",",
"g",
".",
"stride",
")",
"\n",
"}"
] | // Length returns the perimter. | [
"Length",
"returns",
"the",
"perimter",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/polygon.go#L41-L43 |
151,613 | twpayne/go-geom | polygon.go | LinearRing | func (g *Polygon) LinearRing(i int) *LinearRing {
offset := 0
if i > 0 {
offset = g.ends[i-1]
}
return NewLinearRingFlat(g.layout, g.flatCoords[offset:g.ends[i]])
} | go | func (g *Polygon) LinearRing(i int) *LinearRing {
offset := 0
if i > 0 {
offset = g.ends[i-1]
}
return NewLinearRingFlat(g.layout, g.flatCoords[offset:g.ends[i]])
} | [
"func",
"(",
"g",
"*",
"Polygon",
")",
"LinearRing",
"(",
"i",
"int",
")",
"*",
"LinearRing",
"{",
"offset",
":=",
"0",
"\n",
"if",
"i",
">",
"0",
"{",
"offset",
"=",
"g",
".",
"ends",
"[",
"i",
"-",
"1",
"]",
"\n",
"}",
"\n",
"return",
"NewLinearRingFlat",
"(",
"g",
".",
"layout",
",",
"g",
".",
"flatCoords",
"[",
"offset",
":",
"g",
".",
"ends",
"[",
"i",
"]",
"]",
")",
"\n",
"}"
] | // LinearRing returns the ith LinearRing. | [
"LinearRing",
"returns",
"the",
"ith",
"LinearRing",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/polygon.go#L46-L52 |
151,614 | twpayne/go-geom | polygon.go | Push | func (g *Polygon) Push(lr *LinearRing) error {
if lr.layout != g.layout {
return ErrLayoutMismatch{Got: lr.layout, Want: g.layout}
}
g.flatCoords = append(g.flatCoords, lr.flatCoords...)
g.ends = append(g.ends, len(g.flatCoords))
return nil
} | go | func (g *Polygon) Push(lr *LinearRing) error {
if lr.layout != g.layout {
return ErrLayoutMismatch{Got: lr.layout, Want: g.layout}
}
g.flatCoords = append(g.flatCoords, lr.flatCoords...)
g.ends = append(g.ends, len(g.flatCoords))
return nil
} | [
"func",
"(",
"g",
"*",
"Polygon",
")",
"Push",
"(",
"lr",
"*",
"LinearRing",
")",
"error",
"{",
"if",
"lr",
".",
"layout",
"!=",
"g",
".",
"layout",
"{",
"return",
"ErrLayoutMismatch",
"{",
"Got",
":",
"lr",
".",
"layout",
",",
"Want",
":",
"g",
".",
"layout",
"}",
"\n",
"}",
"\n",
"g",
".",
"flatCoords",
"=",
"append",
"(",
"g",
".",
"flatCoords",
",",
"lr",
".",
"flatCoords",
"...",
")",
"\n",
"g",
".",
"ends",
"=",
"append",
"(",
"g",
".",
"ends",
",",
"len",
"(",
"g",
".",
"flatCoords",
")",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // Push appends a LinearRing. | [
"Push",
"appends",
"a",
"LinearRing",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/polygon.go#L66-L73 |
151,615 | twpayne/go-geom | encoding/wkt/wkt.go | Marshal | func Marshal(g geom.T) (string, error) {
b := &bytes.Buffer{}
if err := write(b, g); err != nil {
return "", err
}
return b.String(), nil
} | go | func Marshal(g geom.T) (string, error) {
b := &bytes.Buffer{}
if err := write(b, g); err != nil {
return "", err
}
return b.String(), nil
} | [
"func",
"Marshal",
"(",
"g",
"geom",
".",
"T",
")",
"(",
"string",
",",
"error",
")",
"{",
"b",
":=",
"&",
"bytes",
".",
"Buffer",
"{",
"}",
"\n",
"if",
"err",
":=",
"write",
"(",
"b",
",",
"g",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n",
"return",
"b",
".",
"String",
"(",
")",
",",
"nil",
"\n",
"}"
] | // Marshal marshals an arbitrary geometry. | [
"Marshal",
"marshals",
"an",
"arbitrary",
"geometry",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/encoding/wkt/wkt.go#L11-L17 |
151,616 | twpayne/go-geom | encoding/igc/decode.go | parseH | func (p *parser) parseH(line string) error {
m := hRegexp.FindStringSubmatch(line)
if m == nil {
return fmt.Errorf("invalid H record")
}
header := Header{
Source: m[1],
Key: m[2],
KeyExtra: strings.TrimSuffix(m[3], ":"),
Value: m[4],
}
p.headers = append(p.headers, header)
if header.Key == "DTE" {
if len(header.Value) < 6 {
return fmt.Errorf("H DTE value too short: %d, want >=6", len(header.Value))
}
day, err := parseDecInRange(header.Value, 0, 2, 1, 31+1)
if err != nil {
return err
}
month, err := parseDecInRange(header.Value, 2, 4, 1, 12+1)
if err != nil {
return err
}
year, err := parseDec(header.Value, 4, 6)
if err != nil {
return err
}
p.day = day
p.month = month
if year < 70 {
p.year = 2000 + year
} else {
p.year = 1970 + year
}
}
return nil
} | go | func (p *parser) parseH(line string) error {
m := hRegexp.FindStringSubmatch(line)
if m == nil {
return fmt.Errorf("invalid H record")
}
header := Header{
Source: m[1],
Key: m[2],
KeyExtra: strings.TrimSuffix(m[3], ":"),
Value: m[4],
}
p.headers = append(p.headers, header)
if header.Key == "DTE" {
if len(header.Value) < 6 {
return fmt.Errorf("H DTE value too short: %d, want >=6", len(header.Value))
}
day, err := parseDecInRange(header.Value, 0, 2, 1, 31+1)
if err != nil {
return err
}
month, err := parseDecInRange(header.Value, 2, 4, 1, 12+1)
if err != nil {
return err
}
year, err := parseDec(header.Value, 4, 6)
if err != nil {
return err
}
p.day = day
p.month = month
if year < 70 {
p.year = 2000 + year
} else {
p.year = 1970 + year
}
}
return nil
} | [
"func",
"(",
"p",
"*",
"parser",
")",
"parseH",
"(",
"line",
"string",
")",
"error",
"{",
"m",
":=",
"hRegexp",
".",
"FindStringSubmatch",
"(",
"line",
")",
"\n",
"if",
"m",
"==",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"header",
":=",
"Header",
"{",
"Source",
":",
"m",
"[",
"1",
"]",
",",
"Key",
":",
"m",
"[",
"2",
"]",
",",
"KeyExtra",
":",
"strings",
".",
"TrimSuffix",
"(",
"m",
"[",
"3",
"]",
",",
"\"",
"\"",
")",
",",
"Value",
":",
"m",
"[",
"4",
"]",
",",
"}",
"\n",
"p",
".",
"headers",
"=",
"append",
"(",
"p",
".",
"headers",
",",
"header",
")",
"\n",
"if",
"header",
".",
"Key",
"==",
"\"",
"\"",
"{",
"if",
"len",
"(",
"header",
".",
"Value",
")",
"<",
"6",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"len",
"(",
"header",
".",
"Value",
")",
")",
"\n",
"}",
"\n",
"day",
",",
"err",
":=",
"parseDecInRange",
"(",
"header",
".",
"Value",
",",
"0",
",",
"2",
",",
"1",
",",
"31",
"+",
"1",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"month",
",",
"err",
":=",
"parseDecInRange",
"(",
"header",
".",
"Value",
",",
"2",
",",
"4",
",",
"1",
",",
"12",
"+",
"1",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"year",
",",
"err",
":=",
"parseDec",
"(",
"header",
".",
"Value",
",",
"4",
",",
"6",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"p",
".",
"day",
"=",
"day",
"\n",
"p",
".",
"month",
"=",
"month",
"\n",
"if",
"year",
"<",
"70",
"{",
"p",
".",
"year",
"=",
"2000",
"+",
"year",
"\n",
"}",
"else",
"{",
"p",
".",
"year",
"=",
"1970",
"+",
"year",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // parseB parses an H record from line and updates the state of p. | [
"parseB",
"parses",
"an",
"H",
"record",
"from",
"line",
"and",
"updates",
"the",
"state",
"of",
"p",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/encoding/igc/decode.go#L203-L240 |
151,617 | twpayne/go-geom | encoding/igc/decode.go | parseI | func (p *parser) parseI(line string) error {
var err error
var n int
if len(line) < 3 {
return fmt.Errorf("I record too short: %d, want >=3", len(line))
}
if n, err = parseDec(line, 1, 3); err != nil {
return err
}
if len(line) < 7*n+3 {
return fmt.Errorf("invalid I record length: %d, want %d", len(line), 7*n+3)
}
for i := 0; i < n; i++ {
var start, stop int
if start, err = parseDec(line, 7*i+3, 7*i+5); err != nil {
return err
}
if stop, err = parseDec(line, 7*i+5, 7*i+7); err != nil {
return err
}
if start != p.bRecordLen+1 || stop < start {
return fmt.Errorf("I record index out-of-range: %d-%d", start, stop-1)
}
p.bRecordLen = stop
switch line[7*i+7 : 7*i+10] {
case "LAD":
p.ladStart, p.ladStop = start-1, stop
case "LOD":
p.lodStart, p.lodStop = start-1, stop
case "TDS":
p.tdsStart, p.tdsStop = start-1, stop
}
}
return nil
} | go | func (p *parser) parseI(line string) error {
var err error
var n int
if len(line) < 3 {
return fmt.Errorf("I record too short: %d, want >=3", len(line))
}
if n, err = parseDec(line, 1, 3); err != nil {
return err
}
if len(line) < 7*n+3 {
return fmt.Errorf("invalid I record length: %d, want %d", len(line), 7*n+3)
}
for i := 0; i < n; i++ {
var start, stop int
if start, err = parseDec(line, 7*i+3, 7*i+5); err != nil {
return err
}
if stop, err = parseDec(line, 7*i+5, 7*i+7); err != nil {
return err
}
if start != p.bRecordLen+1 || stop < start {
return fmt.Errorf("I record index out-of-range: %d-%d", start, stop-1)
}
p.bRecordLen = stop
switch line[7*i+7 : 7*i+10] {
case "LAD":
p.ladStart, p.ladStop = start-1, stop
case "LOD":
p.lodStart, p.lodStop = start-1, stop
case "TDS":
p.tdsStart, p.tdsStop = start-1, stop
}
}
return nil
} | [
"func",
"(",
"p",
"*",
"parser",
")",
"parseI",
"(",
"line",
"string",
")",
"error",
"{",
"var",
"err",
"error",
"\n",
"var",
"n",
"int",
"\n",
"if",
"len",
"(",
"line",
")",
"<",
"3",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"len",
"(",
"line",
")",
")",
"\n",
"}",
"\n",
"if",
"n",
",",
"err",
"=",
"parseDec",
"(",
"line",
",",
"1",
",",
"3",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"len",
"(",
"line",
")",
"<",
"7",
"*",
"n",
"+",
"3",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"len",
"(",
"line",
")",
",",
"7",
"*",
"n",
"+",
"3",
")",
"\n",
"}",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"n",
";",
"i",
"++",
"{",
"var",
"start",
",",
"stop",
"int",
"\n",
"if",
"start",
",",
"err",
"=",
"parseDec",
"(",
"line",
",",
"7",
"*",
"i",
"+",
"3",
",",
"7",
"*",
"i",
"+",
"5",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"stop",
",",
"err",
"=",
"parseDec",
"(",
"line",
",",
"7",
"*",
"i",
"+",
"5",
",",
"7",
"*",
"i",
"+",
"7",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"start",
"!=",
"p",
".",
"bRecordLen",
"+",
"1",
"||",
"stop",
"<",
"start",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"start",
",",
"stop",
"-",
"1",
")",
"\n",
"}",
"\n",
"p",
".",
"bRecordLen",
"=",
"stop",
"\n",
"switch",
"line",
"[",
"7",
"*",
"i",
"+",
"7",
":",
"7",
"*",
"i",
"+",
"10",
"]",
"{",
"case",
"\"",
"\"",
":",
"p",
".",
"ladStart",
",",
"p",
".",
"ladStop",
"=",
"start",
"-",
"1",
",",
"stop",
"\n",
"case",
"\"",
"\"",
":",
"p",
".",
"lodStart",
",",
"p",
".",
"lodStop",
"=",
"start",
"-",
"1",
",",
"stop",
"\n",
"case",
"\"",
"\"",
":",
"p",
".",
"tdsStart",
",",
"p",
".",
"tdsStop",
"=",
"start",
"-",
"1",
",",
"stop",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // parseB parses an I record from line and updates the state of p. | [
"parseB",
"parses",
"an",
"I",
"record",
"from",
"line",
"and",
"updates",
"the",
"state",
"of",
"p",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/encoding/igc/decode.go#L243-L277 |
151,618 | twpayne/go-geom | encoding/igc/decode.go | parseLine | func (p *parser) parseLine(line string) error {
switch line[0] {
case 'B':
return p.parseB(line)
case 'H':
return p.parseH(line)
case 'I':
return p.parseI(line)
default:
return nil
}
} | go | func (p *parser) parseLine(line string) error {
switch line[0] {
case 'B':
return p.parseB(line)
case 'H':
return p.parseH(line)
case 'I':
return p.parseI(line)
default:
return nil
}
} | [
"func",
"(",
"p",
"*",
"parser",
")",
"parseLine",
"(",
"line",
"string",
")",
"error",
"{",
"switch",
"line",
"[",
"0",
"]",
"{",
"case",
"'B'",
":",
"return",
"p",
".",
"parseB",
"(",
"line",
")",
"\n",
"case",
"'H'",
":",
"return",
"p",
".",
"parseH",
"(",
"line",
")",
"\n",
"case",
"'I'",
":",
"return",
"p",
".",
"parseI",
"(",
"line",
")",
"\n",
"default",
":",
"return",
"nil",
"\n",
"}",
"\n",
"}"
] | // parseLine parses a single record from line and updates the state of p. | [
"parseLine",
"parses",
"a",
"single",
"record",
"from",
"line",
"and",
"updates",
"the",
"state",
"of",
"p",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/encoding/igc/decode.go#L280-L291 |
151,619 | twpayne/go-geom | encoding/igc/decode.go | doParse | func doParse(r io.Reader) (*parser, Errors) {
var errors Errors
p := newParser()
s := bufio.NewScanner(r)
foundA := false
leadingNoise := false
for lineno := 1; s.Scan(); lineno++ {
line := strings.TrimSuffix(s.Text(), "\r")
switch {
case len(line) == 0:
case foundA:
if err := p.parseLine(line); err != nil {
errors = append(errors, fmt.Errorf("line %d: %q: %v", lineno, line, err))
}
default:
if c := line[0]; c == 'A' {
foundA = true
} else if 'A' <= c && c <= 'Z' {
// All records that start with an uppercase character must be valid.
leadingNoise = true
continue
} else if i := strings.IndexRune(line, 'A'); i != -1 {
// Strip any leading noise.
// Leading Unicode byte order marks and XOFF characters are silently ignored.
// The noise must include at least one unprintable character.
for j, c := range line[:i] {
if !(c == ' ' || ('A' <= c && c <= 'Z')) {
foundA = true
leadingNoise = j != 0 || (c != '\x13' && c != '\ufeff')
break
}
}
}
}
}
if !foundA {
errors = append(Errors{errMissingARecord}, errors...)
} else if leadingNoise {
errors = append(Errors{errInvalidCharactersBeforeARecord}, errors...)
}
return p, errors
} | go | func doParse(r io.Reader) (*parser, Errors) {
var errors Errors
p := newParser()
s := bufio.NewScanner(r)
foundA := false
leadingNoise := false
for lineno := 1; s.Scan(); lineno++ {
line := strings.TrimSuffix(s.Text(), "\r")
switch {
case len(line) == 0:
case foundA:
if err := p.parseLine(line); err != nil {
errors = append(errors, fmt.Errorf("line %d: %q: %v", lineno, line, err))
}
default:
if c := line[0]; c == 'A' {
foundA = true
} else if 'A' <= c && c <= 'Z' {
// All records that start with an uppercase character must be valid.
leadingNoise = true
continue
} else if i := strings.IndexRune(line, 'A'); i != -1 {
// Strip any leading noise.
// Leading Unicode byte order marks and XOFF characters are silently ignored.
// The noise must include at least one unprintable character.
for j, c := range line[:i] {
if !(c == ' ' || ('A' <= c && c <= 'Z')) {
foundA = true
leadingNoise = j != 0 || (c != '\x13' && c != '\ufeff')
break
}
}
}
}
}
if !foundA {
errors = append(Errors{errMissingARecord}, errors...)
} else if leadingNoise {
errors = append(Errors{errInvalidCharactersBeforeARecord}, errors...)
}
return p, errors
} | [
"func",
"doParse",
"(",
"r",
"io",
".",
"Reader",
")",
"(",
"*",
"parser",
",",
"Errors",
")",
"{",
"var",
"errors",
"Errors",
"\n",
"p",
":=",
"newParser",
"(",
")",
"\n",
"s",
":=",
"bufio",
".",
"NewScanner",
"(",
"r",
")",
"\n",
"foundA",
":=",
"false",
"\n",
"leadingNoise",
":=",
"false",
"\n",
"for",
"lineno",
":=",
"1",
";",
"s",
".",
"Scan",
"(",
")",
";",
"lineno",
"++",
"{",
"line",
":=",
"strings",
".",
"TrimSuffix",
"(",
"s",
".",
"Text",
"(",
")",
",",
"\"",
"\\r",
"\"",
")",
"\n",
"switch",
"{",
"case",
"len",
"(",
"line",
")",
"==",
"0",
":",
"case",
"foundA",
":",
"if",
"err",
":=",
"p",
".",
"parseLine",
"(",
"line",
")",
";",
"err",
"!=",
"nil",
"{",
"errors",
"=",
"append",
"(",
"errors",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"lineno",
",",
"line",
",",
"err",
")",
")",
"\n",
"}",
"\n",
"default",
":",
"if",
"c",
":=",
"line",
"[",
"0",
"]",
";",
"c",
"==",
"'A'",
"{",
"foundA",
"=",
"true",
"\n",
"}",
"else",
"if",
"'A'",
"<=",
"c",
"&&",
"c",
"<=",
"'Z'",
"{",
"// All records that start with an uppercase character must be valid.",
"leadingNoise",
"=",
"true",
"\n",
"continue",
"\n",
"}",
"else",
"if",
"i",
":=",
"strings",
".",
"IndexRune",
"(",
"line",
",",
"'A'",
")",
";",
"i",
"!=",
"-",
"1",
"{",
"// Strip any leading noise.",
"// Leading Unicode byte order marks and XOFF characters are silently ignored.",
"// The noise must include at least one unprintable character.",
"for",
"j",
",",
"c",
":=",
"range",
"line",
"[",
":",
"i",
"]",
"{",
"if",
"!",
"(",
"c",
"==",
"' '",
"||",
"(",
"'A'",
"<=",
"c",
"&&",
"c",
"<=",
"'Z'",
")",
")",
"{",
"foundA",
"=",
"true",
"\n",
"leadingNoise",
"=",
"j",
"!=",
"0",
"||",
"(",
"c",
"!=",
"'\\x13'",
"&&",
"c",
"!=",
"'\\ufeff'",
")",
"\n",
"break",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"!",
"foundA",
"{",
"errors",
"=",
"append",
"(",
"Errors",
"{",
"errMissingARecord",
"}",
",",
"errors",
"...",
")",
"\n",
"}",
"else",
"if",
"leadingNoise",
"{",
"errors",
"=",
"append",
"(",
"Errors",
"{",
"errInvalidCharactersBeforeARecord",
"}",
",",
"errors",
"...",
")",
"\n",
"}",
"\n",
"return",
"p",
",",
"errors",
"\n",
"}"
] | // doParse reads r, parsers all the records it finds, updating the state of p. | [
"doParse",
"reads",
"r",
"parsers",
"all",
"the",
"records",
"it",
"finds",
"updating",
"the",
"state",
"of",
"p",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/encoding/igc/decode.go#L294-L335 |
151,620 | twpayne/go-geom | encoding/igc/decode.go | Read | func Read(r io.Reader) (*T, error) {
p, errors := doParse(r)
var err error = errors
if len(errors) == 0 {
err = nil
}
return &T{
Headers: p.headers,
LineString: geom.NewLineStringFlat(geom.Layout(5), p.coords),
}, err
} | go | func Read(r io.Reader) (*T, error) {
p, errors := doParse(r)
var err error = errors
if len(errors) == 0 {
err = nil
}
return &T{
Headers: p.headers,
LineString: geom.NewLineStringFlat(geom.Layout(5), p.coords),
}, err
} | [
"func",
"Read",
"(",
"r",
"io",
".",
"Reader",
")",
"(",
"*",
"T",
",",
"error",
")",
"{",
"p",
",",
"errors",
":=",
"doParse",
"(",
"r",
")",
"\n",
"var",
"err",
"error",
"=",
"errors",
"\n",
"if",
"len",
"(",
"errors",
")",
"==",
"0",
"{",
"err",
"=",
"nil",
"\n",
"}",
"\n",
"return",
"&",
"T",
"{",
"Headers",
":",
"p",
".",
"headers",
",",
"LineString",
":",
"geom",
".",
"NewLineStringFlat",
"(",
"geom",
".",
"Layout",
"(",
"5",
")",
",",
"p",
".",
"coords",
")",
",",
"}",
",",
"err",
"\n",
"}"
] | // Read reads a igc.T from r, which should contain IGC records.
//
// IGC files in the wild are often corrupt, the IGC specification has been
// incomplete, and has evolved over time. The parser is consequently very
// tolerant of what it accepts and ignores several common errors. Consequently,
// the returned T might still contain headers and coordinates, even if the
// returned error is non-nil. | [
"Read",
"reads",
"a",
"igc",
".",
"T",
"from",
"r",
"which",
"should",
"contain",
"IGC",
"records",
".",
"IGC",
"files",
"in",
"the",
"wild",
"are",
"often",
"corrupt",
"the",
"IGC",
"specification",
"has",
"been",
"incomplete",
"and",
"has",
"evolved",
"over",
"time",
".",
"The",
"parser",
"is",
"consequently",
"very",
"tolerant",
"of",
"what",
"it",
"accepts",
"and",
"ignores",
"several",
"common",
"errors",
".",
"Consequently",
"the",
"returned",
"T",
"might",
"still",
"contain",
"headers",
"and",
"coordinates",
"even",
"if",
"the",
"returned",
"error",
"is",
"non",
"-",
"nil",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/encoding/igc/decode.go#L344-L354 |
151,621 | twpayne/go-geom | examples/postgis/main.go | readGeoJSON | func readGeoJSON(db *sql.DB, r io.Reader) error {
var waypoint Waypoint
if err := json.NewDecoder(r).Decode(&waypoint); err != nil {
return err
}
var geometry geom.T
if err := geojson.Unmarshal(waypoint.Geometry, &geometry); err != nil {
return err
}
point, ok := geometry.(*geom.Point)
if !ok {
return errors.New("geometry is not a point")
}
_, err := db.Exec(`
INSERT INTO waypoints(name, geom) VALUES ($1, $2);
`, waypoint.Name, &ewkb.Point{Point: point.SetSRID(4326)})
return err
} | go | func readGeoJSON(db *sql.DB, r io.Reader) error {
var waypoint Waypoint
if err := json.NewDecoder(r).Decode(&waypoint); err != nil {
return err
}
var geometry geom.T
if err := geojson.Unmarshal(waypoint.Geometry, &geometry); err != nil {
return err
}
point, ok := geometry.(*geom.Point)
if !ok {
return errors.New("geometry is not a point")
}
_, err := db.Exec(`
INSERT INTO waypoints(name, geom) VALUES ($1, $2);
`, waypoint.Name, &ewkb.Point{Point: point.SetSRID(4326)})
return err
} | [
"func",
"readGeoJSON",
"(",
"db",
"*",
"sql",
".",
"DB",
",",
"r",
"io",
".",
"Reader",
")",
"error",
"{",
"var",
"waypoint",
"Waypoint",
"\n",
"if",
"err",
":=",
"json",
".",
"NewDecoder",
"(",
"r",
")",
".",
"Decode",
"(",
"&",
"waypoint",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"var",
"geometry",
"geom",
".",
"T",
"\n",
"if",
"err",
":=",
"geojson",
".",
"Unmarshal",
"(",
"waypoint",
".",
"Geometry",
",",
"&",
"geometry",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"point",
",",
"ok",
":=",
"geometry",
".",
"(",
"*",
"geom",
".",
"Point",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"_",
",",
"err",
":=",
"db",
".",
"Exec",
"(",
"`\n\t\tINSERT INTO waypoints(name, geom) VALUES ($1, $2);\n\t`",
",",
"waypoint",
".",
"Name",
",",
"&",
"ewkb",
".",
"Point",
"{",
"Point",
":",
"point",
".",
"SetSRID",
"(",
"4326",
")",
"}",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // readGeoJSON demonstrates reading data in GeoJSON format and inserting it
// into a database in EWKB format. | [
"readGeoJSON",
"demonstrates",
"reading",
"data",
"in",
"GeoJSON",
"format",
"and",
"inserting",
"it",
"into",
"a",
"database",
"in",
"EWKB",
"format",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/examples/postgis/main.go#L83-L100 |
151,622 | twpayne/go-geom | examples/postgis/main.go | writeGeoJSON | func writeGeoJSON(db *sql.DB, w io.Writer) error {
rows, err := db.Query(`
SELECT id, name, ST_AsEWKB(geom) FROM waypoints ORDER BY id ASC;
`)
if err != nil {
return err
}
defer rows.Close()
for rows.Next() {
var id int
var name string
var ewkbPoint ewkb.Point
if err := rows.Scan(&id, &name, &ewkbPoint); err != nil {
return err
}
geometry, err := geojson.Marshal(ewkbPoint.Point)
if err != nil {
return err
}
if err := json.NewEncoder(w).Encode(&Waypoint{
ID: id,
Name: name,
Geometry: geometry,
}); err != nil {
return err
}
}
return nil
} | go | func writeGeoJSON(db *sql.DB, w io.Writer) error {
rows, err := db.Query(`
SELECT id, name, ST_AsEWKB(geom) FROM waypoints ORDER BY id ASC;
`)
if err != nil {
return err
}
defer rows.Close()
for rows.Next() {
var id int
var name string
var ewkbPoint ewkb.Point
if err := rows.Scan(&id, &name, &ewkbPoint); err != nil {
return err
}
geometry, err := geojson.Marshal(ewkbPoint.Point)
if err != nil {
return err
}
if err := json.NewEncoder(w).Encode(&Waypoint{
ID: id,
Name: name,
Geometry: geometry,
}); err != nil {
return err
}
}
return nil
} | [
"func",
"writeGeoJSON",
"(",
"db",
"*",
"sql",
".",
"DB",
",",
"w",
"io",
".",
"Writer",
")",
"error",
"{",
"rows",
",",
"err",
":=",
"db",
".",
"Query",
"(",
"`\n\t\tSELECT id, name, ST_AsEWKB(geom) FROM waypoints ORDER BY id ASC;\n\t`",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"defer",
"rows",
".",
"Close",
"(",
")",
"\n",
"for",
"rows",
".",
"Next",
"(",
")",
"{",
"var",
"id",
"int",
"\n",
"var",
"name",
"string",
"\n",
"var",
"ewkbPoint",
"ewkb",
".",
"Point",
"\n",
"if",
"err",
":=",
"rows",
".",
"Scan",
"(",
"&",
"id",
",",
"&",
"name",
",",
"&",
"ewkbPoint",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"geometry",
",",
"err",
":=",
"geojson",
".",
"Marshal",
"(",
"ewkbPoint",
".",
"Point",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"err",
":=",
"json",
".",
"NewEncoder",
"(",
"w",
")",
".",
"Encode",
"(",
"&",
"Waypoint",
"{",
"ID",
":",
"id",
",",
"Name",
":",
"name",
",",
"Geometry",
":",
"geometry",
",",
"}",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // writeGeoJSON demonstrates reading data from a database in EWKB format and
// writing it as GeoJSON. | [
"writeGeoJSON",
"demonstrates",
"reading",
"data",
"from",
"a",
"database",
"in",
"EWKB",
"format",
"and",
"writing",
"it",
"as",
"GeoJSON",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/examples/postgis/main.go#L104-L132 |
151,623 | twpayne/go-geom | xy/centroid.go | Centroid | func Centroid(geometry geom.T) (centroid geom.Coord, err error) {
switch t := geometry.(type) {
case *geom.Point:
centroid = PointsCentroid(t)
case *geom.MultiPoint:
centroid = MultiPointCentroid(t)
case *geom.LineString:
centroid = LinesCentroid(t)
case *geom.LinearRing:
centroid = LinearRingsCentroid(t)
case *geom.MultiLineString:
centroid = MultiLineCentroid(t)
case *geom.Polygon:
centroid = PolygonsCentroid(t)
case *geom.MultiPolygon:
centroid = MultiPolygonCentroid(t)
default:
err = fmt.Errorf("%v is not a supported type for centroid calculation", t)
}
return centroid, err
} | go | func Centroid(geometry geom.T) (centroid geom.Coord, err error) {
switch t := geometry.(type) {
case *geom.Point:
centroid = PointsCentroid(t)
case *geom.MultiPoint:
centroid = MultiPointCentroid(t)
case *geom.LineString:
centroid = LinesCentroid(t)
case *geom.LinearRing:
centroid = LinearRingsCentroid(t)
case *geom.MultiLineString:
centroid = MultiLineCentroid(t)
case *geom.Polygon:
centroid = PolygonsCentroid(t)
case *geom.MultiPolygon:
centroid = MultiPolygonCentroid(t)
default:
err = fmt.Errorf("%v is not a supported type for centroid calculation", t)
}
return centroid, err
} | [
"func",
"Centroid",
"(",
"geometry",
"geom",
".",
"T",
")",
"(",
"centroid",
"geom",
".",
"Coord",
",",
"err",
"error",
")",
"{",
"switch",
"t",
":=",
"geometry",
".",
"(",
"type",
")",
"{",
"case",
"*",
"geom",
".",
"Point",
":",
"centroid",
"=",
"PointsCentroid",
"(",
"t",
")",
"\n",
"case",
"*",
"geom",
".",
"MultiPoint",
":",
"centroid",
"=",
"MultiPointCentroid",
"(",
"t",
")",
"\n",
"case",
"*",
"geom",
".",
"LineString",
":",
"centroid",
"=",
"LinesCentroid",
"(",
"t",
")",
"\n",
"case",
"*",
"geom",
".",
"LinearRing",
":",
"centroid",
"=",
"LinearRingsCentroid",
"(",
"t",
")",
"\n",
"case",
"*",
"geom",
".",
"MultiLineString",
":",
"centroid",
"=",
"MultiLineCentroid",
"(",
"t",
")",
"\n",
"case",
"*",
"geom",
".",
"Polygon",
":",
"centroid",
"=",
"PolygonsCentroid",
"(",
"t",
")",
"\n",
"case",
"*",
"geom",
".",
"MultiPolygon",
":",
"centroid",
"=",
"MultiPolygonCentroid",
"(",
"t",
")",
"\n",
"default",
":",
"err",
"=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"t",
")",
"\n",
"}",
"\n\n",
"return",
"centroid",
",",
"err",
"\n",
"}"
] | // Centroid calculates the centroid of the geometry. The centroid may be outside of the geometry depending
// on the topology of the geometry | [
"Centroid",
"calculates",
"the",
"centroid",
"of",
"the",
"geometry",
".",
"The",
"centroid",
"may",
"be",
"outside",
"of",
"the",
"geometry",
"depending",
"on",
"the",
"topology",
"of",
"the",
"geometry"
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/xy/centroid.go#L11-L32 |
151,624 | twpayne/go-geom | bounds.go | NewBounds | func NewBounds(layout Layout) *Bounds {
stride := layout.Stride()
min, max := make(Coord, stride), make(Coord, stride)
for i := 0; i < stride; i++ {
min[i], max[i] = math.Inf(1), math.Inf(-1)
}
return &Bounds{
layout: layout,
min: min,
max: max,
}
} | go | func NewBounds(layout Layout) *Bounds {
stride := layout.Stride()
min, max := make(Coord, stride), make(Coord, stride)
for i := 0; i < stride; i++ {
min[i], max[i] = math.Inf(1), math.Inf(-1)
}
return &Bounds{
layout: layout,
min: min,
max: max,
}
} | [
"func",
"NewBounds",
"(",
"layout",
"Layout",
")",
"*",
"Bounds",
"{",
"stride",
":=",
"layout",
".",
"Stride",
"(",
")",
"\n",
"min",
",",
"max",
":=",
"make",
"(",
"Coord",
",",
"stride",
")",
",",
"make",
"(",
"Coord",
",",
"stride",
")",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"stride",
";",
"i",
"++",
"{",
"min",
"[",
"i",
"]",
",",
"max",
"[",
"i",
"]",
"=",
"math",
".",
"Inf",
"(",
"1",
")",
",",
"math",
".",
"Inf",
"(",
"-",
"1",
")",
"\n",
"}",
"\n",
"return",
"&",
"Bounds",
"{",
"layout",
":",
"layout",
",",
"min",
":",
"min",
",",
"max",
":",
"max",
",",
"}",
"\n",
"}"
] | // NewBounds creates a new Bounds. | [
"NewBounds",
"creates",
"a",
"new",
"Bounds",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/bounds.go#L13-L24 |
151,625 | twpayne/go-geom | bounds.go | Extend | func (b *Bounds) Extend(g T) *Bounds {
b.extendLayout(g.Layout())
if b.layout == XYZM && g.Layout() == XYM {
return b.extendXYZMFlatCoordsWithXYM(g.FlatCoords(), 0, len(g.FlatCoords()))
}
return b.extendFlatCoords(g.FlatCoords(), 0, len(g.FlatCoords()), g.Stride())
} | go | func (b *Bounds) Extend(g T) *Bounds {
b.extendLayout(g.Layout())
if b.layout == XYZM && g.Layout() == XYM {
return b.extendXYZMFlatCoordsWithXYM(g.FlatCoords(), 0, len(g.FlatCoords()))
}
return b.extendFlatCoords(g.FlatCoords(), 0, len(g.FlatCoords()), g.Stride())
} | [
"func",
"(",
"b",
"*",
"Bounds",
")",
"Extend",
"(",
"g",
"T",
")",
"*",
"Bounds",
"{",
"b",
".",
"extendLayout",
"(",
"g",
".",
"Layout",
"(",
")",
")",
"\n",
"if",
"b",
".",
"layout",
"==",
"XYZM",
"&&",
"g",
".",
"Layout",
"(",
")",
"==",
"XYM",
"{",
"return",
"b",
".",
"extendXYZMFlatCoordsWithXYM",
"(",
"g",
".",
"FlatCoords",
"(",
")",
",",
"0",
",",
"len",
"(",
"g",
".",
"FlatCoords",
"(",
")",
")",
")",
"\n",
"}",
"\n",
"return",
"b",
".",
"extendFlatCoords",
"(",
"g",
".",
"FlatCoords",
"(",
")",
",",
"0",
",",
"len",
"(",
"g",
".",
"FlatCoords",
"(",
")",
")",
",",
"g",
".",
"Stride",
"(",
")",
")",
"\n",
"}"
] | // Extend extends b to include geometry g. | [
"Extend",
"extends",
"b",
"to",
"include",
"geometry",
"g",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/bounds.go#L32-L38 |
151,626 | twpayne/go-geom | bounds.go | IsEmpty | func (b *Bounds) IsEmpty() bool {
if b.layout == NoLayout {
return true
}
for i, stride := 0, b.layout.Stride(); i < stride; i++ {
if b.max[i] < b.min[i] {
return true
}
}
return false
} | go | func (b *Bounds) IsEmpty() bool {
if b.layout == NoLayout {
return true
}
for i, stride := 0, b.layout.Stride(); i < stride; i++ {
if b.max[i] < b.min[i] {
return true
}
}
return false
} | [
"func",
"(",
"b",
"*",
"Bounds",
")",
"IsEmpty",
"(",
")",
"bool",
"{",
"if",
"b",
".",
"layout",
"==",
"NoLayout",
"{",
"return",
"true",
"\n",
"}",
"\n",
"for",
"i",
",",
"stride",
":=",
"0",
",",
"b",
".",
"layout",
".",
"Stride",
"(",
")",
";",
"i",
"<",
"stride",
";",
"i",
"++",
"{",
"if",
"b",
".",
"max",
"[",
"i",
"]",
"<",
"b",
".",
"min",
"[",
"i",
"]",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"false",
"\n",
"}"
] | // IsEmpty returns true if b is empty. | [
"IsEmpty",
"returns",
"true",
"if",
"b",
"is",
"empty",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/bounds.go#L41-L51 |
151,627 | twpayne/go-geom | bounds.go | Overlaps | func (b *Bounds) Overlaps(layout Layout, b2 *Bounds) bool {
for i, stride := 0, layout.Stride(); i < stride; i++ {
if b.min[i] > b2.max[i] || b.max[i] < b2.min[i] {
return false
}
}
return true
} | go | func (b *Bounds) Overlaps(layout Layout, b2 *Bounds) bool {
for i, stride := 0, layout.Stride(); i < stride; i++ {
if b.min[i] > b2.max[i] || b.max[i] < b2.min[i] {
return false
}
}
return true
} | [
"func",
"(",
"b",
"*",
"Bounds",
")",
"Overlaps",
"(",
"layout",
"Layout",
",",
"b2",
"*",
"Bounds",
")",
"bool",
"{",
"for",
"i",
",",
"stride",
":=",
"0",
",",
"layout",
".",
"Stride",
"(",
")",
";",
"i",
"<",
"stride",
";",
"i",
"++",
"{",
"if",
"b",
".",
"min",
"[",
"i",
"]",
">",
"b2",
".",
"max",
"[",
"i",
"]",
"||",
"b",
".",
"max",
"[",
"i",
"]",
"<",
"b2",
".",
"min",
"[",
"i",
"]",
"{",
"return",
"false",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"true",
"\n",
"}"
] | // Overlaps returns true if b overlaps b2 in layout. | [
"Overlaps",
"returns",
"true",
"if",
"b",
"overlaps",
"b2",
"in",
"layout",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/bounds.go#L69-L76 |
151,628 | twpayne/go-geom | bounds.go | Polygon | func (b *Bounds) Polygon() *Polygon {
if b.IsEmpty() {
return NewPolygonFlat(XY, nil, nil)
}
x1, y1 := b.min[0], b.min[1]
x2, y2 := b.max[0], b.max[1]
flatCoords := []float64{
x1, y1,
x1, y2,
x2, y2,
x2, y1,
x1, y1,
}
return NewPolygonFlat(XY, flatCoords, []int{len(flatCoords)})
} | go | func (b *Bounds) Polygon() *Polygon {
if b.IsEmpty() {
return NewPolygonFlat(XY, nil, nil)
}
x1, y1 := b.min[0], b.min[1]
x2, y2 := b.max[0], b.max[1]
flatCoords := []float64{
x1, y1,
x1, y2,
x2, y2,
x2, y1,
x1, y1,
}
return NewPolygonFlat(XY, flatCoords, []int{len(flatCoords)})
} | [
"func",
"(",
"b",
"*",
"Bounds",
")",
"Polygon",
"(",
")",
"*",
"Polygon",
"{",
"if",
"b",
".",
"IsEmpty",
"(",
")",
"{",
"return",
"NewPolygonFlat",
"(",
"XY",
",",
"nil",
",",
"nil",
")",
"\n",
"}",
"\n",
"x1",
",",
"y1",
":=",
"b",
".",
"min",
"[",
"0",
"]",
",",
"b",
".",
"min",
"[",
"1",
"]",
"\n",
"x2",
",",
"y2",
":=",
"b",
".",
"max",
"[",
"0",
"]",
",",
"b",
".",
"max",
"[",
"1",
"]",
"\n",
"flatCoords",
":=",
"[",
"]",
"float64",
"{",
"x1",
",",
"y1",
",",
"x1",
",",
"y2",
",",
"x2",
",",
"y2",
",",
"x2",
",",
"y1",
",",
"x1",
",",
"y1",
",",
"}",
"\n",
"return",
"NewPolygonFlat",
"(",
"XY",
",",
"flatCoords",
",",
"[",
"]",
"int",
"{",
"len",
"(",
"flatCoords",
")",
"}",
")",
"\n",
"}"
] | // Polygon returns b as a two-dimensional Polygon. | [
"Polygon",
"returns",
"b",
"as",
"a",
"two",
"-",
"dimensional",
"Polygon",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/bounds.go#L79-L93 |
151,629 | twpayne/go-geom | bounds.go | SetCoords | func (b *Bounds) SetCoords(min, max Coord) *Bounds {
b.min = Coord(make([]float64, b.layout.Stride()))
b.max = Coord(make([]float64, b.layout.Stride()))
for i := 0; i < b.layout.Stride(); i++ {
b.min[i] = math.Min(min[i], max[i])
b.max[i] = math.Max(min[i], max[i])
}
return b
} | go | func (b *Bounds) SetCoords(min, max Coord) *Bounds {
b.min = Coord(make([]float64, b.layout.Stride()))
b.max = Coord(make([]float64, b.layout.Stride()))
for i := 0; i < b.layout.Stride(); i++ {
b.min[i] = math.Min(min[i], max[i])
b.max[i] = math.Max(min[i], max[i])
}
return b
} | [
"func",
"(",
"b",
"*",
"Bounds",
")",
"SetCoords",
"(",
"min",
",",
"max",
"Coord",
")",
"*",
"Bounds",
"{",
"b",
".",
"min",
"=",
"Coord",
"(",
"make",
"(",
"[",
"]",
"float64",
",",
"b",
".",
"layout",
".",
"Stride",
"(",
")",
")",
")",
"\n",
"b",
".",
"max",
"=",
"Coord",
"(",
"make",
"(",
"[",
"]",
"float64",
",",
"b",
".",
"layout",
".",
"Stride",
"(",
")",
")",
")",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"b",
".",
"layout",
".",
"Stride",
"(",
")",
";",
"i",
"++",
"{",
"b",
".",
"min",
"[",
"i",
"]",
"=",
"math",
".",
"Min",
"(",
"min",
"[",
"i",
"]",
",",
"max",
"[",
"i",
"]",
")",
"\n",
"b",
".",
"max",
"[",
"i",
"]",
"=",
"math",
".",
"Max",
"(",
"min",
"[",
"i",
"]",
",",
"max",
"[",
"i",
"]",
")",
"\n",
"}",
"\n",
"return",
"b",
"\n",
"}"
] | // SetCoords sets the minimum and maximum values of the Bounds. | [
"SetCoords",
"sets",
"the",
"minimum",
"and",
"maximum",
"values",
"of",
"the",
"Bounds",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/bounds.go#L113-L121 |
151,630 | twpayne/go-geom | derived.gen.go | deriveCloneBounds | func deriveCloneBounds(src *Bounds) *Bounds {
if src == nil {
return nil
}
dst := new(Bounds)
deriveDeepCopy(dst, src)
return dst
} | go | func deriveCloneBounds(src *Bounds) *Bounds {
if src == nil {
return nil
}
dst := new(Bounds)
deriveDeepCopy(dst, src)
return dst
} | [
"func",
"deriveCloneBounds",
"(",
"src",
"*",
"Bounds",
")",
"*",
"Bounds",
"{",
"if",
"src",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"dst",
":=",
"new",
"(",
"Bounds",
")",
"\n",
"deriveDeepCopy",
"(",
"dst",
",",
"src",
")",
"\n",
"return",
"dst",
"\n",
"}"
] | // deriveCloneBounds returns a clone of the src parameter. | [
"deriveCloneBounds",
"returns",
"a",
"clone",
"of",
"the",
"src",
"parameter",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/derived.gen.go#L6-L13 |
151,631 | twpayne/go-geom | derived.gen.go | deriveCloneCoord | func deriveCloneCoord(src Coord) Coord {
if src == nil {
return nil
}
dst := make(Coord, len(src))
deriveDeepCopy_(dst, src)
return dst
} | go | func deriveCloneCoord(src Coord) Coord {
if src == nil {
return nil
}
dst := make(Coord, len(src))
deriveDeepCopy_(dst, src)
return dst
} | [
"func",
"deriveCloneCoord",
"(",
"src",
"Coord",
")",
"Coord",
"{",
"if",
"src",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"dst",
":=",
"make",
"(",
"Coord",
",",
"len",
"(",
"src",
")",
")",
"\n",
"deriveDeepCopy_",
"(",
"dst",
",",
"src",
")",
"\n",
"return",
"dst",
"\n",
"}"
] | // deriveCloneCoord returns a clone of the src parameter. | [
"deriveCloneCoord",
"returns",
"a",
"clone",
"of",
"the",
"src",
"parameter",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/derived.gen.go#L16-L23 |
151,632 | twpayne/go-geom | derived.gen.go | deriveCloneLinearRing | func deriveCloneLinearRing(src *LinearRing) *LinearRing {
if src == nil {
return nil
}
dst := new(LinearRing)
deriveDeepCopy_1(dst, src)
return dst
} | go | func deriveCloneLinearRing(src *LinearRing) *LinearRing {
if src == nil {
return nil
}
dst := new(LinearRing)
deriveDeepCopy_1(dst, src)
return dst
} | [
"func",
"deriveCloneLinearRing",
"(",
"src",
"*",
"LinearRing",
")",
"*",
"LinearRing",
"{",
"if",
"src",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"dst",
":=",
"new",
"(",
"LinearRing",
")",
"\n",
"deriveDeepCopy_1",
"(",
"dst",
",",
"src",
")",
"\n",
"return",
"dst",
"\n",
"}"
] | // deriveCloneLinearRing returns a clone of the src parameter. | [
"deriveCloneLinearRing",
"returns",
"a",
"clone",
"of",
"the",
"src",
"parameter",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/derived.gen.go#L26-L33 |
151,633 | twpayne/go-geom | derived.gen.go | deriveCloneLineString | func deriveCloneLineString(src *LineString) *LineString {
if src == nil {
return nil
}
dst := new(LineString)
deriveDeepCopy_2(dst, src)
return dst
} | go | func deriveCloneLineString(src *LineString) *LineString {
if src == nil {
return nil
}
dst := new(LineString)
deriveDeepCopy_2(dst, src)
return dst
} | [
"func",
"deriveCloneLineString",
"(",
"src",
"*",
"LineString",
")",
"*",
"LineString",
"{",
"if",
"src",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"dst",
":=",
"new",
"(",
"LineString",
")",
"\n",
"deriveDeepCopy_2",
"(",
"dst",
",",
"src",
")",
"\n",
"return",
"dst",
"\n",
"}"
] | // deriveCloneLineString returns a clone of the src parameter. | [
"deriveCloneLineString",
"returns",
"a",
"clone",
"of",
"the",
"src",
"parameter",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/derived.gen.go#L36-L43 |
151,634 | twpayne/go-geom | derived.gen.go | deriveCloneMultiLineString | func deriveCloneMultiLineString(src *MultiLineString) *MultiLineString {
if src == nil {
return nil
}
dst := new(MultiLineString)
deriveDeepCopy_3(dst, src)
return dst
} | go | func deriveCloneMultiLineString(src *MultiLineString) *MultiLineString {
if src == nil {
return nil
}
dst := new(MultiLineString)
deriveDeepCopy_3(dst, src)
return dst
} | [
"func",
"deriveCloneMultiLineString",
"(",
"src",
"*",
"MultiLineString",
")",
"*",
"MultiLineString",
"{",
"if",
"src",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"dst",
":=",
"new",
"(",
"MultiLineString",
")",
"\n",
"deriveDeepCopy_3",
"(",
"dst",
",",
"src",
")",
"\n",
"return",
"dst",
"\n",
"}"
] | // deriveCloneMultiLineString returns a clone of the src parameter. | [
"deriveCloneMultiLineString",
"returns",
"a",
"clone",
"of",
"the",
"src",
"parameter",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/derived.gen.go#L46-L53 |
151,635 | twpayne/go-geom | derived.gen.go | deriveCloneMultiPoint | func deriveCloneMultiPoint(src *MultiPoint) *MultiPoint {
if src == nil {
return nil
}
dst := new(MultiPoint)
deriveDeepCopy_4(dst, src)
return dst
} | go | func deriveCloneMultiPoint(src *MultiPoint) *MultiPoint {
if src == nil {
return nil
}
dst := new(MultiPoint)
deriveDeepCopy_4(dst, src)
return dst
} | [
"func",
"deriveCloneMultiPoint",
"(",
"src",
"*",
"MultiPoint",
")",
"*",
"MultiPoint",
"{",
"if",
"src",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"dst",
":=",
"new",
"(",
"MultiPoint",
")",
"\n",
"deriveDeepCopy_4",
"(",
"dst",
",",
"src",
")",
"\n",
"return",
"dst",
"\n",
"}"
] | // deriveCloneMultiPoint returns a clone of the src parameter. | [
"deriveCloneMultiPoint",
"returns",
"a",
"clone",
"of",
"the",
"src",
"parameter",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/derived.gen.go#L56-L63 |
151,636 | twpayne/go-geom | derived.gen.go | deriveCloneMultiPolygon | func deriveCloneMultiPolygon(src *MultiPolygon) *MultiPolygon {
if src == nil {
return nil
}
dst := new(MultiPolygon)
deriveDeepCopy_5(dst, src)
return dst
} | go | func deriveCloneMultiPolygon(src *MultiPolygon) *MultiPolygon {
if src == nil {
return nil
}
dst := new(MultiPolygon)
deriveDeepCopy_5(dst, src)
return dst
} | [
"func",
"deriveCloneMultiPolygon",
"(",
"src",
"*",
"MultiPolygon",
")",
"*",
"MultiPolygon",
"{",
"if",
"src",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"dst",
":=",
"new",
"(",
"MultiPolygon",
")",
"\n",
"deriveDeepCopy_5",
"(",
"dst",
",",
"src",
")",
"\n",
"return",
"dst",
"\n",
"}"
] | // deriveCloneMultiPolygon returns a clone of the src parameter. | [
"deriveCloneMultiPolygon",
"returns",
"a",
"clone",
"of",
"the",
"src",
"parameter",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/derived.gen.go#L66-L73 |
151,637 | twpayne/go-geom | derived.gen.go | deriveClonePoint | func deriveClonePoint(src *Point) *Point {
if src == nil {
return nil
}
dst := new(Point)
deriveDeepCopy_6(dst, src)
return dst
} | go | func deriveClonePoint(src *Point) *Point {
if src == nil {
return nil
}
dst := new(Point)
deriveDeepCopy_6(dst, src)
return dst
} | [
"func",
"deriveClonePoint",
"(",
"src",
"*",
"Point",
")",
"*",
"Point",
"{",
"if",
"src",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"dst",
":=",
"new",
"(",
"Point",
")",
"\n",
"deriveDeepCopy_6",
"(",
"dst",
",",
"src",
")",
"\n",
"return",
"dst",
"\n",
"}"
] | // deriveClonePoint returns a clone of the src parameter. | [
"deriveClonePoint",
"returns",
"a",
"clone",
"of",
"the",
"src",
"parameter",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/derived.gen.go#L76-L83 |
151,638 | twpayne/go-geom | derived.gen.go | deriveClonePolygon | func deriveClonePolygon(src *Polygon) *Polygon {
if src == nil {
return nil
}
dst := new(Polygon)
deriveDeepCopy_7(dst, src)
return dst
} | go | func deriveClonePolygon(src *Polygon) *Polygon {
if src == nil {
return nil
}
dst := new(Polygon)
deriveDeepCopy_7(dst, src)
return dst
} | [
"func",
"deriveClonePolygon",
"(",
"src",
"*",
"Polygon",
")",
"*",
"Polygon",
"{",
"if",
"src",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"dst",
":=",
"new",
"(",
"Polygon",
")",
"\n",
"deriveDeepCopy_7",
"(",
"dst",
",",
"src",
")",
"\n",
"return",
"dst",
"\n",
"}"
] | // deriveClonePolygon returns a clone of the src parameter. | [
"deriveClonePolygon",
"returns",
"a",
"clone",
"of",
"the",
"src",
"parameter",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/derived.gen.go#L86-L93 |
151,639 | twpayne/go-geom | derived.gen.go | deriveDeepCopy_1 | func deriveDeepCopy_1(dst, src *LinearRing) {
func() {
field := new(geom1)
deriveDeepCopy_8(field, &src.geom1)
dst.geom1 = *field
}()
} | go | func deriveDeepCopy_1(dst, src *LinearRing) {
func() {
field := new(geom1)
deriveDeepCopy_8(field, &src.geom1)
dst.geom1 = *field
}()
} | [
"func",
"deriveDeepCopy_1",
"(",
"dst",
",",
"src",
"*",
"LinearRing",
")",
"{",
"func",
"(",
")",
"{",
"field",
":=",
"new",
"(",
"geom1",
")",
"\n",
"deriveDeepCopy_8",
"(",
"field",
",",
"&",
"src",
".",
"geom1",
")",
"\n",
"dst",
".",
"geom1",
"=",
"*",
"field",
"\n",
"}",
"(",
")",
"\n",
"}"
] | // deriveDeepCopy_1 recursively copies the contents of src into dst. | [
"deriveDeepCopy_1",
"recursively",
"copies",
"the",
"contents",
"of",
"src",
"into",
"dst",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/derived.gen.go#L142-L148 |
151,640 | twpayne/go-geom | derived.gen.go | deriveDeepCopy_2 | func deriveDeepCopy_2(dst, src *LineString) {
func() {
field := new(geom1)
deriveDeepCopy_8(field, &src.geom1)
dst.geom1 = *field
}()
} | go | func deriveDeepCopy_2(dst, src *LineString) {
func() {
field := new(geom1)
deriveDeepCopy_8(field, &src.geom1)
dst.geom1 = *field
}()
} | [
"func",
"deriveDeepCopy_2",
"(",
"dst",
",",
"src",
"*",
"LineString",
")",
"{",
"func",
"(",
")",
"{",
"field",
":=",
"new",
"(",
"geom1",
")",
"\n",
"deriveDeepCopy_8",
"(",
"field",
",",
"&",
"src",
".",
"geom1",
")",
"\n",
"dst",
".",
"geom1",
"=",
"*",
"field",
"\n",
"}",
"(",
")",
"\n",
"}"
] | // deriveDeepCopy_2 recursively copies the contents of src into dst. | [
"deriveDeepCopy_2",
"recursively",
"copies",
"the",
"contents",
"of",
"src",
"into",
"dst",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/derived.gen.go#L151-L157 |
151,641 | twpayne/go-geom | derived.gen.go | deriveDeepCopy_3 | func deriveDeepCopy_3(dst, src *MultiLineString) {
func() {
field := new(geom2)
deriveDeepCopy_9(field, &src.geom2)
dst.geom2 = *field
}()
} | go | func deriveDeepCopy_3(dst, src *MultiLineString) {
func() {
field := new(geom2)
deriveDeepCopy_9(field, &src.geom2)
dst.geom2 = *field
}()
} | [
"func",
"deriveDeepCopy_3",
"(",
"dst",
",",
"src",
"*",
"MultiLineString",
")",
"{",
"func",
"(",
")",
"{",
"field",
":=",
"new",
"(",
"geom2",
")",
"\n",
"deriveDeepCopy_9",
"(",
"field",
",",
"&",
"src",
".",
"geom2",
")",
"\n",
"dst",
".",
"geom2",
"=",
"*",
"field",
"\n",
"}",
"(",
")",
"\n",
"}"
] | // deriveDeepCopy_3 recursively copies the contents of src into dst. | [
"deriveDeepCopy_3",
"recursively",
"copies",
"the",
"contents",
"of",
"src",
"into",
"dst",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/derived.gen.go#L160-L166 |
151,642 | twpayne/go-geom | derived.gen.go | deriveDeepCopy_4 | func deriveDeepCopy_4(dst, src *MultiPoint) {
func() {
field := new(geom1)
deriveDeepCopy_8(field, &src.geom1)
dst.geom1 = *field
}()
} | go | func deriveDeepCopy_4(dst, src *MultiPoint) {
func() {
field := new(geom1)
deriveDeepCopy_8(field, &src.geom1)
dst.geom1 = *field
}()
} | [
"func",
"deriveDeepCopy_4",
"(",
"dst",
",",
"src",
"*",
"MultiPoint",
")",
"{",
"func",
"(",
")",
"{",
"field",
":=",
"new",
"(",
"geom1",
")",
"\n",
"deriveDeepCopy_8",
"(",
"field",
",",
"&",
"src",
".",
"geom1",
")",
"\n",
"dst",
".",
"geom1",
"=",
"*",
"field",
"\n",
"}",
"(",
")",
"\n",
"}"
] | // deriveDeepCopy_4 recursively copies the contents of src into dst. | [
"deriveDeepCopy_4",
"recursively",
"copies",
"the",
"contents",
"of",
"src",
"into",
"dst",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/derived.gen.go#L169-L175 |
151,643 | twpayne/go-geom | derived.gen.go | deriveDeepCopy_5 | func deriveDeepCopy_5(dst, src *MultiPolygon) {
func() {
field := new(geom3)
deriveDeepCopy_10(field, &src.geom3)
dst.geom3 = *field
}()
} | go | func deriveDeepCopy_5(dst, src *MultiPolygon) {
func() {
field := new(geom3)
deriveDeepCopy_10(field, &src.geom3)
dst.geom3 = *field
}()
} | [
"func",
"deriveDeepCopy_5",
"(",
"dst",
",",
"src",
"*",
"MultiPolygon",
")",
"{",
"func",
"(",
")",
"{",
"field",
":=",
"new",
"(",
"geom3",
")",
"\n",
"deriveDeepCopy_10",
"(",
"field",
",",
"&",
"src",
".",
"geom3",
")",
"\n",
"dst",
".",
"geom3",
"=",
"*",
"field",
"\n",
"}",
"(",
")",
"\n",
"}"
] | // deriveDeepCopy_5 recursively copies the contents of src into dst. | [
"deriveDeepCopy_5",
"recursively",
"copies",
"the",
"contents",
"of",
"src",
"into",
"dst",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/derived.gen.go#L178-L184 |
151,644 | twpayne/go-geom | derived.gen.go | deriveDeepCopy_6 | func deriveDeepCopy_6(dst, src *Point) {
func() {
field := new(geom0)
deriveDeepCopy_11(field, &src.geom0)
dst.geom0 = *field
}()
} | go | func deriveDeepCopy_6(dst, src *Point) {
func() {
field := new(geom0)
deriveDeepCopy_11(field, &src.geom0)
dst.geom0 = *field
}()
} | [
"func",
"deriveDeepCopy_6",
"(",
"dst",
",",
"src",
"*",
"Point",
")",
"{",
"func",
"(",
")",
"{",
"field",
":=",
"new",
"(",
"geom0",
")",
"\n",
"deriveDeepCopy_11",
"(",
"field",
",",
"&",
"src",
".",
"geom0",
")",
"\n",
"dst",
".",
"geom0",
"=",
"*",
"field",
"\n",
"}",
"(",
")",
"\n",
"}"
] | // deriveDeepCopy_6 recursively copies the contents of src into dst. | [
"deriveDeepCopy_6",
"recursively",
"copies",
"the",
"contents",
"of",
"src",
"into",
"dst",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/derived.gen.go#L187-L193 |
151,645 | twpayne/go-geom | derived.gen.go | deriveDeepCopy_7 | func deriveDeepCopy_7(dst, src *Polygon) {
func() {
field := new(geom2)
deriveDeepCopy_9(field, &src.geom2)
dst.geom2 = *field
}()
} | go | func deriveDeepCopy_7(dst, src *Polygon) {
func() {
field := new(geom2)
deriveDeepCopy_9(field, &src.geom2)
dst.geom2 = *field
}()
} | [
"func",
"deriveDeepCopy_7",
"(",
"dst",
",",
"src",
"*",
"Polygon",
")",
"{",
"func",
"(",
")",
"{",
"field",
":=",
"new",
"(",
"geom2",
")",
"\n",
"deriveDeepCopy_9",
"(",
"field",
",",
"&",
"src",
".",
"geom2",
")",
"\n",
"dst",
".",
"geom2",
"=",
"*",
"field",
"\n",
"}",
"(",
")",
"\n",
"}"
] | // deriveDeepCopy_7 recursively copies the contents of src into dst. | [
"deriveDeepCopy_7",
"recursively",
"copies",
"the",
"contents",
"of",
"src",
"into",
"dst",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/derived.gen.go#L196-L202 |
151,646 | twpayne/go-geom | derived.gen.go | deriveDeepCopy_8 | func deriveDeepCopy_8(dst, src *geom1) {
func() {
field := new(geom0)
deriveDeepCopy_11(field, &src.geom0)
dst.geom0 = *field
}()
} | go | func deriveDeepCopy_8(dst, src *geom1) {
func() {
field := new(geom0)
deriveDeepCopy_11(field, &src.geom0)
dst.geom0 = *field
}()
} | [
"func",
"deriveDeepCopy_8",
"(",
"dst",
",",
"src",
"*",
"geom1",
")",
"{",
"func",
"(",
")",
"{",
"field",
":=",
"new",
"(",
"geom0",
")",
"\n",
"deriveDeepCopy_11",
"(",
"field",
",",
"&",
"src",
".",
"geom0",
")",
"\n",
"dst",
".",
"geom0",
"=",
"*",
"field",
"\n",
"}",
"(",
")",
"\n",
"}"
] | // deriveDeepCopy_8 recursively copies the contents of src into dst. | [
"deriveDeepCopy_8",
"recursively",
"copies",
"the",
"contents",
"of",
"src",
"into",
"dst",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/derived.gen.go#L205-L211 |
151,647 | twpayne/go-geom | derived.gen.go | deriveDeepCopy_9 | func deriveDeepCopy_9(dst, src *geom2) {
func() {
field := new(geom1)
deriveDeepCopy_8(field, &src.geom1)
dst.geom1 = *field
}()
if src.ends == nil {
dst.ends = nil
} else {
if dst.ends != nil {
if len(src.ends) > len(dst.ends) {
if cap(dst.ends) >= len(src.ends) {
dst.ends = (dst.ends)[:len(src.ends)]
} else {
dst.ends = make([]int, len(src.ends))
}
} else if len(src.ends) < len(dst.ends) {
dst.ends = (dst.ends)[:len(src.ends)]
}
} else {
dst.ends = make([]int, len(src.ends))
}
copy(dst.ends, src.ends)
}
} | go | func deriveDeepCopy_9(dst, src *geom2) {
func() {
field := new(geom1)
deriveDeepCopy_8(field, &src.geom1)
dst.geom1 = *field
}()
if src.ends == nil {
dst.ends = nil
} else {
if dst.ends != nil {
if len(src.ends) > len(dst.ends) {
if cap(dst.ends) >= len(src.ends) {
dst.ends = (dst.ends)[:len(src.ends)]
} else {
dst.ends = make([]int, len(src.ends))
}
} else if len(src.ends) < len(dst.ends) {
dst.ends = (dst.ends)[:len(src.ends)]
}
} else {
dst.ends = make([]int, len(src.ends))
}
copy(dst.ends, src.ends)
}
} | [
"func",
"deriveDeepCopy_9",
"(",
"dst",
",",
"src",
"*",
"geom2",
")",
"{",
"func",
"(",
")",
"{",
"field",
":=",
"new",
"(",
"geom1",
")",
"\n",
"deriveDeepCopy_8",
"(",
"field",
",",
"&",
"src",
".",
"geom1",
")",
"\n",
"dst",
".",
"geom1",
"=",
"*",
"field",
"\n",
"}",
"(",
")",
"\n",
"if",
"src",
".",
"ends",
"==",
"nil",
"{",
"dst",
".",
"ends",
"=",
"nil",
"\n",
"}",
"else",
"{",
"if",
"dst",
".",
"ends",
"!=",
"nil",
"{",
"if",
"len",
"(",
"src",
".",
"ends",
")",
">",
"len",
"(",
"dst",
".",
"ends",
")",
"{",
"if",
"cap",
"(",
"dst",
".",
"ends",
")",
">=",
"len",
"(",
"src",
".",
"ends",
")",
"{",
"dst",
".",
"ends",
"=",
"(",
"dst",
".",
"ends",
")",
"[",
":",
"len",
"(",
"src",
".",
"ends",
")",
"]",
"\n",
"}",
"else",
"{",
"dst",
".",
"ends",
"=",
"make",
"(",
"[",
"]",
"int",
",",
"len",
"(",
"src",
".",
"ends",
")",
")",
"\n",
"}",
"\n",
"}",
"else",
"if",
"len",
"(",
"src",
".",
"ends",
")",
"<",
"len",
"(",
"dst",
".",
"ends",
")",
"{",
"dst",
".",
"ends",
"=",
"(",
"dst",
".",
"ends",
")",
"[",
":",
"len",
"(",
"src",
".",
"ends",
")",
"]",
"\n",
"}",
"\n",
"}",
"else",
"{",
"dst",
".",
"ends",
"=",
"make",
"(",
"[",
"]",
"int",
",",
"len",
"(",
"src",
".",
"ends",
")",
")",
"\n",
"}",
"\n",
"copy",
"(",
"dst",
".",
"ends",
",",
"src",
".",
"ends",
")",
"\n",
"}",
"\n",
"}"
] | // deriveDeepCopy_9 recursively copies the contents of src into dst. | [
"deriveDeepCopy_9",
"recursively",
"copies",
"the",
"contents",
"of",
"src",
"into",
"dst",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/derived.gen.go#L214-L238 |
151,648 | twpayne/go-geom | derived.gen.go | deriveDeepCopy_10 | func deriveDeepCopy_10(dst, src *geom3) {
func() {
field := new(geom1)
deriveDeepCopy_8(field, &src.geom1)
dst.geom1 = *field
}()
if src.endss == nil {
dst.endss = nil
} else {
if dst.endss != nil {
if len(src.endss) > len(dst.endss) {
if cap(dst.endss) >= len(src.endss) {
dst.endss = (dst.endss)[:len(src.endss)]
} else {
dst.endss = make([][]int, len(src.endss))
}
} else if len(src.endss) < len(dst.endss) {
dst.endss = (dst.endss)[:len(src.endss)]
}
} else {
dst.endss = make([][]int, len(src.endss))
}
deriveDeepCopy_12(dst.endss, src.endss)
}
} | go | func deriveDeepCopy_10(dst, src *geom3) {
func() {
field := new(geom1)
deriveDeepCopy_8(field, &src.geom1)
dst.geom1 = *field
}()
if src.endss == nil {
dst.endss = nil
} else {
if dst.endss != nil {
if len(src.endss) > len(dst.endss) {
if cap(dst.endss) >= len(src.endss) {
dst.endss = (dst.endss)[:len(src.endss)]
} else {
dst.endss = make([][]int, len(src.endss))
}
} else if len(src.endss) < len(dst.endss) {
dst.endss = (dst.endss)[:len(src.endss)]
}
} else {
dst.endss = make([][]int, len(src.endss))
}
deriveDeepCopy_12(dst.endss, src.endss)
}
} | [
"func",
"deriveDeepCopy_10",
"(",
"dst",
",",
"src",
"*",
"geom3",
")",
"{",
"func",
"(",
")",
"{",
"field",
":=",
"new",
"(",
"geom1",
")",
"\n",
"deriveDeepCopy_8",
"(",
"field",
",",
"&",
"src",
".",
"geom1",
")",
"\n",
"dst",
".",
"geom1",
"=",
"*",
"field",
"\n",
"}",
"(",
")",
"\n",
"if",
"src",
".",
"endss",
"==",
"nil",
"{",
"dst",
".",
"endss",
"=",
"nil",
"\n",
"}",
"else",
"{",
"if",
"dst",
".",
"endss",
"!=",
"nil",
"{",
"if",
"len",
"(",
"src",
".",
"endss",
")",
">",
"len",
"(",
"dst",
".",
"endss",
")",
"{",
"if",
"cap",
"(",
"dst",
".",
"endss",
")",
">=",
"len",
"(",
"src",
".",
"endss",
")",
"{",
"dst",
".",
"endss",
"=",
"(",
"dst",
".",
"endss",
")",
"[",
":",
"len",
"(",
"src",
".",
"endss",
")",
"]",
"\n",
"}",
"else",
"{",
"dst",
".",
"endss",
"=",
"make",
"(",
"[",
"]",
"[",
"]",
"int",
",",
"len",
"(",
"src",
".",
"endss",
")",
")",
"\n",
"}",
"\n",
"}",
"else",
"if",
"len",
"(",
"src",
".",
"endss",
")",
"<",
"len",
"(",
"dst",
".",
"endss",
")",
"{",
"dst",
".",
"endss",
"=",
"(",
"dst",
".",
"endss",
")",
"[",
":",
"len",
"(",
"src",
".",
"endss",
")",
"]",
"\n",
"}",
"\n",
"}",
"else",
"{",
"dst",
".",
"endss",
"=",
"make",
"(",
"[",
"]",
"[",
"]",
"int",
",",
"len",
"(",
"src",
".",
"endss",
")",
")",
"\n",
"}",
"\n",
"deriveDeepCopy_12",
"(",
"dst",
".",
"endss",
",",
"src",
".",
"endss",
")",
"\n",
"}",
"\n",
"}"
] | // deriveDeepCopy_10 recursively copies the contents of src into dst. | [
"deriveDeepCopy_10",
"recursively",
"copies",
"the",
"contents",
"of",
"src",
"into",
"dst",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/derived.gen.go#L241-L265 |
151,649 | twpayne/go-geom | derived.gen.go | deriveDeepCopy_11 | func deriveDeepCopy_11(dst, src *geom0) {
dst.layout = src.layout
dst.stride = src.stride
if src.flatCoords == nil {
dst.flatCoords = nil
} else {
if dst.flatCoords != nil {
if len(src.flatCoords) > len(dst.flatCoords) {
if cap(dst.flatCoords) >= len(src.flatCoords) {
dst.flatCoords = (dst.flatCoords)[:len(src.flatCoords)]
} else {
dst.flatCoords = make([]float64, len(src.flatCoords))
}
} else if len(src.flatCoords) < len(dst.flatCoords) {
dst.flatCoords = (dst.flatCoords)[:len(src.flatCoords)]
}
} else {
dst.flatCoords = make([]float64, len(src.flatCoords))
}
copy(dst.flatCoords, src.flatCoords)
}
dst.srid = src.srid
} | go | func deriveDeepCopy_11(dst, src *geom0) {
dst.layout = src.layout
dst.stride = src.stride
if src.flatCoords == nil {
dst.flatCoords = nil
} else {
if dst.flatCoords != nil {
if len(src.flatCoords) > len(dst.flatCoords) {
if cap(dst.flatCoords) >= len(src.flatCoords) {
dst.flatCoords = (dst.flatCoords)[:len(src.flatCoords)]
} else {
dst.flatCoords = make([]float64, len(src.flatCoords))
}
} else if len(src.flatCoords) < len(dst.flatCoords) {
dst.flatCoords = (dst.flatCoords)[:len(src.flatCoords)]
}
} else {
dst.flatCoords = make([]float64, len(src.flatCoords))
}
copy(dst.flatCoords, src.flatCoords)
}
dst.srid = src.srid
} | [
"func",
"deriveDeepCopy_11",
"(",
"dst",
",",
"src",
"*",
"geom0",
")",
"{",
"dst",
".",
"layout",
"=",
"src",
".",
"layout",
"\n",
"dst",
".",
"stride",
"=",
"src",
".",
"stride",
"\n",
"if",
"src",
".",
"flatCoords",
"==",
"nil",
"{",
"dst",
".",
"flatCoords",
"=",
"nil",
"\n",
"}",
"else",
"{",
"if",
"dst",
".",
"flatCoords",
"!=",
"nil",
"{",
"if",
"len",
"(",
"src",
".",
"flatCoords",
")",
">",
"len",
"(",
"dst",
".",
"flatCoords",
")",
"{",
"if",
"cap",
"(",
"dst",
".",
"flatCoords",
")",
">=",
"len",
"(",
"src",
".",
"flatCoords",
")",
"{",
"dst",
".",
"flatCoords",
"=",
"(",
"dst",
".",
"flatCoords",
")",
"[",
":",
"len",
"(",
"src",
".",
"flatCoords",
")",
"]",
"\n",
"}",
"else",
"{",
"dst",
".",
"flatCoords",
"=",
"make",
"(",
"[",
"]",
"float64",
",",
"len",
"(",
"src",
".",
"flatCoords",
")",
")",
"\n",
"}",
"\n",
"}",
"else",
"if",
"len",
"(",
"src",
".",
"flatCoords",
")",
"<",
"len",
"(",
"dst",
".",
"flatCoords",
")",
"{",
"dst",
".",
"flatCoords",
"=",
"(",
"dst",
".",
"flatCoords",
")",
"[",
":",
"len",
"(",
"src",
".",
"flatCoords",
")",
"]",
"\n",
"}",
"\n",
"}",
"else",
"{",
"dst",
".",
"flatCoords",
"=",
"make",
"(",
"[",
"]",
"float64",
",",
"len",
"(",
"src",
".",
"flatCoords",
")",
")",
"\n",
"}",
"\n",
"copy",
"(",
"dst",
".",
"flatCoords",
",",
"src",
".",
"flatCoords",
")",
"\n",
"}",
"\n",
"dst",
".",
"srid",
"=",
"src",
".",
"srid",
"\n",
"}"
] | // deriveDeepCopy_11 recursively copies the contents of src into dst. | [
"deriveDeepCopy_11",
"recursively",
"copies",
"the",
"contents",
"of",
"src",
"into",
"dst",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/derived.gen.go#L268-L290 |
151,650 | twpayne/go-geom | derived.gen.go | deriveDeepCopy_12 | func deriveDeepCopy_12(dst, src [][]int) {
for src_i, src_value := range src {
if src_value == nil {
dst[src_i] = nil
} else {
if dst[src_i] != nil {
if len(src_value) > len(dst[src_i]) {
if cap(dst[src_i]) >= len(src_value) {
dst[src_i] = (dst[src_i])[:len(src_value)]
} else {
dst[src_i] = make([]int, len(src_value))
}
} else if len(src_value) < len(dst[src_i]) {
dst[src_i] = (dst[src_i])[:len(src_value)]
}
} else {
dst[src_i] = make([]int, len(src_value))
}
copy(dst[src_i], src_value)
}
}
} | go | func deriveDeepCopy_12(dst, src [][]int) {
for src_i, src_value := range src {
if src_value == nil {
dst[src_i] = nil
} else {
if dst[src_i] != nil {
if len(src_value) > len(dst[src_i]) {
if cap(dst[src_i]) >= len(src_value) {
dst[src_i] = (dst[src_i])[:len(src_value)]
} else {
dst[src_i] = make([]int, len(src_value))
}
} else if len(src_value) < len(dst[src_i]) {
dst[src_i] = (dst[src_i])[:len(src_value)]
}
} else {
dst[src_i] = make([]int, len(src_value))
}
copy(dst[src_i], src_value)
}
}
} | [
"func",
"deriveDeepCopy_12",
"(",
"dst",
",",
"src",
"[",
"]",
"[",
"]",
"int",
")",
"{",
"for",
"src_i",
",",
"src_value",
":=",
"range",
"src",
"{",
"if",
"src_value",
"==",
"nil",
"{",
"dst",
"[",
"src_i",
"]",
"=",
"nil",
"\n",
"}",
"else",
"{",
"if",
"dst",
"[",
"src_i",
"]",
"!=",
"nil",
"{",
"if",
"len",
"(",
"src_value",
")",
">",
"len",
"(",
"dst",
"[",
"src_i",
"]",
")",
"{",
"if",
"cap",
"(",
"dst",
"[",
"src_i",
"]",
")",
">=",
"len",
"(",
"src_value",
")",
"{",
"dst",
"[",
"src_i",
"]",
"=",
"(",
"dst",
"[",
"src_i",
"]",
")",
"[",
":",
"len",
"(",
"src_value",
")",
"]",
"\n",
"}",
"else",
"{",
"dst",
"[",
"src_i",
"]",
"=",
"make",
"(",
"[",
"]",
"int",
",",
"len",
"(",
"src_value",
")",
")",
"\n",
"}",
"\n",
"}",
"else",
"if",
"len",
"(",
"src_value",
")",
"<",
"len",
"(",
"dst",
"[",
"src_i",
"]",
")",
"{",
"dst",
"[",
"src_i",
"]",
"=",
"(",
"dst",
"[",
"src_i",
"]",
")",
"[",
":",
"len",
"(",
"src_value",
")",
"]",
"\n",
"}",
"\n",
"}",
"else",
"{",
"dst",
"[",
"src_i",
"]",
"=",
"make",
"(",
"[",
"]",
"int",
",",
"len",
"(",
"src_value",
")",
")",
"\n",
"}",
"\n",
"copy",
"(",
"dst",
"[",
"src_i",
"]",
",",
"src_value",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] | // deriveDeepCopy_12 recursively copies the contents of src into dst. | [
"deriveDeepCopy_12",
"recursively",
"copies",
"the",
"contents",
"of",
"src",
"into",
"dst",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/derived.gen.go#L293-L314 |
151,651 | twpayne/go-geom | linearring.go | NewLinearRingFlat | func NewLinearRingFlat(layout Layout, flatCoords []float64) *LinearRing {
g := new(LinearRing)
g.layout = layout
g.stride = layout.Stride()
g.flatCoords = flatCoords
return g
} | go | func NewLinearRingFlat(layout Layout, flatCoords []float64) *LinearRing {
g := new(LinearRing)
g.layout = layout
g.stride = layout.Stride()
g.flatCoords = flatCoords
return g
} | [
"func",
"NewLinearRingFlat",
"(",
"layout",
"Layout",
",",
"flatCoords",
"[",
"]",
"float64",
")",
"*",
"LinearRing",
"{",
"g",
":=",
"new",
"(",
"LinearRing",
")",
"\n",
"g",
".",
"layout",
"=",
"layout",
"\n",
"g",
".",
"stride",
"=",
"layout",
".",
"Stride",
"(",
")",
"\n",
"g",
".",
"flatCoords",
"=",
"flatCoords",
"\n",
"return",
"g",
"\n",
"}"
] | // NewLinearRingFlat returns a new LinearRing with the given flat coordinates. | [
"NewLinearRingFlat",
"returns",
"a",
"new",
"LinearRing",
"with",
"the",
"given",
"flat",
"coordinates",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/linearring.go#L14-L20 |
151,652 | twpayne/go-geom | linearring.go | Area | func (g *LinearRing) Area() float64 {
return doubleArea1(g.flatCoords, 0, len(g.flatCoords), g.stride) / 2
} | go | func (g *LinearRing) Area() float64 {
return doubleArea1(g.flatCoords, 0, len(g.flatCoords), g.stride) / 2
} | [
"func",
"(",
"g",
"*",
"LinearRing",
")",
"Area",
"(",
")",
"float64",
"{",
"return",
"doubleArea1",
"(",
"g",
".",
"flatCoords",
",",
"0",
",",
"len",
"(",
"g",
".",
"flatCoords",
")",
",",
"g",
".",
"stride",
")",
"/",
"2",
"\n",
"}"
] | // Area returns the the area. | [
"Area",
"returns",
"the",
"the",
"area",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/linearring.go#L23-L25 |
151,653 | twpayne/go-geom | linearring.go | Length | func (g *LinearRing) Length() float64 {
return length1(g.flatCoords, 0, len(g.flatCoords), g.stride)
} | go | func (g *LinearRing) Length() float64 {
return length1(g.flatCoords, 0, len(g.flatCoords), g.stride)
} | [
"func",
"(",
"g",
"*",
"LinearRing",
")",
"Length",
"(",
")",
"float64",
"{",
"return",
"length1",
"(",
"g",
".",
"flatCoords",
",",
"0",
",",
"len",
"(",
"g",
".",
"flatCoords",
")",
",",
"g",
".",
"stride",
")",
"\n",
"}"
] | // Length returns the length of the perimeter. | [
"Length",
"returns",
"the",
"length",
"of",
"the",
"perimeter",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/linearring.go#L38-L40 |
151,654 | twpayne/go-geom | linearring.go | MustSetCoords | func (g *LinearRing) MustSetCoords(coords []Coord) *LinearRing {
Must(g.SetCoords(coords))
return g
} | go | func (g *LinearRing) MustSetCoords(coords []Coord) *LinearRing {
Must(g.SetCoords(coords))
return g
} | [
"func",
"(",
"g",
"*",
"LinearRing",
")",
"MustSetCoords",
"(",
"coords",
"[",
"]",
"Coord",
")",
"*",
"LinearRing",
"{",
"Must",
"(",
"g",
".",
"SetCoords",
"(",
"coords",
")",
")",
"\n",
"return",
"g",
"\n",
"}"
] | // MustSetCoords sets the coordinates and panics if there is any error. | [
"MustSetCoords",
"sets",
"the",
"coordinates",
"and",
"panics",
"if",
"there",
"is",
"any",
"error",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/linearring.go#L43-L46 |
151,655 | twpayne/go-geom | linearring.go | SetCoords | func (g *LinearRing) SetCoords(coords []Coord) (*LinearRing, error) {
if err := g.setCoords(coords); err != nil {
return nil, err
}
return g, nil
} | go | func (g *LinearRing) SetCoords(coords []Coord) (*LinearRing, error) {
if err := g.setCoords(coords); err != nil {
return nil, err
}
return g, nil
} | [
"func",
"(",
"g",
"*",
"LinearRing",
")",
"SetCoords",
"(",
"coords",
"[",
"]",
"Coord",
")",
"(",
"*",
"LinearRing",
",",
"error",
")",
"{",
"if",
"err",
":=",
"g",
".",
"setCoords",
"(",
"coords",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"g",
",",
"nil",
"\n",
"}"
] | // SetCoords sets the coordinates. | [
"SetCoords",
"sets",
"the",
"coordinates",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/linearring.go#L49-L54 |
151,656 | twpayne/go-geom | xy/internal/coord_stack.go | Push | func (stack *CoordStack) Push(data []float64, idx int) []float64 {
c := data[idx : idx+stack.stride]
stack.Data = append(stack.Data, c...)
return c
} | go | func (stack *CoordStack) Push(data []float64, idx int) []float64 {
c := data[idx : idx+stack.stride]
stack.Data = append(stack.Data, c...)
return c
} | [
"func",
"(",
"stack",
"*",
"CoordStack",
")",
"Push",
"(",
"data",
"[",
"]",
"float64",
",",
"idx",
"int",
")",
"[",
"]",
"float64",
"{",
"c",
":=",
"data",
"[",
"idx",
":",
"idx",
"+",
"stack",
".",
"stride",
"]",
"\n",
"stack",
".",
"Data",
"=",
"append",
"(",
"stack",
".",
"Data",
",",
"c",
"...",
")",
"\n",
"return",
"c",
"\n",
"}"
] | // Push puts the coordinate at the location idx onto the stack. | [
"Push",
"puts",
"the",
"coordinate",
"at",
"the",
"location",
"idx",
"onto",
"the",
"stack",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/xy/internal/coord_stack.go#L21-L25 |
151,657 | twpayne/go-geom | xy/internal/coord_stack.go | Pop | func (stack *CoordStack) Pop() ([]float64, int) {
numOrds := len(stack.Data)
start := numOrds - stack.stride
coord := stack.Data[start:numOrds]
stack.Data = stack.Data[:start]
return coord, stack.Size()
} | go | func (stack *CoordStack) Pop() ([]float64, int) {
numOrds := len(stack.Data)
start := numOrds - stack.stride
coord := stack.Data[start:numOrds]
stack.Data = stack.Data[:start]
return coord, stack.Size()
} | [
"func",
"(",
"stack",
"*",
"CoordStack",
")",
"Pop",
"(",
")",
"(",
"[",
"]",
"float64",
",",
"int",
")",
"{",
"numOrds",
":=",
"len",
"(",
"stack",
".",
"Data",
")",
"\n",
"start",
":=",
"numOrds",
"-",
"stack",
".",
"stride",
"\n",
"coord",
":=",
"stack",
".",
"Data",
"[",
"start",
":",
"numOrds",
"]",
"\n",
"stack",
".",
"Data",
"=",
"stack",
".",
"Data",
"[",
":",
"start",
"]",
"\n",
"return",
"coord",
",",
"stack",
".",
"Size",
"(",
")",
"\n",
"}"
] | // Pop the last pushed coordinate off the stack and return the coordinate | [
"Pop",
"the",
"last",
"pushed",
"coordinate",
"off",
"the",
"stack",
"and",
"return",
"the",
"coordinate"
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/xy/internal/coord_stack.go#L28-L34 |
151,658 | twpayne/go-geom | xy/internal/coord_stack.go | Peek | func (stack *CoordStack) Peek() []float64 {
numOrds := len(stack.Data)
start := numOrds - stack.stride
coord := stack.Data[start:numOrds]
return coord
} | go | func (stack *CoordStack) Peek() []float64 {
numOrds := len(stack.Data)
start := numOrds - stack.stride
coord := stack.Data[start:numOrds]
return coord
} | [
"func",
"(",
"stack",
"*",
"CoordStack",
")",
"Peek",
"(",
")",
"[",
"]",
"float64",
"{",
"numOrds",
":=",
"len",
"(",
"stack",
".",
"Data",
")",
"\n",
"start",
":=",
"numOrds",
"-",
"stack",
".",
"stride",
"\n",
"coord",
":=",
"stack",
".",
"Data",
"[",
"start",
":",
"numOrds",
"]",
"\n",
"return",
"coord",
"\n",
"}"
] | // Peek returns the most recently pushed coord without modifying the stack | [
"Peek",
"returns",
"the",
"most",
"recently",
"pushed",
"coord",
"without",
"modifying",
"the",
"stack"
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/xy/internal/coord_stack.go#L37-L42 |
151,659 | twpayne/go-geom | xy/location/location.go | Symbol | func (t Type) Symbol() rune {
switch t {
case Exterior:
return 'e'
case Boundary:
return 'b'
case Interior:
return 'i'
case None:
return '-'
}
panic(fmt.Sprintf("Unknown location value: %v", int(t)))
} | go | func (t Type) Symbol() rune {
switch t {
case Exterior:
return 'e'
case Boundary:
return 'b'
case Interior:
return 'i'
case None:
return '-'
}
panic(fmt.Sprintf("Unknown location value: %v", int(t)))
} | [
"func",
"(",
"t",
"Type",
")",
"Symbol",
"(",
")",
"rune",
"{",
"switch",
"t",
"{",
"case",
"Exterior",
":",
"return",
"'e'",
"\n",
"case",
"Boundary",
":",
"return",
"'b'",
"\n",
"case",
"Interior",
":",
"return",
"'i'",
"\n",
"case",
"None",
":",
"return",
"'-'",
"\n",
"}",
"\n",
"panic",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"int",
"(",
"t",
")",
")",
")",
"\n",
"}"
] | // Symbol converts the location value to a location symbol, for example, Exterior => 'e'
// locationValue
// Returns either 'e', 'b', 'i' or '-' | [
"Symbol",
"converts",
"the",
"location",
"value",
"to",
"a",
"location",
"symbol",
"for",
"example",
"Exterior",
"=",
">",
"e",
"locationValue",
"Returns",
"either",
"e",
"b",
"i",
"or",
"-"
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/xy/location/location.go#L44-L56 |
151,660 | twpayne/go-geom | point.go | NewPoint | func NewPoint(l Layout) *Point {
return NewPointFlat(l, make([]float64, l.Stride()))
} | go | func NewPoint(l Layout) *Point {
return NewPointFlat(l, make([]float64, l.Stride()))
} | [
"func",
"NewPoint",
"(",
"l",
"Layout",
")",
"*",
"Point",
"{",
"return",
"NewPointFlat",
"(",
"l",
",",
"make",
"(",
"[",
"]",
"float64",
",",
"l",
".",
"Stride",
"(",
")",
")",
")",
"\n",
"}"
] | // NewPoint allocates a new Point with layout l and all values zero. | [
"NewPoint",
"allocates",
"a",
"new",
"Point",
"with",
"layout",
"l",
"and",
"all",
"values",
"zero",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/point.go#L9-L11 |
151,661 | twpayne/go-geom | point.go | NewPointFlat | func NewPointFlat(l Layout, flatCoords []float64) *Point {
g := new(Point)
g.layout = l
g.stride = l.Stride()
g.flatCoords = flatCoords
return g
} | go | func NewPointFlat(l Layout, flatCoords []float64) *Point {
g := new(Point)
g.layout = l
g.stride = l.Stride()
g.flatCoords = flatCoords
return g
} | [
"func",
"NewPointFlat",
"(",
"l",
"Layout",
",",
"flatCoords",
"[",
"]",
"float64",
")",
"*",
"Point",
"{",
"g",
":=",
"new",
"(",
"Point",
")",
"\n",
"g",
".",
"layout",
"=",
"l",
"\n",
"g",
".",
"stride",
"=",
"l",
".",
"Stride",
"(",
")",
"\n",
"g",
".",
"flatCoords",
"=",
"flatCoords",
"\n",
"return",
"g",
"\n",
"}"
] | // NewPointFlat allocates a new Point with layout l and flat coordinates flatCoords. | [
"NewPointFlat",
"allocates",
"a",
"new",
"Point",
"with",
"layout",
"l",
"and",
"flat",
"coordinates",
"flatCoords",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/point.go#L14-L20 |
151,662 | twpayne/go-geom | point.go | MustSetCoords | func (g *Point) MustSetCoords(coords Coord) *Point {
Must(g.SetCoords(coords))
return g
} | go | func (g *Point) MustSetCoords(coords Coord) *Point {
Must(g.SetCoords(coords))
return g
} | [
"func",
"(",
"g",
"*",
"Point",
")",
"MustSetCoords",
"(",
"coords",
"Coord",
")",
"*",
"Point",
"{",
"Must",
"(",
"g",
".",
"SetCoords",
"(",
"coords",
")",
")",
"\n",
"return",
"g",
"\n",
"}"
] | // MustSetCoords is like SetCoords but panics on any error. | [
"MustSetCoords",
"is",
"like",
"SetCoords",
"but",
"panics",
"on",
"any",
"error",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/point.go#L43-L46 |
151,663 | twpayne/go-geom | point.go | Z | func (g *Point) Z() float64 {
zIndex := g.layout.ZIndex()
if zIndex == -1 {
return 0
}
return g.flatCoords[zIndex]
} | go | func (g *Point) Z() float64 {
zIndex := g.layout.ZIndex()
if zIndex == -1 {
return 0
}
return g.flatCoords[zIndex]
} | [
"func",
"(",
"g",
"*",
"Point",
")",
"Z",
"(",
")",
"float64",
"{",
"zIndex",
":=",
"g",
".",
"layout",
".",
"ZIndex",
"(",
")",
"\n",
"if",
"zIndex",
"==",
"-",
"1",
"{",
"return",
"0",
"\n",
"}",
"\n",
"return",
"g",
".",
"flatCoords",
"[",
"zIndex",
"]",
"\n",
"}"
] | // Z returns g's Z-coordinate, or zero if g has no Z-coordinate. | [
"Z",
"returns",
"g",
"s",
"Z",
"-",
"coordinate",
"or",
"zero",
"if",
"g",
"has",
"no",
"Z",
"-",
"coordinate",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/point.go#L78-L84 |
151,664 | twpayne/go-geom | point.go | M | func (g *Point) M() float64 {
mIndex := g.layout.MIndex()
if mIndex == -1 {
return 0
}
return g.flatCoords[mIndex]
} | go | func (g *Point) M() float64 {
mIndex := g.layout.MIndex()
if mIndex == -1 {
return 0
}
return g.flatCoords[mIndex]
} | [
"func",
"(",
"g",
"*",
"Point",
")",
"M",
"(",
")",
"float64",
"{",
"mIndex",
":=",
"g",
".",
"layout",
".",
"MIndex",
"(",
")",
"\n",
"if",
"mIndex",
"==",
"-",
"1",
"{",
"return",
"0",
"\n",
"}",
"\n",
"return",
"g",
".",
"flatCoords",
"[",
"mIndex",
"]",
"\n",
"}"
] | // M returns g's M-coordinate, or zero if g has no M-coordinate. | [
"M",
"returns",
"g",
"s",
"M",
"-",
"coordinate",
"or",
"zero",
"if",
"g",
"has",
"no",
"M",
"-",
"coordinate",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/point.go#L87-L93 |
151,665 | twpayne/go-geom | encoding/ewkb/sql.go | Value | func (ls *LineString) Value() (driver.Value, error) {
if ls.LineString == nil {
return nil, nil
}
return value(ls.LineString)
} | go | func (ls *LineString) Value() (driver.Value, error) {
if ls.LineString == nil {
return nil, nil
}
return value(ls.LineString)
} | [
"func",
"(",
"ls",
"*",
"LineString",
")",
"Value",
"(",
")",
"(",
"driver",
".",
"Value",
",",
"error",
")",
"{",
"if",
"ls",
".",
"LineString",
"==",
"nil",
"{",
"return",
"nil",
",",
"nil",
"\n",
"}",
"\n",
"return",
"value",
"(",
"ls",
".",
"LineString",
")",
"\n",
"}"
] | // Value returns the EWKB encoding of ls. | [
"Value",
"returns",
"the",
"EWKB",
"encoding",
"of",
"ls",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/encoding/ewkb/sql.go#L126-L131 |
151,666 | twpayne/go-geom | encoding/ewkb/sql.go | Value | func (mls *MultiLineString) Value() (driver.Value, error) {
if mls.MultiLineString == nil {
return nil, nil
}
return value(mls.MultiLineString)
} | go | func (mls *MultiLineString) Value() (driver.Value, error) {
if mls.MultiLineString == nil {
return nil, nil
}
return value(mls.MultiLineString)
} | [
"func",
"(",
"mls",
"*",
"MultiLineString",
")",
"Value",
"(",
")",
"(",
"driver",
".",
"Value",
",",
"error",
")",
"{",
"if",
"mls",
".",
"MultiLineString",
"==",
"nil",
"{",
"return",
"nil",
",",
"nil",
"\n",
"}",
"\n",
"return",
"value",
"(",
"mls",
".",
"MultiLineString",
")",
"\n",
"}"
] | // Value returns the EWKB encoding of mls. | [
"Value",
"returns",
"the",
"EWKB",
"encoding",
"of",
"mls",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/encoding/ewkb/sql.go#L231-L236 |
151,667 | twpayne/go-geom | encoding/ewkb/sql.go | Value | func (gc *GeometryCollection) Value() (driver.Value, error) {
if gc.GeometryCollection == nil {
return nil, nil
}
return value(gc.GeometryCollection)
} | go | func (gc *GeometryCollection) Value() (driver.Value, error) {
if gc.GeometryCollection == nil {
return nil, nil
}
return value(gc.GeometryCollection)
} | [
"func",
"(",
"gc",
"*",
"GeometryCollection",
")",
"Value",
"(",
")",
"(",
"driver",
".",
"Value",
",",
"error",
")",
"{",
"if",
"gc",
".",
"GeometryCollection",
"==",
"nil",
"{",
"return",
"nil",
",",
"nil",
"\n",
"}",
"\n",
"return",
"value",
"(",
"gc",
".",
"GeometryCollection",
")",
"\n",
"}"
] | // Value returns the EWKB encoding of gc. | [
"Value",
"returns",
"the",
"EWKB",
"encoding",
"of",
"gc",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/encoding/ewkb/sql.go#L301-L306 |
151,668 | twpayne/go-geom | encoding/wkbcommon/wkbcommon.go | ReadFlatCoords0 | func ReadFlatCoords0(r io.Reader, byteOrder binary.ByteOrder, stride int) ([]float64, error) {
coord := make([]float64, stride)
if err := ReadFloatArray(r, byteOrder, coord); err != nil {
return nil, err
}
return coord, nil
} | go | func ReadFlatCoords0(r io.Reader, byteOrder binary.ByteOrder, stride int) ([]float64, error) {
coord := make([]float64, stride)
if err := ReadFloatArray(r, byteOrder, coord); err != nil {
return nil, err
}
return coord, nil
} | [
"func",
"ReadFlatCoords0",
"(",
"r",
"io",
".",
"Reader",
",",
"byteOrder",
"binary",
".",
"ByteOrder",
",",
"stride",
"int",
")",
"(",
"[",
"]",
"float64",
",",
"error",
")",
"{",
"coord",
":=",
"make",
"(",
"[",
"]",
"float64",
",",
"stride",
")",
"\n",
"if",
"err",
":=",
"ReadFloatArray",
"(",
"r",
",",
"byteOrder",
",",
"coord",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"coord",
",",
"nil",
"\n",
"}"
] | // ReadFlatCoords0 reads flat coordinates 0. | [
"ReadFlatCoords0",
"reads",
"flat",
"coordinates",
"0",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/encoding/wkbcommon/wkbcommon.go#L107-L113 |
151,669 | twpayne/go-geom | encoding/wkbcommon/wkbcommon.go | ReadFlatCoords1 | func ReadFlatCoords1(r io.Reader, byteOrder binary.ByteOrder, stride int) ([]float64, error) {
n, err := ReadUInt32(r, byteOrder)
if err != nil {
return nil, err
}
if limit := MaxGeometryElements[1]; limit >= 0 && int(n) > limit {
return nil, ErrGeometryTooLarge{Level: 1, N: int(n), Limit: limit}
}
flatCoords := make([]float64, int(n)*stride)
if err := ReadFloatArray(r, byteOrder, flatCoords); err != nil {
return nil, err
}
return flatCoords, nil
} | go | func ReadFlatCoords1(r io.Reader, byteOrder binary.ByteOrder, stride int) ([]float64, error) {
n, err := ReadUInt32(r, byteOrder)
if err != nil {
return nil, err
}
if limit := MaxGeometryElements[1]; limit >= 0 && int(n) > limit {
return nil, ErrGeometryTooLarge{Level: 1, N: int(n), Limit: limit}
}
flatCoords := make([]float64, int(n)*stride)
if err := ReadFloatArray(r, byteOrder, flatCoords); err != nil {
return nil, err
}
return flatCoords, nil
} | [
"func",
"ReadFlatCoords1",
"(",
"r",
"io",
".",
"Reader",
",",
"byteOrder",
"binary",
".",
"ByteOrder",
",",
"stride",
"int",
")",
"(",
"[",
"]",
"float64",
",",
"error",
")",
"{",
"n",
",",
"err",
":=",
"ReadUInt32",
"(",
"r",
",",
"byteOrder",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"if",
"limit",
":=",
"MaxGeometryElements",
"[",
"1",
"]",
";",
"limit",
">=",
"0",
"&&",
"int",
"(",
"n",
")",
">",
"limit",
"{",
"return",
"nil",
",",
"ErrGeometryTooLarge",
"{",
"Level",
":",
"1",
",",
"N",
":",
"int",
"(",
"n",
")",
",",
"Limit",
":",
"limit",
"}",
"\n",
"}",
"\n",
"flatCoords",
":=",
"make",
"(",
"[",
"]",
"float64",
",",
"int",
"(",
"n",
")",
"*",
"stride",
")",
"\n",
"if",
"err",
":=",
"ReadFloatArray",
"(",
"r",
",",
"byteOrder",
",",
"flatCoords",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"flatCoords",
",",
"nil",
"\n",
"}"
] | // ReadFlatCoords1 reads flat coordinates 1. | [
"ReadFlatCoords1",
"reads",
"flat",
"coordinates",
"1",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/encoding/wkbcommon/wkbcommon.go#L116-L129 |
151,670 | twpayne/go-geom | encoding/wkbcommon/wkbcommon.go | ReadFlatCoords2 | func ReadFlatCoords2(r io.Reader, byteOrder binary.ByteOrder, stride int) ([]float64, []int, error) {
n, err := ReadUInt32(r, byteOrder)
if err != nil {
return nil, nil, err
}
if limit := MaxGeometryElements[2]; limit >= 0 && int(n) > limit {
return nil, nil, ErrGeometryTooLarge{Level: 2, N: int(n), Limit: limit}
}
var flatCoordss []float64
var ends []int
for i := 0; i < int(n); i++ {
flatCoords, err := ReadFlatCoords1(r, byteOrder, stride)
if err != nil {
return nil, nil, err
}
flatCoordss = append(flatCoordss, flatCoords...)
ends = append(ends, len(flatCoordss))
}
return flatCoordss, ends, nil
} | go | func ReadFlatCoords2(r io.Reader, byteOrder binary.ByteOrder, stride int) ([]float64, []int, error) {
n, err := ReadUInt32(r, byteOrder)
if err != nil {
return nil, nil, err
}
if limit := MaxGeometryElements[2]; limit >= 0 && int(n) > limit {
return nil, nil, ErrGeometryTooLarge{Level: 2, N: int(n), Limit: limit}
}
var flatCoordss []float64
var ends []int
for i := 0; i < int(n); i++ {
flatCoords, err := ReadFlatCoords1(r, byteOrder, stride)
if err != nil {
return nil, nil, err
}
flatCoordss = append(flatCoordss, flatCoords...)
ends = append(ends, len(flatCoordss))
}
return flatCoordss, ends, nil
} | [
"func",
"ReadFlatCoords2",
"(",
"r",
"io",
".",
"Reader",
",",
"byteOrder",
"binary",
".",
"ByteOrder",
",",
"stride",
"int",
")",
"(",
"[",
"]",
"float64",
",",
"[",
"]",
"int",
",",
"error",
")",
"{",
"n",
",",
"err",
":=",
"ReadUInt32",
"(",
"r",
",",
"byteOrder",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"nil",
",",
"err",
"\n",
"}",
"\n",
"if",
"limit",
":=",
"MaxGeometryElements",
"[",
"2",
"]",
";",
"limit",
">=",
"0",
"&&",
"int",
"(",
"n",
")",
">",
"limit",
"{",
"return",
"nil",
",",
"nil",
",",
"ErrGeometryTooLarge",
"{",
"Level",
":",
"2",
",",
"N",
":",
"int",
"(",
"n",
")",
",",
"Limit",
":",
"limit",
"}",
"\n",
"}",
"\n",
"var",
"flatCoordss",
"[",
"]",
"float64",
"\n",
"var",
"ends",
"[",
"]",
"int",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"int",
"(",
"n",
")",
";",
"i",
"++",
"{",
"flatCoords",
",",
"err",
":=",
"ReadFlatCoords1",
"(",
"r",
",",
"byteOrder",
",",
"stride",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"nil",
",",
"err",
"\n",
"}",
"\n",
"flatCoordss",
"=",
"append",
"(",
"flatCoordss",
",",
"flatCoords",
"...",
")",
"\n",
"ends",
"=",
"append",
"(",
"ends",
",",
"len",
"(",
"flatCoordss",
")",
")",
"\n",
"}",
"\n",
"return",
"flatCoordss",
",",
"ends",
",",
"nil",
"\n",
"}"
] | // ReadFlatCoords2 reads flat coordinates 2. | [
"ReadFlatCoords2",
"reads",
"flat",
"coordinates",
"2",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/encoding/wkbcommon/wkbcommon.go#L132-L151 |
151,671 | twpayne/go-geom | encoding/wkbcommon/wkbcommon.go | WriteFlatCoords0 | func WriteFlatCoords0(w io.Writer, byteOrder binary.ByteOrder, coord []float64) error {
return WriteFloatArray(w, byteOrder, coord)
} | go | func WriteFlatCoords0(w io.Writer, byteOrder binary.ByteOrder, coord []float64) error {
return WriteFloatArray(w, byteOrder, coord)
} | [
"func",
"WriteFlatCoords0",
"(",
"w",
"io",
".",
"Writer",
",",
"byteOrder",
"binary",
".",
"ByteOrder",
",",
"coord",
"[",
"]",
"float64",
")",
"error",
"{",
"return",
"WriteFloatArray",
"(",
"w",
",",
"byteOrder",
",",
"coord",
")",
"\n",
"}"
] | // WriteFlatCoords0 writes flat coordinates 0. | [
"WriteFlatCoords0",
"writes",
"flat",
"coordinates",
"0",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/encoding/wkbcommon/wkbcommon.go#L154-L156 |
151,672 | twpayne/go-geom | encoding/wkbcommon/wkbcommon.go | WriteFlatCoords1 | func WriteFlatCoords1(w io.Writer, byteOrder binary.ByteOrder, coords []float64, stride int) error {
if err := WriteUInt32(w, byteOrder, uint32(len(coords)/stride)); err != nil {
return err
}
return WriteFloatArray(w, byteOrder, coords)
} | go | func WriteFlatCoords1(w io.Writer, byteOrder binary.ByteOrder, coords []float64, stride int) error {
if err := WriteUInt32(w, byteOrder, uint32(len(coords)/stride)); err != nil {
return err
}
return WriteFloatArray(w, byteOrder, coords)
} | [
"func",
"WriteFlatCoords1",
"(",
"w",
"io",
".",
"Writer",
",",
"byteOrder",
"binary",
".",
"ByteOrder",
",",
"coords",
"[",
"]",
"float64",
",",
"stride",
"int",
")",
"error",
"{",
"if",
"err",
":=",
"WriteUInt32",
"(",
"w",
",",
"byteOrder",
",",
"uint32",
"(",
"len",
"(",
"coords",
")",
"/",
"stride",
")",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"return",
"WriteFloatArray",
"(",
"w",
",",
"byteOrder",
",",
"coords",
")",
"\n",
"}"
] | // WriteFlatCoords1 writes flat coordinates 1. | [
"WriteFlatCoords1",
"writes",
"flat",
"coordinates",
"1",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/encoding/wkbcommon/wkbcommon.go#L159-L164 |
151,673 | twpayne/go-geom | encoding/wkbcommon/wkbcommon.go | WriteFlatCoords2 | func WriteFlatCoords2(w io.Writer, byteOrder binary.ByteOrder, flatCoords []float64, ends []int, stride int) error {
if err := WriteUInt32(w, byteOrder, uint32(len(ends))); err != nil {
return err
}
offset := 0
for _, end := range ends {
if err := WriteFlatCoords1(w, byteOrder, flatCoords[offset:end], stride); err != nil {
return err
}
offset = end
}
return nil
} | go | func WriteFlatCoords2(w io.Writer, byteOrder binary.ByteOrder, flatCoords []float64, ends []int, stride int) error {
if err := WriteUInt32(w, byteOrder, uint32(len(ends))); err != nil {
return err
}
offset := 0
for _, end := range ends {
if err := WriteFlatCoords1(w, byteOrder, flatCoords[offset:end], stride); err != nil {
return err
}
offset = end
}
return nil
} | [
"func",
"WriteFlatCoords2",
"(",
"w",
"io",
".",
"Writer",
",",
"byteOrder",
"binary",
".",
"ByteOrder",
",",
"flatCoords",
"[",
"]",
"float64",
",",
"ends",
"[",
"]",
"int",
",",
"stride",
"int",
")",
"error",
"{",
"if",
"err",
":=",
"WriteUInt32",
"(",
"w",
",",
"byteOrder",
",",
"uint32",
"(",
"len",
"(",
"ends",
")",
")",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"offset",
":=",
"0",
"\n",
"for",
"_",
",",
"end",
":=",
"range",
"ends",
"{",
"if",
"err",
":=",
"WriteFlatCoords1",
"(",
"w",
",",
"byteOrder",
",",
"flatCoords",
"[",
"offset",
":",
"end",
"]",
",",
"stride",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"offset",
"=",
"end",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // WriteFlatCoords2 writes flat coordinates 2. | [
"WriteFlatCoords2",
"writes",
"flat",
"coordinates",
"2",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/encoding/wkbcommon/wkbcommon.go#L167-L179 |
151,674 | twpayne/go-geom | sorting/sorting.go | IsLess2D | func IsLess2D(v1, v2 []float64) bool {
if v1[0] < v2[0] {
return true
}
if v1[0] > v2[0] {
return false
}
if v1[1] < v2[1] {
return true
}
return false
} | go | func IsLess2D(v1, v2 []float64) bool {
if v1[0] < v2[0] {
return true
}
if v1[0] > v2[0] {
return false
}
if v1[1] < v2[1] {
return true
}
return false
} | [
"func",
"IsLess2D",
"(",
"v1",
",",
"v2",
"[",
"]",
"float64",
")",
"bool",
"{",
"if",
"v1",
"[",
"0",
"]",
"<",
"v2",
"[",
"0",
"]",
"{",
"return",
"true",
"\n",
"}",
"\n",
"if",
"v1",
"[",
"0",
"]",
">",
"v2",
"[",
"0",
"]",
"{",
"return",
"false",
"\n",
"}",
"\n",
"if",
"v1",
"[",
"1",
"]",
"<",
"v2",
"[",
"1",
"]",
"{",
"return",
"true",
"\n",
"}",
"\n\n",
"return",
"false",
"\n",
"}"
] | // IsLess2D is a comparator that compares based on the size of the x and y coords.
//
// First the x coordinates are compared.
// if x coords are equal then the y coords are compared | [
"IsLess2D",
"is",
"a",
"comparator",
"that",
"compares",
"based",
"on",
"the",
"size",
"of",
"the",
"x",
"and",
"y",
"coords",
".",
"First",
"the",
"x",
"coordinates",
"are",
"compared",
".",
"if",
"x",
"coords",
"are",
"equal",
"then",
"the",
"y",
"coords",
"are",
"compared"
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/sorting/sorting.go#L24-L36 |
151,675 | twpayne/go-geom | sorting/sorting.go | NewFlatCoordSorting2D | func NewFlatCoordSorting2D(layout geom.Layout, coordData []float64) FlatCoord {
return NewFlatCoordSorting(layout, coordData, IsLess2D)
} | go | func NewFlatCoordSorting2D(layout geom.Layout, coordData []float64) FlatCoord {
return NewFlatCoordSorting(layout, coordData, IsLess2D)
} | [
"func",
"NewFlatCoordSorting2D",
"(",
"layout",
"geom",
".",
"Layout",
",",
"coordData",
"[",
"]",
"float64",
")",
"FlatCoord",
"{",
"return",
"NewFlatCoordSorting",
"(",
"layout",
",",
"coordData",
",",
"IsLess2D",
")",
"\n",
"}"
] | // NewFlatCoordSorting2D creates a Compare2D based sort.Interface implementation | [
"NewFlatCoordSorting2D",
"creates",
"a",
"Compare2D",
"based",
"sort",
".",
"Interface",
"implementation"
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/sorting/sorting.go#L39-L41 |
151,676 | twpayne/go-geom | sorting/sorting.go | NewFlatCoordSorting | func NewFlatCoordSorting(layout geom.Layout, coordData []float64, comparator IsLess) FlatCoord {
return FlatCoord{
isLess: comparator,
coords: coordData,
layout: layout,
stride: layout.Stride(),
}
} | go | func NewFlatCoordSorting(layout geom.Layout, coordData []float64, comparator IsLess) FlatCoord {
return FlatCoord{
isLess: comparator,
coords: coordData,
layout: layout,
stride: layout.Stride(),
}
} | [
"func",
"NewFlatCoordSorting",
"(",
"layout",
"geom",
".",
"Layout",
",",
"coordData",
"[",
"]",
"float64",
",",
"comparator",
"IsLess",
")",
"FlatCoord",
"{",
"return",
"FlatCoord",
"{",
"isLess",
":",
"comparator",
",",
"coords",
":",
"coordData",
",",
"layout",
":",
"layout",
",",
"stride",
":",
"layout",
".",
"Stride",
"(",
")",
",",
"}",
"\n",
"}"
] | // NewFlatCoordSorting creates a sort.Interface implementation based on the Comparator function | [
"NewFlatCoordSorting",
"creates",
"a",
"sort",
".",
"Interface",
"implementation",
"based",
"on",
"the",
"Comparator",
"function"
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/sorting/sorting.go#L44-L51 |
151,677 | twpayne/go-geom | linestring.go | NewLineStringFlat | func NewLineStringFlat(layout Layout, flatCoords []float64) *LineString {
g := new(LineString)
g.layout = layout
g.stride = layout.Stride()
g.flatCoords = flatCoords
return g
} | go | func NewLineStringFlat(layout Layout, flatCoords []float64) *LineString {
g := new(LineString)
g.layout = layout
g.stride = layout.Stride()
g.flatCoords = flatCoords
return g
} | [
"func",
"NewLineStringFlat",
"(",
"layout",
"Layout",
",",
"flatCoords",
"[",
"]",
"float64",
")",
"*",
"LineString",
"{",
"g",
":=",
"new",
"(",
"LineString",
")",
"\n",
"g",
".",
"layout",
"=",
"layout",
"\n",
"g",
".",
"stride",
"=",
"layout",
".",
"Stride",
"(",
")",
"\n",
"g",
".",
"flatCoords",
"=",
"flatCoords",
"\n",
"return",
"g",
"\n",
"}"
] | // NewLineStringFlat returns a new LineString with layout l and control points
// flatCoords. | [
"NewLineStringFlat",
"returns",
"a",
"new",
"LineString",
"with",
"layout",
"l",
"and",
"control",
"points",
"flatCoords",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/linestring.go#L16-L22 |
151,678 | twpayne/go-geom | linestring.go | Interpolate | func (g *LineString) Interpolate(val float64, dim int) (int, float64) {
n := len(g.flatCoords)
if n == 0 {
panic("geom: empty linestring")
}
if val <= g.flatCoords[dim] {
return 0, 0
}
if g.flatCoords[n-g.stride+dim] <= val {
return (n - 1) / g.stride, 0
}
low := 0
high := n / g.stride
for low < high {
mid := (low + high) / 2
if val < g.flatCoords[mid*g.stride+dim] {
high = mid
} else {
low = mid + 1
}
}
low--
val0 := g.flatCoords[low*g.stride+dim]
if val == val0 {
return low, 0
}
val1 := g.flatCoords[(low+1)*g.stride+dim]
return low, (val - val0) / (val1 - val0)
} | go | func (g *LineString) Interpolate(val float64, dim int) (int, float64) {
n := len(g.flatCoords)
if n == 0 {
panic("geom: empty linestring")
}
if val <= g.flatCoords[dim] {
return 0, 0
}
if g.flatCoords[n-g.stride+dim] <= val {
return (n - 1) / g.stride, 0
}
low := 0
high := n / g.stride
for low < high {
mid := (low + high) / 2
if val < g.flatCoords[mid*g.stride+dim] {
high = mid
} else {
low = mid + 1
}
}
low--
val0 := g.flatCoords[low*g.stride+dim]
if val == val0 {
return low, 0
}
val1 := g.flatCoords[(low+1)*g.stride+dim]
return low, (val - val0) / (val1 - val0)
} | [
"func",
"(",
"g",
"*",
"LineString",
")",
"Interpolate",
"(",
"val",
"float64",
",",
"dim",
"int",
")",
"(",
"int",
",",
"float64",
")",
"{",
"n",
":=",
"len",
"(",
"g",
".",
"flatCoords",
")",
"\n",
"if",
"n",
"==",
"0",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"val",
"<=",
"g",
".",
"flatCoords",
"[",
"dim",
"]",
"{",
"return",
"0",
",",
"0",
"\n",
"}",
"\n",
"if",
"g",
".",
"flatCoords",
"[",
"n",
"-",
"g",
".",
"stride",
"+",
"dim",
"]",
"<=",
"val",
"{",
"return",
"(",
"n",
"-",
"1",
")",
"/",
"g",
".",
"stride",
",",
"0",
"\n",
"}",
"\n",
"low",
":=",
"0",
"\n",
"high",
":=",
"n",
"/",
"g",
".",
"stride",
"\n",
"for",
"low",
"<",
"high",
"{",
"mid",
":=",
"(",
"low",
"+",
"high",
")",
"/",
"2",
"\n",
"if",
"val",
"<",
"g",
".",
"flatCoords",
"[",
"mid",
"*",
"g",
".",
"stride",
"+",
"dim",
"]",
"{",
"high",
"=",
"mid",
"\n",
"}",
"else",
"{",
"low",
"=",
"mid",
"+",
"1",
"\n",
"}",
"\n",
"}",
"\n",
"low",
"--",
"\n",
"val0",
":=",
"g",
".",
"flatCoords",
"[",
"low",
"*",
"g",
".",
"stride",
"+",
"dim",
"]",
"\n",
"if",
"val",
"==",
"val0",
"{",
"return",
"low",
",",
"0",
"\n",
"}",
"\n",
"val1",
":=",
"g",
".",
"flatCoords",
"[",
"(",
"low",
"+",
"1",
")",
"*",
"g",
".",
"stride",
"+",
"dim",
"]",
"\n",
"return",
"low",
",",
"(",
"val",
"-",
"val0",
")",
"/",
"(",
"val1",
"-",
"val0",
")",
"\n",
"}"
] | // Interpolate returns the index and delta of val in dimension dim. | [
"Interpolate",
"returns",
"the",
"index",
"and",
"delta",
"of",
"val",
"in",
"dimension",
"dim",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/linestring.go#L40-L68 |
151,679 | twpayne/go-geom | linestring.go | Length | func (g *LineString) Length() float64 {
return length1(g.flatCoords, 0, len(g.flatCoords), g.stride)
} | go | func (g *LineString) Length() float64 {
return length1(g.flatCoords, 0, len(g.flatCoords), g.stride)
} | [
"func",
"(",
"g",
"*",
"LineString",
")",
"Length",
"(",
")",
"float64",
"{",
"return",
"length1",
"(",
"g",
".",
"flatCoords",
",",
"0",
",",
"len",
"(",
"g",
".",
"flatCoords",
")",
",",
"g",
".",
"stride",
")",
"\n",
"}"
] | // Length returns the length of g. | [
"Length",
"returns",
"the",
"length",
"of",
"g",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/linestring.go#L71-L73 |
151,680 | twpayne/go-geom | linestring.go | MustSetCoords | func (g *LineString) MustSetCoords(coords []Coord) *LineString {
Must(g.SetCoords(coords))
return g
} | go | func (g *LineString) MustSetCoords(coords []Coord) *LineString {
Must(g.SetCoords(coords))
return g
} | [
"func",
"(",
"g",
"*",
"LineString",
")",
"MustSetCoords",
"(",
"coords",
"[",
"]",
"Coord",
")",
"*",
"LineString",
"{",
"Must",
"(",
"g",
".",
"SetCoords",
"(",
"coords",
")",
")",
"\n",
"return",
"g",
"\n",
"}"
] | // MustSetCoords is like SetCoords but it panics on any error. | [
"MustSetCoords",
"is",
"like",
"SetCoords",
"but",
"it",
"panics",
"on",
"any",
"error",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/linestring.go#L76-L79 |
151,681 | twpayne/go-geom | linestring.go | SubLineString | func (g *LineString) SubLineString(start, stop int) *LineString {
return NewLineStringFlat(g.layout, g.flatCoords[start*g.stride:stop*g.stride])
} | go | func (g *LineString) SubLineString(start, stop int) *LineString {
return NewLineStringFlat(g.layout, g.flatCoords[start*g.stride:stop*g.stride])
} | [
"func",
"(",
"g",
"*",
"LineString",
")",
"SubLineString",
"(",
"start",
",",
"stop",
"int",
")",
"*",
"LineString",
"{",
"return",
"NewLineStringFlat",
"(",
"g",
".",
"layout",
",",
"g",
".",
"flatCoords",
"[",
"start",
"*",
"g",
".",
"stride",
":",
"stop",
"*",
"g",
".",
"stride",
"]",
")",
"\n",
"}"
] | // SubLineString returns a LineString from starts at index start and stops at
// index stop of g. The returned LineString aliases g. | [
"SubLineString",
"returns",
"a",
"LineString",
"from",
"starts",
"at",
"index",
"start",
"and",
"stops",
"at",
"index",
"stop",
"of",
"g",
".",
"The",
"returned",
"LineString",
"aliases",
"g",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/linestring.go#L97-L99 |
151,682 | twpayne/go-geom | transform/tree_set.go | NewTreeSet | func NewTreeSet(layout geom.Layout, compare Compare) *TreeSet {
return &TreeSet{
layout: layout,
stride: layout.Stride(),
compare: compare,
}
} | go | func NewTreeSet(layout geom.Layout, compare Compare) *TreeSet {
return &TreeSet{
layout: layout,
stride: layout.Stride(),
compare: compare,
}
} | [
"func",
"NewTreeSet",
"(",
"layout",
"geom",
".",
"Layout",
",",
"compare",
"Compare",
")",
"*",
"TreeSet",
"{",
"return",
"&",
"TreeSet",
"{",
"layout",
":",
"layout",
",",
"stride",
":",
"layout",
".",
"Stride",
"(",
")",
",",
"compare",
":",
"compare",
",",
"}",
"\n",
"}"
] | // NewTreeSet creates a new TreeSet instance | [
"NewTreeSet",
"creates",
"a",
"new",
"TreeSet",
"instance"
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/transform/tree_set.go#L32-L38 |
151,683 | twpayne/go-geom | transform/tree_set.go | Insert | func (set *TreeSet) Insert(coord geom.Coord) bool {
if set.stride == 0 {
set.stride = set.layout.Stride()
}
if len(coord) < set.stride {
panic(fmt.Sprintf("Coordinate inserted into tree does not have a sufficient number of points for the provided layout. Length of Coord was %v but should have been %v", len(coord), set.stride))
}
tree, added := set.insertImpl(set.tree, coord)
if added {
set.tree = tree
set.size++
}
return added
} | go | func (set *TreeSet) Insert(coord geom.Coord) bool {
if set.stride == 0 {
set.stride = set.layout.Stride()
}
if len(coord) < set.stride {
panic(fmt.Sprintf("Coordinate inserted into tree does not have a sufficient number of points for the provided layout. Length of Coord was %v but should have been %v", len(coord), set.stride))
}
tree, added := set.insertImpl(set.tree, coord)
if added {
set.tree = tree
set.size++
}
return added
} | [
"func",
"(",
"set",
"*",
"TreeSet",
")",
"Insert",
"(",
"coord",
"geom",
".",
"Coord",
")",
"bool",
"{",
"if",
"set",
".",
"stride",
"==",
"0",
"{",
"set",
".",
"stride",
"=",
"set",
".",
"layout",
".",
"Stride",
"(",
")",
"\n",
"}",
"\n",
"if",
"len",
"(",
"coord",
")",
"<",
"set",
".",
"stride",
"{",
"panic",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"len",
"(",
"coord",
")",
",",
"set",
".",
"stride",
")",
")",
"\n",
"}",
"\n",
"tree",
",",
"added",
":=",
"set",
".",
"insertImpl",
"(",
"set",
".",
"tree",
",",
"coord",
")",
"\n",
"if",
"added",
"{",
"set",
".",
"tree",
"=",
"tree",
"\n",
"set",
".",
"size",
"++",
"\n",
"}",
"\n\n",
"return",
"added",
"\n",
"}"
] | // Insert adds a new coordinate to the tree set
// the coordinate must be the same size as the Stride of the layout provided
// when constructing the TreeSet
// Returns true if the coordinate was added, false if it was already in the tree | [
"Insert",
"adds",
"a",
"new",
"coordinate",
"to",
"the",
"tree",
"set",
"the",
"coordinate",
"must",
"be",
"the",
"same",
"size",
"as",
"the",
"Stride",
"of",
"the",
"layout",
"provided",
"when",
"constructing",
"the",
"TreeSet",
"Returns",
"true",
"if",
"the",
"coordinate",
"was",
"added",
"false",
"if",
"it",
"was",
"already",
"in",
"the",
"tree"
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/transform/tree_set.go#L44-L58 |
151,684 | twpayne/go-geom | transform/tree_set.go | ToFlatArray | func (set *TreeSet) ToFlatArray() []float64 {
stride := set.layout.Stride()
array := make([]float64, set.size*stride)
i := 0
set.walk(set.tree, func(v []float64) {
for j := 0; j < stride; j++ {
array[i+j] = v[j]
}
i += stride
})
return array
} | go | func (set *TreeSet) ToFlatArray() []float64 {
stride := set.layout.Stride()
array := make([]float64, set.size*stride)
i := 0
set.walk(set.tree, func(v []float64) {
for j := 0; j < stride; j++ {
array[i+j] = v[j]
}
i += stride
})
return array
} | [
"func",
"(",
"set",
"*",
"TreeSet",
")",
"ToFlatArray",
"(",
")",
"[",
"]",
"float64",
"{",
"stride",
":=",
"set",
".",
"layout",
".",
"Stride",
"(",
")",
"\n",
"array",
":=",
"make",
"(",
"[",
"]",
"float64",
",",
"set",
".",
"size",
"*",
"stride",
")",
"\n\n",
"i",
":=",
"0",
"\n",
"set",
".",
"walk",
"(",
"set",
".",
"tree",
",",
"func",
"(",
"v",
"[",
"]",
"float64",
")",
"{",
"for",
"j",
":=",
"0",
";",
"j",
"<",
"stride",
";",
"j",
"++",
"{",
"array",
"[",
"i",
"+",
"j",
"]",
"=",
"v",
"[",
"j",
"]",
"\n",
"}",
"\n",
"i",
"+=",
"stride",
"\n",
"}",
")",
"\n\n",
"return",
"array",
"\n",
"}"
] | // ToFlatArray returns an array of floats containing all the coordinates in the TreeSet | [
"ToFlatArray",
"returns",
"an",
"array",
"of",
"floats",
"containing",
"all",
"the",
"coordinates",
"in",
"the",
"TreeSet"
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/transform/tree_set.go#L61-L74 |
151,685 | twpayne/go-geom | xy/internal/lineintersector/line_intersector.go | PointIntersectsLine | func PointIntersectsLine(strategy Strategy, point, lineStart, lineEnd geom.Coord) (hasIntersection bool) {
intersectorData := &lineIntersectorData{
strategy: strategy,
inputLines: [2][2]geom.Coord{{lineStart, lineEnd}, {}},
intersectionPoints: [2]geom.Coord{{0, 0}, {0, 0}},
}
intersectorData.pa = intersectorData.intersectionPoints[0]
intersectorData.pb = intersectorData.intersectionPoints[1]
strategy.computePointOnLineIntersection(intersectorData, point, lineStart, lineEnd)
return intersectorData.intersectionType != lineintersection.NoIntersection
} | go | func PointIntersectsLine(strategy Strategy, point, lineStart, lineEnd geom.Coord) (hasIntersection bool) {
intersectorData := &lineIntersectorData{
strategy: strategy,
inputLines: [2][2]geom.Coord{{lineStart, lineEnd}, {}},
intersectionPoints: [2]geom.Coord{{0, 0}, {0, 0}},
}
intersectorData.pa = intersectorData.intersectionPoints[0]
intersectorData.pb = intersectorData.intersectionPoints[1]
strategy.computePointOnLineIntersection(intersectorData, point, lineStart, lineEnd)
return intersectorData.intersectionType != lineintersection.NoIntersection
} | [
"func",
"PointIntersectsLine",
"(",
"strategy",
"Strategy",
",",
"point",
",",
"lineStart",
",",
"lineEnd",
"geom",
".",
"Coord",
")",
"(",
"hasIntersection",
"bool",
")",
"{",
"intersectorData",
":=",
"&",
"lineIntersectorData",
"{",
"strategy",
":",
"strategy",
",",
"inputLines",
":",
"[",
"2",
"]",
"[",
"2",
"]",
"geom",
".",
"Coord",
"{",
"{",
"lineStart",
",",
"lineEnd",
"}",
",",
"{",
"}",
"}",
",",
"intersectionPoints",
":",
"[",
"2",
"]",
"geom",
".",
"Coord",
"{",
"{",
"0",
",",
"0",
"}",
",",
"{",
"0",
",",
"0",
"}",
"}",
",",
"}",
"\n\n",
"intersectorData",
".",
"pa",
"=",
"intersectorData",
".",
"intersectionPoints",
"[",
"0",
"]",
"\n",
"intersectorData",
".",
"pb",
"=",
"intersectorData",
".",
"intersectionPoints",
"[",
"1",
"]",
"\n\n",
"strategy",
".",
"computePointOnLineIntersection",
"(",
"intersectorData",
",",
"point",
",",
"lineStart",
",",
"lineEnd",
")",
"\n\n",
"return",
"intersectorData",
".",
"intersectionType",
"!=",
"lineintersection",
".",
"NoIntersection",
"\n",
"}"
] | // PointIntersectsLine tests if point intersects the line | [
"PointIntersectsLine",
"tests",
"if",
"point",
"intersects",
"the",
"line"
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/xy/internal/lineintersector/line_intersector.go#L17-L30 |
151,686 | twpayne/go-geom | xy/internal/lineintersector/line_intersector.go | rParameter | func rParameter(p1, p2, p geom.Coord) float64 {
var r float64
// compute maximum delta, for numerical stability
// also handle case of p1-p2 being vertical or horizontal
dx := math.Abs(p2[0] - p1[0])
dy := math.Abs(p2[1] - p1[1])
if dx > dy {
r = (p[0] - p1[0]) / (p2[0] - p1[0])
} else {
r = (p[1] - p1[1]) / (p2[1] - p1[1])
}
return r
} | go | func rParameter(p1, p2, p geom.Coord) float64 {
var r float64
// compute maximum delta, for numerical stability
// also handle case of p1-p2 being vertical or horizontal
dx := math.Abs(p2[0] - p1[0])
dy := math.Abs(p2[1] - p1[1])
if dx > dy {
r = (p[0] - p1[0]) / (p2[0] - p1[0])
} else {
r = (p[1] - p1[1]) / (p2[1] - p1[1])
}
return r
} | [
"func",
"rParameter",
"(",
"p1",
",",
"p2",
",",
"p",
"geom",
".",
"Coord",
")",
"float64",
"{",
"var",
"r",
"float64",
"\n",
"// compute maximum delta, for numerical stability",
"// also handle case of p1-p2 being vertical or horizontal",
"dx",
":=",
"math",
".",
"Abs",
"(",
"p2",
"[",
"0",
"]",
"-",
"p1",
"[",
"0",
"]",
")",
"\n",
"dy",
":=",
"math",
".",
"Abs",
"(",
"p2",
"[",
"1",
"]",
"-",
"p1",
"[",
"1",
"]",
")",
"\n",
"if",
"dx",
">",
"dy",
"{",
"r",
"=",
"(",
"p",
"[",
"0",
"]",
"-",
"p1",
"[",
"0",
"]",
")",
"/",
"(",
"p2",
"[",
"0",
"]",
"-",
"p1",
"[",
"0",
"]",
")",
"\n",
"}",
"else",
"{",
"r",
"=",
"(",
"p",
"[",
"1",
"]",
"-",
"p1",
"[",
"1",
"]",
")",
"/",
"(",
"p2",
"[",
"1",
"]",
"-",
"p1",
"[",
"1",
"]",
")",
"\n",
"}",
"\n",
"return",
"r",
"\n",
"}"
] | /**
* RParameter computes the parameter for the point p
* in the parameterized equation
* of the line from p1 to p2.
* This is equal to the 'distance' of p along p1-p2
*/ | [
"RParameter",
"computes",
"the",
"parameter",
"for",
"the",
"point",
"p",
"in",
"the",
"parameterized",
"equation",
"of",
"the",
"line",
"from",
"p1",
"to",
"p2",
".",
"This",
"is",
"equal",
"to",
"the",
"distance",
"of",
"p",
"along",
"p1",
"-",
"p2"
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/xy/internal/lineintersector/line_intersector.go#L83-L95 |
151,687 | twpayne/go-geom | xy/point_centroid.go | AddPoint | func (calc *PointCentroidCalculator) AddPoint(point *geom.Point) {
calc.AddCoord(geom.Coord(point.FlatCoords()))
} | go | func (calc *PointCentroidCalculator) AddPoint(point *geom.Point) {
calc.AddCoord(geom.Coord(point.FlatCoords()))
} | [
"func",
"(",
"calc",
"*",
"PointCentroidCalculator",
")",
"AddPoint",
"(",
"point",
"*",
"geom",
".",
"Point",
")",
"{",
"calc",
".",
"AddCoord",
"(",
"geom",
".",
"Coord",
"(",
"point",
".",
"FlatCoords",
"(",
")",
")",
")",
"\n",
"}"
] | // AddPoint adds a point to the calculation | [
"AddPoint",
"adds",
"a",
"point",
"to",
"the",
"calculation"
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/xy/point_centroid.go#L69-L71 |
151,688 | twpayne/go-geom | xy/point_centroid.go | AddCoord | func (calc *PointCentroidCalculator) AddCoord(point geom.Coord) {
calc.ptCount++
calc.centSum[0] += point[0]
calc.centSum[1] += point[1]
} | go | func (calc *PointCentroidCalculator) AddCoord(point geom.Coord) {
calc.ptCount++
calc.centSum[0] += point[0]
calc.centSum[1] += point[1]
} | [
"func",
"(",
"calc",
"*",
"PointCentroidCalculator",
")",
"AddCoord",
"(",
"point",
"geom",
".",
"Coord",
")",
"{",
"calc",
".",
"ptCount",
"++",
"\n",
"calc",
".",
"centSum",
"[",
"0",
"]",
"+=",
"point",
"[",
"0",
"]",
"\n",
"calc",
".",
"centSum",
"[",
"1",
"]",
"+=",
"point",
"[",
"1",
"]",
"\n",
"}"
] | // AddCoord adds a point to the calculation | [
"AddCoord",
"adds",
"a",
"point",
"to",
"the",
"calculation"
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/xy/point_centroid.go#L74-L78 |
151,689 | twpayne/go-geom | xy/point_centroid.go | GetCentroid | func (calc *PointCentroidCalculator) GetCentroid() geom.Coord {
cent := geom.Coord{0, 0}
cent[0] = calc.centSum[0] / float64(calc.ptCount)
cent[1] = calc.centSum[1] / float64(calc.ptCount)
return cent
} | go | func (calc *PointCentroidCalculator) GetCentroid() geom.Coord {
cent := geom.Coord{0, 0}
cent[0] = calc.centSum[0] / float64(calc.ptCount)
cent[1] = calc.centSum[1] / float64(calc.ptCount)
return cent
} | [
"func",
"(",
"calc",
"*",
"PointCentroidCalculator",
")",
"GetCentroid",
"(",
")",
"geom",
".",
"Coord",
"{",
"cent",
":=",
"geom",
".",
"Coord",
"{",
"0",
",",
"0",
"}",
"\n",
"cent",
"[",
"0",
"]",
"=",
"calc",
".",
"centSum",
"[",
"0",
"]",
"/",
"float64",
"(",
"calc",
".",
"ptCount",
")",
"\n",
"cent",
"[",
"1",
"]",
"=",
"calc",
".",
"centSum",
"[",
"1",
"]",
"/",
"float64",
"(",
"calc",
".",
"ptCount",
")",
"\n",
"return",
"cent",
"\n",
"}"
] | // GetCentroid obtains centroid currently calculated. Returns a 0 coord if no coords have been added | [
"GetCentroid",
"obtains",
"centroid",
"currently",
"calculated",
".",
"Returns",
"a",
"0",
"coord",
"if",
"no",
"coords",
"have",
"been",
"added"
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/xy/point_centroid.go#L81-L86 |
151,690 | twpayne/go-geom | xy/internal/cga.go | Distance2D | func Distance2D(c1, c2 geom.Coord) float64 {
dx := c1[0] - c2[0]
dy := c1[1] - c2[1]
return math.Sqrt(dx*dx + dy*dy)
} | go | func Distance2D(c1, c2 geom.Coord) float64 {
dx := c1[0] - c2[0]
dy := c1[1] - c2[1]
return math.Sqrt(dx*dx + dy*dy)
} | [
"func",
"Distance2D",
"(",
"c1",
",",
"c2",
"geom",
".",
"Coord",
")",
"float64",
"{",
"dx",
":=",
"c1",
"[",
"0",
"]",
"-",
"c2",
"[",
"0",
"]",
"\n",
"dy",
":=",
"c1",
"[",
"1",
"]",
"-",
"c2",
"[",
"1",
"]",
"\n\n",
"return",
"math",
".",
"Sqrt",
"(",
"dx",
"*",
"dx",
"+",
"dy",
"*",
"dy",
")",
"\n",
"}"
] | // Distance2D calculates the 2d distance between the two coordinates | [
"Distance2D",
"calculates",
"the",
"2d",
"distance",
"between",
"the",
"two",
"coordinates"
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/xy/internal/cga.go#L59-L64 |
151,691 | twpayne/go-geom | multipolygon.go | NewMultiPolygonFlat | func NewMultiPolygonFlat(layout Layout, flatCoords []float64, endss [][]int) *MultiPolygon {
g := new(MultiPolygon)
g.layout = layout
g.stride = layout.Stride()
g.flatCoords = flatCoords
g.endss = endss
return g
} | go | func NewMultiPolygonFlat(layout Layout, flatCoords []float64, endss [][]int) *MultiPolygon {
g := new(MultiPolygon)
g.layout = layout
g.stride = layout.Stride()
g.flatCoords = flatCoords
g.endss = endss
return g
} | [
"func",
"NewMultiPolygonFlat",
"(",
"layout",
"Layout",
",",
"flatCoords",
"[",
"]",
"float64",
",",
"endss",
"[",
"]",
"[",
"]",
"int",
")",
"*",
"MultiPolygon",
"{",
"g",
":=",
"new",
"(",
"MultiPolygon",
")",
"\n",
"g",
".",
"layout",
"=",
"layout",
"\n",
"g",
".",
"stride",
"=",
"layout",
".",
"Stride",
"(",
")",
"\n",
"g",
".",
"flatCoords",
"=",
"flatCoords",
"\n",
"g",
".",
"endss",
"=",
"endss",
"\n",
"return",
"g",
"\n",
"}"
] | // NewMultiPolygonFlat returns a new MultiPolygon with the given flat coordinates. | [
"NewMultiPolygonFlat",
"returns",
"a",
"new",
"MultiPolygon",
"with",
"the",
"given",
"flat",
"coordinates",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/multipolygon.go#L14-L21 |
151,692 | twpayne/go-geom | multipolygon.go | Area | func (g *MultiPolygon) Area() float64 {
return doubleArea3(g.flatCoords, 0, g.endss, g.stride) / 2
} | go | func (g *MultiPolygon) Area() float64 {
return doubleArea3(g.flatCoords, 0, g.endss, g.stride) / 2
} | [
"func",
"(",
"g",
"*",
"MultiPolygon",
")",
"Area",
"(",
")",
"float64",
"{",
"return",
"doubleArea3",
"(",
"g",
".",
"flatCoords",
",",
"0",
",",
"g",
".",
"endss",
",",
"g",
".",
"stride",
")",
"/",
"2",
"\n",
"}"
] | // Area returns the sum of the area of the individual Polygons. | [
"Area",
"returns",
"the",
"sum",
"of",
"the",
"area",
"of",
"the",
"individual",
"Polygons",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/multipolygon.go#L24-L26 |
151,693 | twpayne/go-geom | multipolygon.go | Length | func (g *MultiPolygon) Length() float64 {
return length3(g.flatCoords, 0, g.endss, g.stride)
} | go | func (g *MultiPolygon) Length() float64 {
return length3(g.flatCoords, 0, g.endss, g.stride)
} | [
"func",
"(",
"g",
"*",
"MultiPolygon",
")",
"Length",
"(",
")",
"float64",
"{",
"return",
"length3",
"(",
"g",
".",
"flatCoords",
",",
"0",
",",
"g",
".",
"endss",
",",
"g",
".",
"stride",
")",
"\n",
"}"
] | // Length returns the sum of the perimeters of the Polygons. | [
"Length",
"returns",
"the",
"sum",
"of",
"the",
"perimeters",
"of",
"the",
"Polygons",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/multipolygon.go#L39-L41 |
151,694 | twpayne/go-geom | multipolygon.go | Polygon | func (g *MultiPolygon) Polygon(i int) *Polygon {
offset := 0
if i > 0 {
ends := g.endss[i-1]
offset = ends[len(ends)-1]
}
ends := make([]int, len(g.endss[i]))
if offset == 0 {
copy(ends, g.endss[i])
} else {
for j, end := range g.endss[i] {
ends[j] = end - offset
}
}
return NewPolygonFlat(g.layout, g.flatCoords[offset:g.endss[i][len(g.endss[i])-1]], ends)
} | go | func (g *MultiPolygon) Polygon(i int) *Polygon {
offset := 0
if i > 0 {
ends := g.endss[i-1]
offset = ends[len(ends)-1]
}
ends := make([]int, len(g.endss[i]))
if offset == 0 {
copy(ends, g.endss[i])
} else {
for j, end := range g.endss[i] {
ends[j] = end - offset
}
}
return NewPolygonFlat(g.layout, g.flatCoords[offset:g.endss[i][len(g.endss[i])-1]], ends)
} | [
"func",
"(",
"g",
"*",
"MultiPolygon",
")",
"Polygon",
"(",
"i",
"int",
")",
"*",
"Polygon",
"{",
"offset",
":=",
"0",
"\n",
"if",
"i",
">",
"0",
"{",
"ends",
":=",
"g",
".",
"endss",
"[",
"i",
"-",
"1",
"]",
"\n",
"offset",
"=",
"ends",
"[",
"len",
"(",
"ends",
")",
"-",
"1",
"]",
"\n",
"}",
"\n",
"ends",
":=",
"make",
"(",
"[",
"]",
"int",
",",
"len",
"(",
"g",
".",
"endss",
"[",
"i",
"]",
")",
")",
"\n",
"if",
"offset",
"==",
"0",
"{",
"copy",
"(",
"ends",
",",
"g",
".",
"endss",
"[",
"i",
"]",
")",
"\n",
"}",
"else",
"{",
"for",
"j",
",",
"end",
":=",
"range",
"g",
".",
"endss",
"[",
"i",
"]",
"{",
"ends",
"[",
"j",
"]",
"=",
"end",
"-",
"offset",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"NewPolygonFlat",
"(",
"g",
".",
"layout",
",",
"g",
".",
"flatCoords",
"[",
"offset",
":",
"g",
".",
"endss",
"[",
"i",
"]",
"[",
"len",
"(",
"g",
".",
"endss",
"[",
"i",
"]",
")",
"-",
"1",
"]",
"]",
",",
"ends",
")",
"\n",
"}"
] | // Polygon returns the ith Polygon. | [
"Polygon",
"returns",
"the",
"ith",
"Polygon",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/multipolygon.go#L55-L70 |
151,695 | twpayne/go-geom | multipolygon.go | Push | func (g *MultiPolygon) Push(p *Polygon) error {
if p.layout != g.layout {
return ErrLayoutMismatch{Got: p.layout, Want: g.layout}
}
offset := len(g.flatCoords)
ends := make([]int, len(p.ends))
if offset == 0 {
copy(ends, p.ends)
} else {
for i, end := range p.ends {
ends[i] = end + offset
}
}
g.flatCoords = append(g.flatCoords, p.flatCoords...)
g.endss = append(g.endss, ends)
return nil
} | go | func (g *MultiPolygon) Push(p *Polygon) error {
if p.layout != g.layout {
return ErrLayoutMismatch{Got: p.layout, Want: g.layout}
}
offset := len(g.flatCoords)
ends := make([]int, len(p.ends))
if offset == 0 {
copy(ends, p.ends)
} else {
for i, end := range p.ends {
ends[i] = end + offset
}
}
g.flatCoords = append(g.flatCoords, p.flatCoords...)
g.endss = append(g.endss, ends)
return nil
} | [
"func",
"(",
"g",
"*",
"MultiPolygon",
")",
"Push",
"(",
"p",
"*",
"Polygon",
")",
"error",
"{",
"if",
"p",
".",
"layout",
"!=",
"g",
".",
"layout",
"{",
"return",
"ErrLayoutMismatch",
"{",
"Got",
":",
"p",
".",
"layout",
",",
"Want",
":",
"g",
".",
"layout",
"}",
"\n",
"}",
"\n",
"offset",
":=",
"len",
"(",
"g",
".",
"flatCoords",
")",
"\n",
"ends",
":=",
"make",
"(",
"[",
"]",
"int",
",",
"len",
"(",
"p",
".",
"ends",
")",
")",
"\n",
"if",
"offset",
"==",
"0",
"{",
"copy",
"(",
"ends",
",",
"p",
".",
"ends",
")",
"\n",
"}",
"else",
"{",
"for",
"i",
",",
"end",
":=",
"range",
"p",
".",
"ends",
"{",
"ends",
"[",
"i",
"]",
"=",
"end",
"+",
"offset",
"\n",
"}",
"\n",
"}",
"\n",
"g",
".",
"flatCoords",
"=",
"append",
"(",
"g",
".",
"flatCoords",
",",
"p",
".",
"flatCoords",
"...",
")",
"\n",
"g",
".",
"endss",
"=",
"append",
"(",
"g",
".",
"endss",
",",
"ends",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // Push appends a Polygon. | [
"Push",
"appends",
"a",
"Polygon",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/multipolygon.go#L73-L89 |
151,696 | twpayne/go-geom | xy/internal/lineintersector/robust_line_intersector.go | normalizeToEnvCentre | func normalizeToEnvCentre(line1Start, line1End, line2Start, line2End, normPt geom.Coord) {
// Note: All these "max" checks are inlined for performance.
// It would be visually cleaner to do that but requires more function calls
line1MinX := line1End[0]
if line1Start[0] < line1End[0] {
line1MinX = line1Start[0]
}
line1MinY := line1End[1]
if line1Start[1] < line1End[1] {
line1MinY = line1Start[1]
}
line1MaxX := line1End[0]
if line1Start[0] > line1End[0] {
line1MaxX = line1Start[0]
}
line1MaxY := line1End[1]
if line1Start[1] > line1End[1] {
line1MaxY = line1Start[1]
}
line2MinX := line2End[0]
if line2Start[0] < line2End[0] {
line2MinX = line2Start[0]
}
line2MinY := line2End[1]
if line2Start[1] < line2End[1] {
line2MinY = line2Start[1]
}
line2MaxX := line2End[0]
if line2Start[0] > line2End[0] {
line2MaxX = line2Start[0]
}
line2MaxY := line2End[1]
if line2Start[1] > line2End[1] {
line2MaxY = line2Start[1]
}
intMinX := line2MinX
if line1MinX > line2MinX {
intMinX = line1MinX
}
intMaxX := line2MaxX
if line1MaxX < line2MaxX {
intMaxX = line1MaxX
}
intMinY := line2MinY
if line1MinY > line2MinY {
intMinY = line1MinY
}
intMaxY := line2MaxY
if line1MaxY < line2MaxY {
intMaxY = line1MaxY
}
intMidX := (intMinX + intMaxX) / 2.0
intMidY := (intMinY + intMaxY) / 2.0
normPt[0] = intMidX
normPt[1] = intMidY
line1Start[0] -= normPt[0]
line1Start[1] -= normPt[1]
line1End[0] -= normPt[0]
line1End[1] -= normPt[1]
line2Start[0] -= normPt[0]
line2Start[1] -= normPt[1]
line2End[0] -= normPt[0]
line2End[1] -= normPt[1]
} | go | func normalizeToEnvCentre(line1Start, line1End, line2Start, line2End, normPt geom.Coord) {
// Note: All these "max" checks are inlined for performance.
// It would be visually cleaner to do that but requires more function calls
line1MinX := line1End[0]
if line1Start[0] < line1End[0] {
line1MinX = line1Start[0]
}
line1MinY := line1End[1]
if line1Start[1] < line1End[1] {
line1MinY = line1Start[1]
}
line1MaxX := line1End[0]
if line1Start[0] > line1End[0] {
line1MaxX = line1Start[0]
}
line1MaxY := line1End[1]
if line1Start[1] > line1End[1] {
line1MaxY = line1Start[1]
}
line2MinX := line2End[0]
if line2Start[0] < line2End[0] {
line2MinX = line2Start[0]
}
line2MinY := line2End[1]
if line2Start[1] < line2End[1] {
line2MinY = line2Start[1]
}
line2MaxX := line2End[0]
if line2Start[0] > line2End[0] {
line2MaxX = line2Start[0]
}
line2MaxY := line2End[1]
if line2Start[1] > line2End[1] {
line2MaxY = line2Start[1]
}
intMinX := line2MinX
if line1MinX > line2MinX {
intMinX = line1MinX
}
intMaxX := line2MaxX
if line1MaxX < line2MaxX {
intMaxX = line1MaxX
}
intMinY := line2MinY
if line1MinY > line2MinY {
intMinY = line1MinY
}
intMaxY := line2MaxY
if line1MaxY < line2MaxY {
intMaxY = line1MaxY
}
intMidX := (intMinX + intMaxX) / 2.0
intMidY := (intMinY + intMaxY) / 2.0
normPt[0] = intMidX
normPt[1] = intMidY
line1Start[0] -= normPt[0]
line1Start[1] -= normPt[1]
line1End[0] -= normPt[0]
line1End[1] -= normPt[1]
line2Start[0] -= normPt[0]
line2Start[1] -= normPt[1]
line2End[0] -= normPt[0]
line2End[1] -= normPt[1]
} | [
"func",
"normalizeToEnvCentre",
"(",
"line1Start",
",",
"line1End",
",",
"line2Start",
",",
"line2End",
",",
"normPt",
"geom",
".",
"Coord",
")",
"{",
"// Note: All these \"max\" checks are inlined for performance.",
"// It would be visually cleaner to do that but requires more function calls",
"line1MinX",
":=",
"line1End",
"[",
"0",
"]",
"\n",
"if",
"line1Start",
"[",
"0",
"]",
"<",
"line1End",
"[",
"0",
"]",
"{",
"line1MinX",
"=",
"line1Start",
"[",
"0",
"]",
"\n",
"}",
"\n\n",
"line1MinY",
":=",
"line1End",
"[",
"1",
"]",
"\n",
"if",
"line1Start",
"[",
"1",
"]",
"<",
"line1End",
"[",
"1",
"]",
"{",
"line1MinY",
"=",
"line1Start",
"[",
"1",
"]",
"\n",
"}",
"\n",
"line1MaxX",
":=",
"line1End",
"[",
"0",
"]",
"\n",
"if",
"line1Start",
"[",
"0",
"]",
">",
"line1End",
"[",
"0",
"]",
"{",
"line1MaxX",
"=",
"line1Start",
"[",
"0",
"]",
"\n",
"}",
"\n",
"line1MaxY",
":=",
"line1End",
"[",
"1",
"]",
"\n",
"if",
"line1Start",
"[",
"1",
"]",
">",
"line1End",
"[",
"1",
"]",
"{",
"line1MaxY",
"=",
"line1Start",
"[",
"1",
"]",
"\n",
"}",
"\n\n",
"line2MinX",
":=",
"line2End",
"[",
"0",
"]",
"\n",
"if",
"line2Start",
"[",
"0",
"]",
"<",
"line2End",
"[",
"0",
"]",
"{",
"line2MinX",
"=",
"line2Start",
"[",
"0",
"]",
"\n",
"}",
"\n",
"line2MinY",
":=",
"line2End",
"[",
"1",
"]",
"\n",
"if",
"line2Start",
"[",
"1",
"]",
"<",
"line2End",
"[",
"1",
"]",
"{",
"line2MinY",
"=",
"line2Start",
"[",
"1",
"]",
"\n",
"}",
"\n",
"line2MaxX",
":=",
"line2End",
"[",
"0",
"]",
"\n",
"if",
"line2Start",
"[",
"0",
"]",
">",
"line2End",
"[",
"0",
"]",
"{",
"line2MaxX",
"=",
"line2Start",
"[",
"0",
"]",
"\n",
"}",
"\n",
"line2MaxY",
":=",
"line2End",
"[",
"1",
"]",
"\n",
"if",
"line2Start",
"[",
"1",
"]",
">",
"line2End",
"[",
"1",
"]",
"{",
"line2MaxY",
"=",
"line2Start",
"[",
"1",
"]",
"\n",
"}",
"\n\n",
"intMinX",
":=",
"line2MinX",
"\n",
"if",
"line1MinX",
">",
"line2MinX",
"{",
"intMinX",
"=",
"line1MinX",
"\n",
"}",
"\n",
"intMaxX",
":=",
"line2MaxX",
"\n",
"if",
"line1MaxX",
"<",
"line2MaxX",
"{",
"intMaxX",
"=",
"line1MaxX",
"\n",
"}",
"\n",
"intMinY",
":=",
"line2MinY",
"\n",
"if",
"line1MinY",
">",
"line2MinY",
"{",
"intMinY",
"=",
"line1MinY",
"\n",
"}",
"\n",
"intMaxY",
":=",
"line2MaxY",
"\n",
"if",
"line1MaxY",
"<",
"line2MaxY",
"{",
"intMaxY",
"=",
"line1MaxY",
"\n",
"}",
"\n\n",
"intMidX",
":=",
"(",
"intMinX",
"+",
"intMaxX",
")",
"/",
"2.0",
"\n",
"intMidY",
":=",
"(",
"intMinY",
"+",
"intMaxY",
")",
"/",
"2.0",
"\n",
"normPt",
"[",
"0",
"]",
"=",
"intMidX",
"\n",
"normPt",
"[",
"1",
"]",
"=",
"intMidY",
"\n\n",
"line1Start",
"[",
"0",
"]",
"-=",
"normPt",
"[",
"0",
"]",
"\n",
"line1Start",
"[",
"1",
"]",
"-=",
"normPt",
"[",
"1",
"]",
"\n",
"line1End",
"[",
"0",
"]",
"-=",
"normPt",
"[",
"0",
"]",
"\n",
"line1End",
"[",
"1",
"]",
"-=",
"normPt",
"[",
"1",
"]",
"\n",
"line2Start",
"[",
"0",
"]",
"-=",
"normPt",
"[",
"0",
"]",
"\n",
"line2Start",
"[",
"1",
"]",
"-=",
"normPt",
"[",
"1",
"]",
"\n",
"line2End",
"[",
"0",
"]",
"-=",
"normPt",
"[",
"0",
"]",
"\n",
"line2End",
"[",
"1",
"]",
"-=",
"normPt",
"[",
"1",
"]",
"\n",
"}"
] | /**
* Normalize the supplied coordinates to
* so that the midpoint of their intersection envelope
* lies at the origin.
*/ | [
"Normalize",
"the",
"supplied",
"coordinates",
"to",
"so",
"that",
"the",
"midpoint",
"of",
"their",
"intersection",
"envelope",
"lies",
"at",
"the",
"origin",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/xy/internal/lineintersector/robust_line_intersector.go#L263-L332 |
151,697 | twpayne/go-geom | geometrycollection.go | Layout | func (g *GeometryCollection) Layout() Layout {
maxLayout := NoLayout
for _, g := range g.geoms {
switch l := g.Layout(); l {
case XYZ:
if maxLayout == XYM {
maxLayout = XYZM
} else if l > maxLayout {
maxLayout = l
}
case XYM:
if maxLayout == XYZ {
maxLayout = XYZM
} else if l > maxLayout {
maxLayout = l
}
default:
if l > maxLayout {
maxLayout = l
}
}
}
return maxLayout
} | go | func (g *GeometryCollection) Layout() Layout {
maxLayout := NoLayout
for _, g := range g.geoms {
switch l := g.Layout(); l {
case XYZ:
if maxLayout == XYM {
maxLayout = XYZM
} else if l > maxLayout {
maxLayout = l
}
case XYM:
if maxLayout == XYZ {
maxLayout = XYZM
} else if l > maxLayout {
maxLayout = l
}
default:
if l > maxLayout {
maxLayout = l
}
}
}
return maxLayout
} | [
"func",
"(",
"g",
"*",
"GeometryCollection",
")",
"Layout",
"(",
")",
"Layout",
"{",
"maxLayout",
":=",
"NoLayout",
"\n",
"for",
"_",
",",
"g",
":=",
"range",
"g",
".",
"geoms",
"{",
"switch",
"l",
":=",
"g",
".",
"Layout",
"(",
")",
";",
"l",
"{",
"case",
"XYZ",
":",
"if",
"maxLayout",
"==",
"XYM",
"{",
"maxLayout",
"=",
"XYZM",
"\n",
"}",
"else",
"if",
"l",
">",
"maxLayout",
"{",
"maxLayout",
"=",
"l",
"\n",
"}",
"\n",
"case",
"XYM",
":",
"if",
"maxLayout",
"==",
"XYZ",
"{",
"maxLayout",
"=",
"XYZM",
"\n",
"}",
"else",
"if",
"l",
">",
"maxLayout",
"{",
"maxLayout",
"=",
"l",
"\n",
"}",
"\n",
"default",
":",
"if",
"l",
">",
"maxLayout",
"{",
"maxLayout",
"=",
"l",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"maxLayout",
"\n",
"}"
] | // Layout returns the smallest layout that covers all of the layouts in g's
// geometries. | [
"Layout",
"returns",
"the",
"smallest",
"layout",
"that",
"covers",
"all",
"of",
"the",
"layouts",
"in",
"g",
"s",
"geometries",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/geometrycollection.go#L27-L50 |
151,698 | twpayne/go-geom | geometrycollection.go | Bounds | func (g *GeometryCollection) Bounds() *Bounds {
// FIXME this needs work for mixing layouts, e.g. XYZ and XYM
b := NewBounds(g.Layout())
for _, g := range g.geoms {
b = b.Extend(g)
}
return b
} | go | func (g *GeometryCollection) Bounds() *Bounds {
// FIXME this needs work for mixing layouts, e.g. XYZ and XYM
b := NewBounds(g.Layout())
for _, g := range g.geoms {
b = b.Extend(g)
}
return b
} | [
"func",
"(",
"g",
"*",
"GeometryCollection",
")",
"Bounds",
"(",
")",
"*",
"Bounds",
"{",
"// FIXME this needs work for mixing layouts, e.g. XYZ and XYM",
"b",
":=",
"NewBounds",
"(",
"g",
".",
"Layout",
"(",
")",
")",
"\n",
"for",
"_",
",",
"g",
":=",
"range",
"g",
".",
"geoms",
"{",
"b",
"=",
"b",
".",
"Extend",
"(",
"g",
")",
"\n",
"}",
"\n",
"return",
"b",
"\n",
"}"
] | // Bounds returns the bounds of all the geometries in g. | [
"Bounds",
"returns",
"the",
"bounds",
"of",
"all",
"the",
"geometries",
"in",
"g",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/geometrycollection.go#L63-L70 |
151,699 | twpayne/go-geom | geometrycollection.go | MustPush | func (g *GeometryCollection) MustPush(gs ...T) *GeometryCollection {
if err := g.Push(gs...); err != nil {
panic(err)
}
return g
} | go | func (g *GeometryCollection) MustPush(gs ...T) *GeometryCollection {
if err := g.Push(gs...); err != nil {
panic(err)
}
return g
} | [
"func",
"(",
"g",
"*",
"GeometryCollection",
")",
"MustPush",
"(",
"gs",
"...",
"T",
")",
"*",
"GeometryCollection",
"{",
"if",
"err",
":=",
"g",
".",
"Push",
"(",
"gs",
"...",
")",
";",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}",
"\n",
"return",
"g",
"\n",
"}"
] | // MustPush pushes gs to g. It panics on any error. | [
"MustPush",
"pushes",
"gs",
"to",
"g",
".",
"It",
"panics",
"on",
"any",
"error",
"."
] | e21b3afba225b21d05fbcbeb8ece2c79c96554c5 | https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/geometrycollection.go#L98-L103 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.