BearMaps is a backend-driven web mapping application inspired by industry giants like Google Maps and OpenStreetMap. This project, developed as part of the CS61B Data Structures course, demonstrates advanced algorithms and data structures for efficient mapping, routing, and location-based search functionalities.
- Dynamic Map Rastering Efficiently generates map images for specific user-defined views by dynamically stitching together rasterized map tiles.
- Shortest Path Calculation Implements the A* Search Algorithm for efficient and optimal route computation, ensuring minimal computational overhead.
- Turn-by-Turn Navigation Provides detailed navigation instructions, including direction changes (e.g., turn left, continue straight) and distances.
- Autocomplete and Search
- Autocomplete: Supports prefix-based location name suggestions with instant results.
- Search: Retrieves location data, including coordinates, IDs, and full names, from OpenStreetMap datasets.
- High-Performance Back-End Utilizes advanced data structures like Graphs, Tries, and Priority Queues to ensure optimal performance and scalability.
BearMaps integrates multiple backend systems to handle rastering, routing, and search functionalities while maintaining modularity and extensibility.
- Input Handling User inputs are processed through RESTful API calls. Queries include viewport dimensions, latitude/longitude bounds, or start/end coordinates.
- Map Rastering The system determines the required map depth and retrieves tiles that match the viewport. Tiles are stitched together to create a complete raster image, reducing unnecessary bandwidth and computational effort.
- Pathfinding The shortest path is calculated between two points using the A* algorithm. The heuristic function (great-circle distance) guides the search toward the goal while ensuring optimal efficiency.
- Turn-by-Turn Navigation Path segments are analyzed to provide detailed directions, including the type of turn, the road name, and the segment distance.
- Search and Autocomplete
Location search and autocomplete functionalities rely on:
- Trie Data Structure for prefix-matching efficiency.
- Graph traversal to retrieve matching locations, including coordinates and names.
MapServer
Manages API endpoints, handles HTTP requests, and integrates rastering, routing, and search functionalities. It connects user input to backend computations.Rasterer
Handles map tile selection and image rasterization, ensuring efficient and accurate rendering of user-defined map views.GraphDB
Parses OpenStreetMap XML data to construct a graph-based representation of road networks. This class manages nodes (intersections) and edges (roads).Router
Implements the A* algorithm for shortest pathfinding. Computes paths between nodes and prepares data for navigation instructions.NavigationDirection
Formats and organizes turn-by-turn navigation instructions for user-friendly output.
- Graph: Represents road networks with nodes (vertices) and edges. Enables efficient adjacency queries and shortest-path computation.
- Trie: Supports fast prefix-based search for location autocomplete.
- Priority Queue: Facilitates efficient exploration in the A* algorithm.
- A* Search Algorithm
- Combines the shortest known path (
g(n)
) with an estimated heuristic (h(n)
), guiding the search toward the target. - Uses great-circle distance as the heuristic for accuracy and performance.
- Combines the shortest known path (
- Map Rastering
- Dynamically determines the optimal zoom depth based on the viewport.
- Retrieves and stitches tiles from pre-saved images to generate complete raster images.
- Turn-by-Turn Directions
- Analyzes the path to detect direction changes based on bearings.
- Outputs navigation instructions like "Continue straight for 1.2 miles on Main Street."
- Search and Autocomplete
- Autocomplete matches location prefixes using a Trie.
- Full location details (name, latitude, longitude) are retrieved from the graph.
- Java: Core language for backend implementation.
- Spark Framework: Handles RESTful API calls.
- OpenStreetMap: Provides real-world map data in XML format.
- JUnit: Ensures code reliability through rigorous unit testing.
- Efficient rastering for large maps with minimal bandwidth usage.
- Implementing a scalable search system for millions of location names.
- Ensuring route accuracy and optimal performance in A* pathfinding.
- Vector-Based Rendering Transition from rasterized images to vector tiles for better scalability and interactivity. This approach leverages technologies like WebGL for real-time rendering.
- Client-Side Optimizations Delegate more tasks to the frontend, such as tile assembly and caching, for improved responsiveness and reduced server load.
- Advanced Search Features
- Introduce ranking for search results based on relevance.
- Add support for filtering results by categories or proximity.
- Integration with Real-Time Data Incorporate real-time traffic data to enhance routing accuracy.
-
Clone the repository:
git clone [email protected]:JzzzX/BearMaps.git cd BearMaps
-
Build the project using Maven:
mvn clean install
-
Start the server:
java -cp target/classes MapServer
-
Open your browser and navigate to:
http://localhost:4567/map.html
This project was developed as part of the CS61B: Data Structures course at the University of California, Berkeley. It incorporates skeleton code and OpenStreetMap data, with thanks to the course staff for guidance and resources.