forked from systemed/mapcss_ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathosm_test.rb
More file actions
38 lines (28 loc) · 1016 Bytes
/
osm_test.rb
File metadata and controls
38 lines (28 loc) · 1016 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '.', 'lib'))
require "OSM"
require "OSM/StreamParser"
require "OSM/Database"
require "style_parser"
css=IO.read('opencyclemap.css')
ruleset=StyleParser::RuleSet.new(12,20)
ruleset.parse(css)
db = OSM::Database.new
puts "Reading"
parser = OSM::StreamParser.new(:filename => 'charlbury.osm', :db => db)
puts "Parsing"
parser.parse
# typing 'export OSMLIB_XML_PARSER=Expat' beforehand would speed things up, if it weren't fucked.
puts "Creating dictionary"
dictionary = StyleParser::Dictionary.instance
dictionary.populate(db)
puts "Results"
puts "Nodes: #{db.nodes.values.collect{ |o| o.id }.join(',')}"
puts "Ways: #{db.ways.values.collect{ |o| o.id }.join(',')}"
puts "Relations: #{db.relations.values.collect{ |o| o.id }.join(',')}"
puts "Parents"
entity=db.get_node(409697)
puts "#{entity}: #{dictionary.parent_objects(entity)}"
puts "Styles"
entity=db.get_way(3044458)
sl=ruleset.get_styles(entity,entity.tags,14)
puts sl