forked from furiousMAC/antitrackingtags
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathohslocations2kml.py
53 lines (41 loc) · 1.24 KB
/
ohslocations2kml.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
49
50
51
52
53
#Takes an output file from FuriosTools batchfetch and turns it into a KML file with map data of the location reports
import sys
import re
import datetime
infile = open(sys.argv[1], "r")
outfile = open(sys.argv[2], "w")
lines = infile.readlines()
outfile.write("""<kml xmlns="http://www.opengis.net/kml/2.2">
<Placemark>
<name>OpenHaystack Path</name>
<LineString>
<altitudeMode>clampToGround</altitudeMode>
<coordinates>\n""")
points = []
if len(sys.argv) == 4:
cmin = int(sys.argv[3])
else:
cmin = 5
for i in range(len(lines)):
if not "speed" in lines[i]:
continue
coords = re.split("<|>", lines[i])[1]
coords = coords.split(",")[1] + "," + coords.split(",")[0]
time = re.split("\(|\)", lines[i+2])[1]
day = datetime.date.fromisoformat(time.split()[0])
time = time.split()[1]
time = time.split(":")
time = datetime.time(hour = int(time[0]), minute = int(time[1]), second = int(time[2]))
confidence = int(lines[i+4][9:10])
if confidence >= cmin:
points.append((day, time, coords))
points.sort()
for (_, _, c) in points:
print(c)
outfile.write(c)
outfile.write("\n")
outfile.write("""
</coordinates>
</LineString>
</Placemark>
</kml>""")