Skip to content

Latest commit

Β 

History

16 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

TrailGuide Logo

TrailGuide: Solo Hike & Backtrack Navigation

A Native iOS application for solo hikers, featuring smart route tracking and an intelligent backtrack navigation system, even without cell service.

Designed with an Offline-First and Privacy-First approach. All trip data is processed and stored locally on the device (100% On-Device), requiring no external servers or internet connection.

iOS Swift SwiftUI Architecture MVVM MapKit SwiftData


πŸ“– Project Overview

TrailGuide is an iOS application developed with Swift and SwiftUI to enhance the safety of solo hikers navigating through areas with no cellular coverage.

The system acts as a Digital Breadcrumb, continuously recording GPS locations in the background while passing the data through a noise-reduction pipeline to generate the most accurate trail possible.

When it's time to head back, the app automatically generates a Backtrack Navigation route from your recorded data and tracks your position in real-time. If you wander off the safe path, the system issues immediate warnings via on-screen banners and Text-to-Speech (TTS) voice alerts.

All trip records, including paths, distances, and durations, are securely stored inside the device using SwiftData, ensuring full offline capability and absolute data privacy.


✨ Core Capabilities

  • πŸ—ΊοΈ Real-time route tracking utilizing MapKit and CoreLocation.
  • 🎯 Multi-stage GPS noise reduction pipeline for high-precision mapping.
  • ↩️ Automatic generation of backtrack navigation routes.
  • 🚨 Real-time off-route detection using cross-track distance math.
  • πŸ—£οΈ Immediate alerts via Text-to-Speech (TTS) and UI banners.
  • πŸ”‹ Dynamic GPS accuracy adjustment for battery optimization.
  • πŸ›οΈ Highly maintainable codebase built on Clean Architecture and MVVM.

πŸš€ App Previews

πŸ“ Smart Route Tracking

While hiking, the system continuously records your GPS coordinates. It filters out anomalies, jitters, and stationary noise in the background to draw a smooth and highly accurate trail.

Smart Route Tracking


↩️ Backtrack Navigation

When returning, the system simplifies your raw path into clean waypoints (Path Simplification), drawing a dashed guide line on the map to help you navigate back to your starting point effortlessly.

Backtrack Navigation


🚨 Off-Route Detection & Voice Alert

If you deviate beyond a safe distance from your backtrack route, a red warning banner appears instantly, and the app speaks out loud via Text-to-Speech to guide you back on track.

Off-Route Detection


πŸ—ΊοΈ Trip History

Upon ending the hike, your total distance, duration, and the precise route polyline are automatically saved into the local SwiftData database, allowing you to review your past adventures anytime.

Trip History 1 Β  Β  Trip History 2 Β  Β  Trip History 3


🌟 Key Features

Feature Description
πŸ—ΊοΈ Smart Route Tracking Real-time trail recording using MapKit and CoreLocation
↩️ Backtrack Navigation Automatically generates a return route from recorded data
🎯 GPS Noise Reduction Multi-stage GPS signal filtering to enhance path accuracy
⚠️ Off-Route Detection Detects route deviation and alerts the user immediately
πŸ—£οΈ Voice & Banner Alert Delivers warnings via TTS and UI notification banners
πŸ”‹ Battery Optimization Dynamically adjusts GPS accuracy to reduce battery consumption
πŸ’Ύ On-Device Storage Safely stores all trip data locally using SwiftData

πŸ› οΈ Tech Stack

Category Technology
Language Swift
UI Framework SwiftUI
Architecture Clean Architecture + MVVM
Database SwiftData
Map MapKit
Location CoreLocation
Audio AVFoundation (AVSpeechSynthesizer)
Notifications UserNotifications
Reactive Combine

πŸ›οΈ System Architecture

TrailGuide is engineered with Clean Architecture and the MVVM pattern, ensuring clear separation between the Presentation, Domain, and Data layers. This makes the system scalable, testable, and highly maintainable.

