fix string_suffixreplace argument loading (closes #63)
yaml returns map[interface{}]interface{} instead of map[string]interface{}master
parent
51c904b39e
commit
406cf4f34a
|
@ -93,7 +93,7 @@ func (t *Table) TableFields() *TableFields {
|
|||
if fieldType != nil {
|
||||
field.Type = *fieldType
|
||||
} else {
|
||||
log.Warn("unhandled type:", mappingField.Type)
|
||||
log.Warn("unhandled type: ", mappingField.Type)
|
||||
}
|
||||
result.fields = append(result.fields, field)
|
||||
}
|
||||
|
@ -313,20 +313,28 @@ func MakeSuffixReplace(fieldName string, fieldType FieldType, field Field) (Make
|
|||
return nil, errors.New("missing suffixes in args for string_suffixreplace")
|
||||
}
|
||||
|
||||
changes, ok := _changes.(map[string]interface{})
|
||||
changes, ok := _changes.(map[interface{}]interface{})
|
||||
if !ok {
|
||||
return nil, errors.New("suffixes in args for string_suffixreplace not a dict")
|
||||
}
|
||||
|
||||
strChanges := make(map[string]string, len(changes))
|
||||
for k, v := range changes {
|
||||
_, kok := k.(string)
|
||||
_, vok := v.(string)
|
||||
if !kok || !vok {
|
||||
return nil, errors.New("suffixes in args for string_suffixreplace not strings")
|
||||
}
|
||||
strChanges[k.(string)] = v.(string)
|
||||
}
|
||||
var suffixes []string
|
||||
for k, _ := range changes {
|
||||
for k, _ := range strChanges {
|
||||
suffixes = append(suffixes, k)
|
||||
}
|
||||
reStr := `(` + strings.Join(suffixes, "|") + `)\b`
|
||||
re := regexp.MustCompile(reStr)
|
||||
|
||||
replFunc := func(match string) string {
|
||||
return changes[match].(string)
|
||||
return strChanges[match]
|
||||
}
|
||||
|
||||
suffixReplace := func(val string, elem *element.OSMElem, geom *geom.Geometry, match Match) interface{} {
|
||||
|
|
|
@ -288,7 +288,7 @@ tables:
|
|||
- footway
|
||||
- pedestrian
|
||||
name: z_order
|
||||
type: eumerate
|
||||
type: enumerate
|
||||
mapping:
|
||||
aeroway:
|
||||
- runway
|
||||
|
@ -409,7 +409,12 @@ tables:
|
|||
type: mapping_value
|
||||
- key: name
|
||||
name: name
|
||||
type: string
|
||||
type: string_suffixreplace
|
||||
args:
|
||||
suffixes:
|
||||
street: str.
|
||||
straße: str.
|
||||
Straße: Str.
|
||||
- key: tunnel
|
||||
name: tunnel
|
||||
type: boolint
|
||||
|
|
Loading…
Reference in New Issue