@@ -62,7 +62,7 @@ def parse_geojson_data(data)
6262 end
6363
6464 def add_tracks_to ( gpx_file , geojson , opts )
65- tracks = [ line_strings_to_track ( geojson , opts ) ] +
65+ tracks = line_strings_to_track ( geojson , opts ) +
6666 multi_line_strings_to_tracks ( geojson , opts )
6767 tracks . compact!
6868 gpx_file . tracks += tracks
@@ -83,6 +83,28 @@ def line_strings_to_track(geojson, opts)
8383 line_strings = line_strings_in ( geojson )
8484 return nil unless line_strings . any?
8585
86+ tracks = [ ]
87+
88+ line_strings . each do |ls |
89+ track = GPX ::Track . new
90+ coords = ls [ 'geometry' ] [ 'coordinates' ]
91+ segment = coords_to_segment ( coords )
92+
93+ opts [ :line_string_feature_to_segment ] &.call ( ls , segment )
94+ track . append_segment ( segment )
95+ tracks << track
96+ end
97+ tracks
98+ end
99+
100+ # Converts GeoJSON 'LineString' features.
101+ # Current strategy is to convert each LineString into a
102+ # Track Segment, returning a Track for all LineStrings.
103+ #
104+ def line_strings_to_track_segment ( geojson , opts )
105+ line_strings = line_strings_in ( geojson )
106+ return nil unless line_strings . any?
107+
86108 track = GPX ::Track . new
87109 line_strings . each do |ls |
88110 coords = ls [ 'geometry' ] [ 'coordinates' ]
0 commit comments