Commit b4911486 authored by Volker Krause's avatar Volker Krause
Browse files

Also consider stations inside terminal buildings outside the airport bounds

This can happen when terminal buildings overlap the airport bounds. Fixes
CPH for example.
parent 91b4705e
...@@ -217,7 +217,7 @@ private Q_SLOTS: ...@@ -217,7 +217,7 @@ private Q_SLOTS:
QTest::addColumn<float>("lon"); QTest::addColumn<float>("lon");
QTest::addColumn<int>("dist"); QTest::addColumn<int>("dist");
QTest::newRow("AGP") << s("AGP") << 36.67764f << -4.49017f << 50; QTest::newRow("AGP") << s("AGP") << 36.67608f << -4.49095f << 100;
QTest::newRow("AMS") << s("AMS") << 52.3095230f << 4.7621813f << 50; QTest::newRow("AMS") << s("AMS") << 52.3095230f << 4.7621813f << 50;
QTest::newRow("ARN") << s("ARN") << 59.64927f << 17.92956f << 100; QTest::newRow("ARN") << s("ARN") << 59.64927f << 17.92956f << 100;
QTest::newRow("BLR") << s("BLR") << 13.20023f << 77.70972f << 150; QTest::newRow("BLR") << s("BLR") << 13.20023f << 77.70972f << 150;
...@@ -292,9 +292,7 @@ private Q_SLOTS: ...@@ -292,9 +292,7 @@ private Q_SLOTS:
qDebug() << coord.latitude << coord.longitude << d; qDebug() << coord.latitude << coord.longitude << d;
#if 0 #if 0
QEXPECT_FAIL("AGP", "terminal proximity station finding not implemented yet", Continue);
QEXPECT_FAIL("BUD", "not optimized yet", Continue); QEXPECT_FAIL("BUD", "not optimized yet", Continue);
QEXPECT_FAIL("CPH", "terminal proximity station finding not implemented yet", Continue);
QEXPECT_FAIL("DEN", "not optimized yet", Continue); QEXPECT_FAIL("DEN", "not optimized yet", Continue);
QEXPECT_FAIL("DUS", "not optimized yet", Continue); QEXPECT_FAIL("DUS", "not optimized yet", Continue);
QEXPECT_FAIL("FRA", "terminal proximity station finding not implemented yet", Continue); QEXPECT_FAIL("FRA", "terminal proximity station finding not implemented yet", Continue);
......
...@@ -279,15 +279,25 @@ void OSMAirportDb::loadStation(const OSM::Node &elem) ...@@ -279,15 +279,25 @@ void OSMAirportDb::loadStation(const OSM::Node &elem)
} }
for (auto it = m_iataMap.begin(); it != m_iataMap.end(); ++it) { for (auto it = m_iataMap.begin(); it != m_iataMap.end(); ++it) {
const auto &airport = (*it).second;
// we need the exact path here, the bounding box can contain a lot more stuff // we need the exact path here, the bounding box can contain a lot more stuff
// the bounding box check is just for speed // the bounding box check is just for speed
if (!OSM::contains((*it).second.bbox, elem.coordinate) if (!OSM::contains(airport.bbox, elem.coordinate)) {
|| !(*it).second.airportPolygon.containsPoint(QPointF(elem.coordinate.latF(), elem.coordinate.lonF()), Qt::WindingFill))
{
continue; continue;
} }
//qDebug() << "found station for airport:" << elem.url() << (*it).first << (*it).second.source;
(*it).second.stations.push_back(elem.coordinate); const auto onPremise = airport.airportPolygon.containsPoint(QPointF(elem.coordinate.latF(), elem.coordinate.lonF()), Qt::WindingFill);
// one would assume that terminals are always within the airport bounds, but that's not the case
// they sometimes expand beyond them. A station inside a terminal is however most likely something relevant for us
const auto inTerminal = std::any_of(airport.terminalBboxes.begin(), airport.terminalBboxes.end(), [&elem](const auto &terminal) {
return OSM::contains(terminal, elem.coordinate);
});
if (onPremise || inTerminal) {
//qDebug() << "found station for airport:" << elem.url() << (*it).first << (*it).second.source;
(*it).second.stations.push_back(elem.coordinate);
}
} }
} }
......
Markdown is supported
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