Skip to main content

CrossTraffic transportations library

Project description

Transportations Library

A comprehensive Rust-based library implementing transportation engineering methodologies (e.g. the Highway Capacity Manual (HCM)) with Python bindings.

What this covers

Currently implements:

  • Highway Capacity Manual (HCM) Chapter 15: Two-Lane Highways analysis
  • Other chapters are to be added in future releases

Installation

Prerequisites

  • Rust: Install from rustup.rs
  • Python: 3.10 or higher
  • UV: Modern Python package manager (recommended)

Using UV (Recommended)

# Clone the repository
git clone https://github.com/crosstraffic/transportations-library
cd transportations-library

# Create and activate virtual environment
uv venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate

# Install in development mode
uv pip install maturin pytest
maturin develop --release

Using pip

# Install dependencies
pip install maturin pytest

# Build and install
maturin develop --release

From PyPI

pip install transportations-library

Quick Start

For Two Lane Highways.

Python Usage

import transportations_library as tl

# Create a highway segment
segment = tl.Segment(
    passing_type=0,     # Passing Constrained
    length=1.5,         # 1.5 miles
    grade=2.0,          # 2% grade
    spl=55.0,           # 55 mph speed limit
    volume=800.0,       # 800 veh/hr
    phf=0.95,           # Peak hour factor
    phv=5.0             # 5% heavy vehicles
)

# Create highway facility
highway = tl.TwoLaneHighways([segment])

# Perform complete analysis
seg_num = 0
demand_flow, opposing_flow, capacity = highway.determine_demand_flow(seg_num)
ffs = highway.determine_free_flow_speed(seg_num)
avg_speed, _ = highway.estimate_average_speed(seg_num)
percent_followers = highway.estimate_percent_followers(seg_num)
follower_density = highway.determine_follower_density_pc_pz(seg_num)
los = highway.determine_segment_los(seg_num, avg_speed, capacity)

print(f"Level of Service: {los}")
print(f"Average Speed: {avg_speed:.1f} mph")
print(f"Follower Density: {follower_density:.1f} followers/mile")

Subsegment sections.

# Highway with horizontal curves
subsegments = [
    tl.SubSegment(length=2640.0, design_rad=800.0, sup_ele=4.0),  # Curved section
    tl.SubSegment(length=2640.0, design_rad=0.0, sup_ele=0.0)     # Tangent section
]

segment_with_curves = tl.Segment(
    passing_type=0, length=1.0, grade=3.0, spl=55.0,
    is_hc=True,  # Has horizontal curves
    subsegments=subsegments,
    volume=900.0, phf=0.92, phv=8.0
)

highway = tl.TwoLaneHighways([segment_with_curves])
# ... perform analysis

Testing

Run Tests

# Rust tests
cargo test

# Python tests
pytest tests/

# With coverage
pytest tests/ --cov=transportations_library

# Integration tests for chapter 15
cargo test --test chapter15_integration

Note: If you want to have changes in the Rust code to be reflected in Python, you need to run cargo clean and maturin develop again after making changes.

Example Test Cases

The library includes comprehensive test cases based on HCM examples:

  • Case 1: Basic passing constrained segment
  • Case 2: Segment with horizontal curves
  • Case 3: Multi-segment facility with different passing types
  • Case 4: Steep grade conditions with heavy vehicles

Development

Project Structure

transportations-library/
├── src/
│   ├── hcm/
│   │   ├── chapter15/           # Two-lane highways implementation
│   │   └── common.rs            # Shared HCM utilities
│   ├── copython/                # Python bindings
│   ├── utils.rs                 # Mathematical utilities
│   └── lib.rs                   # Library root
├── tests/                       # Integration tests
├── examples/                    # Usage examples
└── Cargo.toml                   # Rust configuration

Building from Source

# Development build
cargo build

# Release build
cargo build --release

# Build Python wheel
maturin build --release

# Development install with changes
cargo clean && maturin develop --release

Pipeline

The project uses GitHub Actions for CI/CD, including:

  • Running tests on push and pull requests
  • Building and publishing to Test PyPI on alpha releases
  • Building and publishing to Cargo and PyPI on new releases

To test the alpha release from Test PyPI, use:

pip install --no-cache-dir --verbose -i https://test.pypi.org/simple/ transportations-library==0.1.9a4

Versioning follows Semantic Versioning.

Also, you can find the latest alpha releases on Test PyPI.

Citation

