dedsWithMatches = {
const manualMatches = await FileAttachment("manual-ded-matches-2024-02-29.csv").csv();
const codeToMatch = d3.group(manualMatches, (d) => d.code);
return dedsWithFuzzyMatches.map((d) => {
if (d.matches.length > 0) return d;
if (!codeToMatch.has(d.code)) return d;
const match = codeToMatch.get(d.code)[0];
if (!match.url) return d;
const osmId = match.url.match(/[^/]+$/)[0];
if (osmId === null) return d;
dedsGeojson.features.forEach((f) => {
if (f.properties.id === parseInt(osmId)) {
if (f.properties.cantabularCode?.length) {
console.log('Warning: already matched');
console.log('- ', f.properties.id, f.properties.name, f.properties.normalisedLabel);
console.log('- ', f.properties.cantabularCode, f.properties.cantabularLabel, f.properties.matchType);
}
f.properties.matchType = 'manual';
f.properties.cantabularCode = d.code;
f.properties.cantabularLabel = d.label;
d.matches.push(f);
}
});
return d;
});
}