Simulateur Ferroviaire
Reconstruction et visualisation d'un réseau ferroviaire à partir de données GeoJSON — Win32 / WebView2 / Leaflet
Chargement...
Recherche...
Aucune correspondance
Référence de la classe TopologyRenderer

Utilitaire statique d'export de la topologie ferroviaire en GeoJSON. Plus de détails...

#include <TopologyRenderer.h>

Graphe de collaboration de TopologyRenderer:

Fonctions membres publiques statiques

static void exportToFile (const std::string &outputPath)
 Exporte la topologie ferroviaire dans un fichier GeoJSON.
 
static std::wstring loadGeoJsonToWebView ()
 Génère le script JavaScript d'injection GeoJSON dans le WebView.
 
static std::wstring renderStraightBlock (const StraightBlock &straightBlock)
 Construit l'appel JS renderStraightBlock(id, Coordinates) pour un bloc.
 
static std::wstring renderSwitchBlock (const SwitchBlock &sw)
 Construit l'appel JS renderSwitch(id, lat, lon, isDouble).
 
static std::wstring renderSwitchBranches (const SwitchBlock &sw)
 Construit l'appel JS renderSwitchBranches(...) pour un switch.
 
static std::wstring renderAllTopology ()
 Génère le script JS complet de rendu de toute la topologie.
 
static std::wstring updateSwitchBlocks (const SwitchBlock &sw)
 Génère le script JS de mise à jour visuelle d'un switch et ses partenaires.
 

Fonctions membres privées

 TopologyRenderer ()=delete
 

Fonctions membres privées statiques

static JsonDocument convertStraightToFeature (const StraightBlock &straight)
 Convertit un StraightBlock en feature GeoJSON de type LineString.
 
static JsonDocument convertSwitchToFeature (const SwitchBlock &switchBlock)
 Convertit un SwitchBlock en feature GeoJSON de type Point.
 
static std::wstring escapeForJavaScript (const std::string &input)
 Échappe une chaîne JSON pour l'injection dans JavaScript.
 

Description détaillée

Utilitaire statique d'export de la topologie ferroviaire en GeoJSON.

Convertit :

Usage :

static void exportToFile(const std::string &outputPath)
Exporte la topologie ferroviaire dans un fichier GeoJSON.
Definition TopologyRenderer.cpp:188

Documentation des constructeurs et destructeur

◆ TopologyRenderer()

TopologyRenderer::TopologyRenderer ( )
privatedelete

Documentation des fonctions membres

◆ convertStraightToFeature()

JsonDocument TopologyRenderer::convertStraightToFeature ( const StraightBlock straight)
staticprivate

Convertit un StraightBlock en feature GeoJSON de type LineString.

Paramètres
straightBloc à convertir.
Renvoie
Objet JSON représentant la feature GeoJSON.

◆ convertSwitchToFeature()

JsonDocument TopologyRenderer::convertSwitchToFeature ( const SwitchBlock switchBlock)
staticprivate

Convertit un SwitchBlock en feature GeoJSON de type Point.

Paramètres
switchBlockBloc à convertir.
Renvoie
Objet JSON représentant la feature GeoJSON.

◆ escapeForJavaScript()

std::wstring TopologyRenderer::escapeForJavaScript ( const std::string &  input)
staticprivate

Échappe une chaîne JSON pour l'injection dans JavaScript.

Paramètres
inputChaîne JSON brute.
Renvoie
Chaîne échappée prête à être insérée dans un string JS.

Caractères échappés :

  • " → \"
  • \ → \

  • → \n
  • \r → \r
  • \t → \t

◆ exportToFile()

void TopologyRenderer::exportToFile ( const std::string &  outputPath)
static

Exporte la topologie ferroviaire dans un fichier GeoJSON.

Paramètres
outputPathChemin du fichier de sortie.

◆ loadGeoJsonToWebView()

std::wstring TopologyRenderer::loadGeoJsonToWebView ( )
static

Génère le script JavaScript d'injection GeoJSON dans le WebView.

Renvoie
Instruction window.loadGeoJson(...) prête pour executeScript.

◆ renderAllTopology()

std::wstring TopologyRenderer::renderAllTopology ( )
static

Génère le script JS complet de rendu de toute la topologie.

Produit en une seule passe :

  1. clearStraightBlocks() + renderStraightBlock() × N + zoomToStraights()
  2. clearSwitchBranches() + renderSwitchBranches() × M (switches orientés)
  3. clearSwitches() + renderSwitch() × M

Remplace les trois anciens renderAll*() par un point d'entrée unique destiné à MainWindow::onParsingSuccess().

Renvoie
Script JS complet — un seul executeScript() suffit.

◆ renderStraightBlock()

std::wstring TopologyRenderer::renderStraightBlock ( const StraightBlock straightBlock)
static

Construit l'appel JS renderStraightBlock(id, Coordinates) pour un bloc.

Paramètres
straightBlockBloc à rendre (ignoré si < 2 coordonnées).
Renvoie
Instruction JavaScript.

◆ renderSwitchBlock()

std::wstring TopologyRenderer::renderSwitchBlock ( const SwitchBlock sw)
static

Construit l'appel JS renderSwitch(id, lat, lon, isDouble).

Paramètres
swSwitchBlock à rendre.
Renvoie
Instruction JavaScript.

◆ renderSwitchBranches()

std::wstring TopologyRenderer::renderSwitchBranches ( const SwitchBlock sw)
static

Construit l'appel JS renderSwitchBranches(...) pour un switch.

Émet les coordonnées de la jonction et des trois tips CDC. Un tip absent (nullopt) est encodé comme NaN,NaN et silencieusement ignoré côté JavaScript.

Signature JS : renderSwitchBranches(id, jLat, jLon, rootCoordinates, // [[lat,lon],...] ou null normalCoordinates, // [[lat,lon],...] ou null devCoordinates) // [[lat,lon],...] ou null

Pour les branches simples (non absorbées) : tableau à 1 point [tip]. Pour les branches absorbées (double switch) : polyligne complète. null si le tip est absent.

Paramètres
swSwitchBlock orienté.
Renvoie
Instruction JavaScript : Retourne une chaîne vide si le switch n'est pas orienté...

◆ updateSwitchBlocks()

std::wstring TopologyRenderer::updateSwitchBlocks ( const SwitchBlock sw)
static

Génère le script JS de mise à jour visuelle d'un switch et ses partenaires.

Appelé par MainWindow::onSwitchClick() après toggleActiveBranch(). Propage automatiquement aux partenaires double switch si présents.

Paramètres
swSwitch dont l'état vient d'être modifié.
Renvoie
Série d'appels window.switchApplyState() prête pour executeScript().

La documentation de cette classe a été générée à partir des fichiers suivants :