osrm-backend/features/support/osm_parser.rb

25 lines
571 B
Ruby
Raw Normal View History

2012-12-16 07:36:47 -05:00
require 'OSM/StreamParser'
2013-08-02 03:34:58 -04:00
locations = nil
2012-12-16 07:36:47 -05:00
class OSMTestParserCallbacks < OSM::Callbacks
2013-08-02 03:34:58 -04:00
locations = nil
2012-12-16 07:36:47 -05:00
def self.locations
2013-08-02 03:34:58 -04:00
if locations
locations
2012-12-16 07:36:47 -05:00
else
#parse the test file, so we can later reference nodes and ways by name in tests
2013-08-02 03:34:58 -04:00
locations = {}
2012-12-16 07:36:47 -05:00
file = 'test/data/test.osm'
callbacks = OSMTestParserCallbacks.new
parser = OSM::StreamParser.new(:filename => file, :callbacks => callbacks)
parser.parse
2013-08-02 03:34:58 -04:00
puts locations
2012-12-16 07:36:47 -05:00
end
end
def node(node)
2013-08-02 03:34:58 -04:00
locations[node.name] = [node.lat,node.lon]
2012-12-16 07:36:47 -05:00
end
end