Class: Parosm::Loader

Inherits:
Object
  • Object
show all
Defined in:
lib/parosm/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.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/parosm/loader.rb', line 20

def initialize(filename, options = {})
  @options = options

  @tiles = {}
  @nodes = {}
  @ways  = {}
  
  @routing = {}
  @routeable_nodes = {}

  Loader.route_types.each do |type|
    @routing[type] = {}
    @routeable_nodes[type] = {}
  end

  @osm_filename = filename
  @options[:cache] ? load_cached : parse
end

Class Attribute Details

.cache_dirObject

Returns the value of attribute cache_dir.



14
15
16
# File 'lib/parosm/loader.rb', line 14

def cache_dir
  @cache_dir
end

.route_typesObject (readonly)

Returns the value of attribute route_types.



13
14
15
# File 'lib/parosm/loader.rb', line 13

def route_types
  @route_types
end

Instance Attribute Details

#nodesObject (readonly)

Returns the value of attribute nodes.



17
18
19
# File 'lib/parosm/loader.rb', line 17

def nodes
  @nodes
end

#optionsObject (readonly)

Returns the value of attribute options.



17
18
19
# File 'lib/parosm/loader.rb', line 17

def options
  @options
end

#osm_filenameObject (readonly)

Returns the value of attribute osm_filename.



17
18
19
# File 'lib/parosm/loader.rb', line 17

def osm_filename
  @osm_filename
end

#route_typesObject (readonly)

Returns the value of attribute route_types.



17
18
19
# File 'lib/parosm/loader.rb', line 17

def route_types
  @route_types
end

#routeable_nodesObject (readonly)

Returns the value of attribute routeable_nodes.



17
18
19
# File 'lib/parosm/loader.rb', line 17

def routeable_nodes
  @routeable_nodes
end

#routingObject (readonly)

Returns the value of attribute routing.



17
18
19
# File 'lib/parosm/loader.rb', line 17

def routing
  @routing
end

#tilesObject (readonly)

Returns the value of attribute tiles.



17
18
19
# File 'lib/parosm/loader.rb', line 17

def tiles
  @tiles
end

#waysObject (readonly)

Returns the value of attribute ways.



17
18
19
# File 'lib/parosm/loader.rb', line 17

def ways
  @ways
end

Instance Method Details

#cache_filenameObject



50
51
52
# File 'lib/parosm/loader.rb', line 50

def cache_filename
  File.join Loader.cache_dir, File.basename(@osm_filename) + ".pstore"
end

#reportObject



39
40
41
42
43
44
45
46
47
48
# File 'lib/parosm/loader.rb', line 39

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