move config package into mapping package
parent
560f659b5b
commit
d51cda1ffc
20
goposm.go
20
goposm.go
|
@ -3,11 +3,11 @@ package main
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"goposm/cache"
|
"goposm/cache"
|
||||||
"goposm/config"
|
|
||||||
"goposm/db"
|
"goposm/db"
|
||||||
"goposm/element"
|
"goposm/element"
|
||||||
"goposm/geom"
|
"goposm/geom"
|
||||||
"goposm/geom/geos"
|
"goposm/geom/geos"
|
||||||
|
"goposm/mapping"
|
||||||
"goposm/parser"
|
"goposm/parser"
|
||||||
"goposm/proj"
|
"goposm/proj"
|
||||||
"goposm/stats"
|
"goposm/stats"
|
||||||
|
@ -47,7 +47,7 @@ type ErrorLevel interface {
|
||||||
Level() int
|
Level() int
|
||||||
}
|
}
|
||||||
|
|
||||||
func parse(cache *cache.OSMCache, progress *stats.Statistics, mapping *config.Mapping, filename string) {
|
func parse(cache *cache.OSMCache, progress *stats.Statistics, tagmapping *mapping.Mapping, filename string) {
|
||||||
nodes := make(chan []element.Node)
|
nodes := make(chan []element.Node)
|
||||||
coords := make(chan []element.Node)
|
coords := make(chan []element.Node)
|
||||||
ways := make(chan []element.Way)
|
ways := make(chan []element.Way)
|
||||||
|
@ -78,7 +78,7 @@ func parse(cache *cache.OSMCache, progress *stats.Statistics, mapping *config.Ma
|
||||||
for i := 0; i < runtime.NumCPU(); i++ {
|
for i := 0; i < runtime.NumCPU(); i++ {
|
||||||
waitCounter.Add(1)
|
waitCounter.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
m := mapping.WayTagFilter()
|
m := tagmapping.WayTagFilter()
|
||||||
for ws := range ways {
|
for ws := range ways {
|
||||||
if skipWays {
|
if skipWays {
|
||||||
continue
|
continue
|
||||||
|
@ -95,7 +95,7 @@ func parse(cache *cache.OSMCache, progress *stats.Statistics, mapping *config.Ma
|
||||||
for i := 0; i < runtime.NumCPU(); i++ {
|
for i := 0; i < runtime.NumCPU(); i++ {
|
||||||
waitCounter.Add(1)
|
waitCounter.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
m := mapping.RelationTagFilter()
|
m := tagmapping.RelationTagFilter()
|
||||||
for rels := range relations {
|
for rels := range relations {
|
||||||
for _, r := range rels {
|
for _, r := range rels {
|
||||||
m.Filter(r.Tags)
|
m.Filter(r.Tags)
|
||||||
|
@ -122,7 +122,7 @@ func parse(cache *cache.OSMCache, progress *stats.Statistics, mapping *config.Ma
|
||||||
for i := 0; i < 2; i++ {
|
for i := 0; i < 2; i++ {
|
||||||
waitCounter.Add(1)
|
waitCounter.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
m := mapping.NodeTagFilter()
|
m := tagmapping.NodeTagFilter()
|
||||||
for nds := range nodes {
|
for nds := range nodes {
|
||||||
if skipNodes {
|
if skipNodes {
|
||||||
continue
|
continue
|
||||||
|
@ -214,14 +214,14 @@ func main() {
|
||||||
|
|
||||||
progress := stats.StatsReporter()
|
progress := stats.StatsReporter()
|
||||||
|
|
||||||
mapping, err := config.NewMapping(*mappingFile)
|
tagmapping, err := mapping.NewMapping(*mappingFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if *read != "" {
|
if *read != "" {
|
||||||
osmCache.Coords.SetLinearImport(true)
|
osmCache.Coords.SetLinearImport(true)
|
||||||
parse(osmCache, progress, mapping, *read)
|
parse(osmCache, progress, tagmapping, *read)
|
||||||
osmCache.Coords.SetLinearImport(false)
|
osmCache.Coords.SetLinearImport(false)
|
||||||
progress.Reset()
|
progress.Reset()
|
||||||
osmCache.Coords.Flush()
|
osmCache.Coords.Flush()
|
||||||
|
@ -265,7 +265,7 @@ func main() {
|
||||||
[]db.ColumnSpec{
|
[]db.ColumnSpec{
|
||||||
{"name", "VARCHAR", nil},
|
{"name", "VARCHAR", nil},
|
||||||
{"highway", "VARCHAR", nil},
|
{"highway", "VARCHAR", nil},
|
||||||
{"oneway", "SMALLINT", config.Direction},
|
{"oneway", "SMALLINT", mapping.Direction},
|
||||||
},
|
},
|
||||||
"GEOMETRY",
|
"GEOMETRY",
|
||||||
conf.Srid,
|
conf.Srid,
|
||||||
|
@ -291,8 +291,8 @@ func main() {
|
||||||
for i := 0; i < runtime.NumCPU(); i++ {
|
for i := 0; i < runtime.NumCPU(); i++ {
|
||||||
waitFill.Add(1)
|
waitFill.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
lineStringTables := mapping.LineStringTables()
|
lineStringTables := tagmapping.LineStringTables()
|
||||||
polygonTables := mapping.PolygonTables()
|
polygonTables := tagmapping.PolygonTables()
|
||||||
var err error
|
var err error
|
||||||
geos := geos.NewGEOS()
|
geos := geos.NewGEOS()
|
||||||
defer geos.Finish()
|
defer geos.Finish()
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package config
|
package mapping
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
|
@ -1,44 +1,11 @@
|
||||||
package mapping
|
package mapping
|
||||||
|
|
||||||
import (
|
|
||||||
"goposm/element"
|
|
||||||
)
|
|
||||||
|
|
||||||
type TagMap map[string]map[string]bool
|
type TagMap map[string]map[string]bool
|
||||||
|
|
||||||
var PointTags TagMap
|
var PointTags TagMap
|
||||||
var WayTags TagMap
|
var WayTags TagMap
|
||||||
var RelationTags TagMap
|
var RelationTags TagMap
|
||||||
|
|
||||||
type TagFilter interface {
|
|
||||||
Filter(element.Tags) bool
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m TagMap) Filter(tags element.Tags) bool {
|
|
||||||
for k, v := range tags {
|
|
||||||
values, ok := m[k]
|
|
||||||
if !ok {
|
|
||||||
delete(tags, k)
|
|
||||||
} else {
|
|
||||||
if _, ok := values["__any__"]; ok {
|
|
||||||
continue
|
|
||||||
} else if _, ok := values[v]; ok {
|
|
||||||
continue
|
|
||||||
} else {
|
|
||||||
delete(tags, k)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if _, ok := tags["name"]; ok && len(tags) == 1 {
|
|
||||||
delete(tags, "name")
|
|
||||||
}
|
|
||||||
if len(tags) > 0 {
|
|
||||||
return true
|
|
||||||
} else {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// default mapping created from imposm defaultmapping.py
|
// default mapping created from imposm defaultmapping.py
|
||||||
// TODO make configurable
|
// TODO make configurable
|
||||||
func init() {
|
func init() {
|
||||||
|
|
Loading…
Reference in New Issue