// LineMerge tries to merge lines. Returns slice of LineStrings. // Destroys lines and returns new allocated LineString Geoms. func (this *Geos) LineMerge(lines []*Geom) []*Geom { if len(lines) <= 1 { return lines } multiLineString := this.MultiLineString(lines) if multiLineString == nil { return nil } defer this.Destroy(multiLineString) merged := C.GEOSLineMerge_r(this.v, multiLineString.v) if merged == nil { return nil } geom := &Geom{merged} if this.Type(geom) == "LineString" { return []*Geom{geom} } // extract MultiLineString lines = make([]*Geom, 0, this.NumGeoms(geom)) for _, line := range this.Geoms(geom) { lines = append(lines, this.Clone(line)) } this.Destroy(geom) return lines }
func cGEOSLineMerge(g *C.GEOSGeometry) *C.GEOSGeometry { handlemu.Lock() defer handlemu.Unlock() return C.GEOSLineMerge_r(handle, g) }