Merge lp:~costales/unav/0.59-catch-more-URLs into lp:unav

Proposed by costales
Status: Merged
Approved by: Nekhelesh Ramananthan
Approved revision: 47
Merged at revision: 45
Proposed branch: lp:~costales/unav/0.59-catch-more-URLs
Merge into: lp:unav
Diff against target: 106 lines (+72/-0)
2 files modified
app-dispatcher.json (+12/-0)
qml/js/utils.js (+60/-0)
To merge this branch: bzr merge lp:~costales/unav/0.59-catch-more-URLs
Reviewer Review Type Date Requested Status
Nekhelesh Ramananthan Approve
costales Needs Resubmitting
JkB Needs Information
Review via email: mp+291667@code.launchpad.net
To post a comment you must log in.
Revision history for this message
JkB (joergberroth) wrote :

what about putting in the here maps (m.here.com) prefix also?

review: Needs Information
Revision history for this message
costales (costales) wrote :

@Joerg: I implemented only the free (as in freedom) and the most used (Google).
I don't like a conflict with calls to HERE app too.

Revision history for this message
Nekhelesh Ramananthan (nik90) wrote :

A couple of comments,

1. Please pull the latest trunk into this branch.

2. For me the google maps link did not work. It opened uNav when I clicked the link, but it did not take me to the lat,lng included in the url.

Rest of the links (openstreetmap and opencyclemap) worked as expected. Tested with uNav opened and closed.

@Joerg, can you test and comment as well.

review: Needs Fixing
45. By costales

Fixed Google Maps catch

46. By costales

Revert version in Main

47. By costales

Merged trunk

Revision history for this message
costales (costales) wrote :

Fixed Google links ;) Well see!

review: Needs Resubmitting
Revision history for this message
Nekhelesh Ramananthan (nik90) wrote :

Thanks! Now everything works as expected. Approving!

Side note @marcos. The "resubmit" option is meant to be used by reviewers where they are requesting the developer to resubmit their merge proposal :).

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'app-dispatcher.json'
2--- app-dispatcher.json 2016-03-26 18:53:17 +0000
3+++ app-dispatcher.json 2016-04-13 17:52:20 +0000
4@@ -5,5 +5,17 @@
5 },
6 {
7 "protocol": "geo"
8+ },
9+ {
10+ "protocol": "http",
11+ "domain-suffix": "www.openstreetmap.org"
12+ },
13+ {
14+ "protocol": "http",
15+ "domain-suffix": "www.opencyclemap.org"
16+ },
17+ {
18+ "protocol": "https",
19+ "domain-suffix": "maps.google.com"
20 }
21 ]
22
23=== modified file 'qml/js/utils.js'
24--- qml/js/utils.js 2016-04-11 17:40:45 +0000
25+++ qml/js/utils.js 2016-04-13 17:52:20 +0000
26@@ -99,6 +99,12 @@
27 return {is_dispatcher: true, url_is: 'geo'};
28 if (url.toString().indexOf('http://unav-go.github.io') > -1)
29 return {is_dispatcher: true, url_is: 'unav'};
30+ if (url.toString().indexOf('http://www.openstreetmap.org') > -1)
31+ return {is_dispatcher: true, url_is: 'osm'};
32+ if (url.toString().indexOf('http://www.opencyclemap.org') > -1)
33+ return {is_dispatcher: true, url_is: 'ocm'};
34+ if (url.toString().indexOf('https://maps.google.com') > -1)
35+ return {is_dispatcher: true, url_is: 'googlemaps'};
36
37 return {is_dispatcher: false, url_is: 'none'};
38 }
39@@ -155,6 +161,51 @@
40 }
41
42 /**
43+* Function split_osm_url(url): Return coordenates
44+* url: URL calling OSM. ex: http://www.openstreetmap.org/#map=19/43.30257/-5.68930
45+* http://www.openstreetmap.org/?mlat=43.54217&mlon=-5.67633&zoom=12
46+**/
47+function split_osm_url(url) {
48+ var aux_url = url.replace('http://www.openstreetmap.org/#map=', '');
49+ var params = aux_url.split('/');
50+ if (params.length == 3)
51+ return {lat: validate_lat(params[1]), lng: validate_lng(params[2])};
52+
53+ var aux_url = url.replace('http://www.openstreetmap.org/?', '');
54+ var params = aux_url.split('&');
55+ if (params.length >= 2 && params[0].indexOf('mlat') != 1 && params[1].indexOf('mlon') != 1)
56+ return {lat: validate_lat(params[0].replace('mlat=', '')), lng: validate_lng(params[1].replace('mlon=', ''))};
57+
58+ return {lat: null, lng: null};
59+}
60+
61+/**
62+* Function split_ocm_url(url): Return coordenates
63+* url: URL calling OpenCycleMap. ex: http://www.opencyclemap.org/?zoom=18&lat=43.5414&lon=-5.67165&layers=B0000
64+**/
65+function split_ocm_url(url) {
66+ var aux_url = url.replace('http://www.opencyclemap.org/?', '');
67+ var params = aux_url.split('&');
68+ if (params.length >= 3 && params[1].indexOf('lat') != 1 && params[2].indexOf('lon') != 1)
69+ return {lat: validate_lat(params[1].replace('lat=', '')), lng: validate_lng(params[2].replace('lon=', ''))};
70+
71+ return {lat: null, lng: null};
72+}
73+
74+/**
75+* Function split_googlemaps_url(url): Return coordenates
76+* url: URL calling Google Maps. ex: https://maps.google.com/?q=43.53291443249287,-5.664369592670359
77+**/
78+function split_googlemaps_url(url) {
79+ var aux_url = url.replace('https://maps.google.com/?q=', '');
80+ var params = aux_url.split(',');
81+ if (params.length == 2)
82+ return {lat: validate_lat(params[0]), lng: validate_lng(params[1])};
83+
84+ return {lat: null, lng: null};
85+}
86+
87+/**
88 * Function get_url_coord(url): Return lat,lng
89 * url: URL calling uNav
90 **/
91@@ -172,6 +223,15 @@
92 case 'unav':
93 coord = split_unav_url(url);
94 break;
95+ case 'osm':
96+ coord = split_osm_url(url);
97+ break;
98+ case 'ocm':
99+ coord = split_ocm_url(url);
100+ break;
101+ case 'googlemaps':
102+ coord = split_googlemaps_url(url);
103+ break;
104 }
105 return coord;
106 }

Subscribers

People subscribed via source and target branches