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