// Wählt die Netze aus, deren Kontrolle außerhalb der EU belegt sein soll. Nur diese tragen die Mindestanteile der Studie. // Ergebnis: daten/netze/nichteu-liste.json und nichteu-stapel-.json import { readFileSync, writeFileSync } from 'node:fs'; import { dirname, join } from 'node:path'; import { fileURLToPath } from 'node:url'; const hier = dirname(fileURLToPath(import.meta.url)); const pfad = (d) => join(hier, 'daten', d); const STAPEL = 4; const EU = new Set('AT BE BG HR CY CZ DK EE FI FR DE GR HU IE IT LV LT LU MT NL PL PT RO SK SI ES SE'.split(' ')); const netze = JSON.parse(readFileSync(pfad('netze/netze-klassifiziert.json'), 'utf8')); const liste = new Map(JSON.parse(readFileSync(pfad('netze/liste.json'), 'utf8')).map((e) => [String(e.asn), e])); const belegt = (x) => ['hoch', 'mittel'].includes(x.sicherheit) && x.kontroll_land && !String(x.anmerkung ?? '').startsWith('KONTROLLE OFFEN') && (x.mutter || x.sitz_land === x.kontroll_land); const auswahl = netze.filter((x) => belegt(x) && !EU.has(x.kontroll_land)).map((x) => ({ asn: String(x.asn), as_name: liste.get(String(x.asn))?.as_name ?? null, gemeinden_web: liste.get(String(x.asn))?.gemeinden_web ?? 0, gemeinden_dns: liste.get(String(x.asn))?.gemeinden_dns ?? 0, rechtstraeger: x.rechtstraeger, sitz_land: x.sitz_land, mutter: x.mutter, kontroll_land: x.kontroll_land, typ: x.typ, belege: x.belege, anmerkung: x.anmerkung, })).sort((a, b) => (b.gemeinden_web + b.gemeinden_dns) - (a.gemeinden_web + a.gemeinden_dns)); writeFileSync(pfad('netze/nichteu-liste.json'), JSON.stringify(auswahl, null, 1)); for (let s = 0; s < STAPEL; s++) writeFileSync(pfad(`netze/nichteu-stapel-${s + 1}.json`), JSON.stringify(auswahl.filter((_, i) => i % STAPEL === s), null, 1)); console.log(JSON.stringify({ netze: auswahl.length, jeStapel: auswahl.filter((_, i) => i % STAPEL === 0).length }));