
import fs from 'fs';
import shp from 'shpjs';
global.self = global;

const ZIP_PATH = 'public/daten/Windenergiebereiche-Regionalplanung-NRW_EPSG25832_Geodatabase.zip';

(async () => {
    try {
        console.log("Reading Zip...");
        const buffer = fs.readFileSync(ZIP_PATH);
        const geojson = await shp(buffer);

        if (Array.isArray(geojson)) {
            console.log("Found multiple features/files:", geojson.length);
            geojson.forEach(g => console.log(" - File:", g.fileName || 'unknown', "Features:", g.features.length));
        } else {
            console.log("Found single FeatureCollection. Features:", geojson.features.length);
        }
    } catch (e) {
        console.error("Error parsing ZIP:", e.message); // e.stack for more info
        if (e.message.includes("but-unzip")) console.log("Hint: This might be a GDB format which shpjs cannot read.");
    }
})();
