Example #1
0
func parseRelationMembers(rel *osmpbf.Relation, stringtable stringTable) []element.Member {
	result := make([]element.Member, len(rel.Memids))

	var lastId int64
	for i := range rel.Memids {
		lastId += rel.Memids[i]
		result[i].Id = lastId
		result[i].Role = stringtable[rel.RolesSid[i]]
		result[i].Type = element.MemberType(rel.Types[i])
	}
	return result
}
Example #2
0
func UnmarshalRelation(data []byte) (relation *element.Relation, err error) {
	pbfRelation := &Relation{}
	err = proto.Unmarshal(data, pbfRelation)
	if err != nil {
		return nil, err
	}

	relation = &element.Relation{}
	relation.Members = make([]element.Member, len(pbfRelation.MemberIds))
	for i, _ := range pbfRelation.MemberIds {
		relation.Members[i].Id = pbfRelation.MemberIds[i]
		relation.Members[i].Type = element.MemberType(pbfRelation.MemberTypes[i])
		relation.Members[i].Role = pbfRelation.MemberRoles[i]
	}
	//relation.Nodes = pbfRelation.Node
	relation.Tags = tagsFromArray(pbfRelation.Tags)
	return relation, nil
}