Overview
Mapper is a desktop map of any city, written in C++ in one semester. Beside the 2D map, search, and directions is a 3D viewer that rebuilds the city from open data, lit by the real sun at any hour.
The Brief
Mapper began as the ECE297 (Software Design & Communication) project at the University of Toronto, where every team builds the same map application on OpenStreetMap in four milestones: fast spatial queries, a searchable 2D map, pathfinding, and a travelling salesman problem.
The milestones are graded against the same tests, so the algorithms had to be fast. But a map that only answers “how do I get there” can’t tell you what a place looks like, what you’ll see from it, or whether the terrace faces the sunset. So on top of the required work, the team built a 3D viewer that rebuilds the city under the real sun, and tied it to the map.
The 3D Viewer
The viewer works in three stages: acquisition gathers the city from open data, processing turns it into meshes and textures, and rendering draws it under a sun placed for the chosen hour.
Acquisition
Buildings, roads, areas, and trees from OpenStreetMap, elevation from ArcGIS, and the sun’s position from NREL SPA.
Processing
GLM turns that data into building meshes, complex roofs, landmarks, billboarded trees, and texture assignments.
Rendering
OpenGL and GLSL shaders draw the sky, sun, and buildings, lit for the time of day, in perspective or top down.
Buildings, Roads, and Areas
Every OpenStreetMap building is extruded from its footprint to its tagged height, roads are laid down as geometry, and parks, water, and plazas become coloured surfaces. That alone shows what a 2D map can’t: which towers are tall, and where the city is dense.

Terrain
Hills decide sightlines. On a flat city, a spot that overlooks the water in real life looks into the side of a building, so the ground is a terrain mesh sampled from ArcGIS elevation data. That created the first real problem: OpenStreetMap areas arrive as flat polygons, and draping them over the terrain puts two surfaces in nearly the same place. The GPU can’t tell which is in front, so they flicker through each other as the camera moves. That is z-fighting, and at city scale it covers everything.
Laid over
Cut inThe fix was to cut instead of layer. Each area’s outline is cut into the elevation mesh, and the area’s own mesh is set into the hole, following the ground. With one surface at every point, there is nothing left to fight.
Cutting exposed the next problem: some water polygons overlap the shore, and cutting them in faithfully flooded parts of the city. Rules for which area wins left a mesh that holds up at street level, where pedestrian mode walks on it.


Landmarks and Complex Roofs
People navigate by landmarks, and landmarks are rarely boxes. OpenStreetMap describes them as parts, pieces with their own building:levels, min_level, height, and min_height, stacked into the real shape. A tower on a podium, a bridge between blocks, and a spire are all parts.
24 m5 floors
16 m121
- building:levels=7
- height=24
- building:levels=7
- building:min_level=5
- height=24
- min_height=16
Each part’s roof:shape is built too, from flat and gabled to dome and onion. Level of detail follows the camera: a distant part is a plain block, and gains its real roof as you approach.
Roof shape, from roof:shape
Level of detail, from the camera’s distance
Parts and roofs are what turn a field of extrusions into places people recognise.
Forbidden City
Seoul Tower
Art Gallery of Ontario
ChaotianmenTime of Day
Light is most of what makes a render feel like a place. On startup, the viewer gives NREL’s Solar Position Algorithm the city’s latitude and longitude and the chosen date and time, and gets back where the sun really is and how strong it is. That drives a Hosek-Wilkie sky model, evaluated from precomputed coefficients, which colours the whole sky.
On startup
Place and timeToronto, any date and hourNREL SPA
Sun positionElevation and azimuthHosek-Wilkie
Sky colourFrom precomputed coefficientsGLSL
Sky drawn, city litBy the sky’s average colourThe sky does double duty. Its average colour lights the buildings, so the city is warm at sunset, white at noon, and blue after dusk, without anyone picking a colour.
Midday
DuskTrees
A city needs thousands of trees, and a real tree mesh has thousands of triangles. Instead, each tree is a billboard: three textured quads crossed through each other, which read as a full tree from any angle at a fraction of the cost. Trees go wherever OpenStreetMap marks one and are scattered across woods and natural areas, each with a random size, rotation, and tilt so a forest doesn’t look stamped.



