center = {
const center = { p2006: [0, 0], p2011: [0, 0], p2018: [0, 0], p2021: [0, 0] };
let tot2006 = 0;
let tot2011 = 0;
let tot2018 = 0;
let tot2021 = 0;
for (let c of cells) {
tot2006 += c.TOT_P_2006;
tot2011 += c.TOT_P_2011;
tot2018 += c.TOT_P_2018;
tot2021 += c.TOT_P_2021;
const pos = getPosition(c.GRD_ID);
center.p2006[0] += c.TOT_P_2006 * pos.x;
center.p2006[1] += c.TOT_P_2006 * pos.y;
center.p2011[0] += c.TOT_P_2011 * pos.x;
center.p2011[1] += c.TOT_P_2011 * pos.y;
center.p2018[0] += c.TOT_P_2018 * pos.x;
center.p2018[1] += c.TOT_P_2018 * pos.y;
center.p2021[0] += c.TOT_P_2021 * pos.x;
center.p2021[1] += c.TOT_P_2021 * pos.y;
}
center.p2006[0] /= tot2006;
center.p2006[1] /= tot2006;
center.p2011[0] /= tot2011;
center.p2011[1] /= tot2011;
center.p2018[0] /= tot2018;
center.p2018[1] /= tot2018;
center.p2021[0] /= tot2021;
center.p2021[1] /= tot2021;
return center;
}