-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
54 lines (44 loc) · 960 Bytes
/
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
package main
import (
"fmt"
"path"
"runtime"
"github.com/fdefabricio/gtfs2postgis/config"
"github.com/fdefabricio/gtfs2postgis/query"
_ "github.com/jinzhu/gorm/dialects/postgres"
)
var (
conf *config.Configuration
repo *query.Repository
)
func init() {
conf = new(config.Configuration)
repo = new(query.Repository)
err := config.Init(conf)
if err != nil {
panic(err)
}
}
func main() {
_, filename, _, ok := runtime.Caller(0)
if !ok {
panic("No caller information")
}
dir := path.Dir(filename)
err := repo.Connect(conf.Database)
if err != nil {
panic(err)
}
err = repo.PopulateTableGeom("stops", fmt.Sprintf("%s/gtfs_bhtransit/stops.txt", dir))
if err != nil {
panic(err)
}
err = repo.PopulateTable("trips", fmt.Sprintf("%s/gtfs_bhtransit/trips.txt", dir))
if err != nil {
panic(err)
}
err = repo.PopulateTable("stop_times", fmt.Sprintf("%s/gtfs_bhtransit/stop_times.txt", dir))
if err != nil {
panic(err)
}
}