Class: Mormon::OSM::Loader

Inherits:
Object
  • Object
show all
Defined in:
lib/mormon/osm_loader.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

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 = {})
  @options = 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_dirObject

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_typesObject (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

#nodesObject (readonly)

Returns the value of attribute nodes.



16
17
18
# File 'lib/mormon/osm_loader.rb', line 16

def nodes
  @nodes
end

#optionsObject (readonly)

Returns the value of attribute options.



16
17
18
# File 'lib/mormon/osm_loader.rb', line 16

def options
  @options
end

#osm_filenameObject (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_typesObject (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_nodesObject (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

#routingObject (readonly)

Returns the value of attribute routing.



16
17
18
# File 'lib/mormon/osm_loader.rb', line 16

def routing
  @routing
end

#tilesObject (readonly)

Returns the value of attribute tiles.



16
17
18
# File 'lib/mormon/osm_loader.rb', line 16

def tiles
  @tiles
end

#waysObject (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_filenameObject



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

#reportObject



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