The map navigation system has been refactored into modular components for better organization and maintainability.
Purpose: Central coordinator for marker and route management Contains:
MarkerRouteViewModel: Coordinates all marker and route operationsMarkerRouteManagementSheet: Main UI sheet with tabs for Details/Markers/RoutesMarkerGroupsList,MarkerGroupItem,MarkerListItem: Marker list componentsRoutesList,RouteListItem: Route list componentsLocationEditDialog,RouteEditDialog: Edit dialogs for locations and routes
Responsibilities:
- Managing marker groups and categories
- Listing and filtering markers
- Listing and managing routes
- Coordinating between single-marker and multi-waypoint navigation
Purpose: Handles individual marker navigation and details Contains:
MarkerDetailsContent: Complete marker details view with action buttonsMarkerDetailsHeader: Name and coordinates displayMarkerDetailsInfoGrid: Metadata grid displayMarkerDetailsFrequencies: Frequency information displayMarkerDetailsRunways: Runway cards displayMarkerDetailsActionButtons: Set Route, Edit, Move, Center, Delete buttonsMarkerDeleteConfirmationDialog: Deletion confirmation- Helper functions for marker data display and database operations
Responsibilities:
- Displaying comprehensive marker information
- Single marker navigation ("Set Route" button)
- Quick actions (Edit, Move, Center, Delete)
- Runway and frequency information
- Marker metadata display
Key Features:
- Set Route Button: Primary navigation action to set a single marker as target
- Integrated edit functionality with full database field support
- Move marker capability for non-static markers
- Center map on marker
- Delete with confirmation
Purpose: Handles complex routes with multiple waypoints Contains:
MultiWaypointRouteViewModel: Business logic for route creation and optimizationRouteTextOverlay: Map overlay for route labelsdrawRouteOnMap: Helper function to visualize routes on mapcalculateDistance: Distance calculation between coordinates- Route optimization algorithms (TSP solver)
Responsibilities:
- Creating routes with multiple waypoints
- Route optimization (shortest path calculation)
- Waypoint locking and reordering
- Route candidate generation
- Distance and heading calculations
- Visual route display on map
Key Features:
- Route Optimization: TSP solver for optimal waypoint ordering
- Waypoint Locking: Lock specific waypoints in place during optimization
- Route Candidates: Generate multiple route variations with distances
- Greedy & Exact Algorithms: Choose algorithm based on waypoint count
- Visual route display with distance/heading labels
Purpose: User interface for route creation Contains:
- Type alias:
RouteCreationViewModel = MultiWaypointRouteViewModel RouteCreationSheet: Main UI sheet for route creation/editingRouteSegmentInfo: Distance and heading display between waypointsWaypointItem: Individual waypoint card with actions- UI components for waypoint management
Responsibilities:
- Route creation UI flow
- Waypoint list display and interaction
- Route name and properties editing
- Location picker for adding waypoints
- Visual feedback during route creation
┌──────────────────────────────────────┐
│ MapViewer (Entry Point) │
│ - Initializes all ViewModels │
│ - Manages map state │
└────────────┬─────────────────────────┘
│
├─────────────────────────────────────┐
│ │
┌────────────▼──────────────────┐ ┌────────────▼──────────────────┐
│ MarkerRouteManagement.kt │ │ SingleMarkerNavigation.kt │
│ (Main Coordinator) │ │ (Single Marker Ops) │
│ │ │ │
│ • MarkerRouteViewModel │ │ • MarkerDetailsContent │
│ • Lists markers & routes │───▶│ • "Set Route" button │
│ • Manages visibility │ │ • Edit/Delete/Center │
└────────────┬──────────────────┘ └───────────────────────────────┘
│
│
┌────────────▼──────────────────┐
│ MultiWaypointRouteNav.kt │
│ (Multi-Point Routes) │
│ │
│ • MultiWaypointRouteViewModel│
│ • Route optimization │
│ • TSP algorithms │
│ • Waypoint management │
└────────────┬──────────────────┘
│
│
┌────────────▼──────────────────┐
│ RouteCreationUI.kt │
│ (UI Components) │
│ │
│ • RouteCreationSheet │
│ • WaypointItem │
│ • UI controls │
└───────────────────────────────┘
Use Case: Direct navigation to a specific point Flow:
- User selects marker from list or map
MarkerDetailsContentdisplays in sheet- User clicks "Set Route" button
- Navigation line drawn from player to marker
- Distance and heading calculated in real-time
Files Involved:
SingleMarkerNavigation.kt: Marker details and Set Route buttonMarkerRouteManagement.kt: Marker selection and displayMapViewer.kt: Navigation line rendering
Use Case: Complex routes with multiple stops Flow:
- User opens Route Creation
- Selects multiple waypoints
- Can optimize route order (shortest path)
- Can lock specific waypoints
- Saves route to database
- Route displayed on map with segments
Files Involved:
MultiWaypointRouteNavigation.kt: Route logic and optimizationRouteCreationUI.kt: Route creation UIMarkerRouteManagement.kt: Route list and visibility toggleMapViewer.kt: Route visualization
class MarkerRouteViewModel(
locationRepository: LocationRepository,
routeRepository: RouteRepository
)- Manages marker groups and categories
- Handles route visibility toggling
- Coordinates marker/route CRUD operations
class MultiWaypointRouteViewModel(
application: Application,
routeRepository: RouteRepository,
locationRepository: LocationRepository,
runwayDao: RunwayDao
)- Waypoint selection and ordering
- Route optimization algorithms
- Route candidate generation
- Distance calculations
Complete marker information display with:
- Header (name, coordinates)
- Info grid (metadata)
- Frequencies
- Runways
- Action buttons (Set Route, Edit, Move, Center, Delete)
Route building interface with:
- Waypoint list with drag-to-reorder
- Add waypoint from markers or current position
- Optimize button (TSP solver)
- Lock waypoints option
- Route name editing
- Save/Cancel actions
- LocationRepository: CRUD operations for markers/locations
- RouteRepository: CRUD operations for routes
- RunwayDao: Runway data for airports
- LocationEntity: Marker/waypoint data
- RouteEntity: Route metadata
- RunwayEntity: Runway information
- Generates all permutations
- Finds absolute shortest route
- Computationally expensive
- Guaranteed optimal solution
- Nearest neighbor heuristic
- Fast approximation
- Good enough solution for large routes
- Scalable to many waypoints
- User can lock specific waypoints in place
- Only unlocked waypoints are optimized
- Preserves must-visit-in-order constraints
-
Separation of Concerns
- Single marker operations isolated
- Multi-waypoint logic separated
- UI decoupled from business logic
-
Maintainability
- Each file has clear responsibility
- Easier to locate and fix bugs
- Clearer code organization
-
Reusability
- Components can be used independently
- ViewModels can be tested separately
- UI components are composable
-
Scalability
- Easy to add new navigation modes
- Can extend route optimization algorithms
- Clear extension points
// In MapViewer or other screen
MarkerRouteManagementSheet(
viewModel = markerRouteViewModel,
onSetActiveRoute = { marker ->
// Set active navigation target
activeNavigationTarget = marker
}
)// Open route creation
routeCreationViewModel.startRouteCreation()
// Add waypoints
routeCreationViewModel.addWaypoint(location1)
routeCreationViewModel.addWaypoint(location2)
routeCreationViewModel.addWaypoint(location3)
// Optimize
routeCreationViewModel.optimizeRouteOrder()
// Save
routeCreationViewModel.finishRouteCreation { routeId ->
// Route saved with id: routeId
}drawRouteOnMap(
mapView = mapView,
waypoints = listOf(
Triple(location1, null, null),
Triple(location2, distanceNm, headingDeg),
Triple(location3, distanceNm2, headingDeg2)
),
color = android.graphics.Color.parseColor("#00A8FF")
)RouteCreationViewModelis now an alias toMultiWaypointRouteViewModelMarkerDetailsContentmoved fromMarkerRouteManagement.kttoSingleMarkerNavigation.kt- All imports should be updated to reference new files
- No API breaking changes - all functions maintain same signatures
- Type aliases preserve old naming
- All existing function signatures unchanged
- Database operations remain identical
- UI component interfaces unchanged
-
Navigation Modes
- Add "Follow Route" mode with automatic waypoint progression
- Voice guidance for waypoint approach
- Off-route detection and rerouting
-
Route Sharing
- Export routes to file
- Import routes from other users
- Cloud sync for routes
-
Advanced Optimization
- Consider terrain and obstacles
- Fuel-optimal routing
- Time-based constraints
-
UI Improvements
- Drag-and-drop waypoint reordering on map
- Visual route editing
- Split-screen map and route editor
- Test route optimization algorithms with various waypoint counts
- Verify distance calculations
- Test waypoint locking logic
- Validate route candidate generation
- Test marker selection → route creation flow
- Verify database persistence
- Test route visibility toggling
- Validate UI state management
- Test marker details display
- Verify button actions
- Test route creation flow
- Validate waypoint management UI
Last Updated: December 21, 2025 Version: 1.0 Authors: Architecture refactoring by GitHub Copilot