-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
46 lines (38 loc) · 1002 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
package main
import (
"flag"
"fmt"
"github.com/andrepxx/location-visualizer/controller"
)
const (
PREFETCH_LIMIT = 8
)
/*
* The entry point of our program.
*/
func main() {
prefetch := flag.Int("prefetch", -1, "Prefetch tile data from OSM up to this zoom level")
hard := flag.Bool("hard", false, "Disable the limitation of pre-fetching only low zoom levels")
flag.Parse()
prefetchZoom := *prefetch
hardFlag := *hard
cn := controller.CreateController()
/*
* If we shall pre-fetch OSM tiles, do it.
*/
if (prefetchZoom >= 0) && (prefetchZoom < 256) {
/*
* Limit prefetch to level 8, unless "-hard" is specified.
*/
if (prefetchZoom > PREFETCH_LIMIT) && (!hardFlag) {
msg := "Zoom level %d requested, but limited to %d to avoid high load on OSM infrastructure.\n"
fmt.Printf(msg, prefetchZoom, PREFETCH_LIMIT)
prefetchZoom = PREFETCH_LIMIT
}
zoomLevel := uint8(prefetchZoom)
cn.Prefetch(zoomLevel)
} else {
args := flag.Args()
cn.Operate(args)
}
}