Commit 2b5b7266 authored by Volker Krause's avatar Volker Krause
Browse files

Consider IFOPT platform ids for merging platform elements

Those will eventually also come in for reliably selecting the right
platform and dropping adjacent stops.
parent 9fe5d259
Pipeline #93562 passed with stage
in 17 seconds
......@@ -127,6 +127,16 @@ void Platform::setMode(Platform::Mode mode)
m_mode = mode;
}
QByteArray Platform::ifopt() const
{
return m_ifopt;
}
void Platform::setIfopt(const QByteArray &ifopt)
{
m_ifopt = ifopt;
}
static bool conflictIfPresent(OSM::Element lhs, OSM::Element rhs)
{
return lhs && rhs && lhs != rhs;
......@@ -256,6 +266,10 @@ static bool isOverlappingWay(const std::vector<OSM::Element> &lhs, const std::ve
bool Platform::isSame(const Platform &lhs, const Platform &rhs, const OSM::DataSet &dataSet)
{
if (!lhs.ifopt().isEmpty() && !rhs.ifopt().isEmpty()) {
return lhs.ifopt() == rhs.ifopt();
}
const auto isConnectedEdge = isConnectedGeometry(lhs.m_edge, rhs.m_edge, dataSet);
const auto isConnectedTrack = isConnectedWay(lhs.m_track, rhs.m_track, dataSet);
const auto isOverlappingTrack = isOverlappingWay(lhs.m_track, rhs.m_track);
......@@ -377,6 +391,7 @@ Platform Platform::merge(const Platform &lhs, const Platform &rhs, const OSM::Da
p.m_area = OSM::coalesce(lhs.m_area, rhs.m_area);
p.m_track = mergeWays(lhs.m_track, rhs.m_track);
p.m_level = lhs.hasLevel() ? lhs.m_level : rhs.m_level;
p.m_ifopt = lhs.ifopt().isEmpty() ? rhs.ifopt() : lhs.ifopt();
// TODO
p.m_mode = std::max(lhs.m_mode, rhs.m_mode);
......
......@@ -89,6 +89,10 @@ public:
Mode mode() const;
void setMode(Mode mode);
/** IFOPT identifier */
QByteArray ifopt() const;
void setIfopt(const QByteArray &ifopt);
// TODO - clean up once PlatformModel is ported to PlatformFinder
QStringList lines;
......@@ -111,6 +115,7 @@ private:
Mode m_mode = Rail; // TODO should eventually be "Unknown"
int m_level = std::numeric_limits<int>::min(); // INT_MIN indicates not set, needed for merging
std::vector<PlatformSection> m_sections;
QByteArray m_ifopt;
static void appendSection(std::vector<PlatformSection> &sections, const Platform &p, PlatformSection &&sec, std::vector<const OSM::Node*> &edgePath, const OSM::DataSet &dataSet);
static double maxSectionDistance(const Platform &p, const std::vector<PlatformSection> &sections, const OSM::DataSet &dataSet);
......
......@@ -71,13 +71,17 @@ std::vector<Platform> PlatformFinder::find(const MapData &data)
if (railway == "platform") {
QRegularExpression splitExp(QStringLiteral("[;,/\\+]"));;
const auto names = QString::fromUtf8(e.tagValue("local_ref", "ref")).split(splitExp);
for (const auto &name : names) {
const auto ifopts = e.tagValue("ref:IFOPT").split(';');
for (auto i = 0; i < names.size(); ++i) {
Platform platform;
platform.setArea(e);
platform.setName(name);
platform.setName(names[i]);
platform.setLevel(levelForPlatform((*it).first, e));
platform.setMode(modeForElement(e));
platform.setSections(sectionsForPath(e.outerPath(m_data.dataSet()), name));
platform.setSections(sectionsForPath(e.outerPath(m_data.dataSet()), names[i]));
if (ifopts.size() == names.size()) {
platform.setIfopt(ifopts[i]);
}
// we delay merging of platforms, as those without track names would
// otherwise cobble together two distinct edges when merged to early
m_platformAreas.push_back(std::move(platform));
......@@ -89,6 +93,7 @@ std::vector<Platform> PlatformFinder::find(const MapData &data)
platform.setName(QString::fromUtf8(e.tagValue("local_ref", "ref")));
platform.setLevel(levelForPlatform((*it).first, e));
platform.setSections(sectionsForPath(e.outerPath(m_data.dataSet()), platform.name()));
platform.setIfopt(e.tagValue("ref:IFOPT"));
addPlatform(std::move(platform));
}
else if (!railway.isEmpty() && e.type() == OSM::Type::Way && railway != "disused") {
......@@ -108,6 +113,7 @@ std::vector<Platform> PlatformFinder::find(const MapData &data)
platform.setLevel(levelForPlatform((*it).first, e));
platform.setName(Platform::preferredName(QString::fromUtf8(platform.stopPoint().tagValue("local_ref", "ref", "name")), nameFromTrack(e)));
platform.setMode(modeForElement(OSM::Element(&node)));
platform.setIfopt(platform.stopPoint().tagValue("ref:IFOPT"));
if (platform.mode() == Platform::Unknown) {
platform.setMode(modeForElement(e));
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment