function normalizeWindingInPlace(p) {
console.warn(
"The normalizeWindingInPlace is deprecated and will be removed by Jan 2024. See https://observablehq.com/@fil/normalize-winding"
);
const g = p.geometry || p;
if (p.type === "FeatureCollection") {
p.features = p.features.map(normalizeWindingInPlace);
} else if (p.type === "GeometryCollection") {
p.geometries = p.geometries.map(normalizeWindingInPlace);
} else if (g.type === "MultiPolygon") {
g.coordinates = g.coordinates.map((poly) =>
poly.map((ring, i) =>
(i > 0) ^
(d3.geoArea({ type: "Polygon", coordinates: [ring] }) > 2 * Math.PI)
? ring.reverse()
: ring
)
);
} else if (g.type === "Polygon") {
g.coordinates = g.coordinates.map((ring, i) =>
(i > 0) ^
(d3.geoArea({ type: "Polygon", coordinates: [ring] }) > 2 * Math.PI)
? ring.reverse()
: ring
);
}
return p;
}