fjxmlzn / FindMyHistory

Track your Apple devices and look up their past location, battery levels, and more
MIT License
291 stars 31 forks source link

Idea to synchronize & visualize the data? #5

Open julianguttzeit opened 1 year ago

julianguttzeit commented 1 year ago

Hi fjxmlzn & folks,

I am impressed with your script! I installed it on a MAC VM on a Unraid server & it works great. In fact, I had a break-in the other day and was able to track down the stolen goods using the airtags!

But now I was looking for a solution to save the history. Your script is great for this.

The question now is, how to visualize the data best (live). In the case of a theft, it is of course a bit more complicated to make maps of all days, etc.. manually.

Grandios would be a map where you can select the times to display the positions. I have done this with Mapbox, Atlist Maps and Google My Maps. However, not yet with a live ingest. Now I thought about synchronizing the CSV data with a Google Spreadsheet and then loading it into a map. This works. But it is very uncomfortable.

Do you have an idea for an approach how to visualize the data best? If possible even "live"? So that the data is automatically synchronized. I would have thought about writing the CSV data into a MySQL database or converting it into json etc... To synchronize with a server. However, I have not quite found which MAP could be suitable for this.

I would be very grateful for any approach or idea. If I find a way in the meantime I would of course post it here.

Best Julian

fjxmlzn commented 1 year ago

That's a great proposal! I will look into it and share it here when I have time and feel free to post ideas/approaches or make pull requests about it.

bkarakashev commented 1 year ago

Hi @julianguttzeit @fjxmlzn,

Excellent project, it all works great. Can you help me visualize the data from the CSV file even manually? Can I use the CSV file the way it is or would I need to format it?

What tools are you using to visualize the data?

Thanks

joshelboy commented 1 year ago

I wrote a separate little script for this. If someone (including me) has some spare time... He/she could beautify this, add a cron job... Maybe a timeline for historical heatmaps and buttons for this. Just as a thought. I might do a PR in the next couple of weeks

import pandas as pd
import folium
from folium.plugins import HeatMap

# Read CSV
df = pd.read_csv('./log/2023-07-20/AIRTAG_SN.csv')
df['location|latitude'] = df['location|latitude'].astype(float)
df['location|longitude'] = df['location|longitude'].astype(float)

# Create map around avg lat/long
average_lat = df['location|latitude'].mean()
average_lon = df['location|longitude'].mean()
m = folium.Map([average_lat, average_lon], zoom_start=10)

heat_data = [[row['location|latitude'], row['location|longitude']] for index, row in df.iterrows()]

# heatmap layer
HeatMap(heat_data).add_to(m)

# last known location
last_lat = df['location|latitude'].values[-1]
last_lon = df['location|longitude'].values[-1]

# marker with a cat emoji at the last known location
folium.Marker(
    [last_lat, last_lon],
    icon=folium.DivIcon(html=f"""<div style="font-size:24pt">&#128008;</div>""")
).add_to(m)