Modelling an airport while it is being rebuilt

Most of an airport in Chronotopia is one OpenStreetMap outline per building, with a year it was built and, sometimes, a year it was pulled down. That was enough for El Prat and Ibiza. Palma de Mallorca broke it in a few places, because when we modelled it, in October 2026, the terminal was in the last months of a four-year remodel and the 1997 building had pieces from three different decades.

This article is about the engine changes Palma needed: cutting one outline into pieces with their own heights and dates, timing those pieces separately, tying stands and airlines to one module, and drawing a railway that only exists as a list of stations. Palma de Mallorca airport, rebuilt in the middle of its remodel covers the history and the figures; this one is about the code. All of it is in the repository’s main branch at commit a73a57f.

One outline, several buildings

OpenStreetMap often draws a large building as a single polygon, with one height. Palma’s terminal is a good example: the main building is one outline, but behind the landside canopy the roof steps down to a 54 m strip at 21 m, and the main roof is at 26 m. A single extrusion at either height is wrong.

Each site module can give an OSM feature a split function. It receives the polygon’s rings and returns pieces, each with optional h, built, demolished and style. For the terminal, the cut is a box in the site’s local metres, and polygon-clipping does the geometry. From scripts/sites/palma.mjs:

split: (rings) => [
  ...polygonClipping.intersection(rings, [ring(box(1470, 1531, -686, -990))]).map((rs) => ({ rings: rs, h: 21, style: { plant: false } })),
  ...polygonClipping.difference(rings, [ring(box(1470, 1531, -686, -990))]).map((rs) => ({
    rings: rs, h: 26,
    style: {
      marks: [BRG + 90, BRG - 90, BRG].flatMap((facing) => [
        { facing, shape: 'square', y: 23.5, size: 1.1, every: 4.5, color: '#2a2f33' },
        { facing, shape: 'tri', y: 15, size: 1.8, every: 9, color: '#24282b' },
      ]),
    },
  })),
],

The intersection is the low strip; the difference is everything else, at 26 m, with the rows of small square windows and dark triangles that the aerial views show on its walls. scripts/build-site.mjs turns each piece into its own feature, with the id way/…#0, #1 and so on, and drops any piece under 20 m², because cutting along the outline’s own edges leaves slivers.

Pieces that die at different times

Heights were the first use. Dates were the second, and they exposed a bug.

Module C opened with the terminal in 1997. In 2009-2010 it was extended south over the site of the old Terminal B, and a new pier, a tall blue-green glass hall with six jet bridges, took over its north strip. In the model the pier is a hand-drawn feature, module-c-pier-2010, and Module C’s outline is split so that the part under the pier is demolished in 2010:

split: (rings) => [
  ...polygonClipping.intersection(rings, [MODC_HALL]).map((rs) => ({ rings: rs, demolished: 2010 })),
  // Off the hall: the jet bridges' links (small pieces off its north face) on posts. Slivers left
  // by the cut, and the strip past the hall's east end, are dropped.
  ...polygonClipping.difference(rings, [MODC_HALL]).flatMap((rs) => {
    const a = areaM2(rs[0]);
    if (a >= 400) return [{ rings: rs }];
    if (a < 25 || a > 120) return [];
    return [{ rings: rs, h: 7.8, built: 2010, style: { /* small white links on posts */ } }];
  }),
],

Simplified from scripts/sites/palma.mjs: the style of the links is shortened. The pieces between 25 and 120 m² are the small links where the jet bridges dock, built in 2010; larger ones are the 1997 module; anything else is a sliver.

The data was right, and Module C still disappeared in 2010, label and all. In src/engine/sceneBuilder.ts, the pieces of one OSM feature were grouped into a single scene item, so that a building split by height kept one label and one card. The group took its dates from its first piece, and Module C’s first piece was the strip demolished in 2010.

The fix, in commit 68efac1, groups pieces by building and by span of years:

// Pieces of one OSM feature (a building split by height) stay one item per span of years, since
// pieces can be built or pulled down on their own; the largest carries the building's label.
const key = `piece ${p.osm} ${p.built} ${p.demolished}`;

That leaves several items per building, and only one should carry the label. After the items are built, the one with the largest total area keeps it and the rest are marked unlabelled:

const area = b.feats.reduce((s, f) => s + (f.properties.area ?? 0), 0);
const best = labelled.get(b.osm);
if (!best) labelled.set(b.osm, { area, item });
else if (area > best.area) {
  best.item.unlabelled = true;
  labelled.set(b.osm, { area, item });
} else item.unlabelled = true;

Now Module C has three lives in one outline: the 1997 gate rooms that stay, the strip that goes in 2010, and the links that arrive with the pier. Its label sits on the largest of them in every year.

Stands that belong to a module

Aircraft at El Prat and Ibiza park on stands the engine finds along the apron edges of each terminal. That doesn’t work for Palma’s Module B, the inter-island module opened in 2003: it has no jet bridges, its apron side is glass, and four stands sit in a row in front of it, used by regional turboprops whose passengers walk out.

Palma’s site.json describes that in its traffic block:

"terminalAirlines": { "B": ["airnostrum", "aireuropa/atr72"] },
"fixedStands": {
  "B": {
    "at": [[2.731757, 39.549929], [2.732234, 39.549929], [2.732714, 39.549929], [2.733186, 39.549929]],
    "heading": 186
  }
},
"exclusiveTerminals": ["B"],
"walkTerminals": ["B"],
"based": { "aireuropa": 2.5 },

Excerpt from public/sites/palma/site.json. Each key does one thing:

The same keys are generic. El Prat uses terminalAirlines to keep Vueling and Iberia at T1 and the low-cost airlines at T2.

A railway that is only a list of stations

The Palma–Airport–Llucmajor railway was approved by the Balearic government on 15 April 2026: 30 km, about 10 of them in tunnel, works from 2028 to 2032. The approved study gives the stations by address and nothing else we could find. The model draws three lines, each a proposed feature dated 2032 with approx: true and a width of 14 m:

The stations come from the published addresses. The line between them is a spline through hand-placed points, and each card says the route is estimated.

The first version was invisible. Built railways are drawn as a track with sleepers and rails, and planned ones used the same geometry, hatched: a 5 m track that disappeared from the default camera distance. Commit d73ce11 made a planned line a plain band of its own width instead:

// A planned line is a plain hatched band, wide enough to read from afar; built ones get sleepers and rails.
if (p.kind === 'rail' && p.status !== 'proposed') {
  if (g.type !== 'LineString') return null;
  const t = track(g.coordinates.map((c) => this.proj.toVec3(c)), TRACK_WIDTH);
  return t && this.terrain.drape(t);
}

From src/engine/sceneBuilder.ts. A proposed rail falls through to the generic ribbon used for roads and taxiways, at p.width, and gets the same translucent blue as every planned feature. The same commit added a 2032 milestone, after DORA III’s 2031, so there is a stop on the timeline from which the whole line is in view, and moved the end of Palma’s timeline from 2031 to 2032.

What the engine still can’t say

The runway work in a runway is one line and two fractions went the other way: one feature that changes over time instead of several features with their own dates. Between the two, most of what an airport does to itself in a century can be described with a few dated numbers.