diff --git a/mapping/fields.go b/mapping/fields.go index 7407797..c899ed0 100644 --- a/mapping/fields.go +++ b/mapping/fields.go @@ -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{} { diff --git a/mapping/test_mapping.yml b/mapping/test_mapping.yml index 1f95172..6d632d6 100644 --- a/mapping/test_mapping.yml +++ b/mapping/test_mapping.yml @@ -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