mormon 2.0.2 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +23 -11
- data/README.md +7 -13
- data/lib/mormon/osm_loader.rb +32 -44
- data/lib/mormon/osm_router.rb +24 -24
- data/lib/mormon/version.rb +1 -1
- data/lib/mormon/weight.rb +1 -0
- data/mormon.gemspec +3 -4
- data/spec/router_spec.rb +47 -52
- data/spec/spec_helper.rb +2 -2
- metadata +19 -29
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 781038b964cfb50a23aa301f9373380b88e911fab492348a3bdf5678f8b11608
|
4
|
+
data.tar.gz: e9755b04e7f7608fe80cef9819a7093df55436ed5a00ea22f8710d323f015c1b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 89c78a9e88e655baa4f37f80217bd0d8893c559cf8abb5d928d99fe4d9bde02e961415e7f3f8dc3e3b40750a5ee2b8f06439405ec37b181c442aecf450382ea0
|
7
|
+
data.tar.gz: 2a55e6fe0c15375434da0897cd7a2a1ab067707cef4b000d2aa4fa7c011af8acf1d60244bd67466701c6aeb73635a458c591c79c43cc869d08ccd8df3c41dfb2
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,22 +1,31 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
mormon (2.0.
|
4
|
+
mormon (2.0.4)
|
5
5
|
nokogiri
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
diff-lcs (1.1
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
rspec
|
17
|
-
|
18
|
-
|
19
|
-
|
10
|
+
diff-lcs (1.5.1)
|
11
|
+
mini_portile2 (2.8.7)
|
12
|
+
nokogiri (1.13.10)
|
13
|
+
mini_portile2 (~> 2.8.0)
|
14
|
+
racc (~> 1.4)
|
15
|
+
racc (1.8.0)
|
16
|
+
rspec (3.13.0)
|
17
|
+
rspec-core (~> 3.13.0)
|
18
|
+
rspec-expectations (~> 3.13.0)
|
19
|
+
rspec-mocks (~> 3.13.0)
|
20
|
+
rspec-core (3.13.0)
|
21
|
+
rspec-support (~> 3.13.0)
|
22
|
+
rspec-expectations (3.13.1)
|
23
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
24
|
+
rspec-support (~> 3.13.0)
|
25
|
+
rspec-mocks (3.13.1)
|
26
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
27
|
+
rspec-support (~> 3.13.0)
|
28
|
+
rspec-support (3.13.1)
|
20
29
|
|
21
30
|
PLATFORMS
|
22
31
|
ruby
|
@@ -24,3 +33,6 @@ PLATFORMS
|
|
24
33
|
DEPENDENCIES
|
25
34
|
mormon!
|
26
35
|
rspec
|
36
|
+
|
37
|
+
BUNDLED WITH
|
38
|
+
1.17.3
|
data/README.md
CHANGED
@@ -36,11 +36,11 @@ Caching
|
|
36
36
|
=======
|
37
37
|
|
38
38
|
You probably wants to cache the parsed osm file:
|
39
|
-
|
40
|
-
osm_loader = Mormon::OSM::Loader.new "path/to/filename.osm", :cache => true
|
39
|
+
|
40
|
+
osm_loader = Mormon::OSM::Loader.new "path/to/filename.osm", :cache => true
|
41
41
|
|
42
42
|
The previous code generate a filename.pstore file and it's stored in Dir.tmpdir, "mormon", "cache" depending of your so, if you need to change the cache dir try ie:
|
43
|
-
|
43
|
+
|
44
44
|
cache_dir = File.join File.dirname(__FILE__), "cache"
|
45
45
|
Mormon::OSM::Loader.cache_dir = cache_dir
|
46
46
|
osm_loader = Mormon::OSM::Loader.new "path/to/file.osm", :cache => true
|
@@ -57,15 +57,15 @@ The default algorithm is A* with weights, but a Random algorithm is available, i
|
|
57
57
|
|
58
58
|
**KNOWN ISSUE**: the actual random algorithm has problems when the different between start and end is enough far, i'm working to fix it.
|
59
59
|
|
60
|
-
Breadth in
|
60
|
+
Breadth in random algorithm
|
61
61
|
-----
|
62
62
|
|
63
63
|
The programming technique to find a random route is Backtracking, so in order to don't loop forever we need to narrow the search in neighbors, for that reason i use a breadth value combined with distance between start and end nodes:
|
64
|
-
|
64
|
+
|
65
65
|
max_amplitude = @breadth * distance(start, end)
|
66
66
|
|
67
67
|
The default breadth value is 2 but you could change it doing one of:
|
68
|
-
|
68
|
+
|
69
69
|
osm_router = Mormon::OSM::Router.new osm_loader, :algorithm => :random, :breadth => 1.5
|
70
70
|
or
|
71
71
|
osm_router.algorithm.breath = 2.5
|
@@ -73,10 +73,4 @@ The default breadth value is 2 but you could change it doing one of:
|
|
73
73
|
License
|
74
74
|
=======
|
75
75
|
|
76
|
-
|
77
|
-
|
78
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
79
|
-
|
80
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
81
|
-
|
82
|
-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
76
|
+
LICENSE.txt
|
data/lib/mormon/osm_loader.rb
CHANGED
@@ -4,15 +4,15 @@ require 'tmpdir'
|
|
4
4
|
module Mormon
|
5
5
|
module OSM
|
6
6
|
class Loader
|
7
|
-
|
7
|
+
|
8
8
|
@route_types = [:cycle, :car, :train, :foot, :horse]
|
9
9
|
@cache_dir = File.join Dir.tmpdir, "mormon", "cache"
|
10
|
-
|
10
|
+
|
11
11
|
class << self
|
12
12
|
attr_reader :route_types
|
13
13
|
attr_accessor :cache_dir
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
attr_reader :options, :routing, :nodes, :ways, :tiles, :routeable_nodes, :route_types,
|
17
17
|
:osm_filename
|
18
18
|
|
@@ -22,7 +22,7 @@ module Mormon
|
|
22
22
|
@tiles = {}
|
23
23
|
@nodes = {}
|
24
24
|
@ways = {}
|
25
|
-
|
25
|
+
|
26
26
|
@routing = {}
|
27
27
|
@routeable_nodes = {}
|
28
28
|
|
@@ -41,7 +41,7 @@ module Mormon
|
|
41
41
|
def report
|
42
42
|
report = "Loaded %d nodes,\n" % @nodes.keys.size
|
43
43
|
report += "%d ways, and...\n" % @ways.keys.size
|
44
|
-
|
44
|
+
|
45
45
|
Loader.route_types.each do |type|
|
46
46
|
report += " %d %s routes\n" % [@routing[type].keys.size, type]
|
47
47
|
end
|
@@ -52,18 +52,18 @@ module Mormon
|
|
52
52
|
def cache_filename
|
53
53
|
File.join Loader.cache_dir, File.basename(@osm_filename) + ".pstore"
|
54
54
|
end
|
55
|
-
|
55
|
+
|
56
56
|
private
|
57
57
|
def load_cached
|
58
58
|
require "pstore"
|
59
|
-
|
59
|
+
|
60
60
|
store_path = cache_filename
|
61
61
|
|
62
62
|
FileUtils.mkdir_p Loader.cache_dir
|
63
63
|
FileUtils.touch store_path
|
64
|
-
|
64
|
+
|
65
65
|
store = PStore.new store_path
|
66
|
-
|
66
|
+
|
67
67
|
if !File.zero? store_path
|
68
68
|
puts "Loading from cache %s..." % store.path
|
69
69
|
|
@@ -78,7 +78,7 @@ module Mormon
|
|
78
78
|
@routeable_nodes[type] = store[:routeable_nodes][type]
|
79
79
|
end
|
80
80
|
end
|
81
|
-
|
81
|
+
|
82
82
|
else
|
83
83
|
puts "Parsing %s..." % @osm_filename
|
84
84
|
parse
|
@@ -87,7 +87,7 @@ module Mormon
|
|
87
87
|
store.transaction do
|
88
88
|
store[:tiles] = @tiles
|
89
89
|
store[:nodes] = @nodes
|
90
|
-
store[:ways] = @ways
|
90
|
+
store[:ways] = @ways
|
91
91
|
store[:tiles] = @tiles
|
92
92
|
|
93
93
|
store[:routing] = {}
|
@@ -104,12 +104,12 @@ module Mormon
|
|
104
104
|
|
105
105
|
def parse
|
106
106
|
puts "Loading %s.." % @osm_filename
|
107
|
-
|
107
|
+
|
108
108
|
if !File.exists?(@osm_filename)
|
109
109
|
print "No such data file %s" % @osm_filename
|
110
110
|
return false
|
111
111
|
end
|
112
|
-
|
112
|
+
|
113
113
|
osm = Nokogiri::XML File.open(@osm_filename)
|
114
114
|
|
115
115
|
load_nodes osm
|
@@ -119,13 +119,13 @@ module Mormon
|
|
119
119
|
def load_nodes(nokosm)
|
120
120
|
nokosm.css('node').each do |node|
|
121
121
|
node_id = node[:id]
|
122
|
-
|
122
|
+
|
123
123
|
@nodes[node_id] = {
|
124
124
|
lat: node[:lat].to_f,
|
125
125
|
lon: node[:lon].to_f,
|
126
126
|
tags: {}
|
127
127
|
}
|
128
|
-
|
128
|
+
|
129
129
|
node.css('tag').each do |t|
|
130
130
|
k,v = t[:k].to_sym, t[:v]
|
131
131
|
@nodes[node_id][:tags][k] = v unless useless_tags.include?(k)
|
@@ -136,12 +136,12 @@ module Mormon
|
|
136
136
|
def load_ways(nokosm)
|
137
137
|
nokosm.css('way').each do |way|
|
138
138
|
way_id = way[:id]
|
139
|
-
|
139
|
+
|
140
140
|
@ways[way_id] = {
|
141
141
|
nodes: way.css('nd').map { |nd| nd[:ref] },
|
142
142
|
tags: {}
|
143
143
|
}
|
144
|
-
|
144
|
+
|
145
145
|
way.css('tag').each do |t|
|
146
146
|
k,v = t[:k].to_sym, t[:v]
|
147
147
|
@ways[way_id][:tags][k] = v unless useless_tags.include?(k)
|
@@ -154,31 +154,31 @@ module Mormon
|
|
154
154
|
def useless_tags
|
155
155
|
[:created_by]
|
156
156
|
end
|
157
|
-
|
157
|
+
|
158
158
|
def way_access(highway, railway)
|
159
159
|
access = {}
|
160
|
-
access[:cycle] = [:primary, :secondary, :tertiary, :unclassified, :minor, :cycleway,
|
161
|
-
:residential, :track, :service].include?
|
162
|
-
|
163
|
-
access[:car] = [:motorway, :trunk, :primary, :secondary, :tertiary,
|
164
|
-
:unclassified, :minor, :residential, :service].include?
|
165
|
-
|
166
|
-
access[:train] = [:rail, :light_rail, :subway].include?
|
167
|
-
access[:foot] = access[:cycle] || [:footway, :steps].include?(highway.to_sym)
|
168
|
-
access[:horse] = [:track, :unclassified, :bridleway].include?
|
160
|
+
access[:cycle] = [:primary, :secondary, :tertiary, :unclassified, :minor, :cycleway,
|
161
|
+
:residential, :track, :service].include?(highway.to_sym)
|
162
|
+
|
163
|
+
access[:car] = [:motorway, :trunk, :primary, :secondary, :tertiary,
|
164
|
+
:unclassified, :minor, :residential, :service].include?(highway.to_sym)
|
165
|
+
|
166
|
+
access[:train] = [:rail, :light_rail, :subway].include?(railway.to_sym)
|
167
|
+
access[:foot] = access[:cycle] || [:footway, :steps, :path].include?(highway.to_sym)
|
168
|
+
access[:horse] = [:track, :unclassified, :bridleway].include?(highway.to_sym)
|
169
169
|
access
|
170
170
|
end
|
171
171
|
|
172
172
|
def store_way(way)
|
173
173
|
tags = way[:tags]
|
174
|
-
|
174
|
+
|
175
175
|
highway = equivalent tags.fetch(:highway, "")
|
176
176
|
railway = equivalent tags.fetch(:railway, "")
|
177
177
|
oneway = tags.fetch(:oneway, "")
|
178
178
|
reversible = !['yes','true','1'].include?(oneway)
|
179
|
-
|
179
|
+
|
180
180
|
access = way_access highway, railway
|
181
|
-
|
181
|
+
|
182
182
|
# Store routing information
|
183
183
|
last = -1
|
184
184
|
way[:nodes].each do |node|
|
@@ -188,7 +188,7 @@ module Mormon
|
|
188
188
|
weight = Mormon::Weight.get route_type, highway.to_sym
|
189
189
|
add_link(last, node, route_type, weight)
|
190
190
|
add_link(node, last, route_type, weight) if reversible || route_type == :foot
|
191
|
-
end
|
191
|
+
end
|
192
192
|
end
|
193
193
|
end
|
194
194
|
last = node
|
@@ -207,17 +207,8 @@ module Mormon
|
|
207
207
|
@routing[route_type][fr] = { to => weight }
|
208
208
|
end
|
209
209
|
|
210
|
-
def way_type(tags)
|
211
|
-
# Look for a variety of tags (priority order - first one found is used)
|
212
|
-
[:highway, :railway, :waterway, :natural].each do |type|
|
213
|
-
value = tags.fetch(type, '')
|
214
|
-
return equivalent(value) if value
|
215
|
-
end
|
216
|
-
nil
|
217
|
-
end
|
218
|
-
|
219
210
|
def equivalent(tag)
|
220
|
-
{
|
211
|
+
{
|
221
212
|
primary_link: "primary",
|
222
213
|
trunk: "primary",
|
223
214
|
trunk_link: "primary",
|
@@ -230,7 +221,6 @@ module Mormon
|
|
230
221
|
driveway: "service",
|
231
222
|
pedestrian: "footway",
|
232
223
|
bridleway: "cycleway",
|
233
|
-
track: "cycleway",
|
234
224
|
arcade: "footway",
|
235
225
|
canal: "river",
|
236
226
|
riverbank: "river",
|
@@ -239,8 +229,6 @@ module Mormon
|
|
239
229
|
living_street: "unclassified"
|
240
230
|
}[tag.to_sym] || tag
|
241
231
|
end
|
242
|
-
|
243
232
|
end
|
244
233
|
end
|
245
234
|
end
|
246
|
-
|
data/lib/mormon/osm_router.rb
CHANGED
@@ -23,7 +23,7 @@ module Mormon
|
|
23
23
|
|
24
24
|
lat1, lon1 = node1[:lat], node1[:lon]
|
25
25
|
lat2, lon2 = node2[:lat], node2[:lon]
|
26
|
-
|
26
|
+
|
27
27
|
dlat = lat2 - lat1
|
28
28
|
dlon = lon2 - lon1
|
29
29
|
|
@@ -44,7 +44,7 @@ module Mormon
|
|
44
44
|
end
|
45
45
|
|
46
46
|
closed = [node_start]
|
47
|
-
|
47
|
+
|
48
48
|
# Limit for how long it will search
|
49
49
|
(0..10000).each do
|
50
50
|
next_item = @queue.shift
|
@@ -52,7 +52,7 @@ module Mormon
|
|
52
52
|
|
53
53
|
x = next_item[:node_end]
|
54
54
|
next if closed.include?(x)
|
55
|
-
|
55
|
+
|
56
56
|
# Found the end node - success
|
57
57
|
return ['success', next_item[:nodes]] if x == node_end
|
58
58
|
|
@@ -65,18 +65,18 @@ module Mormon
|
|
65
65
|
|
66
66
|
'gave_up'
|
67
67
|
end
|
68
|
-
|
68
|
+
|
69
69
|
def enqueue(node_start, node_end, node_finish, current_queue, weight = 1)
|
70
70
|
# Add another potential route to the queue
|
71
|
-
|
71
|
+
|
72
72
|
# if already in queue
|
73
73
|
return if @queue.any? { |other| other[:node_end] == node_end }
|
74
74
|
|
75
75
|
distance = distance(node_start, node_end)
|
76
|
-
|
76
|
+
|
77
77
|
return if weight.zero?
|
78
78
|
distance = distance / weight
|
79
|
-
|
79
|
+
|
80
80
|
# Create a hash for all the route's attributes
|
81
81
|
current_distance = current_queue[:distance]
|
82
82
|
nodes = current_queue[:nodes].dup
|
@@ -88,7 +88,7 @@ module Mormon
|
|
88
88
|
nodes: nodes,
|
89
89
|
node_end: node_end
|
90
90
|
}
|
91
|
-
|
91
|
+
|
92
92
|
# Try to insert, keeping the queue ordered by decreasing worst-case distance
|
93
93
|
ix = @queue.find_index { |other| other[:max_distance] > queue_item[:max_distance] } || -1
|
94
94
|
@queue.insert(ix, queue_item)
|
@@ -123,17 +123,17 @@ module Mormon
|
|
123
123
|
if neighbors
|
124
124
|
neighbors = neighbors.keys.map(&:to_i)
|
125
125
|
not_visited = neighbors - (neighbors & visited)
|
126
|
-
|
126
|
+
|
127
127
|
# random sort in order to not take the same order for neighbors every time.
|
128
128
|
not_visited.sort_by { rand }.each do |neighbor|
|
129
129
|
# limit the width of the route go further more than max_distance the distance between start and end
|
130
|
-
next if distance(neighbor, node_end) > max_amplitude
|
130
|
+
next if distance(neighbor, node_end) > max_amplitude
|
131
131
|
current_route << neighbor
|
132
132
|
enqueue neighbor, node_end, transport, current_route, visited, max_amplitude
|
133
133
|
current_route.delete neighbor
|
134
134
|
end
|
135
135
|
end
|
136
|
-
|
136
|
+
|
137
137
|
visited.delete node_start
|
138
138
|
end
|
139
139
|
end
|
@@ -141,31 +141,31 @@ module Mormon
|
|
141
141
|
end
|
142
142
|
end
|
143
143
|
|
144
|
-
|
145
144
|
class Router
|
146
|
-
attr_reader :loader, :
|
145
|
+
attr_reader :loader, :algorithm
|
147
146
|
|
148
147
|
def initialize(loader, options = {})
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
148
|
+
@loader = loader
|
149
|
+
@options = options
|
150
|
+
|
151
|
+
algorithm = @options.delete(:algorithm) || :astar
|
152
|
+
algorithm_classname = algorithm.to_s.capitalize
|
153
|
+
algorithm_class = "Mormon::OSM::Algorithm::#{algorithm_classname}".constantize
|
154
|
+
@algorithm = algorithm_class.new(self, @options)
|
154
155
|
end
|
155
156
|
|
156
157
|
def find_route(node_start, node_end, transport)
|
157
|
-
result, nodes =
|
158
|
-
|
158
|
+
result, nodes = algorithm.route(node_start.to_i, node_end.to_i, transport.to_sym)
|
159
|
+
|
159
160
|
return [result,[]] if result != 'success'
|
160
|
-
|
161
|
+
|
161
162
|
nodes.map! do |node|
|
162
|
-
data =
|
163
|
+
data = loader.nodes[node.to_s]
|
163
164
|
[data[:lat], data[:lon]]
|
164
165
|
end
|
165
166
|
|
166
167
|
[result, nodes]
|
167
168
|
end
|
168
|
-
|
169
169
|
end
|
170
170
|
end
|
171
|
-
end
|
171
|
+
end
|
data/lib/mormon/version.rb
CHANGED
data/lib/mormon/weight.rb
CHANGED
@@ -15,6 +15,7 @@ module Mormon
|
|
15
15
|
service: { cycle: 1, car: 1, foot: 1, horse: 1 },
|
16
16
|
bridleway: { cycle: 0.8, foot: 1, horse: 10, mtb: 3 },
|
17
17
|
footway: { cycle: 0.2, foot: 1 },
|
18
|
+
path: { foot: 1 },
|
18
19
|
steps: { foot: 1, cycle: 0.3 },
|
19
20
|
rail: { train: 1 },
|
20
21
|
light_rail: { train: 1 },
|
data/mormon.gemspec
CHANGED
@@ -6,8 +6,8 @@ require 'mormon/version'
|
|
6
6
|
Gem::Specification.new do |gem|
|
7
7
|
gem.name = "mormon"
|
8
8
|
gem.version = Mormon::VERSION
|
9
|
-
gem.
|
10
|
-
gem.email =
|
9
|
+
gem.author = "Geronimo Diaz"
|
10
|
+
gem.email = "geronimod@gmail.com"
|
11
11
|
gem.description = %q{ OSM Router }
|
12
12
|
gem.summary = %q{ OSM Routing with some extra features: reset tiles cache, random routes and distance optimizer for routes with several stops. It's based on Pyroute library. }
|
13
13
|
gem.homepage = "https://github.com/geronimod/mormon"
|
@@ -18,8 +18,7 @@ Gem::Specification.new do |gem|
|
|
18
18
|
gem.require_paths = ["lib"]
|
19
19
|
|
20
20
|
gem.rubyforge_project = "mormon"
|
21
|
-
|
21
|
+
|
22
22
|
gem.add_dependency "nokogiri"
|
23
23
|
gem.add_development_dependency "rspec"
|
24
|
-
#gem.add_development_dependency "debugger"
|
25
24
|
end
|
data/spec/router_spec.rb
CHANGED
@@ -1,80 +1,75 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'mormon'
|
3
3
|
|
4
|
-
def spec_osm_file
|
5
|
-
File.join File.dirname(__FILE__), "spec.osm"
|
6
|
-
end
|
7
|
-
|
8
4
|
describe Mormon::OSM::Router do
|
9
|
-
|
10
|
-
|
11
|
-
|
5
|
+
let(:osm_filename) { "spec.osm" }
|
6
|
+
let(:osm_file) { File.join(File.dirname(__FILE__), osm_filename) }
|
7
|
+
let(:loader) { Mormon::OSM::Loader.new osm_file }
|
8
|
+
let(:router_args) do
|
9
|
+
{}
|
10
|
+
end
|
11
|
+
let(:router) { Mormon::OSM::Router.new loader, router_args }
|
12
12
|
|
13
|
-
|
13
|
+
it "should find the route if the params are strings" do
|
14
|
+
response, route = router.find_route "448193278", 448193334, "car"
|
14
15
|
response.should eq "success"
|
15
16
|
route.should eq [
|
16
|
-
[-37.3211676, -59.1269871],
|
17
|
-
[-37.3223495, -59.1262886],
|
18
|
-
[-37.3229002, -59.1277355],
|
19
|
-
[-37.3234584, -59.1292045],
|
17
|
+
[-37.3211676, -59.1269871],
|
18
|
+
[-37.3223495, -59.1262886],
|
19
|
+
[-37.3229002, -59.1277355],
|
20
|
+
[-37.3234584, -59.1292045],
|
20
21
|
[-37.3246275, -59.1285124]
|
21
22
|
]
|
22
23
|
end
|
23
24
|
|
24
25
|
it "should do the routing without problems" do
|
25
|
-
|
26
|
-
@router = Mormon::OSM::Router.new @loader
|
27
|
-
|
28
|
-
response, route = @router.find_route 448193311, 453397968, :car
|
26
|
+
response, route = router.find_route 448193311, 453397968, :car
|
29
27
|
response.should eq "success"
|
30
28
|
route.should eq [
|
31
|
-
[-37.322900199999999, -59.1277355],
|
32
|
-
[-37.3234584, -59.1292045],
|
33
|
-
[-37.324045300000002, -59.130744],
|
34
|
-
[-37.324662600000003, -59.132366099999999],
|
35
|
-
[-37.325214799999998, -59.133816899999999],
|
36
|
-
[-37.3263769, -59.133125100000001],
|
37
|
-
[-37.327769600000003, -59.132296199999999],
|
38
|
-
[-37.328298599999997, -59.133707200000003],
|
29
|
+
[-37.322900199999999, -59.1277355],
|
30
|
+
[-37.3234584, -59.1292045],
|
31
|
+
[-37.324045300000002, -59.130744],
|
32
|
+
[-37.324662600000003, -59.132366099999999],
|
33
|
+
[-37.325214799999998, -59.133816899999999],
|
34
|
+
[-37.3263769, -59.133125100000001],
|
35
|
+
[-37.327769600000003, -59.132296199999999],
|
36
|
+
[-37.328298599999997, -59.133707200000003],
|
39
37
|
[-37.328858799999999, -59.135200400000002]
|
40
38
|
]
|
41
39
|
end
|
42
40
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
response, route = @router.find_route 448193311, 448193334, :car
|
48
|
-
response.should eq "success"
|
49
|
-
route.size.should be > 1
|
50
|
-
end
|
41
|
+
context 'Random algorithm' do
|
42
|
+
let(:router_args) do
|
43
|
+
{ algorithm: :random }
|
44
|
+
end
|
51
45
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
response, route = @router.find_route 448193311, 448193334, :car
|
58
|
-
response.should eq "success"
|
59
|
-
route.size.should be > 1
|
46
|
+
it "should support random algorithm" do
|
47
|
+
response, route = router.find_route 448193311, 448193334, :car
|
48
|
+
response.should eq "success"
|
49
|
+
route.size.should be > 1
|
50
|
+
end
|
60
51
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
route1.size.should be > 1
|
52
|
+
it "should support change the breadth of random algorithm" do
|
53
|
+
router.algorithm.breadth = 1
|
54
|
+
response, route = router.find_route 448193311, 448193334, :car
|
65
55
|
|
66
|
-
|
67
|
-
|
56
|
+
response.should eq "success"
|
57
|
+
route.size.should be > 1
|
68
58
|
|
69
|
-
|
59
|
+
router.algorithm.breadth = 3
|
60
|
+
response1, route1 = router.find_route 448193311, 448193334, :car
|
70
61
|
|
71
|
-
|
72
|
-
|
73
|
-
|
62
|
+
response1.should eq "success"
|
63
|
+
route1.size.should be > 1
|
64
|
+
route.should_not eq route1
|
74
65
|
end
|
66
|
+
end
|
67
|
+
|
68
|
+
describe "with tandil.osm map" do
|
69
|
+
let(:osm_filename) { "tandil.osm" }
|
75
70
|
|
76
71
|
it "should find the route in tandil map" do
|
77
|
-
response, route =
|
72
|
+
response, route = router.find_route 1355012894, 1527759159, :car
|
78
73
|
response.should eq "success"
|
79
74
|
route.should eq [
|
80
75
|
[-37.314227500000001, -59.083028499999998], [-37.315150099999997, -59.084156299999997], [-37.314264299999998, -59.085288499999997], [-37.315238600000001, -59.086456400000003], [-37.316189199999997, -59.087621499999997], [-37.317135299999997, -59.088781099999999], [-37.318047200000002, -59.0898988], [-37.3189803, -59.091042600000002], [-37.319898500000001, -59.092168000000001], [-37.320787299999999, -59.093257399999999], [-37.322678799999998, -59.0955759], [-37.324257199999998, -59.097501700000002], [-37.324342399999999, -59.0976675], [-37.323442, -59.0988349], [-37.322537599999997, -59.099982900000001], [-37.320699099999999, -59.102316899999998], [-37.322715600000002, -59.104815500000001], [-37.325489699999999, -59.1082538], [-37.324572699999997, -59.109404599999998], [-37.325524700000003, -59.1105327], [-37.326417999999997, -59.111670400000001], [-37.325528499999997, -59.112850700000003], [-37.326433199999997, -59.113965700000001], [-37.3267904, -59.114365900000003], [-37.326863699999997, -59.114550399999999], [-37.327440500000002, -59.116081100000002], [-37.327991900000001, -59.1175444], [-37.328552999999999, -59.119033799999997], [-37.329104200000003, -59.120496600000003], [-37.329658899999998, -59.121968600000002], [-37.330206199999999, -59.123420899999999], [-37.330755799999999, -59.124884399999999], [-37.331353300000004, -59.126429899999998], [-37.331652400000003, -59.127241400000003], [-37.331941100000002, -59.128025000000001], [-37.332166700000002, -59.1286238], [-37.332491400000002, -59.129485500000001], [-37.333024999999999, -59.130901999999999], [-37.333594699999999, -59.132413800000002], [-37.333622300000002, -59.132487500000003], [-37.334096700000003, -59.133752299999998], [-37.3345178, -59.134863600000003], [-37.335070399999999, -59.136329799999999], [-37.335618599999997, -59.137819700000001], [-37.3361801, -59.139275699999999], [-37.336721400000002, -59.140712100000002], [-37.337293500000001, -59.1422308], [-37.337850899999999, -59.143710200000001], [-37.338389300000003, -59.145182900000002], [-37.3386736, -59.145893600000001], [-37.338952499999998, -59.146633899999998], [-37.339135499999998, -59.147119699999998], [-37.3394239, -59.147885199999997], [-37.339503100000002, -59.148095499999997], [-37.339592099999997, -59.148331900000002], [-37.339890400000002, -59.149123400000001], [-37.340051299999999, -59.149550599999998], [-37.340075400000003, -59.149608000000001], [-37.340349500000002, -59.150260299999999], [-37.340552099999996, -59.150748700000001], [-37.3406783, -59.151004299999997], [-37.340945599999998, -59.151422500000002], [-37.343685100000002, -59.155270399999999], [-37.343783000000002, -59.155505300000002], [-37.344689199999998, -59.159352699999999], [-37.344747900000002, -59.159703200000003], [-37.344740799999997, -59.159876199999999], [-37.344758900000002, -59.159840699999997], [-37.344792099999999, -59.159806099999997], [-37.344832799999999, -59.159787899999998], [-37.344866199999998, -59.159786500000003], [-37.3449077, -59.159801299999998], [-37.344942699999997, -59.1598331], [-37.344966999999997, -59.159877999999999], [-37.344977100000001, -59.159948700000001], [-37.345046400000001, -59.159815899999998], [-37.345127400000003, -59.159665699999998], [-37.346329400000002, -59.158131699999998], [-37.347191299999999, -59.157031799999999], [-37.348837400000001, -59.154906699999998]
|
@@ -82,7 +77,7 @@ describe Mormon::OSM::Router do
|
|
82
77
|
end
|
83
78
|
|
84
79
|
it "should find routes :living_street tags" do
|
85
|
-
response, route =
|
80
|
+
response, route = router.find_route 1426632434, 1353196058, :car
|
86
81
|
response.should eq "success"
|
87
82
|
route.should eq [
|
88
83
|
[-37.3345933, -59.1058391], [-37.3354931, -59.1069492], [-37.3342806, -59.1084889], [-37.33413, -59.1094705], [-37.3339058, -59.1102717], [-37.3341711, -59.1101928], [-37.3352592, -59.1095233], [-37.3354771, -59.1093932], [-37.3361037, -59.1090191], [-37.3362573, -59.1090405], [-37.3364535, -59.1092337], [-37.3366723, -59.1098382], [-37.3367507, -59.1099664], [-37.3373321, -59.1101778], [-37.33786, -59.1101467], [-37.3386116, -59.1100383], [-37.3394134, -59.1100169], [-37.3400105, -59.1102422], [-37.3401523, -59.1103108], [-37.3410888, -59.1091111]
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,58 +1,50 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mormon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
5
|
-
prerelease:
|
4
|
+
version: 2.0.4
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Geronimo Diaz
|
9
|
-
|
10
|
-
autorequire:
|
8
|
+
autorequire:
|
11
9
|
bindir: bin
|
12
10
|
cert_chain: []
|
13
|
-
date:
|
11
|
+
date: 2024-07-16 00:00:00.000000000 Z
|
14
12
|
dependencies:
|
15
13
|
- !ruby/object:Gem::Dependency
|
16
14
|
name: nokogiri
|
17
15
|
requirement: !ruby/object:Gem::Requirement
|
18
|
-
none: false
|
19
16
|
requirements:
|
20
|
-
- -
|
17
|
+
- - ">="
|
21
18
|
- !ruby/object:Gem::Version
|
22
19
|
version: '0'
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
|
-
none: false
|
27
23
|
requirements:
|
28
|
-
- -
|
24
|
+
- - ">="
|
29
25
|
- !ruby/object:Gem::Version
|
30
26
|
version: '0'
|
31
27
|
- !ruby/object:Gem::Dependency
|
32
28
|
name: rspec
|
33
29
|
requirement: !ruby/object:Gem::Requirement
|
34
|
-
none: false
|
35
30
|
requirements:
|
36
|
-
- -
|
31
|
+
- - ">="
|
37
32
|
- !ruby/object:Gem::Version
|
38
33
|
version: '0'
|
39
34
|
type: :development
|
40
35
|
prerelease: false
|
41
36
|
version_requirements: !ruby/object:Gem::Requirement
|
42
|
-
none: false
|
43
37
|
requirements:
|
44
|
-
- -
|
38
|
+
- - ">="
|
45
39
|
- !ruby/object:Gem::Version
|
46
40
|
version: '0'
|
47
|
-
description:
|
48
|
-
email:
|
49
|
-
- geronimod@gmail.com
|
50
|
-
- john.kolle@gmail.com
|
41
|
+
description: " OSM Router "
|
42
|
+
email: geronimod@gmail.com
|
51
43
|
executables: []
|
52
44
|
extensions: []
|
53
45
|
extra_rdoc_files: []
|
54
46
|
files:
|
55
|
-
- .gitignore
|
47
|
+
- ".gitignore"
|
56
48
|
- Gemfile
|
57
49
|
- Gemfile.lock
|
58
50
|
- LICENSE.txt
|
@@ -79,29 +71,27 @@ files:
|
|
79
71
|
- spec/weight_spec.rb
|
80
72
|
homepage: https://github.com/geronimod/mormon
|
81
73
|
licenses: []
|
82
|
-
|
74
|
+
metadata: {}
|
75
|
+
post_install_message:
|
83
76
|
rdoc_options: []
|
84
77
|
require_paths:
|
85
78
|
- lib
|
86
79
|
required_ruby_version: !ruby/object:Gem::Requirement
|
87
|
-
none: false
|
88
80
|
requirements:
|
89
|
-
- -
|
81
|
+
- - ">="
|
90
82
|
- !ruby/object:Gem::Version
|
91
83
|
version: '0'
|
92
84
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
-
none: false
|
94
85
|
requirements:
|
95
|
-
- -
|
86
|
+
- - ">="
|
96
87
|
- !ruby/object:Gem::Version
|
97
88
|
version: '0'
|
98
89
|
requirements: []
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
and distance optimizer for routes with several stops. It''s based on Pyroute library.'
|
90
|
+
rubygems_version: 3.0.9
|
91
|
+
signing_key:
|
92
|
+
specification_version: 4
|
93
|
+
summary: 'OSM Routing with some extra features: reset tiles cache, random routes and
|
94
|
+
distance optimizer for routes with several stops. It''s based on Pyroute library.'
|
105
95
|
test_files:
|
106
96
|
- spec/distance_optimizer_spec.rb
|
107
97
|
- spec/loader_spec.rb
|