A switch (rozjazd) is a relation on a through niweleta, not a niweleta - the through track is never split. It marks the theoretical point on the through centreline; two tangent lines cross there (the through heading and that heading turned by the crossing mark 1:n), and the internal diverging curve is fitted to round the corner between them, reusing the same GapFitter the gap fits go through. So the curve is free: a plain arc, or a łuk koszowy right inside the switch. The theoretical tangent lengths and the curve length follow from it and are read off, not set. The branch niweleta's leaving straight is now locked to the frog: it starts at the frog and runs along the frog heading every solve, only its length is the user's. That enforces tangency no matter what is drawn, and because the first straight is pinned tangent, any fit in the branch's first gap - including a basket - meets the switch tangentially by construction. solve_layout solves the niwelety and the switches together in two passes: solve, read each frog, pin the branches, solve again. Switches serialize as an ejuncs / ejunc section; older files without it still load. Typical Polish turnouts (rozjazdy zwyczajne) are offered as templates that set the crossing mark and radius together; the length each spans is computed from them (arc = R*atan(1/n)) and shown, so how long the switch is is known.
maj0sted
Statyczna biblioteka C++20 do obsługi edytora torowiska, zbudowana zgodnie z Domain-Driven Design (DDD).
Biblioteka dostarcza czysty model domenowy — bez zależności od UI, bazy danych czy frameworka. Warstwy aplikacji i infrastruktury podpina się do zdefiniowanych tu typów.
Model domenowy
maj0sted::domain
├── value_objects/ Value Objects (niezmienne, porównywane przez wartość)
│ ├── Crs układ odniesienia (kod EPSG), domyślnie EPSG:2180
│ └── CartesianPosition pozycja kartezjańska (x, y w jednostkach CRS)
└── MapProject projekt mapy — definiuje CRS dla wszystkich pozycji
Projekt mapy (MapProject) definiuje kartezjański układ odniesienia, w którym
wyrażane są wszystkie pozycje. Domyślnie jest to EPSG:2180 (PUWG 1992 /
Poland CS92), którego jednostką jest metr.
Szybki start
#include "maj0sted/maj0sted.hpp"
using namespace maj0sted::domain;
MapProject project; // domyślnie EPSG:2180
int epsg = project.crs().epsg(); // 2180
CartesianPosition p{500000.0, 300000.0}; // x, y w metrach
Pełniejszy przykład: examples/basic_editor.cpp.
Budowanie
Wymagania: kompilator C++20 (GCC 11+/Clang 14+/MSVC 19.3+) oraz CMake ≥ 3.20.
cmake -S . -B build # dodaj -G Ninja, jeśli masz ninja
cmake --build build
ctest --test-dir build --output-on-failure
./build/examples/maj0sted_example
Opcje CMake
| Opcja | Domyślnie | Znaczenie |
|---|---|---|
MAJ0STED_BUILD_TESTS |
ON |
buduj testy jednostkowe |
MAJ0STED_BUILD_EXAMPLES |
ON |
buduj przykłady |
MAJ0STED_WARNINGS_AS_ERRORS |
OFF |
traktuj ostrzeżenia jak błędy |
Użycie w innym projekcie
Po cmake --install build (albo przez add_subdirectory):
find_package(maj0sted REQUIRED)
target_link_libraries(twoj_target PRIVATE maj0sted::maj0sted)
Struktura projektu
maj0sted/
├── CMakeLists.txt
├── include/maj0sted/ nagłówki publiczne (API)
├── src/domain/ implementacje (.cpp)
├── tests/ testy jednostkowe (CTest, bez zależności)
├── examples/ przykłady użycia
└── cmake/ pliki pakietu find_package
Testy
Testy używają własnego, malutkiego frameworka (tests/check.hpp) — nie wymagają
żadnych zewnętrznych bibliotek. Każdy plik testowy to osobny plik wykonywalny
zwracający kod wyjścia dla CTest.
Licencja
Do uzupełnienia (np. MIT) — dodaj plik LICENSE.