Skip to main content

No project description provided

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.8 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

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.7.tar.gz (27.2 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.7-cp310-cp310-win_amd64.whl (8.0 kB view details)

Uploaded CPython 3.10Windows x86-64

transportations_library-0.1.7-cp310-cp310-macosx_10_12_x86_64.whl (4.1 kB view details)

Uploaded CPython 3.10macOS 10.12+ x86-64

transportations_library-0.1.7-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (165.0 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

File details

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

File metadata

  • Download URL: transportations_library-0.1.7.tar.gz
  • Upload date:
  • Size: 27.2 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.7.tar.gz
Algorithm Hash digest
SHA256 41dbcc6c78b040f9ef9da99383c54b28f9069c14812639b55ff7a0dca70c84ab
MD5 778fe73481a124e827a2fbb915c90330
BLAKE2b-256 53ce1dc23401d9e0d873c280b792a82a2583d61d1df67620391c7aa5a10d30a2

See more details on using hashes here.

Provenance

The following attestation bundles were made for transportations_library-0.1.7.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.7-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for transportations_library-0.1.7-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 c3483f3bc4b770cb474f4836ed9b7ca510ba44a3b152f123aba605212b5c048b
MD5 2dc1d70cab64e44085c547a971161572
BLAKE2b-256 634cd62a2e5f9057d003e2d8506210a2591b172555618d04cc6b33f3d5db50d6

See more details on using hashes here.

Provenance

The following attestation bundles were made for transportations_library-0.1.7-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.7-cp310-cp310-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for transportations_library-0.1.7-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 126e2c7a2ef5e09c22a8bea71e969c10a6943179975f9ec701904b06cb0c8a4d
MD5 9e24a295feaa82651275fbdfd89d1b9d
BLAKE2b-256 6d383d7ae9f39df9934635ddab7287ceda5c558e3b7cc0dd9d73bbb34c4a4004

See more details on using hashes here.

Provenance

The following attestation bundles were made for transportations_library-0.1.7-cp310-cp310-macosx_10_12_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.7-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for transportations_library-0.1.7-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e7e08d1a48b71d043a555ec0eb89b493f3ed7decbef5ae7d33ea8c767891344f
MD5 6e88e97b0005e66e2c6c1d4da742ce59
BLAKE2b-256 41935eb27fb14847f5d3164b7a286e8add13f6814cb57e3fa2614f693965dcdd

See more details on using hashes here.

Provenance

The following attestation bundles were made for transportations_library-0.1.7-cp38-cp38-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.

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