MCPcopy Create free account
hub / github.com/plotly/plotly.js / addCentroidsToGeojson

Function addCentroidsToGeojson

topojson/bin/process_geodata.mjs:48–60  ·  view source on GitHub ↗
(geojsonPath)

Source from the content-addressed store, hash-verified

46}
47
48function addCentroidsToGeojson(geojsonPath) {
49 const geojson = getJsonFile(geojsonPath);
50 if (!geojson.features) return;
51
52 const features = geojson.features.map((feature) => {
53 const centroid = getCentroid(feature);
54 feature.properties.ct = centroid;
55
56 return feature;
57 });
58
59 fs.writeFileSync(geojsonPath, JSON.stringify({ ...geojson, features }));
60}
61
62// Wind the polygon rings in the correct direction to indicate what is solid and what is whole
63const rewindGeojson = (geojson, clockwise = true) => rewind(geojson, clockwise);

Callers 2

createCountriesLayerFunction · 0.85
createSubunitsLayerFunction · 0.85

Calls 2

getJsonFileFunction · 0.85
getCentroidFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…