Merge lp:~costales/unav/0.68-show-north into lp:unav
- 0.68-show-north
- Merge into trunk
Proposed by
costales
Status: | Merged | ||||
---|---|---|---|---|---|
Merged at revision: | 187 | ||||
Proposed branch: | lp:~costales/unav/0.68-show-north | ||||
Merge into: | lp:unav | ||||
Diff against target: |
447 lines (+208/-126) 5 files modified
nav/class/Navigator.js (+99/-121) nav/class/UI.js (+13/-0) nav/css/unav.css (+16/-5) nav/img/marker/north.svg (+71/-0) nav/index.html (+9/-0) |
||||
To merge this branch: | bzr merge lp:~costales/unav/0.68-show-north | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
uNav developers | Pending | ||
Review via email: mp+321912@code.launchpad.net |
Commit message
Description of the change
Show the North if map is rotated
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'nav/class/Navigator.js' |
2 | --- nav/class/Navigator.js 2017-03-31 15:17:02 +0000 |
3 | +++ nav/class/Navigator.js 2017-04-06 20:44:50 +0000 |
4 | @@ -231,9 +231,18 @@ |
5 | tracks[i].type = 30; |
6 | } |
7 | |
8 | + try {var exit_number_elements = tracks[i].sign.exit_number_elements[0].text;} catch (err) {var exit_number_elements = '';} |
9 | + try {var exit_branch_elements = tracks[i].sign.exit_branch_elements[0].text;} catch (err) {var exit_branch_elements = '';} |
10 | + try {var exit_toward_elements = tracks[i].sign.exit_toward_elements[0].text;} catch (err) {var exit_toward_elements = '';} |
11 | + try {var exit_name_elements = tracks[i].sign.exit_name_elements[0].text;} catch (err) {var exit_name_elements = '';} |
12 | + try {var street_name = tracks[i].street_names[0];} catch (err) {var street_name = '';} |
13 | instruction = this.compose_instruction_simple( |
14 | tracks[i].type, |
15 | - tracks[i].hasOwnProperty('street_names') ? tracks[i].street_names[0] : '', |
16 | + exit_number_elements, |
17 | + exit_branch_elements, |
18 | + exit_toward_elements, |
19 | + exit_name_elements, |
20 | + street_name, |
21 | tracks[i].instruction |
22 | ); |
23 | |
24 | @@ -283,164 +292,133 @@ |
25 | } |
26 | } |
27 | |
28 | -Navigator.prototype.compose_instruction_simple = function(type, street_name, original_instruction) { |
29 | - // Return the street name if not public transport |
30 | - if (street_name && (type < 28 || type > 30)) { |
31 | - return street_name; |
32 | - } |
33 | - // Or the instruction if there is not street name |
34 | - var instruction = ''; |
35 | +Navigator.prototype.compose_instruction_simple = function(type, exit_number_elements, exit_branch_elements, exit_toward_elements, exit_name_elements, street_name, instruction) { |
36 | + // Initial instructions |
37 | switch (type) { |
38 | case 0: // None |
39 | - instruction = ''; |
40 | - break; |
41 | + return ''; |
42 | case 1: // Start |
43 | - instruction = t("Go"); |
44 | - break; |
45 | + return t("Go"); |
46 | case 2: // StartRight |
47 | - instruction = t("Go to your right"); |
48 | - break; |
49 | + return t("Go to your right"); |
50 | case 3: // StartLeft |
51 | - instruction = t("Go to your left"); |
52 | - break; |
53 | + return t("Go to your left"); |
54 | case 4: // Destination |
55 | - instruction = t("You have arrived at your destination"); |
56 | - break; |
57 | + return t("You have arrived at your destination"); |
58 | case 5: // DestinationRight |
59 | - instruction = t("Your destination is on the right"); |
60 | - break; |
61 | + return t("Your destination is on the right"); |
62 | case 6: // DestinationLeft |
63 | - instruction = t("Your destination is on the left"); |
64 | - break; |
65 | + return t("Your destination is on the left"); |
66 | + case 26: // RoundaboutsEnter |
67 | + return t("Enter the roundabout and take the designated exit"); |
68 | + case 261: |
69 | + return t("Enter the roundabout and take the first exit"); |
70 | + case 262: |
71 | + return t("Enter the roundabout and take the second exit"); |
72 | + case 263: |
73 | + return t("Enter the roundabout and take the third exit"); |
74 | + case 264: |
75 | + return t("Enter the roundabout and take the fourth exit"); |
76 | + case 265: |
77 | + return t("Enter the roundabout and take the fifth exit"); |
78 | + case 266: |
79 | + return t("Enter the roundabout and take the sixth exit"); |
80 | + case 267: |
81 | + return t("Enter the roundabout and take the seventh exit"); |
82 | + case 268: |
83 | + return t("Enter the roundabout and take the eighth exit"); |
84 | + case 269: |
85 | + return t("Enter the roundabout and take the ninth exit"); |
86 | + case 28: // FerryEnter |
87 | + return t("Take the Ferry"); |
88 | + case 29: // FerryExit |
89 | + return t("Leave the Ferry"); |
90 | + case 30: // Public transports |
91 | + return instruction; |
92 | + } |
93 | + |
94 | + var aux_exits = ''; |
95 | + // exit_number_elements |
96 | + if (exit_number_elements && instruction.split(' ').join('').includes(exit_number_elements.split(' ').join(''))) |
97 | + aux_exits = '#' + exit_number_elements; |
98 | + // exit_branch_elements |
99 | + if (exit_branch_elements && instruction.split(' ').join('').includes(exit_branch_elements.split(' ').join(''))) |
100 | + aux_exits = aux_exits.concat(' ', exit_branch_elements); |
101 | + // exit_toward_elements |
102 | + if (exit_toward_elements && instruction.split(' ').join('').includes(exit_toward_elements.split(' ').join(''))) |
103 | + aux_exits = aux_exits.concat(' ', exit_toward_elements); |
104 | + // exit_name_elements |
105 | + if (exit_name_elements && instruction.split(' ').join('').includes(exit_name_elements.split(' ').join(''))) |
106 | + aux_exits = aux_exits.concat(' ', exit_name_elements); |
107 | + aux_exits = aux_exits.trim(); |
108 | + if (aux_exits) |
109 | + return aux_exits; |
110 | + |
111 | + // street_name |
112 | + if (street_name && instruction.split(' ').join('').includes(street_name.split(' ').join(''))) |
113 | + return street_name; |
114 | + |
115 | + // Instructions without directions |
116 | + switch (type) { |
117 | case 7: // Becomes |
118 | - instruction = t("The current road becomes into a new road"); |
119 | - break; |
120 | + return t("The current road becomes into a new road"); |
121 | case 8: // Continue |
122 | - instruction = t("Continue on the road"); |
123 | - break; |
124 | + return t("Continue on the road"); |
125 | case 9: // SlightRight |
126 | - instruction = t("Bear right"); |
127 | - break; |
128 | + return t("Bear right"); |
129 | case 10: // Right |
130 | - instruction = t("Turn right"); |
131 | - break; |
132 | + return t("Turn right"); |
133 | case 11: // SharpRight |
134 | - instruction = t("Make a sharp right"); |
135 | - break; |
136 | + return t("Make a sharp right"); |
137 | case 12: // UturnRight |
138 | - instruction = t("Make a right U-turn"); |
139 | - break; |
140 | + return t("Make a right U-turn"); |
141 | case 13: // UturnLeft |
142 | - instruction = t("Make a left U-turn"); |
143 | - break; |
144 | + return t("Make a left U-turn"); |
145 | case 14: // SharpLeft |
146 | - instruction = t("Make a sharp left"); |
147 | - break; |
148 | + return t("Make a sharp left"); |
149 | case 15: // Left |
150 | - instruction = t("Turn left"); |
151 | - break; |
152 | + return t("Turn left"); |
153 | case 16: // SlightLeft |
154 | - instruction = t("Bear left"); |
155 | - break; |
156 | + return t("Bear left"); |
157 | case 17: // RampStraight |
158 | - instruction = t("Stay straight to take the ramp"); |
159 | - break; |
160 | + return t("Stay straight to take the ramp"); |
161 | case 18: // RampRight |
162 | - instruction = t("Take the ramp on the right"); |
163 | - break; |
164 | + return t("Take the ramp on the right"); |
165 | case 19: // RampLeft |
166 | - instruction = t("Take the ramp on the left"); |
167 | - break; |
168 | + return t("Take the ramp on the left"); |
169 | case 20: // ExitRight |
170 | - instruction = t("Take the exit on the right"); |
171 | - break; |
172 | + return t("Take the exit on the right"); |
173 | case 21: // ExitLeft |
174 | - instruction = t("Take the exit on the left"); |
175 | - break; |
176 | + return t("Take the exit on the left"); |
177 | case 22: // StayStraight |
178 | - instruction = t("Keep straight at the fork"); |
179 | - break; |
180 | + return t("Keep straight at the fork"); |
181 | case 23: // StayRight |
182 | - instruction = t("Keep right at the fork"); |
183 | - break; |
184 | + return t("Keep right at the fork"); |
185 | case 24: // StayLeft |
186 | - instruction = t("Keep left at the fork"); |
187 | - break; |
188 | + return t("Keep left at the fork"); |
189 | case 25: // Merge |
190 | - instruction = t("The current road merges into a new one"); |
191 | - break; |
192 | - case 26: // RoundaboutsEnter |
193 | - instruction = t("Enter the roundabout and take the designated exit"); |
194 | - return instruction; |
195 | - case 261: |
196 | - instruction = t("Enter the roundabout and take the first exit"); |
197 | - return instruction; |
198 | - case 262: |
199 | - instruction = t("Enter the roundabout and take the second exit"); |
200 | - return instruction; |
201 | - case 263: |
202 | - instruction = t("Enter the roundabout and take the third exit"); |
203 | - return instruction; |
204 | - case 264: |
205 | - instruction = t("Enter the roundabout and take the fourth exit"); |
206 | - return instruction; |
207 | - case 265: |
208 | - instruction = t("Enter the roundabout and take the fifth exit"); |
209 | - return instruction; |
210 | - case 266: |
211 | - instruction = t("Enter the roundabout and take the sixth exit"); |
212 | - return instruction; |
213 | - case 267: |
214 | - instruction = t("Enter the roundabout and take the seventh exit"); |
215 | - return instruction; |
216 | - case 268: |
217 | - instruction = t("Enter the roundabout and take the eighth exit"); |
218 | - return instruction; |
219 | - case 269: |
220 | - instruction = t("Enter the roundabout and take the ninth exit"); |
221 | - return instruction; |
222 | + return t("The current road merges into a new one"); |
223 | case 27: // RoundaboutExits |
224 | - instruction = t("Exit the roundabout"); |
225 | - return instruction; |
226 | + return t("Exit the roundabout"); |
227 | case 271: |
228 | - instruction = t("Take the first exit"); |
229 | - return instruction; |
230 | + return t("Take the first exit"); |
231 | case 272: |
232 | - instruction = t("Take the second exit"); |
233 | - return instruction; |
234 | + return t("Take the second exit"); |
235 | case 273: |
236 | - instruction = t("Take the third exit"); |
237 | - return instruction; |
238 | + return t("Take the third exit"); |
239 | case 274: |
240 | - instruction = t("Take the fourth exit"); |
241 | - return instruction; |
242 | + return t("Take the fourth exit"); |
243 | case 275: |
244 | - instruction = t("Take the fifth exit"); |
245 | - return instruction; |
246 | + return t("Take the fifth exit"); |
247 | case 276: |
248 | - instruction = t("Take the sixth exit"); |
249 | - return instruction; |
250 | + return t("Take the sixth exit"); |
251 | case 277: |
252 | - instruction = t("Take the seventh exit"); |
253 | - return instruction; |
254 | + return t("Take the seventh exit"); |
255 | case 278: |
256 | - instruction = t("Take the eighth exit"); |
257 | - return instruction; |
258 | + return t("Take the eighth exit"); |
259 | case 279: |
260 | - instruction = t("Take the ninth exit"); |
261 | - return instruction; |
262 | - case 28: // FerryEnter |
263 | - instruction = t("Take the Ferry"); |
264 | - break; |
265 | - case 29: // FerryExit |
266 | - instruction = t("Leave the Ferry"); |
267 | - break; |
268 | - case 30: // Public transports |
269 | - instruction = original_instruction; |
270 | - break; |
271 | + return t("Take the ninth exit"); |
272 | } |
273 | - |
274 | - return instruction; |
275 | } |
276 | |
277 | Navigator.prototype.get_route_indication = function() { |
278 | |
279 | === modified file 'nav/class/UI.js' |
280 | --- nav/class/UI.js 2017-04-02 07:11:25 +0000 |
281 | +++ nav/class/UI.js 2017-04-06 20:44:50 +0000 |
282 | @@ -55,6 +55,10 @@ |
283 | $('#marker_pos_end').click(function () { |
284 | window.location = 'http://clicked_on_map?nofollow/' + nav.get_pos_data()['end_lat'] + '/' + nav.get_pos_data()['end_lng'] + '/none/none/none/' + t("Current End"); |
285 | }); |
286 | + |
287 | + $('#img_north').click(function () { |
288 | + map.getView().setRotation(0); |
289 | + }); |
290 | |
291 | this.markers_POI = []; |
292 | for (i=0 ; i<50; i++) { |
293 | @@ -831,7 +835,16 @@ |
294 | default: |
295 | this.map.getView().setRotation(0); |
296 | } |
297 | +} |
298 | |
299 | +UI.prototype.set_north = function(degress) { |
300 | + if (degress == 0 && this.nav.get_route_status() == 'no') { |
301 | + $('#map_north').hide(); |
302 | + } |
303 | + else { |
304 | + $('#img_north').css('transform', 'rotate('+degress+'deg)'); |
305 | + $('#map_north').show(); |
306 | + } |
307 | } |
308 | |
309 | UI.prototype.speak = function(indication) { |
310 | |
311 | === modified file 'nav/css/unav.css' |
312 | --- nav/css/unav.css 2017-04-02 07:11:25 +0000 |
313 | +++ nav/css/unav.css 2017-04-06 20:44:50 +0000 |
314 | @@ -174,14 +174,25 @@ |
315 | color: #333333; |
316 | } |
317 | |
318 | -#max_speed_alert { |
319 | +#max_speed_alert, #map_north { |
320 | width: 50px; |
321 | height: 50px; |
322 | position: absolute; |
323 | - top: 55px; |
324 | - right: 6px; |
325 | -} |
326 | -#img_maxspeed { |
327 | +} |
328 | +@media screen and (orientation:portrait) { |
329 | + #max_speed_alert, #map_north { |
330 | + top: 55px; |
331 | + right: 6px; |
332 | + } |
333 | +} |
334 | +@media screen and (orientation:landscape) { |
335 | + #max_speed_alert, #map_north { |
336 | + top: 47px; |
337 | + left: 47px; |
338 | + } |
339 | +} |
340 | + |
341 | +#img_maxspeed, #img_north { |
342 | width: 100%; |
343 | height: 100%; |
344 | } |
345 | |
346 | === added file 'nav/img/marker/north.svg' |
347 | --- nav/img/marker/north.svg 1970-01-01 00:00:00 +0000 |
348 | +++ nav/img/marker/north.svg 2017-04-06 20:44:50 +0000 |
349 | @@ -0,0 +1,71 @@ |
350 | +<?xml version="1.0" encoding="UTF-8" standalone="no"?> |
351 | +<svg |
352 | + xmlns:dc="http://purl.org/dc/elements/1.1/" |
353 | + xmlns:cc="http://creativecommons.org/ns#" |
354 | + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" |
355 | + xmlns:svg="http://www.w3.org/2000/svg" |
356 | + xmlns="http://www.w3.org/2000/svg" |
357 | + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" |
358 | + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" |
359 | + version="1.1" |
360 | + x="0px" |
361 | + y="0px" |
362 | + viewBox="0 0 100 100" |
363 | + id="svg2" |
364 | + inkscape:version="0.91 r13725" |
365 | + sodipodi:docname="north.svg" |
366 | + width="100" |
367 | + height="100"> |
368 | + <metadata |
369 | + id="metadata16"> |
370 | + <rdf:RDF> |
371 | + <cc:Work |
372 | + rdf:about=""> |
373 | + <dc:format>image/svg+xml</dc:format> |
374 | + <dc:type |
375 | + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> |
376 | + <dc:title></dc:title> |
377 | + </cc:Work> |
378 | + </rdf:RDF> |
379 | + </metadata> |
380 | + <defs |
381 | + id="defs14" /> |
382 | + <sodipodi:namedview |
383 | + pagecolor="#ffffff" |
384 | + bordercolor="#666666" |
385 | + borderopacity="1" |
386 | + objecttolerance="10" |
387 | + gridtolerance="10" |
388 | + guidetolerance="10" |
389 | + inkscape:pageopacity="0" |
390 | + inkscape:pageshadow="2" |
391 | + inkscape:window-width="1680" |
392 | + inkscape:window-height="968" |
393 | + id="namedview12" |
394 | + showgrid="false" |
395 | + inkscape:zoom="5.6568543" |
396 | + inkscape:cx="35.186507" |
397 | + inkscape:cy="58.253012" |
398 | + inkscape:window-x="0" |
399 | + inkscape:window-y="24" |
400 | + inkscape:window-maximized="1" |
401 | + inkscape:current-layer="g4" /> |
402 | + <g |
403 | + transform="translate(0,-977.36218)" |
404 | + id="g4"> |
405 | + <path |
406 | + style="color:#000000;text-indent:0;text-transform:none;direction:ltr;block-progression:tb;baseline-shift:baseline;display:inline;overflow:visible;visibility:visible;fill:#989898;fill-opacity:1;stroke:none;marker:none;enable-background:accumulate" |
407 | + d="m 81.112724,1058.4749 c 17.17469,-17.1747 17.174562,-45.0508 -2.4e-5,-62.22541 -17.174624,-17.17464 -45.050696,-17.17469 -62.225391,-1e-5 -17.1747133,17.17472 -17.1746172,45.05082 0,62.22542 17.174588,17.1746 45.050708,17.1747 62.225415,0 z m -1.414216,-1.4142 c -16.41039,16.4104 -42.986625,16.4103 -59.396993,0 -16.4103107,-16.4103 -16.4103996,-42.9866 1e-6,-59.39701 16.410389,-16.41038 42.986658,-16.41031 59.39698,10e-6 16.410325,16.4103 16.410396,42.9866 1.2e-5,59.397 z m -28.74827,0.6408 10.982203,-29.9857 c 0.0873,-0.216 0.0949,-0.4635 0.0221,-0.685 L 50.950206,997.02292 c -0.288499,-0.76055 -1.607799,-0.74506 -1.878203,0.0221 l -11.004407,29.96368 c -0.08501,0.2252 -0.08497,0.4817 0,0.7071 l 11.004332,30.0078 c 0.701347,1.1294 1.67607,0.7169 1.87831,-0.022 z m -0.95012,-3.2482 -9.546049,-26.0746 19.091922,0 z m 9.567946,-28.0855 -19.091843,0 9.545886,-26.0746 z" |
408 | + visibility="visible" |
409 | + display="inline" |
410 | + overflow="visible" |
411 | + id="path6" |
412 | + inkscape:connector-curvature="0" /> |
413 | + <path |
414 | + style="opacity:1;fill:#ff0000;fill-opacity:1;stroke:#ffffff;stroke-width:0.08838835;stroke-opacity:1" |
415 | + d="m 40.59244,48.839471 c 0.672423,-1.978985 9.412024,-25.672085 9.453656,-25.628904 0.03318,0.03442 2.156685,5.790139 4.718899,12.790497 2.562214,7.000357 4.677531,12.77764 4.700704,12.838407 0.03354,0.08796 -1.889614,0.110485 -9.434333,0.110485 -7.542269,0 -9.468804,-0.02255 -9.438926,-0.110485 z" |
416 | + id="path3386" |
417 | + inkscape:connector-curvature="0" |
418 | + transform="translate(0,977.36218)" /> |
419 | + </g> |
420 | +</svg> |
421 | |
422 | === modified file 'nav/index.html' |
423 | --- nav/index.html 2017-03-31 14:28:02 +0000 |
424 | +++ nav/index.html 2017-04-06 20:44:50 +0000 |
425 | @@ -103,6 +103,11 @@ |
426 | <!-- Map attribution --> |
427 | <div id="map_attribution" style="display:none;"></div> |
428 | |
429 | + <!-- Where is the North --> |
430 | + <div id="map_north" style="display:none;"> |
431 | + <img id="img_north" src="img/marker/north.svg"> |
432 | + </div> |
433 | + |
434 | <!-- Max speed radar alert --> |
435 | <div id="max_speed_alert" style="display:none;"> |
436 | <img id="img_maxspeed" src="img/marker/maxspeed.svg"> |
437 | @@ -459,6 +464,10 @@ |
438 | pointerIsDown=false; |
439 | }); |
440 | |
441 | + map.on('moveend', function () { |
442 | + ui.set_north(maths._toDeg(map.getView().getRotation())); |
443 | + }); |
444 | + |
445 | // Drag |
446 | map.on('pointerdrag', function(evt) { |
447 | ui.set_zoom_unav(false); // Pinch zoom or drag = custom zoom too |