|
| 1 | +# Geographic Distance and Travel Time Calculator |
| 2 | + |
| 3 | +This Python script calculates the geodesic distance between two geographic coordinates and estimates travel time based on a given average speed. It uses the geopy library to compute distances. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- Input coordinates for two locations (latitude and longitude) interactively. |
| 8 | +- Calculate the distance between the two coordinates in kilometers. |
| 9 | +- Estimate the travel time based on a given average speed (in km/h). |
| 10 | + |
| 11 | +## Prerequisites |
| 12 | + |
| 13 | +- Python 3.x installed on your system. |
| 14 | + |
| 15 | +## Setup |
| 16 | + |
| 17 | +1. Clone the repository |
| 18 | + |
| 19 | + ```bash |
| 20 | + git clone https://github.com/king04aman/All-In-One-Python-Projects.git |
| 21 | + cd All-In-One-Python-Projects/Geographic Distance |
| 22 | + ``` |
| 23 | + |
| 24 | +2. Create and activate a virtual environment |
| 25 | + |
| 26 | +- For macOS/Linux: |
| 27 | + |
| 28 | + ```bash |
| 29 | + python3 -m venv venv |
| 30 | + source venv/bin/activate |
| 31 | + ``` |
| 32 | + |
| 33 | +- For Windows: |
| 34 | + |
| 35 | + ```bash |
| 36 | + python -m venv venv |
| 37 | + venv\Scripts\activate |
| 38 | + ``` |
| 39 | + |
| 40 | +3. Install the required dependencies |
| 41 | + |
| 42 | + The required packages are listed in requirements.txt. Install them using the following command: |
| 43 | + |
| 44 | + ```bash |
| 45 | + pip install -r requirements.txt |
| 46 | + ``` |
| 47 | + |
| 48 | + Note: The main dependency is geopy for calculating distances based on geodesic coordinates. |
| 49 | + |
| 50 | +## Usage |
| 51 | + |
| 52 | +1. Run the script: |
| 53 | + |
| 54 | + ```bash |
| 55 | + python geographic_distance.py |
| 56 | + ``` |
| 57 | + |
| 58 | +2. Enter the coordinates (latitude and longitude) of the two locations when prompted. |
| 59 | +3. Enter the average speed in km/h to calculate the travel time. |
| 60 | + |
| 61 | + Example input: |
| 62 | + |
| 63 | + ``` |
| 64 | + Enter the latitude and longitude of the first location (lat1, lon1) Example: 40.7128, -74.006: 52.5200, 13.4050 |
| 65 | + Enter the latitude and longitude of the second location (lat2, lon2) Example: 37.7749, -122.4194: 48.8566, 2.3522 |
| 66 | + Enter the average speed in km/h Example: 60: 80 |
| 67 | + ``` |
| 68 | + |
| 69 | + Example output: |
| 70 | + |
| 71 | + ``` |
| 72 | + Distance between the two coordinates: 878.84 kilometers |
| 73 | + Estimated travel time: 10.99 hours |
| 74 | + ``` |
| 75 | + |
| 76 | +## Requirements |
| 77 | + |
| 78 | +Here’s a list of Python dependencies in requirements.txt: |
| 79 | + |
| 80 | +``` |
| 81 | +geopy==2.2.0 |
| 82 | +pytest==8.3.3 |
| 83 | +``` |
0 commit comments