|
2 | 2 | import requests |
3 | 3 |
|
4 | 4 | from .proto import MapTile_pb2 |
5 | | -from .geo import wgs84_to_tile_coord |
| 5 | +from .geo import wgs84_to_tile_coord, heading_from_unkown10_unknown11 |
6 | 6 | from .panorama import LookaroundPanorama |
7 | 7 |
|
| 8 | +from google.protobuf.json_format import MessageToJson |
8 | 9 |
|
9 | | -def get_coverage_tile_by_latlon(lat, lon): |
10 | | - x, y = wgs84_to_tile_coord(lat, lon, 17) |
| 10 | + |
| 11 | +def get_coverage_tile_by_latlon(lat, lon, tile_z = 17): |
| 12 | + x, y = wgs84_to_tile_coord(lat, lon, tile_z) |
11 | 13 | return get_coverage_tile(x, y) |
12 | 14 |
|
13 | 15 |
|
14 | | -def get_coverage_tile(tile_x, tile_y): |
15 | | - tile = _get_coverage_tile_raw(tile_x, tile_y) |
| 16 | +def get_coverage_tile(tile_x, tile_y, tile_z = 17): |
| 17 | + tile = _get_coverage_tile_raw(tile_x, tile_y, tile_z) |
16 | 18 | panos = [] |
17 | 19 | for pano in tile.pano: |
18 | 20 | lat, lon = geo.protobuf_tile_offset_to_wgs84( |
19 | 21 | pano.unknown4.longitude_offset, |
20 | 22 | pano.unknown4.latitude_offset, |
21 | 23 | tile_x, |
22 | | - tile_y) |
| 24 | + tile_y, |
| 25 | + tile_z |
| 26 | + ) |
23 | 27 | pano_obj = LookaroundPanorama( |
24 | 28 | pano.panoid, |
25 | 29 | tile.unknown13[pano.region_id_idx].region_id, |
26 | | - lat, lon) |
| 30 | + lat, lon, pano.unknown4.unknown10, pano.unknown4.unknown11, heading_from_unkown10_unknown11(pano.unknown4.unknown10, pano.unknown4.unknown11)) |
27 | 31 | pano_obj.date = datetime.fromtimestamp(int(pano.timestamp) / 1000.0) |
28 | 32 | panos.append(pano_obj) |
29 | 33 | return panos |
30 | 34 |
|
31 | 35 |
|
32 | | -def _get_coverage_tile_raw(tile_x, tile_y): |
| 36 | +def _get_coverage_tile_raw_json(tile_x, tile_y, tile_z = 17): |
| 37 | + headers = { |
| 38 | + "maps-tile-style": "style=57&size=2&scale=0&v=0&preflight=2", |
| 39 | + "maps-tile-x": str(tile_x), |
| 40 | + "maps-tile-y": str(tile_y), |
| 41 | + "maps-tile-z": str(tile_z), |
| 42 | + "maps-auth-token": "w31CPGRO/n7BsFPh8X7kZnFG0LDj9pAuR8nTtH3xhH8=", |
| 43 | + } |
| 44 | + response = requests.get("https://gspe76-ssl.ls.apple.com/api/tile?", headers=headers) |
| 45 | + tile = MapTile_pb2.MapTile() |
| 46 | + tile.ParseFromString(response.content) |
| 47 | + json_obj = MessageToJson(tile) |
| 48 | + return json_obj |
| 49 | + |
| 50 | +def _get_coverage_tile_raw(tile_x, tile_y, tile_z = 17): |
33 | 51 | headers = { |
34 | 52 | "maps-tile-style": "style=57&size=2&scale=0&v=0&preflight=2", |
35 | 53 | "maps-tile-x": str(tile_x), |
36 | 54 | "maps-tile-y": str(tile_y), |
37 | | - "maps-tile-z": "17", |
| 55 | + "maps-tile-z": str(tile_z), |
38 | 56 | "maps-auth-token": "w31CPGRO/n7BsFPh8X7kZnFG0LDj9pAuR8nTtH3xhH8=", |
39 | 57 | } |
40 | 58 | response = requests.get("https://gspe76-ssl.ls.apple.com/api/tile?", headers=headers) |
@@ -63,7 +81,7 @@ def get_pano_segment_url(panoid, region_id, segment, zoom, auth): |
63 | 81 |
|
64 | 82 | url = endpoint + f"{panoid_url}/{region_id_padded}/t/{segment}/{zoom}" |
65 | 83 | url = auth.authenticate_url(url) |
66 | | - print(url) |
| 84 | + #print(url) |
67 | 85 | return url |
68 | 86 |
|
69 | 87 |
|
|
0 commit comments