use buffered geometry limiter in diff import
parent
4ec962f002
commit
7500984424
|
@ -9,11 +9,12 @@ 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"`
|
LimitToCacheBuffer float64 `json:"limitto_cache_buffer"`
|
||||||
|
Srid int `json:"srid"`
|
||||||
}
|
}
|
||||||
|
|
||||||
const defaultSrid = 3857
|
const defaultSrid = 3857
|
||||||
|
@ -23,12 +24,13 @@ var ImportFlags = flag.NewFlagSet("import", flag.ExitOnError)
|
||||||
var DiffImportFlags = flag.NewFlagSet("diff", flag.ExitOnError)
|
var DiffImportFlags = flag.NewFlagSet("diff", flag.ExitOnError)
|
||||||
|
|
||||||
type ImportBaseOptions struct {
|
type ImportBaseOptions struct {
|
||||||
Connection string
|
Connection string
|
||||||
CacheDir string
|
CacheDir string
|
||||||
MappingFile string
|
MappingFile string
|
||||||
Srid int
|
Srid int
|
||||||
LimitTo string
|
LimitTo string
|
||||||
ConfigFile string
|
LimitToCacheBuffer float64
|
||||||
|
ConfigFile string
|
||||||
}
|
}
|
||||||
|
|
||||||
type _ImportOptions struct {
|
type _ImportOptions struct {
|
||||||
|
@ -148,6 +150,9 @@ func updateBaseOpts(opts *ImportBaseOptions) []error {
|
||||||
if opts.LimitTo == "" {
|
if opts.LimitTo == "" {
|
||||||
opts.LimitTo = conf.LimitTo
|
opts.LimitTo = conf.LimitTo
|
||||||
}
|
}
|
||||||
|
if opts.LimitToCacheBuffer == 0.0 {
|
||||||
|
opts.LimitToCacheBuffer = conf.LimitToCacheBuffer
|
||||||
|
}
|
||||||
if opts.CacheDir == defaultCacheDir {
|
if opts.CacheDir == defaultCacheDir {
|
||||||
opts.CacheDir = conf.CacheDir
|
opts.CacheDir = conf.CacheDir
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ import (
|
||||||
diffstate "goposm/diff/state"
|
diffstate "goposm/diff/state"
|
||||||
"goposm/element"
|
"goposm/element"
|
||||||
"goposm/expire"
|
"goposm/expire"
|
||||||
|
"goposm/geom/geos"
|
||||||
"goposm/geom/limit"
|
"goposm/geom/limit"
|
||||||
"goposm/logging"
|
"goposm/logging"
|
||||||
"goposm/mapping"
|
"goposm/mapping"
|
||||||
|
@ -126,6 +127,7 @@ func Update(oscFile string, geometryLimiter *limit.Limiter, force bool) {
|
||||||
|
|
||||||
step := log.StartStep("Parsing changes, updating cache and removing elements")
|
step := log.StartStep("Parsing changes, updating cache and removing elements")
|
||||||
|
|
||||||
|
g := geos.NewGeos()
|
||||||
For:
|
For:
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
|
@ -182,10 +184,11 @@ For:
|
||||||
wayIds[elem.Way.Id] = true
|
wayIds[elem.Way.Id] = true
|
||||||
}
|
}
|
||||||
} else if elem.Node != nil {
|
} else if elem.Node != nil {
|
||||||
// TODO: check for intersection with import BBOX/poly
|
if geometryLimiter.IntersectsBuffer(g, elem.Node.Long, elem.Node.Lat) {
|
||||||
osmCache.Nodes.PutNode(elem.Node)
|
osmCache.Nodes.PutNode(elem.Node)
|
||||||
osmCache.Coords.PutCoords([]element.Node{*elem.Node})
|
osmCache.Coords.PutCoords([]element.Node{*elem.Node})
|
||||||
nodeIds[elem.Node.Id] = true
|
nodeIds[elem.Node.Id] = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case err := <-errc:
|
case err := <-errc:
|
||||||
|
|
|
@ -74,7 +74,10 @@ func main() {
|
||||||
if config.DiffImportOptions.Base.LimitTo != "" {
|
if config.DiffImportOptions.Base.LimitTo != "" {
|
||||||
var err error
|
var err error
|
||||||
step := log.StartStep("Reading limitto geometries")
|
step := log.StartStep("Reading limitto geometries")
|
||||||
geometryLimiter, err = limit.NewFromOgrSource(config.DiffImportOptions.Base.LimitTo)
|
geometryLimiter, err = limit.NewFromOgrSourceWithBuffered(
|
||||||
|
config.DiffImportOptions.Base.LimitTo,
|
||||||
|
config.DiffImportOptions.Base.LimitToCacheBuffer,
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue