Example #1
0
func osmRelationToTrainLine(osm *osm.Osm, index *osm.Index, relation osm.Relation) (trainLine model.TrainLine) {

	var sections model.Sections

	for _, member := range relation.WayMembers() {
		way := index.WayById(member.Ref)
		if way != nil {
			sections = append(sections, wayToSection(osm, index, *way))
		}
	}

	trainLine.Sections = sections
	return trainLine
}
Example #2
0
func wayToSection(osm *osm.Osm, index *osm.Index, way osm.Way) (section model.Section) {

	var points model.Points

	for _, nd := range way.Nd {
		node := index.NodeById(nd.Ref)
		if node != nil {
			point := model.Point{X: node.Lon, Y: node.Lat}
			points = append(points, point)
		}

	}
	//TODO extract stations info from way.Nds
	section.Points = points
	return section
}