This project implements an interactive **map search and navigation** feature for the TUT Smart Library student portal. Students type or speak a location in plain English—such as “where is table four” or “shelf 2”—and the system finds the place on a live library floor plan, then draws a walking route from the entrance to that destination.
The map shows study tables, book shelves, the entrance, special areas, and optional live robot position. Route planning uses the library’s saved waypoint map and shortest-path logic so users see distance, estimated walk time, and a visual path with footsteps—not just a pin on a static image.
Overview
The Library Map Search & Navigation module helps students find their way inside the library building without asking staff for directions every time. It is built around a student-facing map page (student_map_navigation.php) backed by two APIs: one that understands search queries (location_query_parser.php) and one that calculates the best walking route (calculate_route.php).
The floor plan is drawn on an HTML canvas using real coordinates from robot/data/waypoints.json—the same waypoint data used by the RoboLibrarian robot. That keeps the map aligned with robot navigation and shelf/table labels used elsewhere in the system.
Search accepts flexible wording: numbers as digits or words (“table 4” / “table four”), shelf numbers mapped to shelf IDs (e.g. shelf 2 → shelf(A001)), and named areas like home (entrance) or special needs area. If a match is found, the map highlights the destination and displays a route from home with distance and estimated walking minutes.
The feature also connects to the library chatbot: when a student asks “where is shelf A001?” or “where is [book title]?”, the chatbot can redirect to the map with the query pre-filled so the route appears automatically.
How It Works
Step 1 — User enters a location query
On the Map Navigation page, the student types a question or location name in the search box (e.g. “table 12”, “shelf 2”, “where is table four”). Pressing Find Location sends the text to the Location Query Parser API.
Step 2 — Query parsing and matching
The parser normalizes the text (lowercase, clean spaces) and tries several strategies:
Tables — Detects “table” plus a number (1–12), including written numbers (one, two, … twenty).
Shelves — Detects “shelf” plus shelf number 1–3 and maps to waypoint IDs shelf(A000), shelf(A001), shelf(A002).
Named areas — Matches home/entrance and special needs area.
Fuzzy match — Compares the query to all waypoint names (with underscores/spaces handled) for partial or close matches.
If nothing matches, the API returns a helpful error suggesting example queries.
When a waypoint is found, the front end calls the Route Calculation API with from=home and to=<waypoint_name>. The server:
Loads all waypoints and their x/y positions.
Builds a graph of reachable connections (tables linked to nearby tables, shelves to shelves/tables, home to nearby nodes, turning point as a bridge between sides, etc.).
Runs Dijkstra’s algorithm to find the shortest path by distance.
Returns the ordered list of waypoints, total distance in meters, and estimated walking time.
Step 4 — Map visualization
The canvas redraws with:
Zones (reading area, shelf area, charging/home, special needs) as colored overlays.
Icons for tables and the entrance.
Destination highlighted.
Route path drawn between waypoints with a footsteps graphic along the path.
Pan, drag, reset view, and rotation (slider and buttons) for easier viewing.
Robot status can be polled periodically so the map may show live robot position when the robot system is online.
Step 5 — Chatbot hand-off (optional)
In chatbot-api.php, location-related messages (shelf, table, directions, or a book’s shelf from the catalog) produce a response with a map URL (student_map_navigation.php?query=...) and optional auto-redirect so the student lands on the map with the route ready.
The end-to-end flow includes:
Natural-language or keyword location search
Waypoint resolution against waypoints.json
Shortest-path route from entrance to destination
Interactive 2D map with legend and zones
Distance and time estimates for walking
Integration with chatbot and book shelf lookups
Features
Plain-English location search (tables, shelves, entrance, special areas)
Written-number support (“table four” as well as “table 4”)
Fuzzy matching for waypoint names
Shortest-route calculation using Dijkstra’s algorithm
Route displayed with distance (meters) and estimated walk time
Canvas-based interactive library floor map
Color-coded zones (reading, shelves, home/charging, special needs)