* Size is only randomised when OpenStreetMap has no age for the tree.
Street level
From the airGround and Building Textures
Solid colours tell buildings apart but don’t make them believable. Walls take a facade texture from the building’s material tag, glass, brick, or concrete, and the areas cut into the terrain take ground textures of their own.
Mesh
Buildings, with roof parts
building:material
Facade texture
To the screen
GLSL
Mesh
Terrain, with areas set in
area tags
Ground texture
Each area cut into the terrain takes a texture of its own
Flat colour
TexturedShading
Two shader choices do most of the work. The first is smooth shading. With one normal per face, a curve shows every triangle, and the only fix is more triangles. Interpolating normals across vertices shades a coarse mesh as if it were smooth, moving the cost from geometry, where it is expensive, to the fragment shader, where it is nearly free.
Face normals
Vertex normals
Faceted
SmoothThe second is Blinn-Phong lighting, built in layers. Sunlight alone turns every shaded side black, where the real atmosphere bounces light back in, so an ambient term fakes the bounce. That still looks matte, so a specular highlight fakes reflection. Three cheap terms read as a lit city.
Sun only
+ Ambient
+ SpecularPerformance
Every choice above was made against one number. Nielsen puts the limit for feeling responsive at a tenth of a second; past it, you are waiting on the program instead of using it. Three principles kept the renderer inside it:
Balance detail
Spend detail where the eye is: real roofs up close, plain blocks far away, and billboards instead of tree meshes.
Cheat
Approximate and precompute: the sky comes from stored coefficients, bounced light is one ambient term, and smoothness is interpolated normals.
Cull
Don’t draw what the camera can’t see.
At 1920×1080, scenes up to about two million triangles hold 60 frames a second, and 5.3 million triangles of Toronto hold 27. The worst case, 12.3 million triangles of Tokyo, still averages 12, with its slowest frames inside the tenth-of-a-second line.
Scenes by triangle count
60 / 56
60 / 54
60 / 54
38 / 34
27 / 24
19 / 18
12 / 11
fps
The 2D Map
The 2D map is where most people start, so it had to feel like a modern map app, not a course assignment. Three tabs, Navigate, Explore, and Directions, sit beside the map, and one button opens the 3D viewer at the same spot.
Custom Styling
The interface is styled with CSS instead of the toolkit’s defaults: rounded inputs, one blue for primary actions, and quiet secondary buttons across the whole panel. The panel’s logic is kept apart from its presentation, MVVM style, so the look can change without touching behaviour.
Find intersection
Route planner
Places Nearby
The Explore tab lists places near where you’re looking and narrows them to a type, such as restaurants, with one dropdown. The list sits beside the map on purpose: Fitts’s law says the time to reach a target grows with its distance. Clicking a result pans the map to it and labels it, so you never hunt for something on the map that you already found in the list.
Explore nearby
The Black Briik
restaurant
Prague Restaurant
restaurant
Pi Co.
restaurant
Harry’s Charbroiled
restaurant
The Fourth Man in the Fire
restaurant
California Sandwiches
restaurant
Drom Taberna
restaurant
Map Algorithms
Under the interface are the algorithm milestones, graded on speed as much as correctness.
Spatial Quadtree
The first milestone is a question the map asks constantly: which intersection is closest to this point? Checking every one works for a town and falls over for a city, so intersections are indexed in a quadtree. The map is split into quadrants, and any quadrant with too many points is split again until each holds only a few. A query checks the region its point falls in first, opens a neighbouring region only if it could hold something closer, and skips the rest unopened.
Home region
Where the query point falls. Its few intersections are checked first.
Neighbours
Opened only where the search circle reaches into them.
Closest
Found without opening the rest of the map.
Against a brute-force scan, the quadtree’s query time stays nearly flat as the city grows, while the scan’s grows linearly. At 65,500 intersections it is 146 to 294 times faster, fastest on a clustered downtown.
Median query latency
intersections indexed
Speedup over brute force at 65.5k intersections
The fairer comparison is a regular grid. There the quadtree is 1.2 times faster on a clustered downtown and along street corridors, even on a uniform city, and 0.7 times as fast on a perfect grid, where the grid’s cells already match the data. Real cities are clustered, so the quadtree earns its complexity where it counts.
Pathfinding
The third milestone, routing, runs on A* search. Roads are explored in order of travel time so far plus an estimate of the time left, obeying one-way rules and charging for every turn, until the destination is reached. The route is then rebuilt from the saved steps.
Explored
Opened in order of time so far plus an estimate of the time left, so the search leans toward the goal.
Route
Rebuilt from the saved steps once the goal is reached.
One-way streets
Followed only in the direction they run. The thick road is faster, so it costs less.
The estimate is straight-line distance over the map’s fastest speed limit, which never overestimates, so the route found is always the fastest. Most of the speed came from caching each segment’s travel time and each intersection’s neighbours instead of recomputing them on every search.
Impossible routes, across water or into a closed-off area, get a clear message instead of a hang or a nonsense path.
Error
No route found between selected intersections.
Intelligent Directions
Real trips are rarely one mode. Mapper can plan a walk plus drive: you walk to a pickup point, within a speed and time limit you set, and are driven from there. It finds every intersection you can reach on foot in that time, then runs one A* search from all of them at once instead of one per candidate, which keeps it fast.
The Directions tab turns either route into turn-by-turn steps, with the total distance and time at the top. The same two endpoints give different instructions depending on whether you walk part of the way.
Step 1 of 5
Start on Queen’s Park and go straight for 109 m.
Step 1 of 4
Start on College Street and go straight for 376 m.
Courier Optimisation
The fourth milestone is the travelling courier problem: the travelling salesman problem with pickups and drop-offs. The courier must find the cheapest route that collects every package before delivering it, within a fixed time budget. Trying every order is hopeless; the count explodes long before the list gets long.
The approach follows Johnson and McGeoch’s work on the problem. Build a valid route greedily, always going to the nearest legal stop, then improve it until the time runs out, trying small changes and keeping the best route seen. Simulated annealing decides which changes to accept, taking some worse routes early to escape local minima and growing strict as time runs down.
Start with a greedy route
Precompute travel times between every pair of stops
- 3
Try a small change to the route
- 4
Decide whether it helps
Return the best route seen
Three things raise the quality. A good greedy start leaves less ground to cover. Precomputed travel times between every pair of stops make each candidate a lookup instead of a pathfinding run. And several threads explore more changes in the same time. Annealing cut the greedy route’s cost by 25.2% within a 47.5-second budget.
Route cost improvement over the greedy start
A Walk in Toronto
The pieces matter most together. Take a real errand: finding a rooftop restaurant in Toronto with a view of the sunset.
On the 2D map, Explore filters nearby places to restaurants, and picking one opens the 3D viewer over its building.


