add keys to composite literals

master
Oliver Tonnhofer 2015-09-25 11:27:56 +02:00
parent b473592bc2
commit 8003ea5fa4
2 changed files with 24 additions and 24 deletions

View File

@ -263,16 +263,16 @@ func TestPointMatcher(t *testing.T) {
matchesEqual(t, []Match{}, points.MatchNode(&elem)) matchesEqual(t, []Match{}, points.MatchNode(&elem))
elem.Tags = element.Tags{"place": "city"} elem.Tags = element.Tags{"place": "city"}
matchesEqual(t, []Match{{"place", "city", DestTable{"places", ""}, nil}}, points.MatchNode(&elem)) matchesEqual(t, []Match{{"place", "city", DestTable{Name: "places"}, nil}}, points.MatchNode(&elem))
elem.Tags = element.Tags{"place": "city", "highway": "unknown"} elem.Tags = element.Tags{"place": "city", "highway": "unknown"}
matchesEqual(t, []Match{{"place", "city", DestTable{"places", ""}, nil}}, points.MatchNode(&elem)) matchesEqual(t, []Match{{"place", "city", DestTable{Name: "places"}, nil}}, points.MatchNode(&elem))
elem.Tags = element.Tags{"place": "city", "highway": "bus_stop"} elem.Tags = element.Tags{"place": "city", "highway": "bus_stop"}
matchesEqual(t, matchesEqual(t,
[]Match{ []Match{
{"place", "city", DestTable{"places", ""}, nil}, {"place", "city", DestTable{Name: "places"}, nil},
{"highway", "bus_stop", DestTable{"transport_points", ""}, nil}}, {"highway", "bus_stop", DestTable{Name: "transport_points"}, nil}},
points.MatchNode(&elem)) points.MatchNode(&elem))
} }
@ -287,7 +287,7 @@ func TestLineStringMatcher(t *testing.T) {
matchesEqual(t, []Match{}, ls.MatchWay(&elem)) matchesEqual(t, []Match{}, ls.MatchWay(&elem))
elem.Tags = element.Tags{"highway": "pedestrian"} elem.Tags = element.Tags{"highway": "pedestrian"}
matchesEqual(t, []Match{{"highway", "pedestrian", DestTable{"roads", "roads"}, nil}}, ls.MatchWay(&elem)) matchesEqual(t, []Match{{"highway", "pedestrian", DestTable{Name: "roads", SubMapping: "roads"}, nil}}, ls.MatchWay(&elem))
// exclude_tags area=yes // exclude_tags area=yes
elem.Tags = element.Tags{"highway": "pedestrian", "area": "yes"} elem.Tags = element.Tags{"highway": "pedestrian", "area": "yes"}
@ -296,13 +296,13 @@ func TestLineStringMatcher(t *testing.T) {
elem.Tags = element.Tags{"highway": "secondary", "railway": "tram"} elem.Tags = element.Tags{"highway": "secondary", "railway": "tram"}
matchesEqual(t, matchesEqual(t,
[]Match{ []Match{
{"highway", "secondary", DestTable{"roads", "roads"}, nil}, {"highway", "secondary", DestTable{Name: "roads", SubMapping: "roads"}, nil},
{"railway", "tram", DestTable{"roads", "railway"}, nil}}, {"railway", "tram", DestTable{Name: "roads", SubMapping: "railway"}, nil}},
ls.MatchWay(&elem)) ls.MatchWay(&elem))
elem.Tags = element.Tags{"highway": "footway", "landuse": "park"} elem.Tags = element.Tags{"highway": "footway", "landuse": "park"}
// landusages not a linestring table // landusages not a linestring table
matchesEqual(t, []Match{{"highway", "footway", DestTable{"roads", "roads"}, nil}}, ls.MatchWay(&elem)) matchesEqual(t, []Match{{"highway", "footway", DestTable{Name: "roads", SubMapping: "roads"}, nil}}, ls.MatchWay(&elem))
} }
func TestPolygonMatcher(t *testing.T) { func TestPolygonMatcher(t *testing.T) {
@ -316,34 +316,34 @@ func TestPolygonMatcher(t *testing.T) {
matchesEqual(t, []Match{}, polys.MatchRelation(&elem)) matchesEqual(t, []Match{}, polys.MatchRelation(&elem))
elem.Tags = element.Tags{"building": "yes"} elem.Tags = element.Tags{"building": "yes"}
matchesEqual(t, []Match{{"building", "yes", DestTable{"buildings", ""}, nil}}, polys.MatchRelation(&elem)) matchesEqual(t, []Match{{"building", "yes", DestTable{Name: "buildings"}, nil}}, polys.MatchRelation(&elem))
elem.Tags = element.Tags{"building": "residential"} elem.Tags = element.Tags{"building": "residential"}
matchesEqual(t, []Match{{"building", "residential", DestTable{"buildings", ""}, nil}}, polys.MatchRelation(&elem)) matchesEqual(t, []Match{{"building", "residential", DestTable{Name: "buildings"}, nil}}, polys.MatchRelation(&elem))
elem.Tags = element.Tags{"building": "shop"} elem.Tags = element.Tags{"building": "shop"}
matchesEqual(t, []Match{ matchesEqual(t, []Match{
{"building", "shop", DestTable{"buildings", ""}, nil}, {"building", "shop", DestTable{Name: "buildings"}, nil},
{"building", "shop", DestTable{"amenity_areas", ""}, nil}}, {"building", "shop", DestTable{Name: "amenity_areas"}, nil}},
polys.MatchRelation(&elem)) polys.MatchRelation(&elem))
elem.Tags = element.Tags{"landuse": "farm"} elem.Tags = element.Tags{"landuse": "farm"}
matchesEqual(t, []Match{{"landuse", "farm", DestTable{"landusages", ""}, nil}}, polys.MatchRelation(&elem)) matchesEqual(t, []Match{{"landuse", "farm", DestTable{Name: "landusages"}, nil}}, polys.MatchRelation(&elem))
elem.Tags = element.Tags{"landuse": "farm", "highway": "secondary"} elem.Tags = element.Tags{"landuse": "farm", "highway": "secondary"}
matchesEqual(t, []Match{{"landuse", "farm", DestTable{"landusages", ""}, nil}}, polys.MatchRelation(&elem)) matchesEqual(t, []Match{{"landuse", "farm", DestTable{Name: "landusages"}, nil}}, polys.MatchRelation(&elem))
elem.Tags = element.Tags{"landuse": "farm", "aeroway": "apron"} elem.Tags = element.Tags{"landuse": "farm", "aeroway": "apron"}
matchesEqual(t, matchesEqual(t,
[]Match{ []Match{
{"aeroway", "apron", DestTable{"transport_areas", ""}, nil}, {"aeroway", "apron", DestTable{Name: "transport_areas"}, nil},
{"landuse", "farm", DestTable{"landusages", ""}, nil}}, {"landuse", "farm", DestTable{Name: "landusages"}, nil}},
polys.MatchRelation(&elem)) polys.MatchRelation(&elem))
elem.Tags = element.Tags{"highway": "footway"} elem.Tags = element.Tags{"highway": "footway"}
matchesEqual(t, []Match{{"highway", "footway", DestTable{"landusages", ""}, nil}}, polys.MatchRelation(&elem)) matchesEqual(t, []Match{{"highway", "footway", DestTable{Name: "landusages"}, nil}}, polys.MatchRelation(&elem))
elem.Tags = element.Tags{"boundary": "administrative", "admin_level": "8"} elem.Tags = element.Tags{"boundary": "administrative", "admin_level": "8"}
matchesEqual(t, []Match{{"boundary", "administrative", DestTable{"admin", ""}, nil}}, polys.MatchRelation(&elem)) matchesEqual(t, []Match{{"boundary", "administrative", DestTable{Name: "admin"}, nil}}, polys.MatchRelation(&elem))
} }
func TestFilterNodes(t *testing.T) { func TestFilterNodes(t *testing.T) {

View File

@ -23,17 +23,17 @@ func BenchmarkTagMatch(b *testing.B) {
func makeMember(id int64, tags element.Tags) element.Member { func makeMember(id int64, tags element.Tags) element.Member {
way := &element.Way{ way := &element.Way{
element.OSMElem{id, tags}, OSMElem: element.OSMElem{Id: id, Tags: tags},
[]int64{0, 1, 2, 0}, // fake closed way, req. for SelectRelationPolygons Refs: []int64{0, 1, 2, 0}, // fake closed way, req. for SelectRelationPolygons
nil} }
return element.Member{Id: id, Type: element.WAY, Role: "", Way: way} return element.Member{Id: id, Type: element.WAY, Role: "", Way: way}
} }
func makeMemberRole(id int64, tags element.Tags, role string) element.Member { func makeMemberRole(id int64, tags element.Tags, role string) element.Member {
way := &element.Way{ way := &element.Way{
element.OSMElem{id, tags}, OSMElem: element.OSMElem{Id: id, Tags: tags},
[]int64{0, 1, 2, 0}, // fake closed way, req. for SelectRelationPolygons Refs: []int64{0, 1, 2, 0}, // fake closed way, req. for SelectRelationPolygons
nil} }
return element.Member{Id: id, Type: element.WAY, Role: role, Way: way} return element.Member{Id: id, Type: element.WAY, Role: role, Way: way}
} }