Skip to content

hahzterry/interactive-map

 
 

Repository files navigation

Interactive Street Navigator

An interactive map navigation simulator using real OpenStreetMap data. Navigate through cities with keyboard controls or watch automated pathfinding algorithms in action.

Features

Phase 1: Map Visualization ✅

  • Load real street maps from OpenStreetMap
  • Visualize road networks for any city
  • Automatic data caching for faster loading

Phase 2: Interactive Navigation ✅

  • Keyboard Control: Navigate with arrow keys (↑/←/→/↓)
  • Smart Junction Detection: Automatically identifies available directions
  • Zoom Inset: Detailed view of current intersection in corner
  • Real-time Statistics: Track distance traveled and junctions visited
  • Visual Feedback: Color-coded directions and path history

Phase 3: Planned

  • Automatic navigation with command sequences (e.g., "left, right, right")
  • Dead-end detection and automatic U-turn logic
  • Road type filtering (highways, forest roads, residential streets)

Demo

┌──────────────────────────────────────────────┐
│              Main Map View                   │
│                                              │
│         [Interactive Navigation]             │
│                                              │
│                        ┌────────────────┐    │
│                        │  Zoom Inset    │    │
│                        │                │    │
│                        │  ┌─────────┐   │    │
│                        │  │GERADEAUS│   │    │
│                        │  └─────────┘   │    │
│                        │       ●        │    │
│                        │    ← / →       │    │
│                        └────────────────┘    │
└──────────────────────────────────────────────┘

Controls: ↑=Forward  ←=Left  →=Right  ↓=Back  I=Info  Q=Quit

Installation

Requirements

  • Python 3.8+
  • pip

Setup

  1. Clone the repository

    git clone https://github.com/YOUR_USERNAME/interactive-street-navigator.git
    cd interactive-street-navigator
  2. Install dependencies

    pip install -r requirements.txt
  3. Run the program

    python src/main.py

Usage

Quick Start

  1. Start the program: python src/main.py
  2. Choose mode:
    • [1] Static map view (Phase 1)
    • [2] Interactive navigation (Phase 2)

Interactive Mode Controls

Key Action
Drive straight
Turn left
Turn right
U-turn / Go back
I Show detailed information
Q Quit

Configuration

Edit src/config.py to customize:

# City to load
CITY_NAME = "Solingen, Germany"

# Visualization
SHOW_ZOOM_INSET = True  # Show/hide zoom inset
FIGURE_SIZE = (15, 15)   # Map window size

# Colors
COLOR_NODES = "#FF0000"      # Junctions
COLOR_EDGES = "#0066CC"      # Streets
COLOR_BACKGROUND = "#F5F5F5" # Background

# Cache
CACHE_DATA = True  # Enable/disable map caching

Project Structure

interactive-street-navigator/
├── src/
│   ├── main.py              # Entry point
│   ├── config.py            # Configuration settings
│   ├── map_loader.py        # OpenStreetMap data loader
│   ├── navigator.py         # Navigation logic
│   ├── visualizer.py        # Static map visualization
│   └── interactive_map.py   # Interactive map with controls
├── data/                    # Cached map data (auto-generated)
├── requirements.txt         # Python dependencies
└── README.md               # This file

How It Works

1. Map Loading

  • Uses osmnx to download street data from OpenStreetMap
  • Converts data into a graph structure (nodes = junctions, edges = streets)
  • Caches data locally for faster subsequent loads

2. Navigation System

  • Navigator class: Manages current position and movement
  • Direction calculation: Uses GPS coordinates to compute bearing angles
  • Junction analysis: Identifies available routes (left/right/straight/back)
  • Relative angles: Classifies directions relative to current heading

3. Visualization

  • Main map: Overview of entire city
  • Zoom inset: Detailed view (200m radius) of current intersection
  • Smart labeling: Labels stay within zoom window
  • Line clipping: Dashed lines indicate roads extending beyond view

Technical Details

Graph Navigation

# Streets are modeled as a directed graph
# Nodes: Intersections with GPS coordinates
# Edges: Street segments with length, type, etc.

graph = ox.graph_from_place("Solingen, Germany", network_type="drive")

Direction Classification

# Compass bearing: 0° = North, 90° = East, 180° = South, 270° = West
# Relative angle = target_bearing - current_heading

if -45° <= relative_angle <= 45°:    # Straight
elif 45° < relative_angle <= 135°:   # Right
elif -135° <= relative_angle < -45°: # Left
else:                                # Back

Learning Objectives

This project was created to learn and practice:

  • Python: OOP, matplotlib, event handling
  • Geospatial data: Working with GPS coordinates and map APIs
  • Graph algorithms: Navigation, pathfinding
  • Real-time visualization: Interactive graphics

Roadmap

  • Phase 1: Map loading and visualization
  • Phase 2: Interactive navigation with keyboard controls
  • Zoom inset for detailed intersection view
  • Smart label placement and line clipping
  • Phase 3: Automated navigation with command sequences
  • Phase 4: Dead-end detection and recovery
  • Phase 5: Road type filtering (highways, forest roads)
  • Phase 6: Pathfinding algorithms (Dijkstra, A*)
  • Future: C++ port for performance comparison

Dependencies

  • osmnx: OpenStreetMap data loader
  • networkx: Graph data structure
  • matplotlib: Visualization and interactive graphics
  • geopandas: Geospatial data processing
  • numpy: Mathematical computations

Contributing

This is a learning project, but suggestions and improvements are welcome!

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is open source and available under the MIT License.

Acknowledgments

  • OpenStreetMap for providing free map data
  • osmnx library by Geoff Boeing
  • Built as a learning project to explore Python and navigation algorithms

Screenshots

Main Map View

Full city overview with current position marked.

Zoom Inset Detail

Color-coded directions with clear labels:

  • 🟢 Green = Straight
  • 🔵 Blue = Left
  • 🟠 Orange = Right
  • ⚪ Gray = Back

Statistics Display

Real-time tracking of:

  • Distance traveled (km)
  • Junctions visited
  • Current GPS coordinates
  • Available directions

Contact

Questions or feedback? Feel free to open an issue!


Built with ❤️ to learn Python and navigation algorithms

About

Interactive map navigation simulator using OpenStreetMap data; built with/by Claude Code

Resources

License

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 100.0%