<h1 align="center">Transportations Library</h1>
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](https://rustup.rs/)
- Python: 3.8 or higher
- UV: Modern Python package manager (recommended)
**Using UV (Recommended)**
```bash
# 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**
```bash
# Install dependencies
pip install maturin pytest
# Build and install
maturin develop --release
```
**From PyPI**
```bash
pip install transportations-library
```
### Quick Start
For Two Lane Highways.
**Python Usage**
```python
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.
```python
# 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
```bash
# 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
```plaintext
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
```bash
# Development build
cargo build
# Release build
cargo build --release
# Build Python wheel
maturin build --release
# Development install with changes
cargo clean && maturin develop --release
```
---
**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.
Raw data
{
"_id": null,
"home_page": null,
"name": "transportations-library",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "rust, pypi, pyo3, transportation, library",
"author": "raynbowy23",
"author_email": "Rei Tamaru <tamaru@wisc.edu>",
"download_url": "https://files.pythonhosted.org/packages/47/78/90d28c5a86a6e4a22466415ea76f3c789b2f14f3e402e0b5dc805ad4855d/transportations_library-0.1.6.tar.gz",
"platform": null,
"description": "<h1 align=\"center\">Transportations Library</h1>\n\nA comprehensive Rust-based library implementing transportation engineering methodologies (e.g. the Highway Capacity Manual (HCM)) with Python bindings.\n\n## What this covers\n\nCurrently implements:\n\n- Highway Capacity Manual (HCM) Chapter 15: Two-Lane Highways analysis\n- Other chapters are to be added in future releases\n\n## Installation\n### Prerequisites\n\n- Rust: Install from [rustup.rs](https://rustup.rs/)\n- Python: 3.8 or higher\n- UV: Modern Python package manager (recommended)\n\n**Using UV (Recommended)**\n```bash\n# Clone the repository\ngit clone https://github.com/crosstraffic/transportations-library\ncd transportations-library\n\n# Create and activate virtual environment\nuv venv\nsource .venv/bin/activate # On Windows: .venv\\Scripts\\activate\n\n# Install in development mode\nuv pip install maturin pytest\nmaturin develop --release\n```\n\n**Using pip**\n```bash\n# Install dependencies\npip install maturin pytest\n\n# Build and install\nmaturin develop --release\n```\n\n**From PyPI**\n```bash\npip install transportations-library\n```\n\n### Quick Start\n\nFor Two Lane Highways.\n\n**Python Usage**\n```python\nimport transportations_library as tl\n\n# Create a highway segment\nsegment = tl.Segment(\n passing_type=0, # Passing Constrained\n length=1.5, # 1.5 miles\n grade=2.0, # 2% grade\n spl=55.0, # 55 mph speed limit\n volume=800.0, # 800 veh/hr\n phf=0.95, # Peak hour factor\n phv=5.0 # 5% heavy vehicles\n)\n\n# Create highway facility\nhighway = tl.TwoLaneHighways([segment])\n\n# Perform complete analysis\nseg_num = 0\ndemand_flow, opposing_flow, capacity = highway.determine_demand_flow(seg_num)\nffs = highway.determine_free_flow_speed(seg_num)\navg_speed, _ = highway.estimate_average_speed(seg_num)\npercent_followers = highway.estimate_percent_followers(seg_num)\nfollower_density = highway.determine_follower_density_pc_pz(seg_num)\nlos = highway.determine_segment_los(seg_num, avg_speed, capacity)\n\nprint(f\"Level of Service: {los}\")\nprint(f\"Average Speed: {avg_speed:.1f} mph\")\nprint(f\"Follower Density: {follower_density:.1f} followers/mile\")\n```\n\nSubsegment sections.\n```python\n# Highway with horizontal curves\nsubsegments = [\n tl.SubSegment(length=2640.0, design_rad=800.0, sup_ele=4.0), # Curved section\n tl.SubSegment(length=2640.0, design_rad=0.0, sup_ele=0.0) # Tangent section\n]\n\nsegment_with_curves = tl.Segment(\n passing_type=0, length=1.0, grade=3.0, spl=55.0,\n is_hc=True, # Has horizontal curves\n subsegments=subsegments,\n volume=900.0, phf=0.92, phv=8.0\n)\n\nhighway = tl.TwoLaneHighways([segment_with_curves])\n# ... perform analysis\n```\n\n## Testing\n\n### Run Tests\n```bash\n# Rust tests\ncargo test\n\n# Python tests \npytest tests/\n\n# With coverage\npytest tests/ --cov=transportations_library\n\n# Integration tests for chapter 15\ncargo test --test chapter15_integration\n```\n\n**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.\n\n### Example Test Cases\nThe library includes comprehensive test cases based on HCM examples:\n\n- Case 1: Basic passing constrained segment\n- Case 2: Segment with horizontal curves\n- Case 3: Multi-segment facility with different passing types\n- Case 4: Steep grade conditions with heavy vehicles\n\n## Development\n### Project Structure\n```plaintext\ntransportations-library/\n\u251c\u2500\u2500 src/\n\u2502 \u251c\u2500\u2500 hcm/\n\u2502 \u2502 \u251c\u2500\u2500 chapter15/ # Two-lane highways implementation\n\u2502 \u2502 \u2514\u2500\u2500 common.rs # Shared HCM utilities\n\u2502 \u251c\u2500\u2500 copython/ # Python bindings\n\u2502 \u251c\u2500\u2500 utils.rs # Mathematical utilities\n\u2502 \u2514\u2500\u2500 lib.rs # Library root\n\u251c\u2500\u2500 tests/ # Integration tests\n\u251c\u2500\u2500 examples/ # Usage examples\n\u2514\u2500\u2500 Cargo.toml # Rust configuration\n```\n\n### Building from Source\n```bash\n# Development build\ncargo build\n\n# Release build \ncargo build --release\n\n# Build Python wheel\nmaturin build --release\n\n# Development install with changes\ncargo clean && maturin develop --release\n```\n\n\n---\n\n**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.\n",
"bugtrack_url": null,
"license": "MIT OR Apache-2.0",
"summary": "A comprehensive Rust-based library implementing transportation engineering methodologies (e.g. the Highway Capacity Manual (HCM)) with Python bindings.",
"version": "0.1.6",
"project_urls": {
"Homepage": "https://github.com/crosstraffic/transportations_library"
},
"split_keywords": [
"rust",
" pypi",
" pyo3",
" transportation",
" library"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "39f6ca870e97ba0af5dc6dc3333d8f459a3e6e1ef196cc011fd386b376b8c305",
"md5": "25be507e2ecd766ef239c2814e3de48a",
"sha256": "1a1c15bdba2a7548a615ed8a6bc44c9a4277d04328896ab40be587ed97ec8f25"
},
"downloads": -1,
"filename": "transportations_library-0.1.6-cp310-cp310-macosx_10_12_x86_64.whl",
"has_sig": false,
"md5_digest": "25be507e2ecd766ef239c2814e3de48a",
"packagetype": "bdist_wheel",
"python_version": "cp310",
"requires_python": ">=3.8",
"size": 269762,
"upload_time": "2025-07-25T18:27:41",
"upload_time_iso_8601": "2025-07-25T18:27:41.468550Z",
"url": "https://files.pythonhosted.org/packages/39/f6/ca870e97ba0af5dc6dc3333d8f459a3e6e1ef196cc011fd386b376b8c305/transportations_library-0.1.6-cp310-cp310-macosx_10_12_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "dc56d4bcc27456e1bda0797c9cb8476309fd07f2d4f4ce464b5997f612387c01",
"md5": "ab4cf327a19955b24ce158c5dfb8fc8a",
"sha256": "1c24ff5db4d526e652c9ac1fd7e0b59068a0e30f3d5678876c5c280f4fb1742a"
},
"downloads": -1,
"filename": "transportations_library-0.1.6-cp310-cp310-win_amd64.whl",
"has_sig": false,
"md5_digest": "ab4cf327a19955b24ce158c5dfb8fc8a",
"packagetype": "bdist_wheel",
"python_version": "cp310",
"requires_python": ">=3.8",
"size": 170465,
"upload_time": "2025-07-25T18:27:43",
"upload_time_iso_8601": "2025-07-25T18:27:43.098246Z",
"url": "https://files.pythonhosted.org/packages/dc/56/d4bcc27456e1bda0797c9cb8476309fd07f2d4f4ce464b5997f612387c01/transportations_library-0.1.6-cp310-cp310-win_amd64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "ac7209f55258429b13cd0c00afce5717c106e726d3a4488fc85d4465147fd6bb",
"md5": "53d2175ff26b86f2c846edec6125b227",
"sha256": "c777799a8bfedc6feb27329d9f761729d02df024a966085729d2c0245180bd6d"
},
"downloads": -1,
"filename": "transportations_library-0.1.6-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"has_sig": false,
"md5_digest": "53d2175ff26b86f2c846edec6125b227",
"packagetype": "bdist_wheel",
"python_version": "cp38",
"requires_python": ">=3.8",
"size": 288325,
"upload_time": "2025-07-25T18:27:44",
"upload_time_iso_8601": "2025-07-25T18:27:44.581906Z",
"url": "https://files.pythonhosted.org/packages/ac/72/09f55258429b13cd0c00afce5717c106e726d3a4488fc85d4465147fd6bb/transportations_library-0.1.6-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "477890d28c5a86a6e4a22466415ea76f3c789b2f14f3e402e0b5dc805ad4855d",
"md5": "7847db5e5513716b25ad3d0d7b0e3794",
"sha256": "149a7195fc8efc8fc76873909dbe6944d9d6c75dcf23efbdcaac5d8e6a05b16a"
},
"downloads": -1,
"filename": "transportations_library-0.1.6.tar.gz",
"has_sig": false,
"md5_digest": "7847db5e5513716b25ad3d0d7b0e3794",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 47605,
"upload_time": "2025-07-25T18:27:45",
"upload_time_iso_8601": "2025-07-25T18:27:45.701393Z",
"url": "https://files.pythonhosted.org/packages/47/78/90d28c5a86a6e4a22466415ea76f3c789b2f14f3e402e0b5dc805ad4855d/transportations_library-0.1.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-25 18:27:45",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "crosstraffic",
"github_project": "transportations_library",
"github_not_found": true,
"lcname": "transportations-library"
}