make wayFill parallel
parent
0cf5b90120
commit
34409088d7
43
parser.go
43
parser.go
|
@ -109,7 +109,7 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
log.SetFlags(log.LstdFlags | log.Llongfile)
|
log.SetFlags(log.LstdFlags | log.Llongfile)
|
||||||
//runtime.GOMAXPROCS(runtime.NumCPU())
|
runtime.GOMAXPROCS(runtime.NumCPU())
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
osmCache, err := cache.NewOSMCache("/tmp/goposm")
|
osmCache, err := cache.NewOSMCache("/tmp/goposm")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -117,7 +117,7 @@ func main() {
|
||||||
}
|
}
|
||||||
defer osmCache.Close()
|
defer osmCache.Close()
|
||||||
|
|
||||||
//parse(osmCache, flag.Arg(0))
|
// parse(osmCache, flag.Arg(0))
|
||||||
fmt.Println("foo")
|
fmt.Println("foo")
|
||||||
|
|
||||||
//rel := osmCache.Relations.Iter()
|
//rel := osmCache.Relations.Iter()
|
||||||
|
@ -126,27 +126,36 @@ func main() {
|
||||||
//}
|
//}
|
||||||
|
|
||||||
way := osmCache.Ways.Iter()
|
way := osmCache.Ways.Iter()
|
||||||
i := 0
|
|
||||||
refCache, err := cache.NewRefIndex("/tmp/refindex")
|
refCache, err := cache.NewRefIndex("/tmp/refindex")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
for w := range way {
|
|
||||||
i += 1
|
waitFill := sync.WaitGroup{}
|
||||||
ok := osmCache.Coords.FillWay(w)
|
for i := 0; i < runtime.NumCPU(); i++ {
|
||||||
if !ok {
|
waitFill.Add(1)
|
||||||
continue
|
|
||||||
}
|
go func() {
|
||||||
if true {
|
i := 0
|
||||||
for _, node := range w.Nodes {
|
for w := range way {
|
||||||
refCache.Add(node.Id, w.Id)
|
ok := osmCache.Coords.FillWay(w)
|
||||||
|
if !ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if true {
|
||||||
|
for _, node := range w.Nodes {
|
||||||
|
refCache.Add(node.Id, w.Id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if i%1000 == 0 {
|
||||||
|
fmt.Println(i)
|
||||||
|
}
|
||||||
|
i++
|
||||||
}
|
}
|
||||||
}
|
waitFill.Done()
|
||||||
if i%1000 == 0 {
|
}()
|
||||||
fmt.Println(i)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
fmt.Println(i)
|
waitFill.Wait()
|
||||||
//parser.PBFStats(os.Args[1])
|
//parser.PBFStats(os.Args[1])
|
||||||
fmt.Println("done")
|
fmt.Println("done")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue