func printSet(txt string, set *treeset.Set) { fmt.Print(txt, "[ ") set.Each(func(index int, value interface{}) { fmt.Print(value, " ") }) fmt.Println("]") }
// Get multiples node by ids at a time. func (this *Db) GetNodes(wanted *treeset.Set, alfound map[int64]*osmpbf.Node) (map[int64]*osmpbf.Node, error) { found := make(map[int64]*osmpbf.Node) nb := wanted.Size() for id, val := range alfound { if wanted.Contains(id) { found[id] = val wanted.Remove(id) } } nb -= wanted.Size() alfound = nil log.Printf("Nodes reused : %d", nb) // On cherche les points l := (*wanted).Size() list := (*wanted).Values() log.Printf("Nodes to find : %v", l) blocks, _ := this.getBlockContainingNodes(wanted) log.Printf("Block to read : %d / %d", len(blocks), len(this.Descriptor.NodesId)) for _, i := range blocks { ns, err := this.Decoder.DecodeBlocAt(this.Descriptor.Nodes[i]) if err != nil { return nil, err } for _, v := range ns { switch v := v.(type) { case *osmpbf.Node: if v.ID == list[0] { found[v.ID] = v if len(list) == 1 { //Il ne restait plus qu'un élément et on vient de le trouver log.Printf("All %d nodes found", len(found)) list = nil return found, nil } //On enleve le première élément list = list[1:] } break } } } log.Printf("All %d nodes found", len(found)) return found, nil }