function calculateIntersectionArea(target) {
let intersects = indicator.features.filter((feature) =>
turf.booleanIntersects(target, feature)
);
let totalWeight = 0;
intersects = intersects
.map((i) => {
const intersect = turf.intersect(i, target);
let intersectArea = 0;
let weight = 0;
if (intersect) {
intersectArea = turf.area(intersect);
weight = (intersectArea / turf.area(i)) * i.properties.population;
totalWeight += weight;
}
return {
...i.properties,
intersectArea,
weight
};
})
.filter((i) => i.intersectArea);
return {
...target.properties,
totalWeight,
intersects
};
}