match on Tags and not OSMElem
parent
15aee91f6d
commit
f07b970951
|
@ -41,7 +41,7 @@ type Mapping struct {
|
|||
GeneralizedTables GeneralizedTables `json:"generalized_tables"`
|
||||
}
|
||||
|
||||
type ElementFilter func(elem *element.OSMElem) bool
|
||||
type ElementFilter func(tags *element.Tags) bool
|
||||
|
||||
type TagTables map[string]map[string][]string
|
||||
|
||||
|
@ -134,8 +134,8 @@ func (m *Mapping) ElementFilters() map[string][]ElementFilter {
|
|||
}
|
||||
if t.Filters.ExcludeTags != nil {
|
||||
for filterKey, filterVal := range *t.Filters.ExcludeTags {
|
||||
f := func(elem *element.OSMElem) bool {
|
||||
if v, ok := elem.Tags[filterKey]; ok {
|
||||
f := func(tags *element.Tags) bool {
|
||||
if v, ok := (*tags)[filterKey]; ok {
|
||||
if filterVal == "__any__" || v == filterVal {
|
||||
return false
|
||||
}
|
||||
|
|
|
@ -42,10 +42,10 @@ func (m *Match) Row(elem *element.OSMElem) []interface{} {
|
|||
return m.tableFields.MakeRow(elem, *m)
|
||||
}
|
||||
|
||||
func (tagMatcher *TagMatcher) Match(elem *element.OSMElem) []Match {
|
||||
func (tagMatcher *TagMatcher) Match(tags *element.Tags) []Match {
|
||||
tables := make(map[string]Match)
|
||||
|
||||
for k, v := range elem.Tags {
|
||||
for k, v := range *tags {
|
||||
values, ok := tagMatcher.mappings[k]
|
||||
if ok {
|
||||
if tbls, ok := values["__any__"]; ok {
|
||||
|
@ -67,7 +67,7 @@ func (tagMatcher *TagMatcher) Match(elem *element.OSMElem) []Match {
|
|||
filteredOut := false
|
||||
if ok {
|
||||
for _, filter := range filters {
|
||||
if !filter(elem) {
|
||||
if !filter(tags) {
|
||||
filteredOut = true
|
||||
break
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ func (nw *NodeWriter) loop() {
|
|||
|
||||
for n := range nw.nodes {
|
||||
nw.progress.AddNodes(1)
|
||||
if matches := nw.tagMatcher.Match(&n.OSMElem); len(matches) > 0 {
|
||||
if matches := nw.tagMatcher.Match(&n.Tags); len(matches) > 0 {
|
||||
proj.NodeToMerc(n)
|
||||
n.Geom, err = geom.PointWKB(geos, *n)
|
||||
if err != nil {
|
||||
|
|
|
@ -79,7 +79,7 @@ func (rw *RelationWriter) loop() {
|
|||
log.Println(err)
|
||||
continue
|
||||
}
|
||||
if matches := rw.tagMatcher.Match(&r.OSMElem); len(matches) > 0 {
|
||||
if matches := rw.tagMatcher.Match(&r.Tags); len(matches) > 0 {
|
||||
for _, match := range matches {
|
||||
row := match.Row(&r.OSMElem)
|
||||
rw.insertBuffer.Insert(match.Table, row)
|
||||
|
|
|
@ -66,7 +66,7 @@ func (ww *WayWriter) loop() {
|
|||
continue
|
||||
}
|
||||
proj.NodesToMerc(w.Nodes)
|
||||
if matches := ww.lineStringTagMatcher.Match(&w.OSMElem); len(matches) > 0 {
|
||||
if matches := ww.lineStringTagMatcher.Match(&w.Tags); len(matches) > 0 {
|
||||
// make copy to avoid interference with polygon matches
|
||||
way := element.Way(*w)
|
||||
way.Geom, err = geom.LineStringWKB(geos, way.Nodes)
|
||||
|
@ -86,7 +86,7 @@ func (ww *WayWriter) loop() {
|
|||
|
||||
}
|
||||
if w.IsClosed() {
|
||||
if matches := ww.polygonTagMatcher.Match(&w.OSMElem); len(matches) > 0 {
|
||||
if matches := ww.polygonTagMatcher.Match(&w.Tags); len(matches) > 0 {
|
||||
way := element.Way(*w)
|
||||
way.Geom, err = geom.PolygonWKB(geos, way.Nodes)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue