Class: Mormon::OSM::Loader
- Inherits:
-
Object
- Object
- Mormon::OSM::Loader
- Defined in:
- lib/mormon/osm_loader.rb
Class Attribute Summary collapse
-
.cache_dir ⇒ Object
Returns the value of attribute cache_dir.
-
.route_types ⇒ Object
readonly
Returns the value of attribute route_types.
Instance Attribute Summary collapse
-
#nodes ⇒ Object
readonly
Returns the value of attribute nodes.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#osm_filename ⇒ Object
readonly
Returns the value of attribute osm_filename.
-
#route_types ⇒ Object
readonly
Returns the value of attribute route_types.
-
#routeable_nodes ⇒ Object
readonly
Returns the value of attribute routeable_nodes.
-
#routing ⇒ Object
readonly
Returns the value of attribute routing.
-
#tiles ⇒ Object
readonly
Returns the value of attribute tiles.
-
#ways ⇒ Object
readonly
Returns the value of attribute ways.
Instance Method Summary collapse
- #cache_filename ⇒ Object
-
#initialize(filename, options = {}) ⇒ Loader
constructor
A new instance of Loader.
- #report ⇒ Object
Constructor Details
#initialize(filename, options = {}) ⇒ Loader
Returns a new instance of Loader.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/mormon/osm_loader.rb', line 19 def initialize(filename, = {}) @options = @tiles = {} @nodes = {} @ways = {} @routing = {} @routeable_nodes = {} Loader.route_types.each do |type| @routing[type] = {} @routeable_nodes[type] = {} end # @tilename = Mormon::Tile::Name.new # @tiledata = Mormon::Tile::Data.new @osm_filename = filename @options[:cache] ? load_cached : parse end |
Class Attribute Details
.cache_dir ⇒ Object
Returns the value of attribute cache_dir.
13 14 15 |
# File 'lib/mormon/osm_loader.rb', line 13 def cache_dir @cache_dir end |
.route_types ⇒ Object (readonly)
Returns the value of attribute route_types.
12 13 14 |
# File 'lib/mormon/osm_loader.rb', line 12 def route_types @route_types end |
Instance Attribute Details
#nodes ⇒ Object (readonly)
Returns the value of attribute nodes.
16 17 18 |
# File 'lib/mormon/osm_loader.rb', line 16 def nodes @nodes end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
16 17 18 |
# File 'lib/mormon/osm_loader.rb', line 16 def @options end |
#osm_filename ⇒ Object (readonly)
Returns the value of attribute osm_filename.
16 17 18 |
# File 'lib/mormon/osm_loader.rb', line 16 def osm_filename @osm_filename end |
#route_types ⇒ Object (readonly)
Returns the value of attribute route_types.
16 17 18 |
# File 'lib/mormon/osm_loader.rb', line 16 def route_types @route_types end |
#routeable_nodes ⇒ Object (readonly)
Returns the value of attribute routeable_nodes.
16 17 18 |
# File 'lib/mormon/osm_loader.rb', line 16 def routeable_nodes @routeable_nodes end |
#routing ⇒ Object (readonly)
Returns the value of attribute routing.
16 17 18 |
# File 'lib/mormon/osm_loader.rb', line 16 def routing @routing end |
#tiles ⇒ Object (readonly)
Returns the value of attribute tiles.
16 17 18 |
# File 'lib/mormon/osm_loader.rb', line 16 def tiles @tiles end |
#ways ⇒ Object (readonly)
Returns the value of attribute ways.
16 17 18 |
# File 'lib/mormon/osm_loader.rb', line 16 def ways @ways end |
Instance Method Details
#cache_filename ⇒ Object
52 53 54 |
# File 'lib/mormon/osm_loader.rb', line 52 def cache_filename File.join Loader.cache_dir, File.basename(@osm_filename) + ".pstore" end |
#report ⇒ Object
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/mormon/osm_loader.rb', line 41 def report report = "Loaded %d nodes,\n" % @nodes.keys.size report += "%d ways, and...\n" % @ways.keys.size Loader.route_types.each do |type| report += " %d %s routes\n" % [@routing[type].keys.size, type] end report end |