mormon 2.0.3 → 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 +4 -4
- data/Gemfile +1 -1
- data/Gemfile.lock +23 -11
- data/lib/mormon/osm_router.rb +6 -7
- data/lib/mormon/version.rb +1 -1
- data/spec/router_spec.rb +47 -52
- data/spec/spec_helper.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 781038b964cfb50a23aa301f9373380b88e911fab492348a3bdf5678f8b11608
|
4
|
+
data.tar.gz: e9755b04e7f7608fe80cef9819a7093df55436ed5a00ea22f8710d323f015c1b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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/lib/mormon/osm_router.rb
CHANGED
@@ -141,27 +141,26 @@ 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
|
-
@loader
|
148
|
+
@loader = loader
|
150
149
|
@options = options
|
151
150
|
|
152
151
|
algorithm = @options.delete(:algorithm) || :astar
|
153
|
-
|
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
|
-
algorithm = @algorithm_class.new(self, @options)
|
158
|
-
|
159
158
|
result, nodes = algorithm.route(node_start.to_i, node_end.to_i, transport.to_sym)
|
160
159
|
|
161
160
|
return [result,[]] if result != 'success'
|
162
161
|
|
163
162
|
nodes.map! do |node|
|
164
|
-
data =
|
163
|
+
data = loader.nodes[node.to_s]
|
165
164
|
[data[:lat], data[:lon]]
|
166
165
|
end
|
167
166
|
|
data/lib/mormon/version.rb
CHANGED
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