-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathLocation2Waze.py
48 lines (41 loc) · 1.39 KB
/
Location2Waze.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
'''
Copyright 2015 Paul Sidnell
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
'''
'''
Takes an Apple Maps pin exported via a WorkFlow action extension and opens it in
the Waze app.
The Workflow Action Extension app (accepts:URLs) is:
URL Encode:
Mode: Encode
Set Variable:
URL
Text:
pythonista://Location2Waze?action=run&args=(URL)
Open URLs
'''
import sys
import urllib
import urlparse
import location
import webbrowser
from string import Template
def locationToUrl(lat, long):
tpl = Template ("waze://?ll=$lat,$long&navigate=yes");
params = {"lat" : lat, "long" : long};
return tpl.substitute(params);
url = sys.argv[1];
#url="http://maps.apple.com/maps?address=31%20Stanton%20Road%20Bristol%20England%20BS10%205SJ%20United%20Kingdom&ll=51.504456,-2.590899&q=51.504456,-2.590899&t=m";
ll = urlparse.parse_qsl(url, True)[2][1].split(",");
lat = float(ll[0]);
long = float(ll[1]);
url = locationToUrl (lat, long);
webbrowser.open(url);