Welcome to the Route Finder with POI Filtering project. This tool allows users to find routes between two locations, while also exploring various Points of Interest (POIs) such as restaurants, cafes, hotels, and more. Users can adjust the maximum distance for the route, and dynamically filter POIs based on selected categories. The project leverages Firebase as the backend for storing and retrieving location data and ratings, and it uses Leaflet.js for rendering the map and routes.
- Features
- Technologies Used
- Setup and Installation Installation (Algorithms)
- Setup and Installation (Full project)
- How to Use
- Firebase Configuration
- Future Improvements
- Backend Algorithms: Written in Python for pathfinding and data processing.
- Interactive Map: Users can click on the map to select starting and ending points.
- POI Filtering: Dynamically filter Points of Interest (POIs) like restaurants, cafes, hotels, etc., based on user selections.
- Distance Slider: Adjust the maximum route distance using a slider, and filter POIs within the specified range.
- Dynamic Route Generation: Users can generate a route between two selected points with real-time updates.
- Custom Icons: Different categories of POIs have custom icons, enhancing the visual experience.
- Draggable Markers: Start and end points are draggable for easy adjustments.
- Rating Display: Each POI displays its rating (1-10) dynamically, retrieved from Firebase.
- Firebase Integration: Leverages Firebase Realtime Database to store and retrieve location data and ratings.
-
Frontend:
- Leaflet.js for interactive maps and routes
- Bootstrap for styling and layout
- Leaflet Routing Machine for route management
- Font Awesome for icons
-
Backend:
- Python for algorithms (pathfinding, POI processing)
- Firebase Realtime Database for storing and retrieving location data
- Firebase SDK for frontend interaction with Firebase
-
API:
- Open Source Routing Machine (OSRM) for route calculation.
This project includes several algorithms to find and optimize routes between points of interest (POIs). The algorithms include:
- Depth First Search (DFS)
- Lookahead Constraint Satisfaction Problem (CSP)
- UCS Local Beam Search
These algorithms can be tested with different graph sizes and configurations by running Python scripts that generate graphs and evaluate the algorithms' performance.
- Clone the repository.
- Install the necessary dependencies (use a virtual environment).
- Navigate to the backend-python folder and run:
python3 algorithm/tests.py
- Python installed (for backend algorithms).
- Node.js installed on your local machine.
- Firebase Project set up on Firebase Console.
- Basic knowledge of HTML, CSS, and JavaScript.
-
Clone the repository:
git clone https://github.com/yosefede06/RouteFinder.git cd RouteFinder
-
Set up Firebase by adding your Firebase configuration to the project. (See Firebase Configuration for details).
-
To run the backend (Python):
python3 algorithm/main.py
- Serve the frontend project locally:
index.html
-
Select Start and End Points:
- Click on the map to choose a start point and an end point. You can also drag the markers to adjust their positions.
- The start and end points will be visually highlighted on the map.
-
Choose Categories of Interest:
- Check the boxes for the categories of Points of Interest (POIs) you want to include, such as restaurants, cafes, hotels, and more.
- Only POIs that fall under the selected categories and meet your distance criteria will be shown on the map.
-
Adjust Maximum Route Distance:
- Use the slider at the bottom of the form to set the maximum allowed distance for the route in kilometers.
- POIs will be dynamically filtered based on this distance.
-
Generate the Route:
- Once you've selected the start and end points, chosen your categories, and set the route distance, click the "Generate Route" button to calculate the route.
- A route will be generated and displayed on the map. Along with the route, the filtered POIs will appear based on your selections.
-
POI Information:
- For each POI shown on the map, a custom icon will represent its category. Click on the icons to see more details, such as the name, category, and rating.
- The ratings are shown on a scale of 1-10 and are fetched dynamically from Firebase.
-
Refreshing the Map:
- To start over or choose new points and filters, click the "Refresh" button. This will reset the map and allow you to choose new start and end points, categories, and distances.
-
Route Distance and Time:
- After generating a route, the total distance (in kilometers) and estimated time (in hours and minutes) will be displayed beneath the map.
In this project, Firebase is used to manage real-time data, including storing location-based points of interest (POIs) and route requests/responses. Below are the steps to configure Firebase:
-
Create a Firebase Project:
- Go to the Firebase Console.
- Create a new Firebase project by following the prompts.
-
Add a Web App to Firebase:
- In the Firebase console, navigate to the "Project Settings" and find the option to add a web app.
- Once created, Firebase will provide a configuration object. You’ll use this in your frontend to initialize Firebase.
-
Set Up Firebase Realtime Database:
- In the Firebase console, enable the Realtime Database under the "Build" section.
- Create a new database and select the appropriate location for your data.
-
Add Firebase SDK to Your Project:
- In your frontend code, initialize Firebase using the configuration details provided when you added the web app. This typically includes the API key, project ID, database URL, and other Firebase credentials.
// Initialize Firebase const firebaseConfig = { apiKey: "YOUR_API_KEY", authDomain: "YOUR_AUTH_DOMAIN", databaseURL: "YOUR_DATABASE_URL", projectId: "YOUR_PROJECT_ID", storageBucket: "YOUR_STORAGE_BUCKET", messagingSenderId: "YOUR_MESSAGING_SENDER_ID", appId: "YOUR_APP_ID", measurementId: "YOUR_MEASUREMENT_ID" }; firebase.initializeApp(firebaseConfig); const db = firebase.database();
-
Loading Environment Variables:
- This project uses a
.env
file to store Firebase credentials
- Create a
.env
file in the root directory of your project. - Add the required environment variables in the following format:
# .env file FIREBASE_PRIVATE_KEY=your_firebase_api_key FIREBASE_DATABASE_URL=your_firebase_auth_domain
- This project uses a
Firebase Realtime Database is central to managing Points of Interest (POIs), route requests, and route responses. Here's how the data is structured:
- This node stores details of POIs such as restaurants, cafes, hotels, etc.
- Each POI includes:
name
: Name of the location (e.g., "Restaurant ABC")category
: Type of location (e.g., "restaurant", "cafe")x
,y
: Latitude and longituderating
: Randomly generated rating (1-10)
- Example:
{ "locations": { "poi1": { "name": "Restaurant ABC", "category": "restaurant", "x": 31.771534, "y": 35.2223878, "rating": 8.7 } } }
- Stores user-submitted route requests, including:
start
: Coordinates for the start pointend
: Coordinates for the end pointcategories
: List of selected POI categoriesmaxDistanceKm
: Maximum distance for the route
- Example:
{ "routeRequests": { "request1": { "start": { "lat": 31.771534, "lon": 35.2223878 }, "end": { "lat": 31.7802464, "lon": 35.221699 }, "categories": ["restaurant", "cafe"], "maxDistanceKm": 10 } } }
- Contains the backend-calculated routes with details of selected POIs:
path
: Array of POIs along the route- Each POI includes
name
,category
,lat
,lon
, andrating
- Example:
{ "routeResponses": { "response1": { "requestId": "request1", "path": [ { "lat": 31.771534, "lon": 35.2223878, "name": "Restaurant ABC", "category": "restaurant", "rating": 8.7 } ] } } }
- User Authentication: Allow users to sign in and save their preferred routes or POI settings.
- Rating System: Implement a user rating system where users can rate POIs.