Skip to content

Commit

Permalink
Plots all the coordinates from the decrypted json data onto a map. (#30)
Browse files Browse the repository at this point in the history
* Add files via upload

* Delete display_coordinates.py

* Create display_coordinates.py

* Create data.json

* Update display_coordinates.py
  • Loading branch information
luu176 authored Mar 21, 2024
1 parent 254bb54 commit eb6b752
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions DisplayCoordinates/data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// Add your decrypted position data in here
26 changes: 26 additions & 0 deletions DisplayCoordinates/display_coordinates.py
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.")

0 comments on commit eb6b752

Please sign in to comment.