31 lines
1.1 KiB
JavaScript
31 lines
1.1 KiB
JavaScript
const fs = require('fs');
|
|
|
|
async function findLines() {
|
|
const data = JSON.parse(fs.readFileSync('Geodaten/project.json', 'utf8'));
|
|
const results = [];
|
|
|
|
function search(obj, path = '') {
|
|
if (!obj || typeof obj !== 'object') return;
|
|
|
|
if (obj.type === 'Feature' && obj.geometry && (obj.geometry.type === 'LineString' || obj.geometry.type === 'MultiLineString')) {
|
|
results.push({ path, properties: obj.properties });
|
|
} else if (obj.type === 'FeatureCollection' && obj.features) {
|
|
obj.features.forEach((f, i) => search(f, `${path}.features[${i}]`));
|
|
} else {
|
|
for (const key in obj) {
|
|
if (key !== 'features') {
|
|
search(obj[key], `${path}.${key}`);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
search(data, 'root');
|
|
console.log(`Found ${results.length} line features:`);
|
|
results.forEach((r, i) => {
|
|
console.log(`[${i}] Path: ${r.path}, Properties:`, JSON.stringify(r.properties));
|
|
});
|
|
}
|
|
|
|
findLines().catch(err => console.error(err));
|