add cachedir and limitto to config
parent
8195dd0b77
commit
1429bcae8a
|
@ -8,17 +8,22 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Cachedir string `json:"cachedir"`
|
CacheDir string `json:"cachedir"`
|
||||||
Connection string `json:"connection"`
|
Connection string `json:"connection"`
|
||||||
MappingFile string `json:"mapping"`
|
MappingFile string `json:"mapping"`
|
||||||
LimitTo string `json:"limitto"`
|
LimitTo string `json:"limitto"`
|
||||||
Srid int `json:"srid"`
|
Srid int `json:"srid"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const defaultSrid = 3857
|
||||||
|
const defaultCacheDir = "/tmp/goposm"
|
||||||
|
|
||||||
var (
|
var (
|
||||||
connection = flag.String("connection", "", "connection parameters")
|
connection = flag.String("connection", "", "connection parameters")
|
||||||
|
cachedir = flag.String("cachedir", defaultCacheDir, "cache directory")
|
||||||
mappingFile = flag.String("mapping", "", "mapping file")
|
mappingFile = flag.String("mapping", "", "mapping file")
|
||||||
srid = flag.Int("srid", 3857, "srs id")
|
srid = flag.Int("srid", defaultSrid, "srs id")
|
||||||
|
limitTo = flag.String("limitto", "", "limit to geometries")
|
||||||
configFile = flag.String("config", "", "config (json)")
|
configFile = flag.String("config", "", "config (json)")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -40,14 +45,20 @@ func Parse() (*Config, []error) {
|
||||||
config.Connection = *connection
|
config.Connection = *connection
|
||||||
}
|
}
|
||||||
if config.Srid == 0 {
|
if config.Srid == 0 {
|
||||||
config.Srid = 3857
|
config.Srid = defaultSrid
|
||||||
}
|
}
|
||||||
if *srid != 3857 {
|
if *srid != defaultSrid {
|
||||||
config.Srid = *srid
|
config.Srid = *srid
|
||||||
}
|
}
|
||||||
if *mappingFile != "" {
|
if *mappingFile != "" {
|
||||||
config.MappingFile = *mappingFile
|
config.MappingFile = *mappingFile
|
||||||
}
|
}
|
||||||
|
if *limitTo != "" {
|
||||||
|
config.LimitTo = *limitTo
|
||||||
|
}
|
||||||
|
if *cachedir != defaultCacheDir {
|
||||||
|
config.CacheDir = *cachedir
|
||||||
|
}
|
||||||
|
|
||||||
errs := checkConfig(config)
|
errs := checkConfig(config)
|
||||||
return config, errs
|
return config, errs
|
||||||
|
@ -67,20 +78,3 @@ func checkConfig(config *Config) []error {
|
||||||
|
|
||||||
return errs
|
return errs
|
||||||
}
|
}
|
||||||
|
|
||||||
// cpuprofile = flag.String("cpuprofile", "", "filename of cpu profile output")
|
|
||||||
// httpprofile = flag.String("httpprofile", "", "bind address for profile server")
|
|
||||||
// memprofile = flag.String("memprofile", "", "dir name of mem profile output and interval (fname:interval)")
|
|
||||||
// cachedir = flag.String("cachedir", "/tmp/goposm", "cache directory")
|
|
||||||
// overwritecache = flag.Bool("overwritecache", false, "overwritecache")
|
|
||||||
// appendcache = flag.Bool("appendcache", false, "append cache")
|
|
||||||
// read = flag.String("read", "", "read")
|
|
||||||
// write = flag.Bool("write", false, "write")
|
|
||||||
// optimize = flag.Bool("optimize", false, "optimize")
|
|
||||||
// diff = flag.Bool("diff", false, "enable diff support")
|
|
||||||
// mappingFile = flag.String("mapping", "", "mapping file")
|
|
||||||
// deployProduction = flag.Bool("deployproduction", false, "deploy production")
|
|
||||||
// revertDeploy = flag.Bool("revertdeploy", false, "revert deploy to production")
|
|
||||||
// removeBackup = flag.Bool("removebackup", false, "remove backups from deploy")
|
|
||||||
// limitTo = flag.String("limitto", "", "limit to geometries")
|
|
||||||
// quiet = flag.Bool("quiet", false, "quiet log output")
|
|
||||||
|
|
36
goposm.go
36
goposm.go
|
@ -23,21 +23,23 @@ import (
|
||||||
var log = logging.NewLogger("")
|
var log = logging.NewLogger("")
|
||||||
|
|
||||||
var (
|
var (
|
||||||
cpuprofile = flag.String("cpuprofile", "", "filename of cpu profile output")
|
cpuprofile = flag.String("cpuprofile", "", "filename of cpu profile output")
|
||||||
httpprofile = flag.String("httpprofile", "", "bind address for profile server")
|
httpprofile = flag.String("httpprofile", "", "bind address for profile server")
|
||||||
memprofile = flag.String("memprofile", "", "dir name of mem profile output and interval (fname:interval)")
|
memprofile = flag.String("memprofile", "", "dir name of mem profile output and interval (fname:interval)")
|
||||||
cachedir = flag.String("cachedir", "/tmp/goposm", "cache directory")
|
|
||||||
overwritecache = flag.Bool("overwritecache", false, "overwritecache")
|
overwritecache = flag.Bool("overwritecache", false, "overwritecache")
|
||||||
appendcache = flag.Bool("appendcache", false, "append cache")
|
appendcache = flag.Bool("appendcache", false, "append cache")
|
||||||
read = flag.String("read", "", "read")
|
|
||||||
write = flag.Bool("write", false, "write")
|
read = flag.String("read", "", "read")
|
||||||
optimize = flag.Bool("optimize", false, "optimize")
|
write = flag.Bool("write", false, "write")
|
||||||
diff = flag.Bool("diff", false, "enable diff support")
|
optimize = flag.Bool("optimize", false, "optimize")
|
||||||
|
diff = flag.Bool("diff", false, "enable diff support")
|
||||||
|
|
||||||
deployProduction = flag.Bool("deployproduction", false, "deploy production")
|
deployProduction = flag.Bool("deployproduction", false, "deploy production")
|
||||||
revertDeploy = flag.Bool("revertdeploy", false, "revert deploy to production")
|
revertDeploy = flag.Bool("revertdeploy", false, "revert deploy to production")
|
||||||
removeBackup = flag.Bool("removebackup", false, "remove backups from deploy")
|
removeBackup = flag.Bool("removebackup", false, "remove backups from deploy")
|
||||||
limitTo = flag.String("limitto", "", "limit to geometries")
|
|
||||||
quiet = flag.Bool("quiet", false, "quiet log output")
|
quiet = flag.Bool("quiet", false, "quiet log output")
|
||||||
)
|
)
|
||||||
|
|
||||||
func die(args ...interface{}) {
|
func die(args ...interface{}) {
|
||||||
|
@ -111,21 +113,21 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
var geometryClipper *clipper.Clipper
|
var geometryClipper *clipper.Clipper
|
||||||
if *write && *limitTo != "" {
|
if *write && conf.LimitTo != "" {
|
||||||
var err error
|
var err error
|
||||||
step := log.StartStep("Reading limitto geometries")
|
step := log.StartStep("Reading limitto geometries")
|
||||||
geometryClipper, err = clipper.NewFromOgrSource(*limitTo)
|
geometryClipper, err = clipper.NewFromOgrSource(conf.LimitTo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
die(err)
|
die(err)
|
||||||
}
|
}
|
||||||
log.StopStep(step)
|
log.StopStep(step)
|
||||||
}
|
}
|
||||||
|
|
||||||
osmCache := cache.NewOSMCache(*cachedir)
|
osmCache := cache.NewOSMCache(conf.CacheDir)
|
||||||
|
|
||||||
if *read != "" && osmCache.Exists() {
|
if *read != "" && osmCache.Exists() {
|
||||||
if *overwritecache {
|
if *overwritecache {
|
||||||
log.Printf("removing existing cache %s", *cachedir)
|
log.Printf("removing existing cache %s", conf.CacheDir)
|
||||||
err := osmCache.Remove()
|
err := osmCache.Remove()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
die("unable to remove cache:", err)
|
die("unable to remove cache:", err)
|
||||||
|
@ -195,7 +197,7 @@ func main() {
|
||||||
|
|
||||||
var diffCache *cache.DiffCache
|
var diffCache *cache.DiffCache
|
||||||
if *diff {
|
if *diff {
|
||||||
diffCache = cache.NewDiffCache(*cachedir)
|
diffCache = cache.NewDiffCache(conf.CacheDir)
|
||||||
if err = diffCache.Remove(); err != nil {
|
if err = diffCache.Remove(); err != nil {
|
||||||
die(err)
|
die(err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue