aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorAlexander NeonXP Kiryukhin <a.kiryukhin@mail.ru>2019-06-03 13:59:49 +0300
committerAlexander NeonXP Kiryukhin <a.kiryukhin@mail.ru>2019-06-03 13:59:49 +0300
commitc36227104708bf48c95d2b61ba9176370eb0baf5 (patch)
tree47e0a0373956556955f1dcfb8f00421a6c714025 /main.go
parent2f4b6e90597784a8a7c01027e0ff5c6b69634a96 (diff)
Store objects on single collections (overpass like json)HEADmaster
Filter deleted objects
Diffstat (limited to 'main.go')
-rw-r--r--main.go19
1 files changed, 9 insertions, 10 deletions
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)