Moin,
auch von mir vielen Dank für das nützliche Tool!
Ich hab mir zum Erleichtern von Surveys mal ein kleines Skript geschrieben, das die Punkte für einen Landkreis als CSV exportiert, das man dann wiederum in SCEE als custom quests importieren kann.
Vielleicht ist das ja auch für andere hier interessant. Das Skript muss auf der Unterseite des jeweiligen Landkreises in die Browser-Konsole eingefügt werden und lädt dann die entsprechende CSV-Datei herunter.
Die wiederum kann dann in SCEE importiert werden über: Settings → Quest selection and display order → Custom quest (fast ganz unten) → Zahnrad → Provide.
// Visit district page on addresses.tillb.de (e.g.
// https://addresses.tillb.de/addresses.html?state=nds&district=Stadt_Braunschweig) and paste this into the browser
// console to get the items exported as an SCEE custom quest JSON.
// Optionally pass `true` to the function below to omit items marked as completed.
await exportToScee();
function isset(n) {
return n != null && n !== 'nan' && n !== '';
}
function getCompleted() {
try {
const n = localStorage.getItem('osm_alkis_done_by_district');
return n ? JSON.parse(n) : {};
} catch (n) {
return (console.error('Error reading from localStorage', n), {});
}
}
function hasBeenCompleted(alkisId, district) {
if (!alkisId || !district) return !1;
const c = getCompleted()[district];
return c ? c.includes(alkisId) : !1;
}
function dumpObj(obj, filterEmpty = true) {
const entries = Object.entries(obj).filter((e) => isset(e[1]));
return entries.map((e) => e[0] + '=' + e[1]).join('; ');
}
function download(filename, text) {
const elem = document.createElement('a');
elem.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
elem.setAttribute('download', filename);
elem.click();
}
async function exportToScee(ignoreCompleted = false) {
const params = new URLSearchParams(window.location.search);
const state = params.get('state');
const district = params.get('district');
const geoJson = await fetch(`https://addresses.tillb.de/states/${state}/districts/${district}.geojson`).then((r) =>
r.json(),
);
const translations = {
missing: 'Existiert im ALKIS, fehlt in OSM',
wrong_street: 'Abweichender Straßenname',
corrected_osm: 'ALKIS korrigiert, in OSM gefunden',
corrected_not_osm: 'ALKIS korrigiert, fehlt in OSM',
ignored: 'ALKIS ignoriert',
done: 'Lokal als erledigt markiert',
};
const res = geoJson.features
.map((f) => ({
lat: f.geometry.coordinates[1],
lon: f.geometry.coordinates[0],
...f.properties,
}))
.map((d) => {
let type = 'missing';
if (isset(d.correction_type))
type =
d.correction_type === 'ignored'
? 'ignored'
: d.correction_type === 'wrong_street'
? 'wrong_street'
: d.matched
? 'corrected_osm'
: 'corrected_not_osm';
else if (d.matched) type = 'corrected_osm';
if (!ignoreCompleted && d.alkis_id && hasBeenCompleted(d.alkis_id, district)) type = 'done';
return {
...d,
type: type,
message: translations[type] + ': ' + d.street + ' ' + d.housenumber + ' :: Rohdaten: ' + dumpObj(d),
};
});
const csv = res
.map((r) => [r.lat, r.lon, r.message].map((c) => JSON.stringify(c).replace('\\"', "'")).join(','))
.join('\n');
download('scee-alkis-' + state + '-' + district + '-' + new Date().toISOString() + '.csv', csv);
}
Bei Interesse sollte sich so ein Export auch leicht direkt in das Tool integrieren lassen. Andersherum wäre es vielleicht auch eine Idee, das direkt als Quest in SCEE zu implementieren.
