server-side-google-maps 0.0.2 → 0.0.3

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.
@@ -120,6 +120,7 @@ module ServerSideGoogleMaps
120
120
 
121
121
  def calculate_points_and_levels
122
122
  polyline = route['overview_polyline']
123
+ return [ origin_point + [0], destination_point + [0]] unless polyline && polyline['points'] && polyline['levels']
123
124
  ::GoogleMapsPolyline.decode_polyline(polyline['points'], polyline['levels'])
124
125
  end
125
126
 
@@ -1,3 +1,3 @@
1
1
  module ServerSideGoogleMaps
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -128,8 +128,6 @@ module ServerSideGoogleMaps
128
128
  parser = Parser.new(data, :json)
129
129
  parser.parse
130
130
  end
131
-
132
- directions = Directions.new('Montreal,QC', 'Ottawa,ON')
133
131
  end
134
132
 
135
133
  it('should calculate the distance by summing the parts') do
@@ -137,5 +135,24 @@ module ServerSideGoogleMaps
137
135
  directions.distance.should == 199901
138
136
  end
139
137
  end
138
+
139
+ context('when Google forgets the overview polyline') do
140
+ class Parser < HTTParty::Parser
141
+ public_class_method(:new)
142
+ end
143
+
144
+ before(:each) do
145
+ Directions.stub(:get) do
146
+ data = File.read(File.dirname(__FILE__) + '/files/directions-Montreal,QC-to-Ottawa,ON-without-overview-polyline.txt')
147
+ parser = Parser.new(data, :json)
148
+ parser.parse
149
+ end
150
+ end
151
+
152
+ it('should provide the start-point and end-point instead') do
153
+ directions = Directions.new('Montreal,QC', 'Ottawa,ON')
154
+ directions.points.should == [[45.50867, -73.55368], [45.4119, -75.69846]]
155
+ end
156
+ end
140
157
  end
141
158
  end