The walking route crosses the rail corridor, and a flat map doesn’t show where. The viewer’s overview mode shows the textured city from directly above, beside the route, and the crossing is obvious.
Overview modePedestrian mode then walks the route at street height. Towers close in, and the CN Tower appears as the route crosses the tracks, something you would otherwise only learn by going.




The trip is for the view. From the rooftop, the tower next door blocks the southeast and the south, and only the southwest is open.
Southeast
South
SouthwestMoving the clock to evening settles it: the sun sets behind the neighbouring building. The terrace would sit in shadow with its view blocked, and no flat map could have warned you.


Back to search. KOST, another rooftop downtown, gets the same check at the same hour.



Search, the handoff to 3D, routing, pedestrian mode, and the sun each carried part of that errand, and together they answered a question ordinary maps can’t.
Pitch and Vision
The project’s goal was to make urban environments easier to understand and explore, through realistic renders of any city at any time. The test is whether a render matches the real place, so the team checked it against their own photos from earlier trips.
Render
Photo
Render
PhotoApple Maps is the obvious comparison. Its 3D mode shows nothing in Chongqing, and Look Around has real photos only where a camera car has driven, frozen at the moment they were taken. Neither can show you a view at sunset in December. Mapper can, anywhere OpenStreetMap has buildings.


Nothing is tied to Toronto. The same pipeline renders any city in the data, with its own terrain, landmarks, and sky.






Improvements
The next steps deepen the same product in three directions: better data, higher fidelity, and more interactivity.
Data Sources
OpenStreetMap is excellent at buildings and poor at everything else. Some of the world’s most recognisable landmarks aren’t buildings: in Rio de Janeiro, Christ the Redeemer is missing from its mountain. Hand-made meshes for landmarks like it would fill the gaps.
Rio de Janeiro
Model meshTransit is the other gap. Streetcar rails and schedules and the VIA and GO lines are missing from both the render and routing. Adding them would put transit in directions, and the rail corridor from the walk would finally show its tracks.

Visual Fidelity
The renders are realistic; the next step is photorealistic. Physically based rendering would make the Art Gallery of Ontario’s glass reflect the street as it does in person, instead of reading as a flat blue wall.
Render
PhotoShadow maps are the other half. For a question like “will this terrace be in the sun”, shadows are the answer, and beside ShadowMap at noon, the render lights streets that are really in shade.
Mapper
ShadowMapInteractivity
A sunset spot is only a sunset spot if it isn’t raining. Weather would answer the question after “where is the view”: is it worth going tonight?
MockupMoving vehicles would add what a rendered city most obviously lacks: life. In some cities transit is part of the identity, like Toronto’s red streetcars and San Francisco’s cable cars.
Mockup
San FranciscoOpportunities
The renderer is useful well beyond maps. The first opening is a digital twin for planners and architects: a live model of a city where you can add or change a building and see its effect at once, on sightlines, shadows, and the skyline. Digital twins are among the fastest-growing markets in software, estimated at around 41% a year, and cities already use them to plan for climate and change.
Proposed tower
Google EarthThe second is simulation: flight, driving, and disaster planning. Photorealistic renders plus flight controls and physics make a flight simulator, and even Microsoft Flight Simulator players have found Toronto’s CN Tower missing. The same engine fits urban air mobility research, where drone and air-taxi projects already build simulations on game engines, and a growing market of flight simulation enthusiasts and pilots.
Mapper
Flight SimulatorThe Real Goal
The project began with a goal about maps: make urban environments easier to understand and explore. Seen through a planner placing a tower, or a pilot learning an approach over a city they have never flown, it is a narrower version of a larger one.
Make spatial intelligence more accessible. Knowing what a place is like, what you’ll see from it, when the sun reaches it, and what changes if something is built beside it has always meant being there or paying for expensive tools. Mapper is a first step toward that for any city, at any hour, on an ordinary laptop.