New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider missing time as error and skip trackpoint #1

Merged
merged 1 commit into from Mar 9, 2017
Jump to file or symbol
Failed to load files and symbols.
+8 −5
Diff settings

Always

Just for now

@@ -12,13 +12,14 @@ def initialize
end
attr_reader :coords
attr_reader :error_count
def add_file(path)
f = File.new(path)
doc = Nokogiri::XML(f)
doc.remove_namespaces!
a = Array.new
error_count = 0
@error_count = 0
trackpoints = doc.xpath('//gpx/trk/trkseg/trkpt')
trackpoints.each do |wpt|
@@ -32,7 +33,7 @@ def add_file(path)
if self.class.coord_valid?(w[:lat], w[:lon], w[:alt], w[:time])
a << w
else
error_count += 1
@error_count += 1
end
end
@@ -45,7 +46,7 @@ def add_file(path)
# Only import valid coords
def self.coord_valid?(lat, lon, elevation, time)
return true if lat and lon
return true if lat and lon and time
return false
end
@@ -60,4 +61,4 @@ def proc_time(ts)
end
end
end
end
Copy path View file
@@ -18,6 +18,7 @@
</gpxx:TrackExtension>
</extensions>
<trkseg>
<trkpt lat="53.852123" lon="27.519203"><ele>235.000000</ele><hdop>7.2</hdop><sat>4</sat><fix>3d</fix></trkpt>
<trkpt lat="52.4600566830" lon="16.9067105837">
<ele>70.79</ele>
<time>2012-03-24T15:54:56Z</time>
@@ -2428,4 +2429,4 @@
</trkpt>
</trkseg>
</trk>
</gpx>
</gpx>
@@ -13,5 +13,6 @@
coord[:lat].should_not == 0.0
coord[:lon].should_not == 0.0
end
g.error_count.should == 1
end
end
ProTip! Use n and p to navigate between commits in a pull request.