Class: CartoDB::GPX

Inherits:
Object
  • Object
show all
Defined in:
lib/cartodb-importer/gpx.rb

Overview

class to get the point number in GPX files

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ GPX

Returns a new instance of GPX.



7
8
9
10
# File 'lib/cartodb-importer/gpx.rb', line 7

def initialize(filename) 
  @filename = filename
  @ogr2ogr_bin_path = `which ogr2ogr`.strip
end

Instance Method Details

#_points_for(table) ⇒ Object



12
13
14
15
16
# File 'lib/cartodb-importer/gpx.rb', line 12

def _points_for(table) 
  cmd = "#{@ogr2ogr_bin_path} -f CSV /vsistdout/ #{@filename} -sql 'select count(*) from #{table}'"
  #RUBY WAY
  `#{cmd}`.strip.split[1].to_i
end

#route_pointsObject



22
23
24
# File 'lib/cartodb-importer/gpx.rb', line 22

def route_points
  _points_for('route_points')
end

#track_pointsObject



18
19
20
# File 'lib/cartodb-importer/gpx.rb', line 18

def track_points
  _points_for('track_points')
end