Skip to content

chore: Update topojson deps - #8188

Merged
camdecoster merged 11 commits into
mainfrom
cam/7922/update-topojson-deps
Dec 4, 2026
Merged

camdecoster merged 11 commits into
mainfrom
cam/7922/update-topojson-deps

Conversation

@camdecoster

@camdecoster camdecoster commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Description

Update the dependencies in the topojson subproject and fix a few bugs.

Closes #7922.

Changes

  • Update dependencies (this addresses a security vulnerability in an old Mapshaper dependency)
  • Refactor the scripts to be clearer
  • Combine polygons with same ISO code
  • Improve stitching near antimeridian
  • Update resulting maps

Screenshots

Before After
image image

Testing

  • Review the CI results
  • Be on main
  • Open Plotly devtools and paste the following snippet into browser devtools:
// Orange is the choropleth fill and green is land without fill
const panels = [
    { title: 'PRT, ESP: Azores, Madeira, Canaries', locations: ['PRT', 'ESP'], lon: [-32, 4], lat: [26, 45] },
    { title: 'ECU: Galápagos', locations: ['ECU'], lon: [-92.5, -75], lat: [-5.5, 2] },
    { title: 'PSE: West Bank', locations: ['PSE'], lon: [34, 35.8], lat: [31.1, 32.7] },
    { title: 'MUS: Diego Garcia (Chagos)', locations: ['MUS'], lon: [72.3, 72.55], lat: [-7.48, -7.22] },
    { title: 'BES: Saba, Sint Eustatius', locations: ['BES'], lon: [-63.35, -62.85], lat: [17.4, 17.7] },
    { title: 'FJI: eastern tip of Vanua Levu', locations: ['FJI'], lon: [179.6, 180.4], lat: [-16.5, -15.9], rotate: true },
    { title: 'FJI, scope oceania: Taveuni at 180°', locations: ['FJI'], lon: [179.75, 180.25], lat: [-17.05, -16.7], rotate: true, scope: 'oceania' }
];

const data = [];
const layout = { width: 1400, height: 750, margin: { t: 40, b: 10, l: 10, r: 10 }, annotations: [] };
panels.forEach(({ title, locations, lon, lat, rotate, scope = 'world' }, i) => {
    const geo = i ? `geo${i + 1}` : 'geo';
    const [col, row] = [i % 4, Math.floor(i / 4)];
    const x = [col * 0.25 + 0.01, col * 0.25 + 0.24];
    const y = row ? [0, 0.43] : [0.52, 0.95];
    data.push({ type: 'choropleth', geo, locations, z: locations.map(() => 1), showscale: false, colorscale: [[0, '#ff7f0e'], [1, '#ff7f0e']] });
    layout[geo] = {
        domain: { x, y },
        scope,
        resolution: 50,
        fitbounds: false,
        projection: { type: 'mercator', ...(rotate && { rotation: { lon: 180 } }) },
        lonaxis: { range: lon },
        lataxis: { range: lat },
        showland: true,
        landcolor: '#b7e4a1',
        showocean: true,
        oceancolor: '#cfe8ff'
    };
    layout.annotations.push({ text: title, x: (x[0] + x[1]) / 2, y: y[1], xref: 'paper', yref: 'paper', yanchor: 'bottom', showarrow: false });
});

Plotly.newPlot(Tabs.fresh(), data, layout);
  • Note that the other polygons with the same ISO codes aren't being filled in for the choropleths and Fiji has stitching issues
  • Switch to this branch
  • Run the snippet again
  • Note that the polygons are filled in and there aren't any Fiji stitching issues

Notes

@KoolADE85 KoolADE85 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good overall with one potential issue:
With the Azores now included (correctly) with Portugal, a map scoped to Europe now zooms out to include those islands, and I doubt that's what we want.

Map of Portugal:

Plotly.newPlot(gd,
  [{type: 'choropleth', locations: ['DEU', 'FRA', 'GBR', 'ITA', 'POL', 'ESP', 'PRT'], z: [1, 2, 3, 4, 5, 6, 7]}],
  {geo: {scope: 'europe', resolution: 50, showocean: true, showland: true}});

Image showing main on the left, this PR on the right:

pair-ocean50-europe7

@camdecoster

Copy link
Copy Markdown
Contributor Author

While that does look a bit odd, that's the correct result with fitbounds turned on (which is the default). With fitbounds off, the results look the same with the exception of the islands:

main PR
image image

If users don't like the fit, they can turn fitbounds off or choose their own extents. I'll add a note in the draftlog that describes how this change will affect fitbounds.

@KoolADE85 KoolADE85 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm good with this! 💃

@camdecoster
camdecoster merged commit 5a64d8d into main Dec 4, 2026
88 of 89 checks passed
@camdecoster
camdecoster deleted the cam/7922/update-topojson-deps branch December 4, 2026 20:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CHORE]: Update dependencies in topojson/, stackgl_modules/

2 participants