Skip to content

timeplus-io/taxi-route-simulator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Taxi Route Simulator

A generator for simulated NYC taxi data streams.

Installation

pip install .

Usage

Command Line

Run the simulator and output JSON lines to stdout:

taxi-sim

Python API

from taxi_simulator import stream_taxi_data

for event in stream_taxi_data(num_cars=5, speed_kmh=80):
    print(f"Car {event['car_id']} is at {event['latitude']}, {event['longitude']}")
    
    if event['speed_kmh'] > 100:
        print("Warning: Speeding!")

Parameters

Parameter Default Description
num_cars 10 Number of simulated cars
speed_kmh 60.0 Base speed in km/h (actual speed varies ±20%)
update_interval 0.5 Time between updates in seconds
realtime_factor 5.0 Speed multiplier for simulation
custom_routes_file None Path to custom routes JSON file

Output Format

Each event is a dictionary with the following fields:

{
  "car_id": "car_0001",
  "time": "2024-01-15T12:30:45.123456+00:00",
  "longitude": -73.976964,
  "latitude": 40.755987,
  "speed_kmh": 62.4
}

Custom Routes

You can provide your own routes file in JSON format. The simulator supports various GeoJSON-like structures and will automatically extract coordinate arrays. Example:

[
  {
    "geometry": {
      "coordinates": [[-73.976, 40.755], [-73.975, 40.756]]
    }
  }
]

About

a car data stream simulator base on nyc taxi data

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages