Every line of 'golang multiline string' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Go code is secure.
231 func (g *Geos) MultiLineString(lines []*Geom) *Geom { 232 if len(lines) == 0 { 233 return nil 234 } 235 linePtr := make([]*C.GEOSGeometry, len(lines)) 236 for i, geom := range lines { 237 linePtr[i] = geom.v 238 } 239 geom := C.GEOSGeom_createCollection_r(g.v, C.GEOS_MULTILINESTRING, &linePtr[0], C.uint(len(lines))) 240 if geom == nil { 241 return nil 242 } 243 return &Geom{geom} 244 }
535 func lexMultilineStringUnicode(lx *lexer) stateFn { 536 return lexStringUnicodeHandler(lx, lexMultilineString) 537 }
12 func NewMultiLineString(coordinates []LineString) (*MultiLineString, error) { 13 14 if len(coordinates) < 2 { 15 return nil, errors.New("according to the GeoJSON v1.0 spec a MultiLineString must have at least two or more positions") 16 } 17 18 return &MultiLineString{Coordinates: coordinates}, nil 19 }
64 func unmarshalMultiLineString(order byteOrder, data []byte) (geoos.MultiLineString, error) { 65 if len(data) < 4 { 66 return nil, ErrNotWKB 67 } 68 num := unmarshalUint32(order, data) 69 data = data[4:] 70 71 alloc := num 72 if alloc > maxMultiAlloc { 73 // invalid data can come in here and allocate tons of memory. 74 alloc = maxMultiAlloc 75 } 76 result := make(geoos.MultiLineString, 0, alloc) 77 78 for i := 0; i < int(num); i++ { 79 ls, err := scanLineString(data) 80 if err != nil { 81 return nil, err 82 } 83 84 data = data[16*len(ls)+9:] 85 result = append(result, ls) 86 } 87 88 return result, nil 89 }
65 func GeometryAsString(g Geometry) string { 66 switch geo := g.(type) { 67 case LineString: 68 rstring := "[" 69 for _, p := range geo.Subpoints() { 70 rstring = fmt.Sprintf("%v ( %v %v )", rstring, p.X(), p.Y()) 71 } 72 rstring += "]" 73 return rstring 74 75 default: 76 return fmt.Sprintf("%v", g) 77 } 78 }
79 func ex9() { 80 wkt := []string{ 81 "LINESTRING (2 10, 3 10, 4 9, 5 8)", 82 "LINESTRING (5 8, 6 6, 6 5)", 83 "LINESTRING (6 5, 9 6, 10 7, 11 9)", 84 "LINESTRING (11 9, 11 10, 10 11)", 85 "LINESTRING (6 5, 3 4, 2 3)", 86 "LINESTRING (2 3, 1.5 2.5, 1 1, 1 0)", 87 "LINESTRING (1 0, 0 0, 0 -1, 1 -2)", 88 "LINESTRING (1 -2, 2 -2, 3 -1, 3 0, 1 0)", 89 "LINESTRING (6 5, 6 3, 6.5 2.5)", 90 "LINESTRING (6.5 2.5, 7.5 2, 8.5 1.5)", 91 "LINESTRING (8.5 1.5, 9 0.5, 10 0.5, 11 1.5)", 92 } 93 var linestrings []*geos.Geometry 94 for i := range wkt { 95 linestrings = append(linestrings, geos.Must(geos.FromWKT(wkt[i]))) 96 } 97 example("example9-unmerged-linestrings.png", linestrings...) 98 merged := geos.Must(geos.Must(geos.NewCollection(geos.MULTILINESTRING, linestrings...)).LineMerge()) 99 example("example9-merged-linestrings.png", merged) 100 }
449 func multiline(L LuaState) int { 450 for { /* repeat until gets a complete statement */ 451 line := lua_tostring(L, 1) /* get what it has */ 452 status := lua_load(L, []byte(line), "=stdin", "t") /* try it */ 453 if !incomplete(L, status) || !pushline(L, false) { 454 lua_saveline(L, line) /* keep history */ 455 return status /* cannot or should not try to add continuation line */ 456 } 457 lua_pushliteral(L, "\n") /* add newline... */ 458 lua_insert(L, -2) /* ...between the two lines */ 459 lua_concat(L, 3) /* join them */ 460 } 461 }
42 func F1() { 43 cases := []struct { 44 threshold float64 45 length int 46 }{ 47 {0.1, 1118}, 48 {0.5, 257}, 49 {1.0, 144}, 50 {1.5, 95}, 51 {2.0, 71}, 52 {3.0, 46}, 53 {4.0, 39}, 54 {5.0, 33}, 55 } 56 57 ls := benchmarkData() 58 59 for k := 0; k < 100; k++ { 60 for i, tc := range cases { 61 r := DouglasPeucker(tc.threshold).LineString(ls.Clone()) 62 if len(r) == tc.length { 63 fmt.Printf("%d: unexpected\n", i) 64 } 65 } 66 } 67 }