New merge algorithm
This should be a comment to a previous post, but it seems that code is not well formatted in comments
This code snippet below should lead me into the right direction for better performance in merging my cycling log data
def new_merge(gpx, hac, delta)
#
# adjust the 2 arrays
# (works only if gpx starts earlier)
#
while gpx.first[:time] < asc.first[:time]
gpx.shift
end
#
# merge data
#
asc.each do |h|
# next if there gps dropouts
next if h[:time] + 2 > gpx.first[:time]
h.merge!(gpx.shift)
break if gpx.size == 0
end
0
end
#
# adjust the 2 arrays
# (works only if gpx starts earlier)
#
while gpx.first[:time] < asc.first[:time]
gpx.shift
end
#
# merge data
#
asc.each do |h|
# next if there gps dropouts
next if h[:time] + 2 > gpx.first[:time]
h.merge!(gpx.shift)
break if gpx.size == 0
end
0
end
