Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ViewOSMMap

A pure OpenStreetMap viewer and renderer developed with Qt 6, featuring classic map style rendering. Browse and view only, no map editing functionality included.

example.jpg

Features

  • Multi-format Support: Supports OSM XML (.osm) and PBF (.osm.pbf) map data formats
  • Self-contained Parsing: Built-in zero-dependency Protobuf PBF parser, no external protobuf library required
  • Classic Map Style Rendering:
    • Classic #f2efe9 beige background
    • Double-layer road rendering (CASING outline + NORMAL body)
    • Real-world width mapping, road width dynamically changes with zoom
    • Road width differentiated by grade (footway 1.5m to motorway 25m)
    • Railway dashed lines, water area filling, green space/building area rendering
    • Layered transparency effects, upper elements more transparent
    • FlatCap+MiterJoin pen style, smooth road junctions without bumps
    • Road direction arrows and one-way arrows display, arrow size differentiated by road grade
  • Interactive Functions: Mouse drag pan, scroll wheel zoom
  • Layer Control: Independent toggle controls for each layer
    • Roads (H), Buildings (B), Water (W), Green Space (G)
    • Railways (Shift+R), Land Use (L), Nodes (N)
    • Show/Hide All buttons
  • Road Navigation: Road direction arrows, one-way small arrows display
  • Search Function: Search road features by name, supports quick location to geographic coordinates
  • Road Highlighting: Highlight effect when hovering and selecting roads, highlight width matches actual road width
  • High-performance Rendering: 512×512 tile parallel rendering, LRU cache (max 64 tiles)
  • Coordinate Correction: Latitude correction processing to avoid road stretching distortion in high-latitude regions
  • MapCSS Style Customization:
    • Support import/export MapCSS style files
    • Auto-loads map-style.mapcss configuration file
    • Customizable colors, line widths, transparency and other rendering parameters
    • Built-in default style, one-click restore
  • Distance Threshold Control: Auto show/hide roads at corresponding levels based on zoom level, optimizing performance

Build Environment

  • Qt 6.11.1 (MinGW 64-bit)
  • MinGW 13.1.0
  • zlib (statically linked, no additional DLL required)

Build Instructions

# Clean old build files
mingw32-make.exe clean

# Generate Makefile
qmake.exe ViewOSMMap.pro

# Build (8 threads)
mingw32-make.exe -j8

# Deploy Qt dependency DLLs
C:\Qt\6.11.1\mingw_64\bin\windeployqt.exe --compiler-runtime release\ViewOSMMap.exe

After building, the executable file is located at release/ViewOSMMap.exe.

Project Structure

├── main.cpp / mainwindow.*     # Main program entry and window UI
├── osmmodel.*                  # OSM data model (Node/Way/Relation)
├── osmparser.*                 # Parser abstract factory interface
├── osmpbfparser.*              # PBF binary format parser (built-in protobuf decoding)
├── osmstyle.*                  # Map style definitions (colors, line widths, levels)
├── osmmapwidget.*              # Map rendering core (QPainter drawing, tile caching)
├── osmquadtree.*               # Spatial index quadtree
├── osmsearch.*                 # Road search functionality
├── osmmapcss.*                 # MapCSS parser and style generation
├── osmevents.*                 # Event handling
├── map-style.mapcss            # MapCSS style configuration file (customizable)
└── release/                    # Build output directory (contains executable and Qt dependencies)

Usage

Basic Operations

  1. After launching the program, load .osm or .osm.pbf files via "File" → "Open"
  2. Use mouse scroll wheel to zoom, drag to pan the map
  3. Toggle layer visibility via toolbar buttons or keyboard shortcuts
  4. Use the search box to search for road names

Style Customization

The program supports customizing map styles via MapCSS files:

  1. Auto-load: On startup, the program automatically reads map-style.mapcss in the same directory as the executable. If the file doesn't exist, it automatically generates a default style file
  2. Load Custom Style: Load custom .mapcss or .css files via "Style" → "Load MapCSS Style" menu
  3. Export Style: Export current style to a file for editing via "Style" → "Export MapCSS Style" menu
  4. Restore Default: Reset to built-in hardcoded style via "Style" → "Restore Default Style" menu

MapCSS Style Properties Supported

  • fill-color / fill: Area fill color
  • fill-opacity: Area fill opacity (0.0-1.0)
  • color: Line body color
  • width: Line body width (px)
  • opacity: Line opacity (0.0-1.0)
  • casing-color: Road outline color
  • casing-width: Road outline width (px)
  • casing-opacity: Road outline opacity
  • dashes: Dash pattern, e.g., 8,6 means 8px solid + 6px gap
  • z-index: Layer drawing order
  • background-color: Canvas background color
  • Supports |zN- syntax to specify minimum display zoom level

Keyboard Shortcuts

Shortcut Function
Ctrl+O Open OSM file
Ctrl+S Export PNG image
Ctrl+Q Quit program
+/= Zoom in
- Zoom out
H Toggle roads display
B Toggle buildings display
W Toggle water display
G Toggle green space display
Shift+R Toggle railways display
L Toggle land use display
N Toggle nodes display

Default Style Color Reference

Feature Type Color Description
Background #f2efe9 Beige
Water #8cc8ff Light blue fill
Forest/Green #a0d28c / #beebaa Green tones
Buildings #dcbec8 Lavender
Residential #f5f0e6 Cream
Motorway #ff6432 Orange-red with dark red outline
Trunk #ff783c Orange with dark red outline
Primary #ffb450 Golden orange with brown outline
Secondary #ffdc64 Light yellow
Tertiary/Residential #dcdcdc / #f0f0f0 White/light gray
Footway/Cycleway #96dc96 Light green
Railway #787878 Gray dashed
Waterway #64b4ff Blue line
Administrative #c86464 Red dashed

About

ViewOSMMap is a lightweight Qt6-based viewer for OSM XML and PBF files. It features high-performance rendering, latitude correction, MapCSS styling and layer control for clean, pure local map visualization.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages