V1.1.1 //
-> Patch du bug du logo de l'horaire pas affiché. Corrigé pour les Horaires TER à 6 numéros.
This commit is contained in:
1 parent
06cce59f82
commit
eb198cc727
9 files changed
+270
-186
No files matched your search
@@ -0,0 +1,77 @@
|
||||
const fs = require('fs');
|
||||
let content = fs.readFileSync('src/utils/trainLogoHelper.js', 'utf8');
|
||||
|
||||
if (!content.includes('import { resolveRegionByNumber }')) {
|
||||
content = "import { resolveRegionByNumber } from './gtfsRegionalRanges';\n" + content;
|
||||
}
|
||||
|
||||
const targetStart = " // Application du plan de num";
|
||||
const startIndex = content.indexOf(targetStart);
|
||||
if (startIndex !== -1) {
|
||||
const newLogic = ` let isCar = opNorm.includes('car') || opNorm.includes('autocar') || opNorm.includes('bus');
|
||||
let isSubstitution = false;
|
||||
let brand = typeLabel;
|
||||
|
||||
// 4. Application du plan de numérotation déterministe depuis GTFS (nouveau moteur)
|
||||
if ((typeLabel === 'TER' || typeLabel === 'AUTOCAR' || typeLabel === 'Car TER' || typeLabel === 'Car' || typeLabel === 'Autocar' || opRaw.toUpperCase().includes('CAR')) && numTrain) {
|
||||
const regionMatch = resolveRegionByNumber(numTrain);
|
||||
if (regionMatch) {
|
||||
if (regionMatch.isCar) {
|
||||
isCar = true;
|
||||
typeLabel = 'Car TER'; // Forcer l'affichage CAR
|
||||
}
|
||||
if (regionMatch.isSubstitution) {
|
||||
isSubstitution = true;
|
||||
}
|
||||
|
||||
brand = regionMatch.brand;
|
||||
|
||||
// Affiner le typeLabel selon la marque si train
|
||||
if (!isCar) {
|
||||
switch (brand) {
|
||||
case 'FLUO': typeLabel = 'FLUO'; break;
|
||||
case 'TER HDF': typeLabel = 'TER HDF'; break;
|
||||
case 'NOMAD': typeLabel = 'NOMAD'; break;
|
||||
case 'BREIZHGO': typeLabel = 'BREIZHGO'; break;
|
||||
case 'ALEOP': typeLabel = 'ALÉOP'; break;
|
||||
case 'REMI': typeLabel = 'RÉMI'; break;
|
||||
case 'TER NA': typeLabel = 'TER NA'; break;
|
||||
case 'LIO': typeLabel = 'LiO'; break;
|
||||
case 'ZOU': typeLabel = 'ZOU !'; break;
|
||||
case 'MOBIGO': typeLabel = 'MOBIGO'; break;
|
||||
case 'TER AURA': typeLabel = 'TER AURA'; break;
|
||||
default: typeLabel = 'TER';
|
||||
}
|
||||
}
|
||||
|
||||
// Tenter de charger le logo SVG de la marque si ce n'est pas un car
|
||||
if (!isCar) {
|
||||
const slugMatch = logoLookup.get(brand.toLowerCase().replace(/[^a-z]/g, ''));
|
||||
if (slugMatch) {
|
||||
matchedLogo = slugMatch;
|
||||
} else if (brand === 'TER AURA') {
|
||||
matchedLogo = logoLookup.get('terrhonealpes');
|
||||
} else if (brand === 'TER NA') {
|
||||
matchedLogo = logoLookup.get('teraquitaine');
|
||||
} else if (brand === 'TER HDF') {
|
||||
matchedLogo = logoLookup.get('hautsdefrance');
|
||||
}
|
||||
} else {
|
||||
// Pour les cars régionaux, on associe l'icône de car
|
||||
matchedLogo = logoLookup.get('trackcar') || { file: 'track-car.svg', name: 'Car TER' };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const logoFile = (matchedLogo && matchedLogo.file) || (isCar ? 'track-car.svg' : 'sncf-voyageurs-logo.png');
|
||||
const logoSrc = \`/type/\${logoFile}\`;
|
||||
|
||||
return { logoSrc, typeLabel, numTrain, isCar, isSubstitution, brand };
|
||||
}
|
||||
`;
|
||||
|
||||
content = content.substring(0, startIndex) + newLogic;
|
||||
fs.writeFileSync('src/utils/trainLogoHelper.js', content, 'utf8');
|
||||
} else {
|
||||
console.log('Target block not found');
|
||||
}
|
||||
Reference in new issue
Block a user