From c36227104708bf48c95d2b61ba9176370eb0baf5 Mon Sep 17 00:00:00 2001 From: Alexander NeonXP Kiryukhin Date: Mon, 3 Jun 2019 13:59:49 +0300 Subject: Store objects on single collections (overpass like json) Filter deleted objects --- main.go | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'main.go') diff --git a/main.go b/main.go index e5dab33..f975187 100644 --- a/main.go +++ b/main.go @@ -16,12 +16,12 @@ import ( func main() { dbconnection := flag.String("dbconnection", "mongodb://localhost:27017", "Mongo database name") dbname := flag.String("dbname", "map", "Mongo database name") - osmfile := flag.String("osmfile", "", "OSM file") - initial := flag.Bool("initial", false, "Is initial import") + osmfile := flag.String("osmfile", "./RU.osm.pbf", "Path to OSM file (PBF format only)") + initial := flag.Bool("initial", false, "Is initial import?") indexes := flag.Bool("indexes", false, "Create indexes") layersString := flag.String("layers", "nodes,ways,relations", "Layers to import") blockSize := flag.Int("block", 1000, "Block size to bulk write") - concurrency := flag.Int("concurrency", 32, "Concurrency read and write") + concurrency := flag.Int("concurrency", 32, "Workers count") flag.Parse() layers := strings.Split(*layersString, ",") r := rutina.New() @@ -34,26 +34,25 @@ func main() { db := client.Database(*dbname) if *indexes { + log.Println("Creating indexes...") if err := createIndexes(db); err != nil { log.Fatal(err) } - log.Println("Indexes created") + log.Println("Done!") } - log.Printf("Started import file %s to db %s", *osmfile, *dbname) - nodesCh := make(chan Node, 1) - waysCh := make(chan Way, 1) - relationsCh := make(chan Relation, 1) + log.Printf("Started import file %s to db %s (%d workers)", *osmfile, *dbname, *concurrency) + insertCh := make(chan Object, 1) for i := 0; i < *concurrency; i++ { worker := i r.Go(func(ctx context.Context) error { - return write(ctx, db, nodesCh, waysCh, relationsCh, *initial, *blockSize, worker) + return write(ctx, db, insertCh, *initial, *blockSize, worker) }) } r.Go(func(ctx context.Context) error { - return read(ctx, *osmfile, nodesCh, waysCh, relationsCh, *concurrency, layers) + return read(ctx, *osmfile, insertCh, *concurrency, layers) }) if err := r.Wait(); err != nil { log.Fatal(err) -- cgit v1.2.3