Skip to content

Commit 5697add

Browse files
authored
Merge pull request #3 from stocc/analyze-heading
Analyze heading
2 parents 6a8991d + 904172a commit 5697add

File tree

17 files changed

+3879
-40
lines changed

17 files changed

+3879
-40
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,5 @@ ENV/
9090

9191
.idea/
9292

93-
.venv/
93+
.venv/
94+
.vl/

analyzeheading.py

Lines changed: 38 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,48 @@
11
import json, numpy
22
from matplotlib import pyplot as plt
33

4-
with open("eastwestAutobahn.json", "r") as f:
5-
# import as json
6-
json_obj = json.load(f)
4+
unknown_10s = {}
5+
unknown_11s = {}
76

8-
panos = json_obj["pano"]
7+
for fn in ["eastwestAutobahn.json"]: #, "eow.json"]:
98

10-
unknown_8s = []
11-
unknown_9s = []
12-
unknown_10s = []
13-
unknown_11s = []
9+
with open(fn, "r") as f:
10+
# import as json
11+
panos = json.load(f)["pano"]
1412

15-
for p in panos:
16-
unknown_8s.append(p["unknown4"]["unknown8"])
17-
unknown_9s.append(p["unknown4"]["unknown9"])
18-
unknown_10s.append(p["unknown4"]["unknown10"])
19-
unknown_11s.append(p["unknown4"]["unknown11"])
13+
u10 = []
14+
u11 = []
15+
for p in panos:
16+
try:
17+
u10.append(p["unknown4"]["unknown10"])
18+
u11.append(p["unknown4"]["unknown11"])
19+
except:
20+
print(p)
21+
unknown_10s[fn] = u10
22+
unknown_11s[fn] = u11
2023

2124

22-
plt.figure()
25+
#print(min(unknown_10s["random.json"]), max(unknown_10s["random.json"]))
26+
#print(min(unknown_11s["random.json"]), max(unknown_11s["random.json"]))
27+
28+
plt.figure(figsize=(20,10))
29+
plt.subplot(2,1,1)
30+
plt.title("unknown10")
2331
#plt.hlines(1,1,20) # Draw a horizontal line
24-
plt.eventplot(unknown_8s, orientation='horizontal', colors='b')
32+
colors=["red", "blue", "green", "black"]
33+
i = 0
34+
for k,v in unknown_10s.items():
35+
plt.eventplot(v, label=k, orientation='horizontal', colors=colors[i], linewidths=0.1)
36+
i += 1
37+
plt.legend()
2538
#plt.axis('off')
26-
plt.show()
27-
39+
plt.subplot(2,1,2)
40+
plt.title("unknown11")
41+
#plt.hlines(1,1,20) # Draw a horizontal line
42+
i = 0
43+
for k,v in unknown_11s.items():
44+
plt.eventplot(v, label=k, orientation='horizontal', colors=colors[i], linewidths=0.1)
45+
i += 1
46+
plt.legend()
47+
#plt.axis('off')
48+
plt.show()

analyzerandom.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import json, numpy
2+
from matplotlib import pyplot as plt
3+
4+
unknown_10s = {}
5+
unknown_11s = {}
6+
7+
for fn in ["random.json"]: #, "eow.json"]:
8+
9+
with open(fn, "r") as f:
10+
# import as json
11+
panos = json.load(f)#["pano"]
12+
13+
u10 = []
14+
u11 = []
15+
for p in panos:
16+
try:
17+
u10.append(p["unknown4"]["unknown10"])
18+
u11.append(p["unknown4"]["unknown11"])
19+
except:
20+
print(p)
21+
unknown_10s[fn] = u10
22+
unknown_11s[fn] = u11
23+
24+
25+
print(min(unknown_10s["random.json"]), max(unknown_10s["random.json"]))
26+
print(min(unknown_11s["random.json"]), max(unknown_11s["random.json"]))
27+
28+
plt.figure(figsize=(20,10))
29+
plt.subplot(2,1,1)
30+
plt.title("unknown10")
31+
#plt.hlines(1,1,20) # Draw a horizontal line
32+
colors=["red", "blue", "green", "black"]
33+
i = 0
34+
for k,v in unknown_10s.items():
35+
plt.eventplot(v, label=k, orientation='horizontal', colors=colors[i], linewidths=0.1)
36+
i += 1
37+
plt.legend()
38+
#plt.axis('off')
39+
plt.subplot(2,1,2)
40+
plt.title("unknown11")
41+
#plt.hlines(1,1,20) # Draw a horizontal line
42+
i = 0
43+
for k,v in unknown_11s.items():
44+
plt.eventplot(v, label=k, orientation='horizontal', colors=colors[i], linewidths=0.1)
45+
i += 1
46+
plt.legend()
47+
#plt.axis('off')
48+
plt.show()
49+
print(numpy.average(unknown_10s["random.json"]))

