Initial mock-up cache tool
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
// Copyright (c) 2026 Elizabeth Cray
|
||||
const fs = require('fs');
|
||||
require('dotenv').config();
|
||||
|
||||
const osmData = JSON.parse(fs.readFileSync('osm_data.json', 'utf8'));
|
||||
|
||||
const geoJsonTemplate = {
|
||||
type: "FeatureCollection",
|
||||
features: [],
|
||||
};
|
||||
|
||||
if (osmData && osmData.elements && osmData.elements.length > 0) {
|
||||
osmData.elements.forEach(element => {
|
||||
if (element.type === 'node' && element.lat && element.lon) {
|
||||
geoJsonTemplate.features.push({
|
||||
type: "Feature",
|
||||
geometry: {
|
||||
type: "Point",
|
||||
coordinates: [element.lon, element.lat],
|
||||
},
|
||||
properties: element.tags || {},
|
||||
});
|
||||
}
|
||||
});
|
||||
fs.writeFileSync('osm_data.geojson', JSON.stringify(geoJsonTemplate, null, 2));
|
||||
}
|
||||
Reference in New Issue
Block a user