@@ -0,0 +1,343 @@
1
+ {
2
+ "status": "OK",
3
+ "routes": [ {
4
+ "summary": "Autoroute 40 W and ON-417 W",
5
+ "legs": [ {
6
+ "steps": [ {
7
+ "travel_mode": "DRIVING",
8
+ "start_location": {
9
+ "lat": 45.5086700,
10
+ "lng": -73.5536800
11
+ },
12
+ "end_location": {
13
+ "lat": 45.5062300,
14
+ "lng": -73.5556900
15
+ },
16
+ "polyline": {
17
+ "points": "elwtGn}|_MfNpK",
18
+ "levels": "BB"
19
+ },
20
+ "duration": {
21
+ "value": 20,
22
+ "text": "1 min"
23
+ },
24
+ "html_instructions": "Head \u003cb\u003esouthwest\u003c/b\u003e on \u003cb\u003eRue Notre-Dame E\u003c/b\u003e toward \u003cb\u003ePlace Jacques Cartier\u003c/b\u003e",
25
+ "distance": {
26
+ "value": 313,
27
+ "text": "0.3 km"
28
+ }
29
+ }, {
30
+ "travel_mode": "DRIVING",
31
+ "start_location": {
32
+ "lat": 45.5062300,
33
+ "lng": -73.5556900
34
+ },
35
+ "end_location": {
36
+ "lat": 45.5068900,
37
+ "lng": -73.5572800
38
+ },
39
+ "polyline": {
40
+ "points": "}|vtG`j}_McC|H",
41
+ "levels": "BB"
42
+ },
43
+ "duration": {
44
+ "value": 25,
45
+ "text": "1 min"
46
+ },
47
+ "html_instructions": "Take the 1st \u003cb\u003eright\u003c/b\u003e onto \u003cb\u003eBoulevard Saint-Laurent\u003c/b\u003e",
48
+ "distance": {
49
+ "value": 144,
50
+ "text": "0.1 km"
51
+ }
52
+ }, {
53
+ "travel_mode": "DRIVING",
54
+ "start_location": {
55
+ "lat": 45.5068900,
56
+ "lng": -73.5572800
57
+ },
58
+ "end_location": {
59
+ "lat": 45.5082100,
60
+ "lng": -73.5563400
61
+ },
62
+ "polyline": {
63
+ "points": "aawtG~s}_MgG{D",
64
+ "levels": "BB"
65
+ },
66
+ "duration": {
67
+ "value": 40,
68
+ "text": "1 min"
69
+ },
70
+ "html_instructions": "Take the 1st \u003cb\u003eright\u003c/b\u003e onto \u003cb\u003eRue Saint Antoine E\u003c/b\u003e",
71
+ "distance": {
72
+ "value": 164,
73
+ "text": "0.2 km"
74
+ }
75
+ }, {
76
+ "travel_mode": "DRIVING",
77
+ "start_location": {
78
+ "lat": 45.5082100,
79
+ "lng": -73.5563400
80
+ },
81
+ "end_location": {
82
+ "lat": 45.5071400,
83
+ "lng": -73.5585500
84
+ },
85
+ "polyline": {
86
+ "points": "iiwtGbn}_MuA]g@P}@xBAn@^d@fHnEjAd@",
87
+ "levels": "B???@??B"
88
+ },
89
+ "duration": {
90
+ "value": 61,
91
+ "text": "1 min"
92
+ },
93
+ "html_instructions": "Take the \u003cb\u003eAutoroute 720 O\u003c/b\u003e ramp on the \u003cb\u003eleft\u003c/b\u003e",
94
+ "distance": {
95
+ "value": 404,
96
+ "text": "0.4 km"
97
+ }
98
+ }, {
99
+ "travel_mode": "DRIVING",
100
+ "start_location": {
101
+ "lat": 45.5071400,
102
+ "lng": -73.5585500
103
+ },
104
+ "end_location": {
105
+ "lat": 45.4728800,
106
+ "lng": -73.5967400
107
+ },
108
+ "polyline": {
109
+ "points": "sbwtG|{}_M`TtPjMlIpCnAz@TvJ`@dBXjC`AfBjAfA`AzAtB~@fBr@lBtHhYvClH|DbG~StYrHhLvSj`@|_@~r@lEjErF|BdU`H",
110
+ "levels": "B?@??????@????@??@?@??B"
111
+ },
112
+ "duration": {
113
+ "value": 202,
114
+ "text": "3 mins"
115
+ },
116
+ "html_instructions": "Merge onto \u003cb\u003eAutoroute 720 W\u003c/b\u003e",
117
+ "distance": {
118
+ "value": 5006,
119
+ "text": "5.0 km"
120
+ }
121
+ }, {
122
+ "travel_mode": "DRIVING",
123
+ "start_location": {
124
+ "lat": 45.4728800,
125
+ "lng": -73.5967400
126
+ },
127
+ "end_location": {
128
+ "lat": 45.5019000,
129
+ "lng": -73.6638100
130
+ },
131
+ "polyline": {
132
+ "points": "olptGrje`MPPrD~A|A|AtAhBhAdC~@`Dv@nGFjEIzAg@nDiAnEeFnPsDpKeA~ByKx[uEjKoErIaCdDwGzFaClC{AbCyAjDmJ~WcJrXqItUiFrOOLwWrv@uGlSGp@eDtKqA|CeZbj@QHyG~LqApBuCnD{DjD",
133
+ "levels": "B???@??@????@???@?????@?????????@?????B"
134
+ },
135
+ "duration": {
136
+ "value": 378,
137
+ "text": "6 mins"
138
+ },
139
+ "html_instructions": "Take exit \u003cb\u003e1N\u003c/b\u003e to merge onto \u003cb\u003eAutoroute Décarie/Autoroute 15 N\u003c/b\u003e toward \u003cb\u003eSaint-Jérôme\u003c/b\u003e",
140
+ "distance": {
141
+ "value": 6611,
142
+ "text": "6.6 km"
143
+ }
144
+ }, {
145
+ "travel_mode": "DRIVING",
146
+ "start_location": {
147
+ "lat": 45.5019000,
148
+ "lng": -73.6638100
149
+ },
150
+ "end_location": {
151
+ "lat": 45.5026400,
152
+ "lng": -73.6676900
153
+ },
154
+ "polyline": {
155
+ "points": "{avtGxmr`McAz@uFdDsAlBa@~A@xBXlA\\n@VXl@XzCj@",
156
+ "levels": "B???@??@??B"
157
+ },
158
+ "duration": {
159
+ "value": 30,
160
+ "text": "1 min"
161
+ },
162
+ "html_instructions": "Take exit \u003cb\u003e70O\u003c/b\u003e on the \u003cb\u003eleft\u003c/b\u003e for \u003cb\u003eAutoroute 40 O\u003c/b\u003e toward \u003cb\u003eHull/Ottawa/Autoroute 520/Pierre Elliott Trudeau\u003c/b\u003e",
163
+ "distance": {
164
+ "value": 542,
165
+ "text": "0.5 km"
166
+ }
167
+ }, {
168
+ "travel_mode": "DRIVING",
169
+ "start_location": {
170
+ "lat": 45.5026400,
171
+ "lng": -73.6676900
172
+ },
173
+ "end_location": {
174
+ "lat": 45.5390400,
175
+ "lng": -74.3889100
176
+ },
177
+ "polyline": {
178
+ "points": "ofvtG`fs`MxAp@|AvAjXl^xEfHhAxBxA`Ep@hCl@dDn@bHNvF`@xl@ZvIt@xIfBdLlCfMdA~DtQnz@nAbIl@hG`@~JEpNsIrsDWfOAzN\\tVpB~t@b@pWfAla@d@tHrAfMhBfKlBbIlDzKni@bvAxl@|~A~gAlnCzR|f@pBvGn@lC~AbJjQduAnAdHfBbHrFhOx}@r~BvFlOvAnEfCxIhChKfEpT`J`l@nArGxChMxAlErBzFlG`Od[rs@xRdc@rOf^`C`FhBdFnBpIv@bHT|DPfHMzGeG`hBiCzp@a@xM@bHlQzyEvEpp@vArWnB|UjEpl@l@pGnBtMhD`OrBnGfNl_@vD`Jzh@btA|DzKlGnWjA`JN`GC`Dc@hGiBtI{AzDeC`EcBhBsCbCy@f@k^tYcSnQi{@r_AsChEg@fAgAlCeBhGs@bEc@rEaCzl@_@lTwAb{AWlGiAtKw@rDwChK_p@tvBiB|GwAvIw@xH[`JCvJ~DhhAT|PAhp@YpIuAnSmBxNyLht@iEhRaEbNuBrFgExJ{IpP}d@f~@m`@~p@qL~T}EpM}\\pmAcRnh@gQ`t@uBjLa\\`vCiAfFsAvD}D~GuR|VmR~U{CvF{CpI_Jfh@gL|s@q@xGUvFDbJpOxfDKhGc@`FqBpIwCfGkzA|kBgJvLeg@pr@wC|CkAbAuF~C_DfAgdBbe@mDd@yC?qHo@{C@cEz@wCpA}DdDaE|G{AtEsGj`@",
179
+ "levels": "B??@???@?????@?????A????@???@??A???@?@?????@???@??????@???????A???@???@@???A???@???@???A???@????@@???A??????@??@??@????@???A???@????@??@??@????@??A??@@??A????@???@???@?@?@?B"
180
+ },
181
+ "duration": {
182
+ "value": 2666,
183
+ "text": "44 mins"
184
+ },
185
+ "html_instructions": "Merge onto \u003cb\u003eAutoroute 40 W\u003c/b\u003e\u003cdiv style=\"font-size:0.9em\"\u003eEntering Ontario\u003c/div\u003e",
186
+ "distance": {
187
+ "value": 66555,
188
+ "text": "66.6 km"
189
+ }
190
+ }, {
191
+ "travel_mode": "DRIVING",
192
+ "start_location": {
193
+ "lat": 45.5390400,
194
+ "lng": -74.3889100
195
+ },
196
+ "end_location": {
197
+ "lat": 45.4124300,
198
+ "lng": -75.6833000
199
+ },
200
+ "polyline": {
201
+ "points": "_j}tGta`eMoRzmAab@vcCu\\|nCuF~]uThiAeE~VyR`wAcSfzA}AjLgA|J[|FK|FTpHp@nIfApGtBxHvBrFfGtIfj@`l@fHjJfGzJhKrVdSzs@pD|KdHxOfGdKvF`IxcAbmAtJ~IvJrH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G}@zDu@vE]zC[~EmIxnBeF|gAiBb\\yBn\\aEne@}e@v_FwBlNiA|EoBvGsBlFyA|CmDfG}OdTgFhI}EnJwKpWkBtDwDnGoGhIeE`EoDvCiHjE{F`CiGhBkHpAyF^}Oj@qC`@kDz@yChAeFtCsNxK_C~AeCrAkE~AqMdDeBx@aBfA{BxBsAfBkCdFoArDcArFk@lGq@zKk@rE}@fEcAdDkBzDqCtD_CpBkBjAgBr@eCn@mM~AqAf@sBnAwBlB{B|C_B`EsA|FS~AYvFDrEZhE^fCrEdRfBdJvA~JjAhMt@vRnEr`Bb@lIXxCh@~CjE|Pd@vCZhDnB`k@ExE{@xLOxEF`GP|Cz@rGpAhFrQdg@rEnQ",
202
+ "levels": "B?@@??@?@???@??A??@??@??@??@?@???@??A?@???@???@????@???@????@???@????@?@??@??@?@???@???A???@??@??@??@?@?@??@??@?A???@???@?@???@????A??@????@???@????A??@??@?@?@??@??@?@????B??????@???????@??@?????A??@????@??@?A????????@????@???@???A???@??@???A??????@????@???@???@??@????@??@????@???@?????@??A???@???????@???@?????@????@???@???@??????@??@????@???A???@????@??@????@?????@???B"
203
+ },
204
+ "duration": {
205
+ "value": 4744,
206
+ "text": "1 hour 19 mins"
207
+ },
208
+ "html_instructions": "Continue onto \u003cb\u003eON-417 W\u003c/b\u003e",
209
+ "distance": {
210
+ "value": 118628,
211
+ "text": "119 km"
212
+ }
213
+ }, {
214
+ "travel_mode": "DRIVING",
215
+ "start_location": {
216
+ "lat": 45.4124300,
217
+ "lng": -75.6833000
218
+ },
219
+ "end_location": {
220
+ "lat": 45.4112800,
221
+ "lng": -75.6874000
222
+ },
223
+ "polyline": {
224
+ "points": "urdtGr{|lMNzAvAjGf@fFtAbF",
225
+ "levels": "B???B"
226
+ },
227
+ "duration": {
228
+ "value": 27,
229
+ "text": "1 min"
230
+ },
231
+ "html_instructions": "Take exit \u003cb\u003e119\u003c/b\u003e for \u003cb\u003eCatherine Street\u003c/b\u003e",
232
+ "distance": {
233
+ "value": 347,
234
+ "text": "0.3 km"
235
+ }
236
+ }, {
237
+ "travel_mode": "DRIVING",
238
+ "start_location": {
239
+ "lat": 45.4112800,
240
+ "lng": -75.6874000
241
+ },
242
+ "end_location": {
243
+ "lat": 45.4088400,
244
+ "lng": -75.6937300
245
+ },
246
+ "polyline": {
247
+ "points": "okdtGfu}lM|@jF`AjDfJxY",
248
+ "levels": "B??B"
249
+ },
250
+ "duration": {
251
+ "value": 108,
252
+ "text": "2 mins"
253
+ },
254
+ "html_instructions": "Slight \u003cb\u003eleft\u003c/b\u003e at \u003cb\u003eCatherine St/Regional Road 60\u003c/b\u003e",
255
+ "distance": {
256
+ "value": 565,
257
+ "text": "0.6 km"
258
+ }
259
+ }, {
260
+ "travel_mode": "DRIVING",
261
+ "start_location": {
262
+ "lat": 45.4088400,
263
+ "lng": -75.6937300
264
+ },
265
+ "end_location": {
266
+ "lat": 45.4125400,
267
+ "lng": -75.6968900
268
+ },
269
+ "polyline": {
270
+ "points": "g|ctGx|~lMU^}ElDoNhL",
271
+ "levels": "B??B"
272
+ },
273
+ "duration": {
274
+ "value": 56,
275
+ "text": "1 min"
276
+ },
277
+ "html_instructions": "Turn \u003cb\u003eright\u003c/b\u003e at \u003cb\u003eKent St/Hwy 17B/Regional Road 83\u003c/b\u003e",
278
+ "distance": {
279
+ "value": 480,
280
+ "text": "0.5 km"
281
+ }
282
+ }, {
283
+ "travel_mode": "DRIVING",
284
+ "start_location": {
285
+ "lat": 45.4125400,
286
+ "lng": -75.6968900
287
+ },
288
+ "end_location": {
289
+ "lat": 45.4119000,
290
+ "lng": -75.6984600
291
+ },
292
+ "polyline": {
293
+ "points": "ksdtGpp_mM~BxH",
294
+ "levels": "BB"
295
+ },
296
+ "duration": {
297
+ "value": 38,
298
+ "text": "1 min"
299
+ },
300
+ "html_instructions": "Turn \u003cb\u003eleft\u003c/b\u003e at \u003cb\u003eJames St\u003c/b\u003e\u003cdiv style=\"font-size:0.9em\"\u003eDestination will be on the left\u003c/div\u003e",
301
+ "distance": {
302
+ "value": 142,
303
+ "text": "0.1 km"
304
+ }
305
+ } ],
306
+ "duration": {
307
+ "value": 8395,
308
+ "text": "2 hours 20 mins"
309
+ },
310
+ "distance": {
311
+ "value": 199901,
312
+ "text": "200 km"
313
+ },
314
+ "start_location": {
315
+ "lat": 45.5086700,
316
+ "lng": -73.5536800
317
+ },
318
+ "end_location": {
319
+ "lat": 45.4119000,
320
+ "lng": -75.6984600
321
+ },
322
+ "start_address": "Montreal, QC, Canada",
323
+ "end_address": "Ottawa, ON, Canada",
324
+ "via_waypoint": [ ]
325
+ } ],
326
+ "copyrights": "Map data ©2011 Google",
327
+ "overview_polyline": {
328
+ "points": ""
329
+ },
330
+ "warnings": [ ],
331
+ "waypoint_order": [ ],
332
+ "bounds": {
333
+ "southwest": {
334
+ "lat": 45.3026900,
335
+ "lng": -75.6984600
336
+ },
337
+ "northeast": {
338
+ "lat": 45.5655200,
339
+ "lng": -73.5536800
340
+ }
341
+ }
342
+ } ]
343
+ }
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: server-side-google-maps
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Adam Hooper
@@ -83,6 +83,7 @@ files:
83
83
  - spec/directions_spec.rb
84
84
  - spec/files/directions-45.5086700,-73.5536800-to-45.4119000,-75.6984600.txt
85
85
  - spec/files/directions-Montreal,QC-to-Ottawa,ON-without-distance.txt
86
+ - spec/files/directions-Montreal,QC-to-Ottawa,ON-without-overview-polyline.txt
86
87
  - spec/files/directions-Montreal,QC-to-Ottawa,ON.txt
87
88
  - spec/files/directions-Ottawa,ON-to-Toronto,ON.txt
88
89
  - spec/route_spec.rb