routing 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +22 -0
- data/Gemfile +8 -0
- data/Guardfile +5 -0
- data/LICENSE +22 -0
- data/README.md +54 -0
- data/Rakefile +10 -0
- data/lib/routing.rb +77 -0
- data/lib/routing/adapter.rb +22 -0
- data/lib/routing/adapter/navteq.rb +83 -0
- data/lib/routing/adapter/test.rb +24 -0
- data/lib/routing/geo_point.rb +34 -0
- data/lib/routing/middleware.rb +29 -0
- data/lib/routing/parser.rb +26 -0
- data/lib/routing/parser/navteq_simple.rb +112 -0
- data/lib/routing/version.rb +3 -0
- data/routing.gemspec +24 -0
- data/spec/fixtures/navteq/error_response.json +1 -0
- data/spec/fixtures/navteq/response.json +357 -0
- data/spec/routing/adapter/navteq_spec.rb +59 -0
- data/spec/routing/adapter/test_spec.rb +29 -0
- data/spec/routing/geo_point_spec.rb +40 -0
- data/spec/routing/parser/navteq_simple_spec.rb +81 -0
- data/spec/routing_spec.rb +82 -0
- data/spec/spec_helper.rb +23 -0
- metadata +113 -0
data/routing.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/routing/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Christian Bäuerlein"]
|
6
|
+
gem.email = ["christian@ffwdme.com"]
|
7
|
+
gem.summary = %q{A ruby interface for route calculation services}
|
8
|
+
gem.description = %q{
|
9
|
+
Provides a generic interface for routing services that can by used to calculate directions between geolocations.
|
10
|
+
Makes parsing and use-case specific data handling easy trough an extendable middleware stack.
|
11
|
+
}
|
12
|
+
gem.homepage = "https://github.com/flinc/routing"
|
13
|
+
|
14
|
+
gem.add_dependency "faraday", ">= 0.7.0"
|
15
|
+
gem.add_dependency "json"
|
16
|
+
gem.add_development_dependency "rspec", ">= 2.9.0"
|
17
|
+
|
18
|
+
gem.files = `git ls-files`.split($\)
|
19
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
20
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
21
|
+
gem.name = "routing"
|
22
|
+
gem.require_paths = ["lib"]
|
23
|
+
gem.version = Routing::VERSION
|
24
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
{"Error":{"Details":"Start and destination waypoints are the same.","type":"ApplicationError","subtype":"InvalidInputData"}}
|
@@ -0,0 +1,357 @@
|
|
1
|
+
{
|
2
|
+
"Response": {
|
3
|
+
"MetaInfo": {
|
4
|
+
"Timestamp": "2012-05-03T17:21:15.962+02:00",
|
5
|
+
"AdditionalData": [
|
6
|
+
{
|
7
|
+
"value": "2011Q1_DICI",
|
8
|
+
"key": "Map0"
|
9
|
+
},
|
10
|
+
{
|
11
|
+
"value": "routeserver,9.1-2011.07.06",
|
12
|
+
"key": "Module0"
|
13
|
+
},
|
14
|
+
{
|
15
|
+
"value": "66",
|
16
|
+
"key": "Module0ExecTime"
|
17
|
+
},
|
18
|
+
{
|
19
|
+
"value": "routing-route-service,6.2.6.0",
|
20
|
+
"key": "Service"
|
21
|
+
}
|
22
|
+
]
|
23
|
+
},
|
24
|
+
"Route": [
|
25
|
+
{
|
26
|
+
"RouteId": "REMtZ3UAAAH-1EdCQmAPQZrUR0I5Yg9B8pzd_H3QHQmxJTAEUdEdCcEhMASR1D_xgwbwSCjZTiEI8O9IaOVOIejx_Zu_0QBdAyEDH3chSUB6fQwAew",
|
27
|
+
"Waypoint": [
|
28
|
+
{
|
29
|
+
"LinkId": "-52585230",
|
30
|
+
"MappedPosition": {
|
31
|
+
"Latitude": 49.9576187,
|
32
|
+
"Longitude": 8.9614801
|
33
|
+
},
|
34
|
+
"OriginalPosition": {
|
35
|
+
"Latitude": 49.958,
|
36
|
+
"Longitude": 8.961
|
37
|
+
},
|
38
|
+
"Type": "stopOver"
|
39
|
+
},
|
40
|
+
{
|
41
|
+
"LinkId": "-61868764",
|
42
|
+
"MappedPosition": {
|
43
|
+
"Latitude": 49.8636017,
|
44
|
+
"Longitude": 8.7520599
|
45
|
+
},
|
46
|
+
"OriginalPosition": {
|
47
|
+
"Latitude": 49.8634,
|
48
|
+
"Longitude": 8.7523
|
49
|
+
},
|
50
|
+
"Type": "stopOver"
|
51
|
+
},
|
52
|
+
{
|
53
|
+
"LinkId": "-52433009",
|
54
|
+
"MappedPosition": {
|
55
|
+
"Latitude": 49.8745117,
|
56
|
+
"Longitude": 8.6540937
|
57
|
+
},
|
58
|
+
"OriginalPosition": {
|
59
|
+
"Latitude": 49.8752,
|
60
|
+
"Longitude": 8.654
|
61
|
+
},
|
62
|
+
"Type": "stopOver"
|
63
|
+
}
|
64
|
+
],
|
65
|
+
"Mode": {
|
66
|
+
"Type": "fastest",
|
67
|
+
"TransportModes": [
|
68
|
+
"car"
|
69
|
+
]
|
70
|
+
},
|
71
|
+
"Leg": [
|
72
|
+
{
|
73
|
+
"Start": {
|
74
|
+
"LinkId": "-52585230",
|
75
|
+
"MappedPosition": {
|
76
|
+
"Latitude": 49.9576187,
|
77
|
+
"Longitude": 8.9614801
|
78
|
+
},
|
79
|
+
"OriginalPosition": {
|
80
|
+
"Latitude": 49.958,
|
81
|
+
"Longitude": 8.961
|
82
|
+
},
|
83
|
+
"Type": "stopOver"
|
84
|
+
},
|
85
|
+
"End": {
|
86
|
+
"LinkId": "-61868764",
|
87
|
+
"MappedPosition": {
|
88
|
+
"Latitude": 49.8636017,
|
89
|
+
"Longitude": 8.7520599
|
90
|
+
},
|
91
|
+
"OriginalPosition": {
|
92
|
+
"Latitude": 49.8634,
|
93
|
+
"Longitude": 8.7523
|
94
|
+
},
|
95
|
+
"Type": "stopOver"
|
96
|
+
},
|
97
|
+
"Length": 21813,
|
98
|
+
"TravelTime": 1312.7,
|
99
|
+
"Maneuver": [
|
100
|
+
{
|
101
|
+
"_type": "PrivateTransportManeuverType",
|
102
|
+
"Position": {
|
103
|
+
"Latitude": 49.9576187,
|
104
|
+
"Longitude": 8.9614801
|
105
|
+
},
|
106
|
+
"Instruction": "In Richtung Rhönstraße fahren in der Friedrich-Ebert-Straße. 250 m der Straße folgen.",
|
107
|
+
"TravelTime": 48.1,
|
108
|
+
"Length": 268,
|
109
|
+
"Time": "2012-05-03T17:21:15.890+02:00",
|
110
|
+
"id": "M1"
|
111
|
+
},
|
112
|
+
{
|
113
|
+
"_type": "PrivateTransportManeuverType",
|
114
|
+
"Position": {
|
115
|
+
"Latitude": 49.9569397,
|
116
|
+
"Longitude": 8.95786
|
117
|
+
},
|
118
|
+
"Instruction": "Rechts halten auf die Hindenburgstraße. 40 m der Straße folgen.",
|
119
|
+
"TravelTime": 9.5,
|
120
|
+
"Length": 40,
|
121
|
+
"Time": "2012-05-03T17:22:03.990+02:00",
|
122
|
+
"id": "M2"
|
123
|
+
},
|
124
|
+
{
|
125
|
+
"_type": "PrivateTransportManeuverType",
|
126
|
+
"Position": {
|
127
|
+
"Latitude": 49.95718,
|
128
|
+
"Longitude": 8.9574299
|
129
|
+
},
|
130
|
+
"Instruction": "Links abbiegen auf die Darmstädter Straße (B26). 18 km der Straße folgen.",
|
131
|
+
"TravelTime": 849.2,
|
132
|
+
"Length": 17512,
|
133
|
+
"Time": "2012-05-03T17:22:13.450+02:00",
|
134
|
+
"id": "M3"
|
135
|
+
},
|
136
|
+
{
|
137
|
+
"_type": "PrivateTransportManeuverType",
|
138
|
+
"Position": {
|
139
|
+
"Latitude": 49.8759689,
|
140
|
+
"Longitude": 8.7687302
|
141
|
+
},
|
142
|
+
"Instruction": "Auffahren auf die B38. 1.9 km der Straße folgen.",
|
143
|
+
"TravelTime": 93.2,
|
144
|
+
"Length": 1934,
|
145
|
+
"Time": "2012-05-03T17:36:22.640+02:00",
|
146
|
+
"id": "M4"
|
147
|
+
},
|
148
|
+
{
|
149
|
+
"_type": "PrivateTransportManeuverType",
|
150
|
+
"Position": {
|
151
|
+
"Latitude": 49.8628807,
|
152
|
+
"Longitude": 8.7691898
|
153
|
+
},
|
154
|
+
"Instruction": "Rechts abbiegen auf die Dieburger Straße (L3115). 1.1 km der Straße folgen.",
|
155
|
+
"TravelTime": 138.1,
|
156
|
+
"Length": 1109,
|
157
|
+
"Time": "2012-05-03T17:37:55.880+02:00",
|
158
|
+
"id": "M5"
|
159
|
+
},
|
160
|
+
{
|
161
|
+
"_type": "PrivateTransportManeuverType",
|
162
|
+
"Position": {
|
163
|
+
"Latitude": 49.8574791,
|
164
|
+
"Longitude": 8.7565403
|
165
|
+
},
|
166
|
+
"Instruction": "Rechts halten auf die Darmstädter Straße (L3104). 500 m der Straße folgen.",
|
167
|
+
"TravelTime": 75.3,
|
168
|
+
"Length": 524,
|
169
|
+
"Time": "2012-05-03T17:40:13.930+02:00",
|
170
|
+
"id": "M6"
|
171
|
+
},
|
172
|
+
{
|
173
|
+
"_type": "PrivateTransportManeuverType",
|
174
|
+
"Position": {
|
175
|
+
"Latitude": 49.8612404,
|
176
|
+
"Longitude": 8.7521095
|
177
|
+
},
|
178
|
+
"Instruction": "Rechts abbiegen auf den Messeler Weg. 350 m der Straße folgen.",
|
179
|
+
"TravelTime": 70.1,
|
180
|
+
"Length": 340,
|
181
|
+
"Time": "2012-05-03T17:41:29.220+02:00",
|
182
|
+
"id": "M7"
|
183
|
+
},
|
184
|
+
{
|
185
|
+
"_type": "PrivateTransportManeuverType",
|
186
|
+
"Position": {
|
187
|
+
"Latitude": 49.8639412,
|
188
|
+
"Longitude": 8.75313
|
189
|
+
},
|
190
|
+
"Instruction": "Links abbiegen auf die Straße Am Rödersberg. 100 m der Straße folgen.",
|
191
|
+
"TravelTime": 29.3,
|
192
|
+
"Length": 86,
|
193
|
+
"Time": "2012-05-03T17:42:39.310+02:00",
|
194
|
+
"id": "M8"
|
195
|
+
},
|
196
|
+
{
|
197
|
+
"_type": "PrivateTransportManeuverType",
|
198
|
+
"Position": {
|
199
|
+
"Latitude": 49.8636017,
|
200
|
+
"Longitude": 8.7520599
|
201
|
+
},
|
202
|
+
"Instruction": "Ihr Ziel in der Straße Am Rödersberg ist links. Ihre Fahrt ist 22 km lang und dauert etwa 22 min.",
|
203
|
+
"TravelTime": 0,
|
204
|
+
"Length": 0,
|
205
|
+
"Time": "2012-05-03T17:43:08.560+02:00",
|
206
|
+
"id": "M9"
|
207
|
+
}
|
208
|
+
]
|
209
|
+
},
|
210
|
+
{
|
211
|
+
"Start": {
|
212
|
+
"LinkId": "+61868764",
|
213
|
+
"MappedPosition": {
|
214
|
+
"Latitude": 49.8636017,
|
215
|
+
"Longitude": 8.7520599
|
216
|
+
},
|
217
|
+
"OriginalPosition": {
|
218
|
+
"Latitude": 49.8634,
|
219
|
+
"Longitude": 8.7523
|
220
|
+
},
|
221
|
+
"Type": "stopOver"
|
222
|
+
},
|
223
|
+
"End": {
|
224
|
+
"LinkId": "-52433009",
|
225
|
+
"MappedPosition": {
|
226
|
+
"Latitude": 49.8745117,
|
227
|
+
"Longitude": 8.6540937
|
228
|
+
},
|
229
|
+
"OriginalPosition": {
|
230
|
+
"Latitude": 49.8752,
|
231
|
+
"Longitude": 8.654
|
232
|
+
},
|
233
|
+
"Type": "stopOver"
|
234
|
+
},
|
235
|
+
"Length": 8200,
|
236
|
+
"TravelTime": 693.3,
|
237
|
+
"Maneuver": [
|
238
|
+
{
|
239
|
+
"_type": "PrivateTransportManeuverType",
|
240
|
+
"Position": {
|
241
|
+
"Latitude": 49.8636017,
|
242
|
+
"Longitude": 8.7520599
|
243
|
+
},
|
244
|
+
"Instruction": "In Richtung Messeler Weg fahren in der Straße Am Rödersberg. 100 m der Straße folgen.",
|
245
|
+
"TravelTime": 12.2,
|
246
|
+
"Length": 85,
|
247
|
+
"Time": "2012-05-03T17:43:08.590+02:00",
|
248
|
+
"id": "M10"
|
249
|
+
},
|
250
|
+
{
|
251
|
+
"_type": "PrivateTransportManeuverType",
|
252
|
+
"Position": {
|
253
|
+
"Latitude": 49.8639412,
|
254
|
+
"Longitude": 8.75313
|
255
|
+
},
|
256
|
+
"Instruction": "Rechts abbiegen auf den Messeler Weg. 100 m der Straße folgen.",
|
257
|
+
"TravelTime": 20.9,
|
258
|
+
"Length": 90,
|
259
|
+
"Time": "2012-05-03T17:43:20.830+02:00",
|
260
|
+
"id": "M11"
|
261
|
+
},
|
262
|
+
{
|
263
|
+
"_type": "PrivateTransportManeuverType",
|
264
|
+
"Position": {
|
265
|
+
"Latitude": 49.8632507,
|
266
|
+
"Longitude": 8.7537298
|
267
|
+
},
|
268
|
+
"Instruction": "Rechts halten und auf dem Messeler Weg bleiben. 250 m der Straße folgen.",
|
269
|
+
"TravelTime": 46.2,
|
270
|
+
"Length": 250,
|
271
|
+
"Time": "2012-05-03T17:43:41.730+02:00",
|
272
|
+
"id": "M12"
|
273
|
+
},
|
274
|
+
{
|
275
|
+
"_type": "PrivateTransportManeuverType",
|
276
|
+
"Position": {
|
277
|
+
"Latitude": 49.8612404,
|
278
|
+
"Longitude": 8.7521095
|
279
|
+
},
|
280
|
+
"Instruction": "Rechts abbiegen auf die Darmstädter Straße (L3104). 1.7 km der Straße folgen.",
|
281
|
+
"TravelTime": 142.1,
|
282
|
+
"Length": 1670,
|
283
|
+
"Time": "2012-05-03T17:44:27.900+02:00",
|
284
|
+
"id": "M13"
|
285
|
+
},
|
286
|
+
{
|
287
|
+
"_type": "PrivateTransportManeuverType",
|
288
|
+
"Position": {
|
289
|
+
"Latitude": 49.8641891,
|
290
|
+
"Longitude": 8.7293701
|
291
|
+
},
|
292
|
+
"Instruction": "Weiter auf die Aschaffenburger Straße fahren. 400 m der Straße folgen.",
|
293
|
+
"TravelTime": 33.5,
|
294
|
+
"Length": 418,
|
295
|
+
"Time": "2012-05-03T17:46:50.050+02:00",
|
296
|
+
"id": "M14"
|
297
|
+
},
|
298
|
+
{
|
299
|
+
"_type": "PrivateTransportManeuverType",
|
300
|
+
"Position": {
|
301
|
+
"Latitude": 49.8653107,
|
302
|
+
"Longitude": 8.7237902
|
303
|
+
},
|
304
|
+
"Instruction": "Auffahren auf die B26 in Richtung Darmstadt. 5.5 km der Straße folgen.",
|
305
|
+
"TravelTime": 384.6,
|
306
|
+
"Length": 5356,
|
307
|
+
"Time": "2012-05-03T17:47:23.590+02:00",
|
308
|
+
"id": "M15"
|
309
|
+
},
|
310
|
+
{
|
311
|
+
"_type": "PrivateTransportManeuverType",
|
312
|
+
"Position": {
|
313
|
+
"Latitude": 49.8731689,
|
314
|
+
"Longitude": 8.65728
|
315
|
+
},
|
316
|
+
"Instruction": "Rechts abbiegen auf die Straße Schlossgraben (B26). 150 m der Straße folgen.",
|
317
|
+
"TravelTime": 25,
|
318
|
+
"Length": 153,
|
319
|
+
"Time": "2012-05-03T17:53:48.230+02:00",
|
320
|
+
"id": "M16"
|
321
|
+
},
|
322
|
+
{
|
323
|
+
"_type": "PrivateTransportManeuverType",
|
324
|
+
"Position": {
|
325
|
+
"Latitude": 49.8741608,
|
326
|
+
"Longitude": 8.6561899
|
327
|
+
},
|
328
|
+
"Instruction": "Links abbiegen auf die Straße Karolinenplatz (B26). 200 m der Straße folgen.",
|
329
|
+
"TravelTime": 28.6,
|
330
|
+
"Length": 178,
|
331
|
+
"Time": "2012-05-03T17:54:13.200+02:00",
|
332
|
+
"id": "M17"
|
333
|
+
},
|
334
|
+
{
|
335
|
+
"_type": "PrivateTransportManeuverType",
|
336
|
+
"Position": {
|
337
|
+
"Latitude": 49.8745117,
|
338
|
+
"Longitude": 8.6540937
|
339
|
+
},
|
340
|
+
"Instruction": "Ihr Ziel in der Friedensplatz, Zeughausstraße (B26) ist rechts. Ihre Fahrt ist 30 km lang und dauert etwa 33 min.",
|
341
|
+
"TravelTime": 0,
|
342
|
+
"Length": 0,
|
343
|
+
"Time": "2012-05-03T17:54:41.840+02:00",
|
344
|
+
"id": "M18"
|
345
|
+
}
|
346
|
+
]
|
347
|
+
}
|
348
|
+
],
|
349
|
+
"Summary": {
|
350
|
+
"Distance": 30013,
|
351
|
+
"TrafficTime": 2005,
|
352
|
+
"BaseTime": 2005
|
353
|
+
}
|
354
|
+
}
|
355
|
+
]
|
356
|
+
}
|
357
|
+
}
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Routing::Adapter::Navteq do
|
4
|
+
|
5
|
+
context 'creating a new instance' do
|
6
|
+
|
7
|
+
it 'can be instantiated without arguments' do
|
8
|
+
expect { Routing::Adapter::Navteq.new }.to_not raise_error
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'sets the host in its options' do
|
12
|
+
described_class.new(:host => "new_host").host.should == "new_host"
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'sets the default params in its options' do
|
16
|
+
params = { :hello => "world" }
|
17
|
+
described_class.new(:default_params => params).default_params == params
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'ignores unknown options' do
|
21
|
+
expect { described_class.new(:hello => "world") }.to_not raise_error
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
its(:service_path){ should be_a String }
|
27
|
+
|
28
|
+
its(:default_params){ should be_a Hash }
|
29
|
+
|
30
|
+
describe '#connection' do
|
31
|
+
|
32
|
+
it 'returns a faraday connection' do
|
33
|
+
subject.send(:connection).should be_a Faraday::Connection
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
describe '#calculate' do
|
39
|
+
pending
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#get' do
|
43
|
+
pending
|
44
|
+
end
|
45
|
+
|
46
|
+
describe '#geo_points_to_params' do
|
47
|
+
|
48
|
+
let(:geo_points) { [stub(:lat => 1, :lng => 2), stub(:lat => 3, :lng => 4), stub(:lat => 5, :lng => 6)] }
|
49
|
+
let(:params){ subject.send(:geo_points_to_params, geo_points) }
|
50
|
+
|
51
|
+
it 'creates a hash with enumerated waypoint keys and the navteq special geo! syntax as values' do
|
52
|
+
params['waypoint0'].should == 'geo!1,2'
|
53
|
+
params['waypoint1'].should == 'geo!3,4'
|
54
|
+
params['waypoint2'].should == 'geo!5,6'
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|