Architecture Diagram

                 SwiftUI Views
                       β”‚
                       β–Ό
             ViewModels (@Observable)
                       β”‚
                       β–Ό
                 Domain Use Cases
      (e.g., SaveTripUseCase, LocationCalculator)
                       β”‚
                       β–Ό
             Repository Interfaces
           β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
           β–Ό                       β–Ό
   Location Repository     TripHistory Repository
           β”‚                       β”‚
           β–Ό                       β–Ό
 CoreLocation Manager        SwiftData Context
      (Data Source)             (Data Source)

πŸ“‚ Project Structure

TrailGuide
β”‚
β”œβ”€β”€ App                 # App Entry Point & DI Container
β”œβ”€β”€ Core                # Utilities & Math formulas (LocationCalculator)
β”œβ”€β”€ Data
β”‚   β”œβ”€β”€ DataSources     # LocationManager, LocalNotificationService
β”‚   β”œβ”€β”€ Models          # SwiftData Schemas (TripHistoryModel)
β”‚   └── Repositories    # Implementation of Repository Interfaces
β”œβ”€β”€ Domain
β”‚   β”œβ”€β”€ Entities        # Business Models (TripHistory, UserProfileEntity)
β”‚   β”œβ”€β”€ Interfaces      # Repository Protocols
β”‚   └── UseCases        # SaveTripUseCase, GetAllTripsUseCase, etc.
└── Presentation
    β”œβ”€β”€ Common          # Custom Alerts, Shared UI Components
    └── Features
        β”œβ”€β”€ Breadcrumb  # Solo Hike tracking, Map UI, and Backtrack
        └── History     # Trip history lists and detailed views
Folder Responsibility
App Application entry point and Dependency Injection container.
Core Centralized utilities and complex mathematical functions.
Data Data management layer including Data Sources, Models, and Repositories.
Domain Core business logic encompassing Entities and Use Cases.
Presentation User interface layer containing SwiftUI Views and ViewModels.

πŸ”„ GPS Processing Pipeline

A robust pipeline is implemented in LocationRepositoryImpl to filter raw GPS data before rendering, preventing zigzag jumps or track overlapping in dense forests:

πŸ“‘ CoreLocation (Fetches raw GPS from hardware)
      β”‚
      β–Ό
🎯 Accuracy Filter (Drops coordinates if horizontal accuracy > 35m)
      β”‚
      β–Ό
πŸ›‘ Stationary Detection (Pauses recording if speed < 0.5 m/s for over 30s)
      β”‚
      β–Ό
πŸš€ Speed Anomaly Detection (Drops points if hiking speed exceeds 15 km/h)
      β”‚
      β–Ό
πŸ“ Distance Filter (Records next point only if moved > 10m from the last point)
      β”‚
      β–Ό
πŸ“ˆ Moving Average Smoothing (Averages the last 2 points to smooth the trail)
      β”‚
      β–Ό
πŸ—ΊοΈ MapKit Polyline Rendering (Draws the refined, smooth path on the map)

βš™οΈ Development Challenges

Challenge Solution Result
GPS Jitter & Inaccuracy Developed a multi-stage signal filtering pipeline and applied Moving Average Smoothing. The path rendered on the map is exceptionally smooth and accurate, eliminating zigzag jumps.
Cluttered Backtrack Route Utilized LocationCalculator.simplifyPath to filter out turns with bearing changes under 30Β°. Significantly reduced unnecessary waypoints, making backtrack navigation easier to read and faster to process.
Off-Route Detection Accuracy Calculated Cross-Track Distance between the user's location and the main trail line. Precisely alerts the user immediately when they stray more than 5 meters from the original path.
High Battery Consumption Dynamically toggled CLLocationManager modes (Battery Saving for normal hiking / High Accuracy for backtracking). Conserved battery life during normal use while ensuring maximum safety during backtrack navigation.

πŸš€ Installation

git clone [https://github.com/MarkCnw/TrailGuide-iOS.git](https://github.com/MarkCnw/TrailGuide-iOS.git)
cd TrailGuide-iOS
open TrailGuide.xcodeproj

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages