A simple script to find potential intersections between two sets of Foursquare or Google location history.
This script takes a Google Location history KML file generated by Google Takeout and/or a Foursquare history KML file generated with this repo's Python script for two different people and searches for intersections.
The inspiration for this came from wanting to find out if two people were in similar places before they actually met, thus meet-cute ❤️.
- Parses the KML files into GeoJson including coordinates, timestamps, the source, and any additional data (in Foursquare's case, information about the location and checkin)
- Normalizes and sorts data coming from both Google and Foursquare into one array
- Compares the data by choosing the source with the smallest number of location points, then searching an hour before and an hour after for a location in the second source whose coordinates fall within the spread indicated (defaulting to 0.0015 in both latitude and longitude)
- Prints out the data in the terminal as well as to another file
Built with Node v14.18.0. Run npm i to install node modules.
In meet-cute, include a data folder. In this folder, include a directory for first and second
Include a .env file in the root folder that has the following:
-
DATA_LOC- a relative path to the data folder, something like./data -
MATCH_LOC- a relative path to the matches folder, something like./matches -
BEFORE_DATE(optional, defaults to now) - the milliseconds time before which you want to find any intersections -
SPREAD(optional, default to 0.0015) - the maximum latitudinal and longitudinal distance to search from a single coordinate -
FIRST- the name of the first directory in theDATA_LOCdirectory, defaults to'a' -
SECOND- the name of the second directory in theDATA_LOCdirectory, defaults to'b' -
GOOGLE_FILENAME- the name of the file for Google location history, defaults to'location_history.kml' -
FOURSQUARE_FILENAME- the name of the file generated using this repo's Python script, defaults to'checkins.kml' -
MATCH_FILENAME- a name for the matches file, defaults tomatches.json
Once environment variables are set up and you've placed your data, run npm start to run the script.
Terminal output will look something like this:
/-------MATCH FOUND-----/
Source Location
{
coordinates: [ -71.089804, 42.3558071, 0 ],
timestamp: '2021-12-01T15:45:58Z',
milliseconds: 1638373558000,
source: 'Google',
directory: 'a',
link: 'https://google.com/maps/place/42.3558071,-71.089804'
}
Matching Locations
[
{
coordinates: [ -71.0886809, 42.355512399999995, 0 ],
timestamp: '2021-12-01T15:46:43Z',
milliseconds: 1638373603000,
source: 'Google',
directory: 'b',
link: 'https://google.com/maps/place/42.355512399999995,-71.0886809'
}
]
Total number matched: 1
The JSON file will look something like this:
[
{
"source": {
"coordinates": [
-71.089804,
42.3558071,
0
],
"timestamp": "2021-12-01T15:45:58Z",
"milliseconds": 1638373558000,
"source": "Google",
"directory": "a",
"link": "https://google.com/maps/place/42.3558071,-71.089804"
},
"matches": [
{
"coordinates": [
-71.0886809,
42.355512399999995,
0
],
"timestamp": "2021-12-01T15:46:43Z",
"milliseconds": 1638373603000,
"source": "Google",
"directory": "b",
"link": "https://google.com/maps/place/42.355512399999995,-71.0886809"
}
]
}
]