If you use transportations-library or CrossTraffic in your research, please cite it as follows:

@software{tamaru2025tralib,
  title = {Transportations Library: Transportation knowledge management platform},
  author = {Tamaru, Rei},
  year = {2025},
  url = {https://github.com/crosstraffic/transportations-library},
  doi = {10.5281/zenodo.17295792},
}

You can also use the DOI to cite a specific version: DOI

Alternatively, you can find the citation information in the CITATION.cff file in this repository, which follows the Citation File Format standard.


Note: This library implements established transportation engineering methodologies for educational and professional use. Users should verify results and apply appropriate engineering judgment for real-world applications.

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

transportations_library-0.1.10.tar.gz (81.6 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

transportations_library-0.1.10-cp314-cp314-manylinux_2_34_x86_64.whl (355.5 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.34+ x86-64

transportations_library-0.1.10-cp312-cp312-win_amd64.whl (169.6 kB view details)

Uploaded CPython 3.12Windows x86-64

transportations_library-0.1.10-cp312-cp312-manylinux_2_34_x86_64.whl (356.1 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

transportations_library-0.1.10-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (288.6 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

transportations_library-0.1.10-cp312-cp312-macosx_11_0_arm64.whl (262.6 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

transportations_library-0.1.10-cp311-cp311-win_amd64.whl (169.0 kB view details)

Uploaded CPython 3.11Windows x86-64

transportations_library-0.1.10-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (288.3 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

transportations_library-0.1.10-cp311-cp311-macosx_11_0_arm64.whl (263.4 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

transportations_library-0.1.10-cp310-cp310-win_amd64.whl (168.7 kB view details)

Uploaded CPython 3.10Windows x86-64

transportations_library-0.1.10-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (288.3 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

transportations_library-0.1.10-cp310-cp310-macosx_11_0_arm64.whl (263.6 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

Details for the file transportations_library-0.1.10.tar.gz.

File metadata

  • Download URL: transportations_library-0.1.10.tar.gz
  • Upload date:
  • Size: 81.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for transportations_library-0.1.10.tar.gz
Algorithm Hash digest
SHA256 ac2120c10f2e378ba7643b1102f8a13edc2b5d0fbd684be03d683894014b64fd
MD5 a66743e25c6362f0a23bd1e65cabf1a5
BLAKE2b-256 927ae07b1b564f981dbbb530dc3ed0f1d29c7aaaf9dd21001dbbb985e73c0d8f

See more details on using hashes here.

Provenance

The following attestation bundles were made for transportations_library-0.1.10.tar.gz:

Publisher: release.yaml on crosstraffic/transportations-library

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file transportations_library-0.1.10-cp314-cp314-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for transportations_library-0.1.10-cp314-cp314-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 4870900e5ed87be72202696914c9bea05460bad23272cb08d54c609391af0892
MD5 d29266552db7c5b9c4bd951846a7cc81
BLAKE2b-256 4e83f83f31ba61bf43895c61466010a921a35db1e88120388629d0a5cd4c2448

See more details on using hashes here.

Provenance

The following attestation bundles were made for transportations_library-0.1.10-cp314-cp314-manylinux_2_34_x86_64.whl:

Publisher: release.yaml on crosstraffic/transportations-library

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file transportations_library-0.1.10-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for transportations_library-0.1.10-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 4c2d5378234e940262f2c5cc9ec307338812b64ee0afca00d44d12547d051405
MD5 e41be724fddf52f750872da8182e2547
BLAKE2b-256 69a9d07488eb81dedab2603e56625133ea6fd3d65a76b111d2f241536e385182

See more details on using hashes here.

Provenance

The following attestation bundles were made for transportations_library-0.1.10-cp312-cp312-win_amd64.whl:

Publisher: release.yaml on crosstraffic/transportations-library

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file transportations_library-0.1.10-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for transportations_library-0.1.10-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 2134f759645f32bfdb073eb23f3e84c3f6d1223914192f9a3c80f643065ca923
MD5 fd152046ee296f5989ded220b47e87aa
BLAKE2b-256 9908cc8809f5af90aacc023e5d5ef3a91c3d4109256bbaf4fedc454fb721389e

See more details on using hashes here.

Provenance

The following attestation bundles were made for transportations_library-0.1.10-cp312-cp312-manylinux_2_34_x86_64.whl:

Publisher: release.yaml on crosstraffic/transportations-library

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file transportations_library-0.1.10-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for transportations_library-0.1.10-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6abfea7d844703f0bcbd754370e7fa3bf115e35bb0f0cfe86a711a56091f61cc
MD5 03e4efbf50aa0d9593fb93143cf98d87
BLAKE2b-256 dda1c3209e46afccf346d046a5aafd06f98c1c11c3b4af5f1707e73636935dcf

See more details on using hashes here.

Provenance

The following attestation bundles were made for transportations_library-0.1.10-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yaml on crosstraffic/transportations-library

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file transportations_library-0.1.10-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for transportations_library-0.1.10-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5e4348155f60d7517f753b10187b350f84398ec3d2fd5ca99c01782b48a640c6
MD5 5a9515cc5d5f27e45d9dd1c52e6aaeea
BLAKE2b-256 0e23624e8a26c7400a95f8a171d52b47c813ef08c3daf5c0fc289cfba249b33a

See more details on using hashes here.

Provenance

The following attestation bundles were made for transportations_library-0.1.10-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: release.yaml on crosstraffic/transportations-library

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file transportations_library-0.1.10-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for transportations_library-0.1.10-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 bca2d8d8d72deb60e86ccb8bb6c3163e508984885b13401750b7c81f8c5b1aec
MD5 ee0b9144e8de2b4e0c9fe7cdc9e53121
BLAKE2b-256 4b0e6a2110beaaa15a85584874bcf8a072a5f89b66280fcfc6fd77d57e31faaa

See more details on using hashes here.

Provenance

The following attestation bundles were made for transportations_library-0.1.10-cp311-cp311-win_amd64.whl:

Publisher: release.yaml on crosstraffic/transportations-library

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file transportations_library-0.1.10-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for transportations_library-0.1.10-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 90e068a557ab617a25a14fd5ce078c049dc3973b1917efdf04b25e22af8bc6e2
MD5 b92607cc618174fc0860d0721e4ae671
BLAKE2b-256 adcbac242ce2541d08896b69f95ac9e267e462b4cfaa796f972eb300769a5e5d

See more details on using hashes here.

Provenance

The following attestation bundles were made for transportations_library-0.1.10-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yaml on crosstraffic/transportations-library

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file transportations_library-0.1.10-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for transportations_library-0.1.10-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6d1fd10183fff662f6c890497688e099d414ac84c736ed3e472af1d0592978e1
MD5 7e55a7eb8fac85e58c086fb7efa10140
BLAKE2b-256 6b0022922d6d2817053a0e40fab58f0866928580e2f683885a095a613fcb6ae2

See more details on using hashes here.

Provenance

The following attestation bundles were made for transportations_library-0.1.10-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: release.yaml on crosstraffic/transportations-library

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file transportations_library-0.1.10-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for transportations_library-0.1.10-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 11fdf30a46745e173b375e3888d3149daf3d96c13e551b4198e5d47131ed6b2a
MD5 c8fd5d6ab4b3314458b1fa0943afd8e2
BLAKE2b-256 a3b6ea84d73d3bf90dff001e0e2f035ddd5c117b69f68d3ba46967ac9ff689c9

See more details on using hashes here.

Provenance

The following attestation bundles were made for transportations_library-0.1.10-cp310-cp310-win_amd64.whl:

Publisher: release.yaml on crosstraffic/transportations-library

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file transportations_library-0.1.10-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for transportations_library-0.1.10-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0f623a650b64c371eb1f8336907e0bd210b8e76b258fb42fd971b1a2f9a16322
MD5 600c4186d60cf085bbdcc422a744f89b
BLAKE2b-256 904512f616693aa9c7f786077268891bf0833c403f9cd0579734ce9ec4e9901d

See more details on using hashes here.

Provenance

The following attestation bundles were made for transportations_library-0.1.10-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yaml on crosstraffic/transportations-library

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file transportations_library-0.1.10-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for transportations_library-0.1.10-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e99c20d05dd034e56fb2df6005b7f5bb9e8e8c49ae1d37c5d80ffef1773ab915
MD5 27a55af74301a9bfccb04d707f2ed502
BLAKE2b-256 119f6fe6581177fc451d7e88db8007d6e800e088c96db4c6ff97c29d037b5890

See more details on using hashes here.

Provenance

The following attestation bundles were made for transportations_library-0.1.10-cp310-cp310-macosx_11_0_arm64.whl:

Publisher: release.yaml on crosstraffic/transportations-library

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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