Skip to main content

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, and feet to meters.
  • Clean Object-Oriented Design: Core domain abstractions including Person, Location, Route, DistanceCalculator, and ReportGenerator.
  • 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

stepdistancecalculator-1.0.0.tar.gz (22.9 kB view details)

Uploaded Source

Built Distribution

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

stepdistancecalculator-1.0.0-py3-none-any.whl (24.3 kB view details)

Uploaded Python 3

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

Hashes for stepdistancecalculator-1.0.0.tar.gz
Algorithm Hash digest
SHA256 3ac4439e8559bc5a8c9ee13c3d787739ade3bad4b43e985663220dfdb864f5e5
MD5 bb4c74232475e2bf050a959af4d91782
BLAKE2b-256 1ca7f2e9f64bc2479caa75e4129d08daa53171a9ab96c04ccce9e646dc29ed90

See more details on using hashes here.

Provenance

The following attestation bundles were made for stepdistancecalculator-1.0.0.tar.gz:

Publisher: publish.yml on Amit123103/Stepcount_python_module

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

File details

Details for the file stepdistancecalculator-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for stepdistancecalculator-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3ec6b041a9a1e7230659487fd58112cbdb030362749c7f26aad4960523d81d20
MD5 5b93a62f9e151c452f87fc9514a323db
BLAKE2b-256 b2e43fb8ceff081b791a845b9af24d331e85b0eab741ff637da288d670e29a8c

See more details on using hashes here.

Provenance

The following attestation bundles were made for stepdistancecalculator-1.0.0-py3-none-any.whl:

Publisher: publish.yml on Amit123103/Stepcount_python_module

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