StepDistanceCalculator ๐ถโโ๏ธ๐
A professional, object-oriented Python package to calculate walking step counts between places or cities based on total distance, unit conversion, and average step lengths.
๐ Features
- Single & Multi-City Calculation: Compute step counts for single routes or multi-segment route chains.
- Default & Custom Step Lengths: Default values based on gender (Adult Male:
0.78m, Adult Female:0.70m) or custom length. - Automatic Unit Conversion: Seamlessly convert distances in
meters,kilometers,miles, andfeetto meters. - Clean Object-Oriented Design: Core domain abstractions including
Person,Location,Route,DistanceCalculator, andReportGenerator. - Comprehensive Reports: Export reports as plain text, JSON, CSV, or formatted PDF.
- Data Visualization: Generate matplotlib charts for segment steps (bar chart), percentage distance contribution (pie chart), and cumulative steps (line chart).
- CLI & Interactive Mode: Built-in Command Line Interface with interactive menu mode.
- Robust & Validated: Input validation, custom exception hierarchy, and structured logging.
๐ Project Structure
StepDistanceCalculator/
โ
โโโ stepdistance/
โ โโโ __init__.py # Package exports & versioning
โ โโโ person.py # Person class (name, gender, step length)
โ โโโ location.py # Location data class
โ โโโ route.py # Route and Segment classes
โ โโโ calculator.py # DistanceCalculator & result dataclasses
โ โโโ converter.py # Unit conversion module
โ โโโ reports.py # ReportGenerator (Text, JSON, CSV, PDF)
โ โโโ visualization.py # Matplotlib charts (Bar, Pie, Line)
โ โโโ utils.py # Validators, logging & exceptions
โ โโโ cli.py # CLI & Interactive Menu Program
โ
โโโ examples/
โ โโโ basic_usage.py # Single distance calculation
โ โโโ multi_city.py # Multi-city route calculation
โ โโโ generate_reports.py # Exporting JSON/CSV/PDF & Charts
โ
โโโ tests/
โ โโโ test_converter.py
โ โโโ test_person.py
โ โโโ test_location.py
โ โโโ test_route.py
โ โโโ test_calculator.py
โ โโโ test_reports.py
โ โโโ test_utils.py
โ
โโโ docs/
โ โโโ usage_guide.md
โโโ pyproject.toml
โโโ setup.py
โโโ requirements.txt
โโโ README.md
๐ Quick Start
Installation
Install locally in editable mode:
pip install -e .
Or install dependencies directly:
pip install -r requirements.txt
๐ป Python Usage Examples
1. Basic Single Calculation
from stepdistance import Person, DistanceCalculator
person = Person(name="Amit", step_length=0.75)
calc = DistanceCalculator(person=person)
result = calc.calculate_steps(distance=233, unit="km", origin="Delhi", destination="Agra")
print(f"Steps required: {result.steps_rounded:,}")
# Output: Steps required: 310,667
2. Multi-City Route Chain
from stepdistance import Person, Route, DistanceCalculator, ReportGenerator
person = Person(name="Amit", step_length=0.75)
route = Route()
route.add_location("Delhi", "Agra", 233, unit="km")
route.add_location("Agra", "Jaipur", 238, unit="km")
route.add_location("Jaipur", "Udaipur", 394, unit="km")
calc = DistanceCalculator(person=person, route=route)
route_result = calc.calculate_route()
report_gen = ReportGenerator(route_result)
print(report_gen.generate_text())
3. Generate Reports & Charts
# Export reports
report_gen.save_json("report.json")
report_gen.save_csv("report.csv")
report_gen.save_pdf("report.pdf")
# Plot matplotlib graphs
from stepdistance import plot_all
plot_all(route_result, save_dir="./charts")
๐ ๏ธ Command Line & Interactive Mode
Launch the interactive menu-driven program:
stepdistance interactive
Calculate via command line arguments:
stepdistance calculate --from Delhi --to Agra --distance 233 --unit km --step-length 0.75
๐งช Running Unit Tests
Run the test suite with pytest:
pytest tests/ -v
๐ License
This project is licensed under the MIT License.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file stepdistancecalculator-1.0.0.tar.gz.
File metadata
- Download URL: stepdistancecalculator-1.0.0.tar.gz
- Upload date:
- Size: 22.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3ac4439e8559bc5a8c9ee13c3d787739ade3bad4b43e985663220dfdb864f5e5
|
|
| MD5 |
bb4c74232475e2bf050a959af4d91782
|
|
| BLAKE2b-256 |
1ca7f2e9f64bc2479caa75e4129d08daa53171a9ab96c04ccce9e646dc29ed90
|
Provenance
The following attestation bundles were made for stepdistancecalculator-1.0.0.tar.gz:
Publisher:
publish.yml on Amit123103/Stepcount_python_module
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
stepdistancecalculator-1.0.0.tar.gz -
Subject digest:
3ac4439e8559bc5a8c9ee13c3d787739ade3bad4b43e985663220dfdb864f5e5 - Sigstore transparency entry: 2218482337
- Sigstore integration time:
-
Permalink:
Amit123103/Stepcount_python_module@b2eefa3fa65d3defdb1bbed4cc47d0ecf3d05b56 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/Amit123103
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b2eefa3fa65d3defdb1bbed4cc47d0ecf3d05b56 -
Trigger Event:
push
-
Statement type:
File details
Details for the file stepdistancecalculator-1.0.0-py3-none-any.whl.
File metadata
- Download URL: stepdistancecalculator-1.0.0-py3-none-any.whl
- Upload date:
- Size: 24.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3ec6b041a9a1e7230659487fd58112cbdb030362749c7f26aad4960523d81d20
|
|
| MD5 |
5b93a62f9e151c452f87fc9514a323db
|
|
| BLAKE2b-256 |
b2e43fb8ceff081b791a845b9af24d331e85b0eab741ff637da288d670e29a8c
|
Provenance
The following attestation bundles were made for stepdistancecalculator-1.0.0-py3-none-any.whl:
Publisher:
publish.yml on Amit123103/Stepcount_python_module
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
stepdistancecalculator-1.0.0-py3-none-any.whl -
Subject digest:
3ec6b041a9a1e7230659487fd58112cbdb030362749c7f26aad4960523d81d20 - Sigstore transparency entry: 2218482405
- Sigstore integration time:
-
Permalink:
Amit123103/Stepcount_python_module@b2eefa3fa65d3defdb1bbed4cc47d0ecf3d05b56 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/Amit123103
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b2eefa3fa65d3defdb1bbed4cc47d0ecf3d05b56 -
Trigger Event:
push
-
Statement type: