File tree 2 files changed +9
-10
lines changed
2 files changed +9
-10
lines changed Original file line number Diff line number Diff line change @@ -203,7 +203,7 @@ def import
203
203
logger . info ( "GPX Import importing #{ name } (#{ id } ) from #{ user . email } " )
204
204
205
205
file . open do |file |
206
- gpx = GPX ::File . new ( file . path , :maximum_points => Settings . max_trace_size )
206
+ gpx = GPX ::File . new ( :maximum_points => Settings . max_trace_size )
207
207
208
208
f_lat = 0
209
209
f_lon = 0
@@ -212,7 +212,7 @@ def import
212
212
# If there are any existing points for this trace then delete them
213
213
Tracepoint . where ( :trace => id ) . delete_all
214
214
215
- gpx . points . each_slice ( 1_000 ) do |points |
215
+ gpx . read ( file . path ) . each_slice ( 1_000 ) do |points |
216
216
# Gather the trace points together for a bulk import
217
217
tracepoints = [ ]
218
218
Original file line number Diff line number Diff line change @@ -6,8 +6,7 @@ class File
6
6
7
7
attr_reader :possible_points , :actual_points , :tracksegs
8
8
9
- def initialize ( file , options = { } )
10
- @file = file
9
+ def initialize ( options = { } )
11
10
@maximum_points = options [ :maximum_points ] || Float ::INFINITY
12
11
@possible_points = 0
13
12
@actual_points = 0
@@ -16,19 +15,19 @@ def initialize(file, options = {})
16
15
@lons = [ ]
17
16
end
18
17
19
- def points ( &block )
20
- return enum_for ( :points ) unless block
18
+ def read ( file , &block )
19
+ return enum_for ( :read , file ) unless block
21
20
22
21
begin
23
- Archive ::Reader . open_filename ( @ file) . each_entry_with_data do |entry , data |
22
+ Archive ::Reader . open_filename ( file ) . each_entry_with_data do |entry , data |
24
23
parse_file ( XML ::Reader . string ( data ) , &block ) if entry . regular?
25
24
end
26
25
rescue Archive ::Error
27
- io = ::File . open ( @ file)
26
+ io = ::File . open ( file )
28
27
29
28
case Marcel ::MimeType . for ( io )
30
- when "application/gzip" then io = Zlib ::GzipReader . open ( @ file)
31
- when "application/x-bzip" then io = Bzip2 ::FFI ::Reader . open ( @ file)
29
+ when "application/gzip" then io = Zlib ::GzipReader . open ( file )
30
+ when "application/x-bzip" then io = Bzip2 ::FFI ::Reader . open ( file )
32
31
end
33
32
34
33
parse_file ( XML ::Reader . io ( io , :options => XML ::Parser ::Options ::NOERROR ) , &block )
You can’t perform that action at this time.
0 commit comments