Giter Site home page Giter Site logo

gps-simulator's Introduction

Python script to simulate a car moving between two points on a map.

The primary purpose of this script is to simulate a car moving along a route and sending its current location every n seconds to a central server. Think simulating 1000's of uber cars driving in a city.

The script generates an OrderDict of points. The key is the timestamp, value is the (lat, long) tuple representing the location of the car at that point in time. Time is relative, with t=0 indicating the time when the journey begins.

This script requires a google maps api key.

Getting Started

virtualenv -p python3 venv
source venv/bin/activate
pip install -r requirements.txt
python vehicles.py <API Key> "HashedIn Technologies, Bangalore" "Cubbon Park, Bangalore"

The script will print two things -

  1. A list of (lat, long) along with a timestamp starting at 0
  2. A Polyline for the route

You can use visualize the polyline using google's polyline utility - https://developers.google.com/maps/documentation/utilities/polylineutility. Paste the generated polyline and click "Decode Polyline".

Using it programmatically

To use this programmatically, call the function get_points_along_path.

How it works

The script calls google maps directions api to get the directions from start point to end point. However, google maps does not give a smooth set of points. For some parts of the journey, you may have a large number of (lat, long) pairs, while for others it may just be a single point.

So this script interpolates points and smoothens it so that you get a (lat, long) pair roughly every 5 seconds.

gps-simulator's People

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.