Skip to main content

Simple driving trip simulator for OpenStreetMap graphs

Project description

tripsim

Driving trip simulator for building a series of coordinates that can be used for testing telematics systems.

:warning: This is quite a simplified implementation that should not be used for anything beyond simple load testing or distance calculations.

Getting Started

from tripsim import simulate_trip

# other imports for this example
import matplotlib.pyplot as plt
from shapely.geometry import LineString
import osmnx as ox


def main():
    # Get the graph of the city of Cork
    graph = ox.graph_from_place('Cork City, Ireland', network_type='drive')

    # the simulated trip will return a list of points
    # each point has a latitude and longitude, along with a timestamp (in seconds)
    trip = simulate_trip(graph)

    # adjust your styling accordingly
    _, ax = ox.plot_graph(
        graph, dpi=180,
        node_color='green',
        node_size=1,
        node_alpha=0.1,
        node_edgecolor='white',
        node_zorder=5,
        edge_color='white',
        edge_linewidth=2,
        edge_alpha=0.1,
        show=False,
        close=False
    )

    # the points are a dataclass with a few convenience methods
    coords = [
        (point.get_lat(), point.get_lon())
        for point in trip
    ]

    # here we are setting the list of coords as a LineString
    # for easy plotting
    coords_graph_line = LineString(coords)
    x, y = coords_graph_line.xy

    ax.plot(x, y, '-o', color='red',
            markersize=3, alpha=0.7, zorder=1)

    plt.show()


if __name__ == '__main__':
    main()

The created trip should look something like this when plotted.

trip

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tripsim-0.1.4.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

tripsim-0.1.4-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file tripsim-0.1.4.tar.gz.

File metadata

  • Download URL: tripsim-0.1.4.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for tripsim-0.1.4.tar.gz
Algorithm Hash digest
SHA256 1362a375a784a27f9d9658fa39e656a32a0b6f31ad9c73712c4c9c67a67fee74
MD5 430077d5dd0fd1d5514db923e021cf9e
BLAKE2b-256 1ffccabb57ef71362862bb600c91053e3f5bb8879fa9dae36e47f0ca698c2ae3

See more details on using hashes here.

File details

Details for the file tripsim-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: tripsim-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for tripsim-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 cb44c746d0d9e9dbc5e456753a17a227b5c3602d8190b7194f34b256e892ff0e
MD5 89c11105f3ead3a50f66341f3447c469
BLAKE2b-256 ec362031f3f80e617050e8dba9050d18e6a9f5da3e08c75b19c7c5aee84ad34c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page