class PistePal::DataServices::Trackpoints
Constants
- MINIMUM_ACCEPTABLE_DOP
Public Class Methods
call()
click to toggle source
# File lib/piste_pal/data_services/trackpoints.rb, line 8 def self.call new().call end
new()
click to toggle source
# File lib/piste_pal/data_services/trackpoints.rb, line 19 def initialize() @doc = PistePal::DataServices::GpxDoc.instance.doc @trackpoints = [] end
Public Instance Methods
call()
click to toggle source
# File lib/piste_pal/data_services/trackpoints.rb, line 12 def call extract_trackpoints @trackpoints end
Private Instance Methods
extract_params_from_trackpoint_node(trackpoint)
click to toggle source
# File lib/piste_pal/data_services/trackpoints.rb, line 32 def extract_params_from_trackpoint_node trackpoint params = Hash.new params[:lat] = trackpoint.xpath('@lat').to_s.to_f params[:lon] = trackpoint.xpath('@lon').to_s.to_f trackpoint.children.each do |child| params[:elevation] = child.text.strip.to_f if child.name == "ele" params[:time] = child.text.strip if child.name == "time" params[:hdop] = child.text.strip.to_i if child.name == "hdop" params[:vdop] = child.text.strip.to_i if child.name == "vdop" end extensions = trackpoint.children.search("extensions").first extensions.children.each do |child| params[:speed] = child.attributes["speed"].value.to_s.to_f if child.name == "gps" && !child.attributes["speed"].nil? end return params end
extract_trackpoints()
click to toggle source
# File lib/piste_pal/data_services/trackpoints.rb, line 24 def extract_trackpoints trackpoints = @doc.xpath("//xmlns:trkpt") trackpoints.each do |tp| trackpoint = PistePal::Trackpoint.new(**extract_params_from_trackpoint_node(tp)) @trackpoints.push(trackpoint) if trackpoint.hdop <= MINIMUM_ACCEPTABLE_DOP && trackpoint.vdop <= MINIMUM_ACCEPTABLE_DOP end end