add open plaques

This commit is contained in:
Tykayn 2025-04-18 15:34:53 +02:00 committed by tykayn
parent e33aecb565
commit a79be23ccd
8 changed files with 114916 additions and 29 deletions

View file

@ -8,7 +8,7 @@
* npx ts-node csv_to_geojson.ts -d etalab_data/panneaux -f panneaux_limite_de_vitesse_fr_panoramax_detections.csv --latColumn 'GPSLatitude' --lonColumn 'GPSLongitude' -h
*
*/
import fs from 'fs';
import fs, { writeFile } from 'fs';
import path from 'path';
import minimist from 'minimist';
import { csvToGeoJSON, checkFile, countGeoJSONFeatures } from './csv_to_geojson.utils';
@ -20,9 +20,9 @@ const args = minimist<CSVConversionOptions>(process.argv.slice(2), {
alias: {
dir: 'd', // dossier source
file: 'f', // fichier source
// infos pour un fichier CSV en source au lieu d'un fichier geojson
latColumn: 'lat', // colonne latitude
lonColumn: 'lon', // colonne longitude
wktColumn: 'wkt', // Nouvelle alias pour la colonne WKT
hasHeaders: 'h', // headers présents
},
default: {
@ -32,5 +32,15 @@ const args = minimist<CSVConversionOptions>(process.argv.slice(2), {
checkFile(args);
csvToGeoJSON(args);
let geojsonContent = csvToGeoJSON(args);
// Construire le chemin de sortie dans le même dossier que le fichier source
const outputPath = path.join(args.dir, `${args.file}.geojson`);
// Écrire le fichier GeoJSON
fs.writeFileSync(outputPath, JSON.stringify(geojsonContent, null, 2));
console.log(`Fichier GeoJSON créé: ${outputPath}`);
countGeoJSONFeatures(args);