Example #1
0
func makeWay(id int64, tags element.Tags, coords []coord) element.Way {
	way := element.Way{}
	way.Id = id
	way.Tags = tags
	for _, coord := range coords {
		way.Refs = append(way.Refs, coord.id)
		way.Nodes = append(way.Nodes,
			element.Node{OSMElem: element.OSMElem{Id: coord.id}, Long: coord.long, Lat: coord.lat})
	}
	return way
}
Example #2
0
func TestLineStringMatcher(t *testing.T) {
	elem := element.Way{}
	ls := mapping.LineStringMatcher()

	elem.Tags = element.Tags{"unknown": "baz"}
	matchesEqual(t, []Match{}, ls.MatchWay(&elem))

	elem.Tags = element.Tags{"highway": "unknown"}
	matchesEqual(t, []Match{}, ls.MatchWay(&elem))

	elem.Tags = element.Tags{"highway": "pedestrian"}
	matchesEqual(t, []Match{{"highway", "pedestrian", DestTable{"roads", "roads"}, nil}}, ls.MatchWay(&elem))

	// exclude_tags area=yes
	elem.Tags = element.Tags{"highway": "pedestrian", "area": "yes"}
	matchesEqual(t, []Match{}, ls.MatchWay(&elem))

	elem.Tags = element.Tags{"highway": "secondary", "railway": "tram"}
	matchesEqual(t,
		[]Match{
			{"highway", "secondary", DestTable{"roads", "roads"}, nil},
			{"railway", "tram", DestTable{"roads", "railway"}, nil}},
		ls.MatchWay(&elem))

	elem.Tags = element.Tags{"highway": "footway", "landuse": "park"}
	// landusages not a linestring table
	matchesEqual(t, []Match{{"highway", "footway", DestTable{"roads", "roads"}, nil}}, ls.MatchWay(&elem))
}