This project provides a Django-based web API for determining the optimal refueling stops along a route between two addresses. It uses geospatial data, optimization techniques, and interactive maps to help users minimize travel costs and fuel consumption.
- Computes optimal refueling stops along a given route.
- Provides results as both JSON data and interactive HTML maps.
- Calculates total travel distance and associated fuel costs.
- Identifies states crossed during the journey.
- User Input: The API receives a start and end address.
- Geocoding: Converts addresses into geographical coordinates using Nominatim.
- Route Data: Fetches route details (geometry and distance) using the OSRM API.
- State Traversal: Identifies states crossed using GeoJSON state boundary data.
- Fuel Optimization: Calculates optimal refueling stops based on factors like fuel prices, station proximity, and vehicle constraints.
- Visualization: Outputs route data and refueling stops as JSON or an interactive HTML map.
GET /optapi/<address1>/<address2>- Returns route data and optimized refueling stops as JSON.
- Parameters:
address1(str): Starting address.address2(str): Ending address.
GET /optapi/map/<address1>/<address2>- Returns an HTML map showing the route and refueling stops.
- Parameters:
address1(str): Starting address.address2(str): Ending address.
- Geocoding and Routing:
get_coordinates(address): Retrieves geographical coordinates for an address.get_route_data(start_address, end_address): Fetches route geometry and distance from OSRM.
- Fuel Optimization:
refuel_optimizer(route_data, states_crossed): Computes optimal refueling plan based on route data and station details.
- Map Visualization:
generate_map(route, markers): Creates an interactive map with the route and refueling stops.
- Clone the repository and navigate to the project directory:
git clone <repository-url> cd <project-directory>
- Install dependencies:
pip install -r requirements.txt
- Run the Django development server:
python manage.py runserver
- Access the API endpoints:
- JSON response:
http://localhost:8000/optapi/<address1>/<address2> - HTML map:
http://localhost:8000/optapi/map/<address1>/<address2>
- JSON response:
- Vehicle parameters:
- Maximum range: 500 miles per tank.
- Fuel efficiency: 10 miles per gallon.
- Refueling buffer: 75 miles of fuel reserve.
- Maximum detour: 30 miles to a refueling station.
- GeoJSON state boundaries are used to identify states crossed.
- OSRM is assumed to be available for routing services.
- Provides cost-effective and efficient travel plans.
- Integrates interactive visualizations for better route understanding.
- Supports seamless geospatial data processing and optimization.
- Depends on external services (Nominatim, OSRM, GeoJSON).
- Limited to driving routes and fuel optimization scenarios.
- Requires preprocessed fuel station data with accurate pricing and locations.
- Does not account for real-time traffic or fuel price fluctuations.
- Django: Web framework for API development.
- GeoPy: Geocoding library for address lookup.
- Numba: Accelerated numerical computations.
- NumPy, Pandas: Data manipulation and processing.
- SciPy: Optimization functions.
- Folium: Map visualization.
- Shapely, GeoPandas: Geospatial data handling.
Contributions are welcome! Please fork the repository, make changes, and submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
Please if you find these useful in anyway, cite it or my github account, much appreciated!
