Skip to content

πŸš— A browser-based HD map editor for the Apollo autonomous driving platform.

Notifications You must be signed in to change notification settings

SakuraPuare/apollo-map-studio

Repository files navigation

πŸš— Apollo Map Studio

A browser-based HD map editor for the Apollo autonomous driving platform. Draw lanes, junctions, signals, and all other map elements visually, then export Apollo-compatible binary map files directly from your browser β€” no C++ toolchain required.

License Version


Why

Apollo requires three binary map files to operate:

File Purpose
base_map.bin Full HD map with all elements and metadata
sim_map.bin Downsampled version for Dreamview visualization
routing_map.bin Topological graph used by the routing module

Traditionally, generating these files requires the Apollo C++ build environment. Apollo Map Studio replaces that entire workflow with a web app β€” open it in a browser, draw your map, click Export.


Features

  • Interactive drawing β€” lanes, junctions, crosswalks, signals, stop signs, speed bumps, clear areas, parking spaces
  • Real-time boundary rendering β€” left/right lane boundaries computed and rendered as you draw, with correct dash styles per boundary type
  • Lane topology editor β€” connect predecessor/successor lanes, set left/right neighbors
  • Properties panel β€” edit speed limit, lane type, turn direction, boundary types per element
  • Binary export β€” produces all three Apollo .bin files in the browser via protobufjs
    • base_map.bin with full overlap computation (lane ↔ signal, crosswalk, junction, etc.)
    • sim_map.bin using the same downsampling algorithm as sim_map_generator.cc
    • routing_map.bin with node/edge costs matching topo_creator exactly
  • Binary import β€” load an existing base_map.bin and continue editing it
  • Undo / Redo β€” full history via Zustand temporal middleware
  • Layer toggles β€” show/hide any element type
  • Offline capable β€” blank map background, no tile server or external API needed

Tech Stack

Concern Library
Map rendering MapLibre GL
Drawing tools @mapbox/mapbox-gl-draw
Spatial math @turf/turf
Protobuf encode/decode protobufjs
Coordinate projection proj4 (WGS84 ↔ ENU)
State management Zustand + immer + zundo
Build Vite + TypeScript

Getting Started

# Clone and install
git clone https://github.com/SakuraPuare/apollo-map-studio
cd apollo-map-studio
npm install

# Start dev server
npm run dev

Open http://localhost:5173 in your browser.

First map

  1. Click New Project, enter a name and the origin coordinates (lat/lon) of your map area
  2. Select Draw Lane from the toolbar and click to place lane centerline points
  3. Double-click to finish drawing a lane
  4. Use the Properties panel on the right to set speed limit, type, boundary styles, etc.
  5. Select Connect Lanes to link predecessor/successor relationships between lanes
  6. Add junctions, signals, crosswalks, etc. using the corresponding toolbar buttons
  7. Click Export to download base_map.bin, sim_map.bin, and routing_map.bin

Import existing map

Click Import and drop a base_map.bin file. The editor will decode it and restore all elements for further editing.


Project Structure

src/
β”œβ”€β”€ types/
β”‚   β”œβ”€β”€ apollo-map.ts        # Apollo proto type mirrors (Map, Lane, Road, ...)
β”‚   β”œβ”€β”€ apollo-routing.ts    # Routing graph types (TopoNode, TopoEdge, ...)
β”‚   └── editor.ts            # GeoJSON-based editor types (LaneFeature, ...)
β”‚
β”œβ”€β”€ store/
β”‚   β”œβ”€β”€ mapStore.ts          # Map element state + actions (Zustand + immer + undo)
β”‚   └── uiStore.ts           # Draw mode, selection, layer visibility
β”‚
β”œβ”€β”€ geo/
β”‚   β”œβ”€β”€ projection.ts        # proj4: WGS84 ↔ ENU coordinate conversion
β”‚   β”œβ”€β”€ laneGeometry.ts      # turf: boundary offset, width sampling, headings
β”‚   └── overlapCalc.ts       # turf: lane/element intersection β†’ Overlap proto
β”‚
β”œβ”€β”€ proto/
β”‚   β”œβ”€β”€ loader.ts            # protobufjs: dynamic .proto loading
β”‚   └── codec.ts             # encode/decode Map + Graph, download as .bin
β”‚
β”œβ”€β”€ export/
β”‚   β”œβ”€β”€ buildBaseMap.ts      # Assemble full Apollo Map proto object
β”‚   β”œβ”€β”€ buildSimMap.ts       # Downsample (port of sim_map_generator.cc)
β”‚   └── buildRoutingMap.ts   # Build topo graph (port of topo_creator)
β”‚
β”œβ”€β”€ import/
β”‚   └── parseBaseMap.ts      # Decode base_map.bin β†’ editor GeoJSON state
β”‚
└── components/
    β”œβ”€β”€ MapEditor/            # MapLibre GL container, draw control, layer rendering
    β”œβ”€β”€ Toolbar/              # Draw mode buttons
    β”œβ”€β”€ PropertiesPanel/      # Per-element attribute forms
    β”œβ”€β”€ NewProjectDialog/     # Project name + origin coordinate setup
    β”œβ”€β”€ ExportDialog/         # Export all three .bin files
    β”œβ”€β”€ ImportDialog/         # Import base_map.bin
    └── StatusBar/            # Status messages and undo/redo controls

public/proto/                 # Apollo .proto files served statically

Export Accuracy

The export engine is a direct port of the Apollo C++ source:

  • sim_map.bin β€” replicates the DownsampleByAngle + DownsampleByDistance passes from points_downsampler.h
  • routing_map.bin β€” replicates node/edge cost formulas from node_creator.cc and edge_creator.cc:
    • Node cost: length Γ— √(base_speed / speed_limit) + turn penalty
    • Lane-change edge cost: 500 Γ— (changing_length / 50)^βˆ’1.5
    • Lane changes only allowed across dotted boundaries

Development

npm run dev          # start dev server with HMR
npm run build        # production build
npm run lint         # ESLint check
npm run lint:fix     # ESLint auto-fix
npm run format       # Prettier format all files
npm run format:check # Prettier check (CI)

Pre-commit hooks (Husky + lint-staged) run ESLint and Prettier automatically on every commit.


Roadmap

  • Road grouping UI (assign lanes to named roads)
  • Snap-to-endpoint when connecting lanes
  • Map validation report (orphan lanes, missing overlaps, ID conflicts)
  • OSM tile background option
  • Multi-select and bulk property editing
  • Export to Apollo text proto format (.txt) for inspection

License

MIT

Packages

No packages published

Contributors 2

  •  
  •  

Languages