forked from flipperdevices/flipperzero-firmware
-
-
Notifications
You must be signed in to change notification settings - Fork 546
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Plots all the coordinates from the decrypted json data onto a map. (#30)
* Add files via upload * Delete display_coordinates.py * Create display_coordinates.py * Create data.json * Update display_coordinates.py
- Loading branch information
Showing
2 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
// Add your decrypted position data in here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import json | ||
import gmplot | ||
|
||
with open("data.json", "r") as file: | ||
data = json.load(file) | ||
|
||
sorted_data = [] | ||
for device_id, positions in data.items(): | ||
for pos in positions: | ||
sorted_data.append(pos) | ||
sorted_data.sort(key=lambda x: x["decrypted_payload"]["timestamp"]) | ||
|
||
latitudes = [pos["decrypted_payload"]["lat"] for pos in sorted_data] | ||
longitudes = [pos["decrypted_payload"]["lon"] for pos in sorted_data] | ||
|
||
if latitudes and longitudes: | ||
gmap = gmplot.GoogleMapPlotter(latitudes[0], longitudes[0], 13) | ||
gmap.plot(latitudes, longitudes, color='red', edge_width=2.5) | ||
for lat, lon in zip(latitudes, longitudes): | ||
gmap.marker(lat, lon, color='red') | ||
|
||
gmap.draw("map.html") | ||
|
||
print("Map generated! Open 'map.html' in a web browser to view.") | ||
else: | ||
print("No data available to plot.") |