-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
58 lines (49 loc) · 1.94 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package main
import (
"fmt"
"log"
"github.com/dschila/osm-street-extractor/internal/csv"
"github.com/dschila/osm-street-extractor/internal/models"
"github.com/dschila/osm-street-extractor/internal/osm"
)
var urls = []string{
"https://download.geofabrik.de/europe/germany/baden-wuerttemberg-latest.osm.bz2",
"https://download.geofabrik.de/europe/germany/bayern-latest.osm.bz2",
"https://download.geofabrik.de/europe/germany/berlin-latest.osm.bz2",
"https://download.geofabrik.de/europe/germany/brandenburg-latest.osm.bz2",
"https://download.geofabrik.de/europe/germany/bremen-latest.osm.bz2",
"https://download.geofabrik.de/europe/germany/hamburg-latest.osm.bz2",
"https://download.geofabrik.de/europe/germany/hessen-latest.osm.bz2",
"https://download.geofabrik.de/europe/germany/mecklenburg-vorpommern-latest.osm.bz2",
"https://download.geofabrik.de/europe/germany/niedersachsen-latest.osm.bz2",
"https://download.geofabrik.de/europe/germany/nordrhein-westfalen-latest.osm.bz2",
"https://download.geofabrik.de/europe/germany/rheinland-pfalz-latest.osm.bz2",
"https://download.geofabrik.de/europe/germany/saarland-latest.osm.bz2",
"https://download.geofabrik.de/europe/germany/sachsen-latest.osm.bz2",
"https://download.geofabrik.de/europe/germany/sachsen-anhalt-latest.osm.bz2",
"https://download.geofabrik.de/europe/germany/schleswig-holstein-latest.osm.bz2",
"https://download.geofabrik.de/europe/germany/thueringen-latest.osm.bz2",
}
func main() {
writer, err := csv.CreateCSVWriter()
if err != nil {
fmt.Println("create csv file failed:", err)
return
}
defer writer.Flush()
writer.Comma = ';'
err = writer.Write([]string{"street", "postcode", "city"})
if err != nil {
log.Fatal(err)
}
addressStream := make(chan models.Address)
go csv.WriteAddress(addressStream, writer)
for _, url := range urls {
fmt.Printf("Download from %s\n", url)
osm.ParseFromUrl(url, addressStream)
if err != nil {
panic(err)
}
}
close(addressStream)
}