Commit 0829e295 authored by Volker Krause's avatar Volker Krause
Browse files

Generate lookup tables for Amtrak and IATA train station codes as well

parent cdcbfdb3
......@@ -13,6 +13,8 @@ add_executable(generate-knowledgedb
util.cpp
../lib/stringutil.cpp
../lib/knowledgedb/airportnametokenizer.cpp
../lib/knowledgedb/alphaid.cpp
../lib/knowledgedb/iatacode.cpp
../lib/knowledgedb/stationidentifier.cpp
)
target_compile_definitions(generate-knowledgedb PRIVATE "KITINERARY_STATIC_DEFINE")
......
......@@ -38,6 +38,8 @@ bool TrainStationDbGenerator::generate(QIODevice *out)
|| !fetch("P722", "uic", m_uicMap)
|| !fetch("P8181", "sncf", m_sncfIdMap)
|| !fetch("P8448", "benerail", m_benerailIdMap)
|| !fetch("P238", "iata", m_iataMap)
|| !fetch("P4803", "amtrak", m_amtrakMap)
|| !fetchIndianRailwaysStationCode()
|| !fetchFinishStationCodes()
) {
......@@ -64,6 +66,8 @@ namespace KnowledgeDb {
writeIdMap(out, m_uicMap, "uic", "UICStation");
writeIdMap(out, m_sncfIdMap, "sncfStationId", "SncfStationId");
writeIdMap(out, m_benerailIdMap, "benerail", "BenerailStationId");
writeIdMap(out, m_iataMap, "iata", "IataCode");
writeIdMap(out, m_amtrakMap, "amtrak", "AmtrakStationCode");
writeIndianRailwaysMap(out);
writeVRMap(out);
out->write(R"(
......@@ -98,7 +102,7 @@ bool TrainStationDbGenerator::fetch(const char *prop, const char *name, std::map
}
const auto uri = insertOrMerge(stationObj);
const auto idStr = stationObj.value(QLatin1String("id")).toObject().value(QLatin1String("value")).toString();
const auto idStr = stationObj.value(QLatin1String("id")).toObject().value(QLatin1String("value")).toString().toUpper();
const auto id = Id(idStr);
if (!id.isValid()) {
++m_idFormatViolations;
......@@ -397,6 +401,8 @@ void TrainStationDbGenerator::printSummary()
qDebug() << "Benerail station code index:" << m_benerailIdMap.size() << "elements";
qDebug() << "Indian Railwaiys station code index:" << m_indianRailwaysMap.size() << "elements";
qDebug() << "VR (Finland) station code index:" << m_vrfiMap.size() << "elements";
qDebug() << "IATA location code index:" << m_iataMap.size() << "elements";
qDebug() << "Amtrak station code index:" << m_amtrakMap.size() << "elements";
qDebug() << "Identifier collisions:" << m_idConflicts;
qDebug() << "Identifier format violations:" << m_idFormatViolations;
qDebug() << "Coordinate conflicts:" << m_coordinateConflicts;
......
......@@ -8,6 +8,7 @@
#include <knowledgedb.h>
#include <stationidentifier.h>
#include <iatacode.h>
#include <QByteArray>
#include <QString>
......@@ -63,6 +64,8 @@ private:
std::map<KnowledgeDb::BenerailStationId, QUrl> m_benerailIdMap;
std::map<QString, QUrl> m_indianRailwaysMap;
std::map<KnowledgeDb::VRStationCode, QUrl> m_vrfiMap;
std::map<KnowledgeDb::IataCode, QUrl> m_iataMap;
std::map<KnowledgeDb::AmtrakStationCode, QUrl> m_amtrakMap;
int m_idConflicts = 0;
int m_idFormatViolations = 0;
......
......@@ -7,6 +7,8 @@
#pragma once
#include "kitinerary_export.h"
#include "alphaid.h"
#include "knowledgedb.h"
class QString;
......@@ -120,6 +122,8 @@ private:
}
};
/** Amtrak staion codes. */
using AmtrakStationCode = AlphaId<uint16_t, 3>;
}
}
......@@ -7,9 +7,11 @@
#pragma once
#include "kitinerary_export.h"
#include "stationidentifier.h"
#include "countrydb.h"
#include "iatacode.h"
#include "knowledgedb.h"
#include "stationidentifier.h"
#include <cstdint>
......
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