GithubHelp home page GithubHelp logo

mm-wang / meet-cute Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 109 KB

A simple script to find potential intersections between two sets of Foursquare or Google location history

License: MIT License

JavaScript 100.00%

meet-cute's Introduction

meet-cute

A simple script to find potential intersections between two sets of Foursquare or Google location history.

Map of places visited, intersected

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 ❤️.

How it works

  • 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

Setup

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 the DATA_LOC directory, defaults to 'a'

  • SECOND - the name of the second directory in the DATA_LOC directory, 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 to matches.json

Once environment variables are set up and you've placed your data, run npm start to run the script.

Output

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"
            }
        ]
    }
]

meet-cute's People

Contributors

mm-wang avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.