School Route Mapper - Comprehensive Documentation
Table of Contents
- System Overview
- Architecture & Components
- Data Model & Schema
- User Interface & Features
- API Reference
- Configuration & Settings
- Development & Deployment
- Technical Specifications
System Overview
Purpose
The School Route Mapper is a sophisticated web-based application designed for creating detailed interactive campus maps with advanced routing capabilities. It enables users to:
- Design accurate school building layouts with walls, corridors, and pathways
- Place and manage Points of Interest (POIs) like classrooms, offices, and facilities
- Calculate optimal routes between any two locations on campus
- Export/import map data for sharing and collaboration
- Provide navigation assistance for students, staff, and visitors
Key Features
- Interactive Map Creation: Draw polylines representing building structures and pathways
- Point of Interest Management: Place and categorize campus locations and facilities
- Intelligent Routing: Calculate optimal paths considering obstacles and walking surfaces
- Category System: Define different types of features with routing properties
- Import/Export: Save projects in structured
.schoolmap.json format
- Background Integration: Overlay drawings on floor plans or satellite imagery
- Grid System: Precise measurement and alignment tools
- Theme Support: Light and dark mode interfaces
- Autosave: Automatic project backup and version history
Technology Stack
- Frontend: Pure JavaScript ES6 modules, HTML5 Canvas, CSS3
- Storage: LocalStorage with JSON serialization
- Architecture: Modular event-driven design
- File Format: Custom
.schoolmap.json schema
- No Dependencies: Zero external frameworks or libraries
Architecture & Components
Core Architecture
The application follows a modular, event-driven architecture with clear separation of concerns:
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ app.js │ │ data-model.js │ │ storage.js │
│ (Controller) │◄──►│ (Model) │◄──►│ (Storage) │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│ │ │
▼ ▼ ▼
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ ui-controls.js │ │ canvas-grid.js │ │ drawing-tools.js│
│ (View) │ │ (Canvas) │ │ (Tools) │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│ │ │
▼ ▼ ▼
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ poi.js │ │ spline.js │ │pathfinding- │
│ (POIs) │ │ (Curves) │ │worker.js (AI) │
└─────────────────┘ └─────────────────┘ └─────────────────┘
Component Details
1. app.js - Main Application Controller
- Location:
/js/app.js
- Purpose: Central coordinator managing all subsystems
- Key Responsibilities:
- Application initialization and lifecycle management
- Module coordination and event routing
- Browser compatibility checking
- Error handling and user feedback
- Project lifecycle (new, load, save, export)
2. data-model.js - Core Data Management
- Location:
/js/data-model.js
- Purpose: Defines data structures, validation, and business logic
- Key Components:
- Project schema definition and validation
- Category management system
- Feature creation and manipulation utilities
- Data migration and versioning
- Geometric calculations and hit testing
3. canvas-grid.js - Rendering Engine
- Location:
/js/canvas-grid.js
- Purpose: Canvas management, rendering, and viewport control
- Features:
- High-performance HTML5 canvas rendering
- Viewport management (pan, zoom, fit-to-content)
- Grid system with configurable spacing
- Background image overlay support
- Mouse interaction and coordinate transformation
- Location:
/js/drawing-tools.js
- Purpose: Handles all drawing and editing operations
- Tools Available:
- Select Tool: Feature selection and manipulation
- Polyline Tool: Draw walls, paths, and boundaries
- Erase Tool: Delete features and segments
- Pan Tool: Navigate the canvas
- POI Tool: Place points of interest
5. poi.js - Point of Interest Management
- Location:
/js/poi.js
- Purpose: Manages campus locations and facilities
- Features:
- POI placement and editing
- Type categorization (rooms, offices, facilities)
- Visual styling by category
- Integration with routing system
6. pathfinding-worker.js - Route Calculation
- Location:
/js/pathfinding-worker.js
- Purpose: Intelligent path finding between locations
- Algorithms:
- A* pathfinding with obstacles
- Grid-based navigation mesh
- Turn penalties and surface considerations
- Distance and time estimation
7. storage.js - Data Persistence
- Location:
/js/storage.js
- Purpose: Project storage, backup, and file operations
- Capabilities:
- LocalStorage autosave (30-second intervals)
- Project import/export (.schoolmap.json)
- Version history management
- Settings persistence
8. ui-controls.js - User Interface Management
- Location:
/js/ui-controls.js
- Purpose: Handles all UI interactions and controls
- Components:
- Toolbar and button management
- Modal dialogs (settings, POI editing)
- Tab panels (layers, properties, history)
- Keyboard shortcuts and hotkeys
9. spline.js - Curve Generation
- Location:
/js/spline.js
- Purpose: Smooth curve generation for paths
- Features:
- Bezier and Catmull-Rom splines
- Path smoothing algorithms
- Configurable tension and resolution
Data Model & Schema
Project Structure (.schoolmap.json)
{
"schemaVersion": 1,
"meta": {
"title": "School Name",
"created": "2024-01-01T00:00:00.000Z",
"updated": "2024-01-01T00:00:00.000Z",
"unit": "m",
"grid": {
"spacing": 0.5,
"origin": [0, 0]
},
"render": {
"theme": "light"
}
},
"background": {
"source": null,
"transform": {
"x": 0,
"y": 0,
"scale": 1,
"rotation": 0
},
"opacity": 0.35
},
"categories": [...],
"features": {
"polylines": [...],
"pois": [...]
}
}
Category System
Categories define the visual appearance and routing behavior of map features:
{
"id": "ext-wall",
"name": "External Wall",
"color": "#1f2937",
"dash": [],
"walkability": "blocked",
"buffer": 0.5
}
Default Categories
- External Wall - Building perimeter (blocked)
- Internal Wall - Room divisions (blocked)
- Corridor Boundary - Hallway edges (blocked)
- Door - Entrances and exits (gate)
- Stairs - Vertical circulation (slow)
- Elevator - Accessible vertical circulation (slow)
- Ramp - Accessible paths (normal)
- Outdoor Path - Campus walkways (fast)
- Zebra Crossing - Safe road crossings (fast)
- Road - Vehicle areas to avoid (discouraged)
- Grass - Natural areas (slower)
- No-Go Area - Restricted zones (blocked)
- Shortcut - Quick routes (fast)
Walkability Types
- blocked: Impassable obstacles (walls, barriers)
- gate: Passable openings (doors, gates)
- normal: Standard walking surfaces
- fast: Preferred routes (main paths)
- slow: Reduced speed areas (stairs, elevators)
- slower: Difficult terrain (grass, gravel)
- discouraged: Avoid when possible (roads)
Polyline Features
Represent linear features like walls, paths, and boundaries:
{
"id": "pl-abc123",
"category": "ext-wall",
"points": [[0, 0], [10, 0], [10, 5]],
"properties": {
"level": 0,
"description": "Main entrance wall"
}
}
POI Features
Represent specific locations and facilities:
{
"id": "poi-xyz789",
"name": "Main Office",
"type": "office",
"pos": [5, 2.5],
"properties": {
"level": 0,
"tags": ["admin", "reception"],
"description": "School administration office"
}
}
POI Types
- room: General classrooms
- entrance: Building entrances
- stairs: Stairway access points
- elevator: Elevator access
- restroom: Bathroom facilities
- office: Administrative offices
- exit: Emergency and regular exits
- emergency-exit: Fire exits only
- cafeteria: Dining facilities
- library: Library and media center
- gym: Gymnasium and sports facilities
- auditorium: Large assembly spaces
- lab: Science laboratories
- computer-lab: Technology centers
- nurse: Health office
- admin: Administrative areas
- parking: Vehicle parking
- bike-rack: Bicycle storage
- bus-stop: Transportation pickup
- other: Miscellaneous locations
User Interface & Features
Interface Layout
Top Navigation Bar
- Title Section: Application name and project title
- Mode Selection:
- Edit Mode (✏️): Create and modify maps
- Navigate Mode (🧭): Route planning and navigation
- File Operations: New, Import, Export, Save, Load, Demo
- Settings: Application preferences and theme toggle
- Tools Panel:
- Select/Move (V): Feature selection and manipulation
- Draw (P): Polyline drawing tool
- Erase (E): Delete features and segments
- Label (L): Place POIs
- Pan (Space): Navigate canvas
- Grid Controls: Toggle visibility and spacing
- Background: Load and position reference images
- Categories: Manage drawing categories
- Route Planning:
- Start/End point selection
- Checkpoint management
- Route optimization options
- Route Information:
- Distance and time estimates
- Animation controls
- Speed adjustment
Main Canvas
- Interactive Drawing Surface: Primary work area
- Zoom Controls: +/- buttons and fit-to-content
- Coordinate Display: Real-time position indicator
- Grid Overlay: Measurement and alignment aid
Right Panel
- Layers Tab: Feature hierarchy and visibility
- Properties Tab: Selected feature details
- History Tab: Autosave versions and project history
Keyboard Shortcuts
- 1: Switch to Edit Mode
- 2: Switch to Navigate Mode
- V: Select Tool
- P: Polyline Tool
- E: Erase Tool
- L: POI Tool
- Space: Pan Tool
- G: Toggle Grid
- +/-: Zoom In/Out
- 0: Fit to Content
- Ctrl+N: New Project
- Ctrl+O: Import Project
- Ctrl+S: Save Checkpoint
- Ctrl+Shift+S: Export Project
Features in Detail
Map Creation Workflow
- Setup: Configure grid spacing and load background image if available
- Structure Drawing: Use polyline tool to trace building outlines and walls
- Category Assignment: Apply appropriate categories for routing behavior
- POI Placement: Add locations like rooms, entrances, and facilities
- Validation: Test routes and verify navigation accuracy
- Export: Save project for sharing or deployment
Route Planning Process
- Mode Switch: Change to Navigate Mode
- Point Selection: Choose start and end locations from POI dropdown
- Checkpoints: Optionally add intermediate stops
- Calculation: Click “Calculate Route” to find optimal path
- Visualization: View route with distance and time estimates
- Animation: Watch step-by-step navigation simulation
API Reference
Main Application (app.js)
SchoolRouteMapperApp Class
class SchoolRouteMapperApp {
constructor() // Initialize application
initialize() // Setup all subsystems
newProject(title) // Create new project
loadProject(project) // Load existing project
saveProject() // Save to localStorage
exportProject(filename) // Export to file
loadDemo() // Load sample project
getContentBounds() // Calculate feature bounds
render() // Refresh display
destroy() // Cleanup resources
}
Data Model (data-model.js)
Core Functions
createEmptyProject(title) // Create new project structure
validateProject(data) // Validate project data
migrateProject(data) // Upgrade old versions
createPolyline(categoryId, points, properties)
createPOI(name, type, position, properties)
generateId(prefix) // Generate unique IDs
calculateBounds(features) // Compute bounding box
findFeaturesNear(features, point, tolerance)
snapToGrid(point, spacing, origin)
CategoryManager Class
class CategoryManager {
getCategory(id) // Find category by ID
addCategory(category) // Add new category
updateCategory(id, updates) // Modify category
removeCategory(id) // Delete category
getAllCategories() // List all categories
getWalkableCategories() // Filter passable types
getBlockedCategories() // Filter blocked types
}
class DrawingTools {
setTool(tool) // Change active tool
setCategory(categoryId) // Set drawing category
clearSelection() // Deselect all features
deleteSelected() // Remove selected features
getCurrentTool() // Get active tool name
getSelectedFeatures() // Get selection list
}
POI Management (poi.js)
POIManager Class
class POIManager {
placePOI(position, name, type, properties)
updatePOI(poiId, updates) // Modify existing POI
deletePOI(poiId) // Remove POI
showPOIDialog(poi) // Open edit dialog
hidePOIDialog() // Close edit dialog
getAllPOIs() // List all POIs
getPOIsByType(type) // Filter by type
}
Storage System (storage.js)
StorageManager Class
class StorageManager {
saveProject(project, updateMeta)
loadProject() // Load from localStorage
exportProject(project, filename)
importProject(file) // Import from file
startAutosave(project) // Begin auto-backup
stopAutosave() // End auto-backup
getSettings() // Load app settings
saveSettings(settings) // Save app settings
isDirty() // Check for unsaved changes
}
Pathfinding (pathfinding-worker.js)
PathfindingEngine Class
class PathfindingEngine {
initializeGrid(features, categories, bounds, resolution)
findPath(startWorld, endWorld) // Calculate route
setParameters(params) // Configure algorithm
worldToGrid(x, y) // Convert coordinates
gridToWorld(gridX, gridY) // Convert coordinates
}
Canvas Grid (canvas-grid.js)
CanvasGrid Class
class CanvasGrid {
setGridSpacing(spacing) // Configure grid
setGridOrigin(origin) // Set grid origin
fitToContent(bounds, padding) // Auto-zoom to features
getSnapPosition() // Get grid-snapped cursor
screenToWorld(screenX, screenY)
worldToScreen(worldX, worldY)
draw() // Render canvas
}
Configuration & Settings
Application Settings
Stored in localStorage under key schoolRouteMapper_settings:
{
theme: 'light', // 'light' or 'dark'
gridSpacing: 0.5, // Default grid spacing (meters)
autosaveEnabled: true, // Enable automatic saves
routingResolution: 0.25, // Pathfinding grid resolution
defaultBuffer: 0.3, // Obstacle clearance distance
turnPenalty: 0.3, // Cost for direction changes
splineTension: 0.5, // Curve smoothness (0-1)
animationSpeed: 1.0, // Route animation speed
highQualityRendering: true // Enhanced graphics quality
}
- Routing Resolution: Lower values (0.1m) provide more accuracy but slower computation
- High Quality Rendering: Enables anti-aliasing and smooth curves
- Animation Speed: Controls route visualization playback rate
- Autosave Interval: Fixed at 30 seconds for optimal performance
Grid Configuration
- Spacing: Distance between grid lines (0.1m - 5.0m)
- Origin: Grid reference point [x, y] in world coordinates
- Visibility: Toggle grid display on/off
- Snapping: Automatic alignment to grid intersections
Theme Support
- Light Theme: Default professional appearance
- Dark Theme: Reduced eye strain for extended use
- Custom Colors: CSS variables enable easy customization
Development & Deployment
Prerequisites
- Modern web browser with ES6 module support
- Web server for development (can be simple file server)
- No build process or compilation required
Development Setup
- Clone/Download: Obtain source files
- Web Server: Serve files from route/ directory
- Browser: Open index.html in browser
- Development: Edit files directly, refresh to see changes
File Structure
route/
├── index.html # Main application page
├── debug.html # Development/testing page
├── test.html # Unit test page
├── test-canvas.html # Canvas testing page
├── js/ # JavaScript modules
│ ├── app.js # Main application
│ ├── data-model.js # Data structures
│ ├── canvas-grid.js # Rendering engine
│ ├── drawing-tools.js # Interactive tools
│ ├── poi.js # POI management
│ ├── pathfinding-worker.js # Route calculation
│ ├── storage.js # Data persistence
│ ├── ui-controls.js # User interface
│ ├── spline.js # Curve generation
│ └── demo-data.js # Sample data
├── styles/ # CSS stylesheets
│ ├── main.css # Core styles
│ └── themes.css # Theme definitions
└── ROUTE_MAPPER_DOCUMENTATION.md # This file
Deployment Options
Static Web Hosting
- Upload route/ folder to any web server
- Configure server to serve .json files with correct MIME type
- Enable HTTPS for file operations to work properly
GitHub Pages
# Push to GitHub repository
git add route/
git commit -m "Deploy School Route Mapper"
git push origin main
# Enable GitHub Pages in repository settings
# Point to route/ folder or root directory
Local Development Server
# Python 3
cd route/
python -m http.server 8000
# Node.js
npx http-server route/ -p 8000
# PHP
cd route/
php -S localhost:8000
Browser Compatibility
- Chrome/Edge: 65+
- Firefox: 60+
- Safari: 12+
- Mobile: iOS Safari 12+, Chrome Mobile 65+
Required Browser Features
- ES6 Modules
- HTML5 Canvas
- FileReader API
- LocalStorage
- JSON support
- CSS Custom Properties
- Canvas Size: Automatically sized to container
- Memory Usage: Minimal due to efficient data structures
- File Size: Entire application under 200KB
- Load Time: Near-instantaneous on modern connections
Technical Specifications
Coordinate System
- Origin: Top-left corner (0, 0)
- Units: Meters (configurable)
- Precision: 32-bit floating point
- Range: Practically unlimited (limited by JavaScript number precision)
.schoolmap.json Schema
- Format: JSON with UTF-8 encoding
- Version: Schema version 1 (current)
- Size Limit: No inherent limits (browser memory dependent)
- Compression: Optional (not implemented in current version)
Export Capabilities
- JSON Export: Complete project data
- Image Export: Canvas screenshot (planned feature)
- PDF Export: Printable maps (planned feature)
- Startup Time: < 100ms on modern hardware
- Rendering: 60 FPS for smooth interactions
- Pathfinding: Sub-second for typical school layouts
- Memory: < 50MB for large projects
- Storage: Efficient JSON serialization
Security Considerations
- Local Storage Only: No server-side data transmission
- File Access: Browser security sandbox
- XSS Prevention: Sanitized user inputs
- CORS Compliance: Proper header handling for file operations
Accessibility Features
- Keyboard Navigation: Full keyboard support
- High Contrast: Theme support for visibility
- Screen Readers: Semantic HTML structure
- ARIA Labels: Proper accessibility attributes
Error Handling
- Graceful Degradation: Fallback for missing features
- User Feedback: Clear error messages
- Recovery: Autosave and version history
- Validation: Input sanitization and bounds checking
Future Enhancements
- Multi-floor Support: 3D building navigation
- Real-time Collaboration: Multiple users editing simultaneously
- Mobile App: Native iOS/Android versions
- API Integration: Connect with school information systems
- Advanced Routing: Accessibility considerations, time-based routing
- Analytics: Usage patterns and optimization suggestions
Support and Documentation
Getting Help
- User Manual: Embedded help system (planned)
- Video Tutorials: Screen recordings of common tasks
- FAQ: Frequently asked questions and solutions
- Community: User forums and discussion groups
Contributing
- Bug Reports: Issue tracking system
- Feature Requests: Enhancement proposals
- Code Contributions: Pull request guidelines
- Documentation: Help improve this documentation
Version History
- v1.0.0: Initial release with core functionality
- Schema v1: Current data format specification
License
Open source software - check LICENSE file for specific terms and conditions.
This documentation was generated for the School Route Mapper application. For the most current information, please refer to the source code and inline comments.