예제 #1
0
파일: main.go 프로젝트: kirillrdy/train
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
}
예제 #2
0
파일: main.go 프로젝트: kirillrdy/train
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
}