analyzesingletile.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import json, numpy, requests
2+
from matplotlib import pyplot as plt
3+
import sys
4+
5+
tileX = sys.argv[1]
6+
tileY = sys.argv[2]
7+
8+
unknown_10s = {}
9+
unknown_11s = {}
10+
11+
resp = requests.get("http://127.0.0.1:5001/rawtile/{}/{}/".format(tileX,tileY))
12+
j = (resp.json())
13+
14+
fn = str(tileX) + "/" + str(tileY) + ".json"
15+
16+
u10 = []
17+
u11 = []
18+
for p in j["pano"]:
19+
try:
20+
u10.append(p["unknown4"]["unknown10"])
21+
u11.append(p["unknown4"]["unknown11"])
22+
except:
23+
print(p)
24+
unknown_10s[fn] = u10
25+
unknown_11s[fn] = u11
26+
27+
28+
#print(min(unknown_10s["random.json"]), max(unknown_10s["random.json"]))
29+
#print(min(unknown_11s["random.json"]), max(unknown_11s["random.json"]))
30+
31+
plt.figure(figsize=(20,10))
32+
plt.subplot(2,1,1)
33+
plt.title("unknown10")
34+
plt.xlim(left=0, right=16400)
35+
#plt.hlines(1,1,20) # Draw a horizontal line
36+
colors=["red", "blue", "green", "black"]
37+
i = 0
38+
for k,v in unknown_10s.items():
39+
plt.eventplot(v, label=k, orientation='horizontal', colors=colors[i], linewidths=1)
40+
i += 1
41+
plt.legend()
42+
#plt.axis('off')
43+
plt.subplot(2,1,2)
44+
plt.title("unknown11")
45+
plt.xlim(left=0, right=12000)
46+
47+
#plt.hlines(1,1,20) # Draw a horizontal line
48+
i = 0
49+
for k,v in unknown_11s.items():
50+
plt.eventplot(v, label=k, orientation='horizontal', colors=colors[i], linewidths=1)
51+
i += 1
52+
plt.legend()
53+
#plt.axis('off')
54+
plt.show()

app.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
from lookaround.lookaround.auth import Authenticator
1515
from lookaround.lookaround.geo import wgs84_to_tile_coord
16-
from lookaround.lookaround import get_coverage_tile, fetch_pano_segment, get_pano_segment_url
16+
from lookaround.lookaround import _get_coverage_tile_raw_json, get_coverage_tile, fetch_pano_segment, get_pano_segment_url
1717

1818
from util import CustomJSONEncoder
1919
from geo import haversine_distance
@@ -70,7 +70,7 @@ def relay_road_tile(tint, z, x, y):
7070
url = auth.authenticate_url(
7171
f"https://cdn3.apple-mapkit.com/ti/tile?style=0&size=1&x={x}&y={y}&z={z}&scale=1&lang=en"
7272
f"&poi=1&tint={tint_param}&emphasis=standard")
73-
print(url)
73+
#print(url)
7474
response = requests.get(url)
7575
return send_file(
7676
io.BytesIO(response.content),
@@ -91,8 +91,8 @@ def closest_pano_to_coord(lat, lon):
9191
if distance < smallest_distance:
9292
smallest_distance = distance
9393
closest = pano
94-
print(x,y)
95-
return jsonify(closest)
94+
#print(x,y)
95+
return jsonify(date=closest.date,lat = closest.lat, lon = closest.lon, panoid = str(closest.panoid), region_id = str(closest.region_id), unknown10 = closest.unknown10, unknown11 = closest.unknown11, heading = closest.heading)
9696

9797

9898

@@ -102,6 +102,11 @@ def tile_of_coord(lat, lon):
102102

103103
return jsonify(x=x,y=y)
104104

105+
@app.route("/rawtile/<int:x>/<int:y>/")
106+
def rawtile(x, y):
107+
panos = _get_coverage_tile_raw_json(x, y)
108+
109+
return panos
105110

106111
@app.route("/fullTileInfo/<int:x>/<int:y>/")
107112
def full_tile_coverage_incl_neighbors(x, y):
@@ -124,7 +129,6 @@ def relay_full_pano(panoid, region_id, zoom):
124129
image = None
125130

126131
TILE_SIZE = round(heic_array[0].width * (256 / 5632))
127-
print("TILE_SIZE:", TILE_SIZE)
128132
WIDTH_SIZE = round(heic_array[0].width * (1024 / 5632))
129133
widths, heights = zip(*(i.size for i in heic_array))
130134
total_width, max_height = (sum(widths)-WIDTH_SIZE), max(heights)
@@ -148,7 +152,6 @@ def relay_full_pano(panoid, region_id, zoom):
148152

149153
@app.route("/panodbg/<int:panoid>/<int:region_id>/<int:zoom>/")
150154
def relay_pano_dbg(panoid, region_id, zoom):
151-
print("Starting")
152155
heic_array = []
153156
for i in range(4):
154157
heic_bytes = fetch_pano_segment(panoid, region_id, i, zoom, auth)

collectrandom.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from typing import final
2+
import requests
3+
import json
4+
5+
panos = []
6+
7+
try:
8+
for i in range(68630,68630+100):
9+
for j in range(43260,43260+100):
10+
print("http://localhost:5001/rawtile/{}/{}/".format(i,j))
11+
resp = requests.get("http://localhost:5001/rawtile/{}/{}/".format(i,j))
12+
j = (resp.json())
13+
print("{}/{}".format(i,j))
14+
15+
if not "pano" in resp.json().keys():
16+
continue
17+
panos.extend(j["pano"])
18+
except KeyboardInterrupt:
19+
pass
20+
finally:
21+
with open("random.json", "w") as f:
22+
json.dump(panos, f)

0 commit comments

Comments
 (0)