✨ Internal train network structure
- Defines Network, StopArea, StopPoints and JourneySections - Loads them from json using the build_from_json method
This commit is contained in:
parent
27c5a55400
commit
61aec3d856
9 changed files with 1877 additions and 0 deletions
54
lib/trenesis/network/graph.h
Normal file
54
lib/trenesis/network/graph.h
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
#pragma once
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
#include "trenesis/geojson.h"
|
||||
|
||||
namespace trenesis {
|
||||
using json = nlohmann::json;
|
||||
|
||||
struct StopPoint;
|
||||
|
||||
struct StopArea {
|
||||
std::string id;
|
||||
std::string label;
|
||||
std::string name;
|
||||
Point coord;
|
||||
|
||||
std::unordered_map<std::string, std::unique_ptr<StopPoint>> stop_points;
|
||||
|
||||
StopArea(std::string id, std::string label, std::string name, Point coord);
|
||||
};
|
||||
|
||||
struct JourneySection {
|
||||
StopPoint* origin;
|
||||
StopPoint* destination;
|
||||
// TODO: use real types for times
|
||||
std::string departure_time;
|
||||
std::string arrival_time;
|
||||
};
|
||||
|
||||
struct StopPoint {
|
||||
std::string id;
|
||||
std::string label;
|
||||
std::string name;
|
||||
Point coord;
|
||||
StopArea* stop_area;
|
||||
|
||||
std::vector<JourneySection> departures;
|
||||
|
||||
StopPoint(
|
||||
std::string id,
|
||||
std::string label,
|
||||
std::string name,
|
||||
Point coord,
|
||||
StopArea* stop_area
|
||||
);
|
||||
};
|
||||
|
||||
struct Network {
|
||||
std::unordered_map<std::string, std::unique_ptr<StopArea>> stop_areas;
|
||||
|
||||
static Network build_from_json(const json& vehicle_journeys, const json& stop_points);
|
||||
};
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue