Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Kind of figured out heading
  • Loading branch information
stocc committed Aug 16, 2022
commit 44d1d5c4d097d740f47930eae07391bd81d55a34
2 changes: 1 addition & 1 deletion analyzerandom.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@
plt.legend()
#plt.axis('off')
plt.show()
print(sorted(unknown_10s["random.json"]))
print(numpy.average(unknown_10s["random.json"]))
6 changes: 3 additions & 3 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def relay_road_tile(tint, z, x, y):
url = auth.authenticate_url(
f"https://cdn3.apple-mapkit.com/ti/tile?style=0&size=1&x={x}&y={y}&z={z}&scale=1&lang=en"
f"&poi=1&tint={tint_param}&emphasis=standard")
print(url)
#print(url)
response = requests.get(url)
return send_file(
io.BytesIO(response.content),
Expand All @@ -91,8 +91,8 @@ def closest_pano_to_coord(lat, lon):
if distance < smallest_distance:
smallest_distance = distance
closest = pano
print(x,y)
return jsonify(date="asdf",lat = closest.lat, lon = closest.lon, panoid = str(closest.panoid), region_id = str(closest.region_id), unknown10 = closest.unknown10, unknown11 = closest.unknown11)
#print(x,y)
return jsonify(date="asdf",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())



Expand Down
2 changes: 1 addition & 1 deletion lookaround/lookaround/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def get_pano_segment_url(panoid, region_id, segment, zoom, auth):

url = endpoint + f"{panoid_url}/{region_id_padded}/t/{segment}/{zoom}"
url = auth.authenticate_url(url)
print(url)
#print(url)
return url


Expand Down
50 changes: 50 additions & 0 deletions lookaround/lookaround/panorama.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import math
class LookaroundPanorama:
def __init__(self, panoid, region_id, lat, lon, unknown10, unknown11):
self.panoid = panoid
Expand All @@ -8,6 +9,55 @@ def __init__(self, panoid, region_id, lat, lon, unknown10, unknown11):
self.unknown11 = unknown11
self.date = None

'''
Approximate heading of the panorama, assuming the POV is facing
to the left of the Apple Car in cthe direction of driving.
'''
def heading(self):
# Whatever is the logic behind this?
# Who at Apple thought of these values?

# unknown10
# These are the extreme values of unkown10 I have observed in a random selection of about 1000 tiles.
# The values are in two clusters.
# In the range [1,2159] you're looking more west than east.
# In the range [14318,16383] you're looking more east than west.
westmin = 1
westmax = 2159
eastmin = 16383 # looking (north/south) and very slightly east
eastmax = 14318 # looking slightly (north/south) directly east

# unknown11
# This is slightly more speculative
northmin = 8204 # this is likely lower
northmax = 6054
southmin = 8204 # this is likely lower
southmax = 10173


ew=0
if self.unknown10 < westmax:
# Looking west
ew = -(float(self.unknown10 - westmin) / float(westmax - westmin))
elif self.unknown10 > eastmax:
# Looking east
ew = (float(self.unknown10 - eastmin) / float(eastmax - eastmin))

ns=0
if self.unknown11 <= northmin:
# Looking north
ns = (float(self.unknown11 - northmin) / float(northmax - northmin))
else:
ns = -(float(self.unknown11 - southmin) / float(southmax - southmin))


print(ns,ew)
r = math.degrees(math.atan2(ew,ns))
if r < 0:
r += 360
return r


def __repr__(self):
return str(self)

Expand Down
2 changes: 1 addition & 1 deletion static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ function displayPano(pano) {
panoInfo.innerHTML = `
<strong>${pano.panoid}</strong>/${pano.region_id}<br>
<small>${pano.lat.toFixed(5)}, ${pano.lon.toFixed(5)} |
${pano.unknown10} ${pano.unknown11}</small>
${pano.unknown10} ${pano.unknown11} ${pano.heading}</small>
`;

/*panoViewer.on('zoom-updated', (e, zoom_level) => {
Expand Down
7 changes: 4 additions & 3 deletions userscript.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ Massive thank you to the following people:
// BEGIN CODE SECTION

// 0 best, 4 worst

const resolutionSetting = 2;

const headingCalibration = 40;


const extensionFactor = 2; // TODO Play around with this value for best results with image stretching
Expand Down Expand Up @@ -243,7 +242,7 @@ const getPano = (pano) => {
worldSize: new google.maps.Size(fullWidth, Math.round(rp.big.height * extensionFactor)),
// The heading in degrees at the origin of the panorama
// tile set.
centerHeading: 180,
centerHeading: curHeading,
getTileUrl: getCustomPanoramaTileUrl,
},
};
Expand All @@ -256,6 +255,7 @@ var newRound = true;
var curlat = 0;
var curlng = 0;
var curNeighbors = [];
var curHeading = 0;
// param panoFullId is "panoId/regionId"
async function loadTileForPano(panoFullId, x) {
try {
Expand Down Expand Up @@ -439,6 +439,7 @@ function initLookAround() {
regionId = closestObject.region_id;
curlat = closestObject.lat;
curlng = closestObject.lon;
curHeading = (closestObject.heading + headingCalibration) % 360;
curNeighbors = await getNeighborsPrimitive(curlat, curlng);
// Request pano to load
this.setPano("r"+lookAroundPanoId+"/"+regionId);
Expand Down