Project

tcxxxer

0.0
No commit activity in last 3 years
No release in over 3 years
A converter for TCX/GPX file, you get can all `lap`, `track` info from the `tcx` file!
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.9
= 1.6.8
~> 10.0
 Project Readme

Tcxxxer

Gem Version

I search a lot but I couldn't find out a valid gem which I can use to parse/conert a tcx file easily. so I wrote this, essentially I check the gem guppy but I found it outdated a long age, the logic to parse tcx file had been outdated. please check this gem if you want to work with tcx file.

Installation

Add this line to your application's Gemfile:

gem 'tcxxxer'

And then execute:

$ bundle

Or install it yourself as:

$ gem install tcxxxer

Usage

get '/map' do
  # input parameter
  # name
  day = params['day']
  file_name = "TourDeHokkaido_day#{day}"
  db           = Tcxxxer::DB.open("./tcx/#{file_name}.tcx")
  @points_list = []
  db.courses.each do |course|
    max_distance = (course.track.last.distance/1000).round(2).to_s + "km"
    course_range = course.track.each_slice(400).to_a

    course_range.each_with_index do |range, _i|
      @points    = []
      @altitudes = []
      range.each do |point|
        @points << (point.distance/1000).round(2).to_s + "km"
        @altitudes << point.altitude.round(2)
        # @points_list << {:points => @points, :altitudes => @altitudes}
      end

      begin
          # read all, get each id
          html_file = "./tcx_result/#{file_name}_#{_i}.html"
          puts "start read erb, and create html file ...."
          renderer = ERB.new(File.read("./views/line.erb"))
          result   = renderer.result(binding)

          File.open(html_file, 'w') do |f|
            puts "write #{html_file} start"
            f.write(result)
          end

        rescue => e
          puts e.message
        end

    end
  end
  # get file list
  @result_list = Dir["./tcx_result/#{file_name}*.html"]
  erb :line_result
end

more please check my strava 次世代の名刺