Skip to content

moeinghaeini/nl_map

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NL Map - Interactive Map Visualization

An interactive map visualization application built with C++, SFML, and ImGui. This project displays road networks and allows for interactive exploration of map data.

Features

  • Interactive Map Display: Visualize road networks with different colors for different road types
  • A Pathfinding Algorithm*: Complete implementation with optimal path finding
  • Node Selection: Click on nodes to select them and view connections
  • Path Visualization: Real-time path rendering with distance and statistics
  • Customizable Colors: Adjust colors for different road types through the GUI
  • Zoom and Pan: Navigate the map using mouse controls
  • Real-time Rendering: Efficient rendering using SFML vertex arrays
  • Comprehensive Error Handling: Robust data validation and error reporting
  • Unit Testing: Complete test suite for core functionality
  • Professional Documentation: Detailed code documentation and API references

Dependencies

  • SFML 3.0.2: Graphics, window, and input handling
  • ImGui: Immediate mode GUI
  • C++20: Modern C++ features
  • OpenGL: Graphics rendering

Building

Prerequisites

Make sure you have the following installed:

# Install SFML via Homebrew (macOS)
brew install sfml

# Or install via package manager on other systems
# Ubuntu/Debian: sudo apt-get install libsfml-dev
# Fedora: sudo dnf install SFML-devel

Compilation

# Clean previous build
make clean

# Build the project
make

# Or build and run in one command
make run

Usage

  1. Run the application:

    cd bin
    ./sfmlgame
  2. Navigation:

    • Right-click and drag: Pan around the map
    • Mouse wheel: Zoom in/out
    • Left-click: Select nodes
  3. GUI Controls:

    • Way Info Tab: View statistics, toggle way/node display, set start/goal nodes
    • Colors Tab: Customize colors for different road types
  4. Path Planning:

    • Click on nodes to select them
    • Use "Set Start" and "Set Goal" buttons to define path endpoints
    • Click "Start Search" to find optimal path using A* algorithm
    • View path statistics: length, distance, nodes explored

Project Structure

src/
├── main.cpp              # Application entry point
├── GUI.hpp               # Main GUI and rendering class
├── MapData.hpp           # Data structures for map nodes and ways
├── ViewController.hpp    # Camera/view control logic
└── imgui/                # ImGui library files

bin/
├── sfmlgame              # Compiled executable
├── ways.txt              # Map data (CSV format)
├── fonts/                # Font assets
└── imgui.ini             # ImGui configuration

Data Format

The application loads map data from bin/ways.txt, which contains CSV data with the following structure:

  • Road information (ID, type, name, etc.)
  • Node coordinates
  • Road connectivity

Road Types

The application supports different road types with customizable colors:

  • footway: Walking paths (green)
  • residential: Residential streets (yellow)
  • motorway_link: Highway connections (magenta)
  • primary: Primary roads (red)
  • secondary: Secondary roads (light gray)
  • tertiary: Tertiary roads (gray)

Testing

Run the comprehensive unit test suite:

# Run all tests
make test

# Clean test files
make test-clean

The test suite covers:

  • Node creation and ID generation
  • Way parsing from CSV data
  • NodeData and WayData functionality
  • Error handling and validation

Development

Adding New Features

  1. Enhanced Pathfinding: The A* algorithm is fully implemented and can be extended with different heuristics
  2. Additional Road Types: Add new types to the m_colorOptions vector
  3. UI Enhancements: Extend the ImGui interface in the imgui() method
  4. Performance Optimizations: Add spatial indexing or other optimizations

Code Style

  • Uses modern C++20 features
  • SFML for graphics and input
  • ImGui for immediate mode GUI
  • Efficient rendering with vertex arrays

License

See LICENSE file for details.

About

Map of Newfoundland written in C++/SFML3

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 91.9%
  • C 7.9%
  • Other 0.2%