mirror of
https://codeberg.org/comaps/comaps
synced 2026-01-01 10:33:45 +00:00
[core] Switch to ankerl::unordered_dense
Signed-off-by: x7z4w <x7z4w@noreply.codeberg.org>
This commit is contained in:
@@ -11,9 +11,10 @@
|
||||
#include <cstring>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include "3party/ankerl/unordered_dense.h"
|
||||
|
||||
#include "cppjansson/cppjansson.hpp"
|
||||
|
||||
namespace transit
|
||||
@@ -21,7 +22,7 @@ namespace transit
|
||||
namespace experimental
|
||||
{
|
||||
using OsmIdToFeatureIdsMap = std::map<base::GeoObjectId, std::vector<FeatureId>>;
|
||||
using EdgeIdToFeatureId = std::unordered_map<EdgeId, uint32_t, EdgeIdHasher>;
|
||||
using EdgeIdToFeatureId = ankerl::unordered_dense::map<EdgeId, uint32_t, EdgeIdHasher>;
|
||||
// Functions for parsing one line of line-by-line json and creating corresponding item in container.
|
||||
void Read(base::Json const & obj, std::vector<Network> & networks);
|
||||
void Read(base::Json const & obj, std::vector<Route> & routes);
|
||||
|
||||
@@ -38,7 +38,8 @@ using TransitLinesInfoPT = std::map<::transit::TransitId, ::transit::experimenta
|
||||
using TransitLinesMetadataInfoPT = std::map<::transit::TransitId, ::transit::experimental::LineMetadata>;
|
||||
using TransitRoutesInfoPT = std::map<::transit::TransitId, ::transit::experimental::Route>;
|
||||
using TransitNetworksInfoPT = std::map<::transit::TransitId, ::transit::experimental::Network>;
|
||||
using TransitEdgesInfoPT = std::unordered_map<::transit::EdgeId, ::transit::EdgeData, ::transit::EdgeIdHasher>;
|
||||
using TransitEdgesInfoPT =
|
||||
ankerl::unordered_dense::map<::transit::EdgeId, ::transit::EdgeData, ::transit::EdgeIdHasher>;
|
||||
struct TransitDisplayInfo
|
||||
{
|
||||
::transit::TransitVersion m_transitVersion;
|
||||
|
||||
@@ -16,10 +16,10 @@
|
||||
#include <limits>
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
#include "3party/ankerl/unordered_dense.h"
|
||||
|
||||
#include "3party/opening_hours/opening_hours.hpp"
|
||||
|
||||
namespace routing
|
||||
@@ -43,7 +43,7 @@ inline std::string const kTransfersFile = "transfers" + kTransitFileExtension;
|
||||
inline std::string const kGatesFile = "gates" + kTransitFileExtension;
|
||||
|
||||
// Route types shown on the subway layer.
|
||||
inline std::unordered_set<std::string> const kSubwayLayerTypes{"subway", "train", "light_rail", "monorail"};
|
||||
inline ankerl::unordered_dense::set<std::string> const kSubwayLayerTypes{"subway", "train", "light_rail", "monorail"};
|
||||
|
||||
// Unique id for transit entities. It is generated by gtfs_converter and is persistent between
|
||||
// re-runs. Generated based on the unique string hash of the GTFS entity. Lies in the interval
|
||||
@@ -53,7 +53,7 @@ using TransitId = uint32_t;
|
||||
inline TransitId constexpr kInvalidTransitId = std::numeric_limits<TransitId>::max();
|
||||
|
||||
// Mapping of language id to text. Language id exists in |StringUtf8Multilang::kLanguages|.
|
||||
using Translations = std::unordered_map<std::string, std::string>;
|
||||
using Translations = ankerl::unordered_dense::map<std::string, std::string>;
|
||||
|
||||
struct TimeFromGateToStop
|
||||
{
|
||||
@@ -72,8 +72,8 @@ struct TimeFromGateToStop
|
||||
};
|
||||
|
||||
using IdList = std::vector<TransitId>;
|
||||
using IdSet = std::unordered_set<TransitId>;
|
||||
using TimeTable = std::unordered_map<TransitId, std::vector<TimeInterval>>;
|
||||
using IdSet = ankerl::unordered_dense::set<TransitId>;
|
||||
using TimeTable = ankerl::unordered_dense::map<TransitId, std::vector<TimeInterval>>;
|
||||
using EdgeWeight = uint32_t;
|
||||
|
||||
// Link to the shape: shape id and indexes in the corresponding polyline.
|
||||
@@ -136,7 +136,7 @@ struct EdgeIdHasher
|
||||
}
|
||||
};
|
||||
|
||||
using IdEdgeSet = std::unordered_set<EdgeId, EdgeIdHasher>;
|
||||
using IdEdgeSet = ankerl::unordered_dense::set<EdgeId, EdgeIdHasher>;
|
||||
|
||||
struct EdgeData
|
||||
{
|
||||
|
||||
@@ -10,10 +10,11 @@
|
||||
#include <ctime>
|
||||
#include <map>
|
||||
#include <tuple>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "3party/ankerl/unordered_dense.h"
|
||||
|
||||
#include "3party/just_gtfs/just_gtfs.h"
|
||||
|
||||
// This is the implementation of the Schedule class and its helpers for handling transit service
|
||||
@@ -205,8 +206,8 @@ private:
|
||||
std::map<TimeInterval, Frequency> m_intervals;
|
||||
};
|
||||
|
||||
using DatesIntervals = std::unordered_map<DatesInterval, FrequencyIntervals, DatesIntervalHasher>;
|
||||
using DatesExceptions = std::unordered_map<DateException, FrequencyIntervals, DateExceptionHasher>;
|
||||
using DatesIntervals = ankerl::unordered_dense::map<DatesInterval, FrequencyIntervals, DatesIntervalHasher>;
|
||||
using DatesExceptions = ankerl::unordered_dense::map<DateException, FrequencyIntervals, DateExceptionHasher>;
|
||||
|
||||
// Line schedule with line service days (as DatesInterval ranges) and exceptions in service days
|
||||
// (as DateException items). For each date there are frequency intervals (time ranges with headway
|
||||
|
||||
@@ -20,9 +20,10 @@
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include "3party/ankerl/unordered_dense.h"
|
||||
|
||||
#include "3party/opening_hours/opening_hours.hpp"
|
||||
|
||||
namespace routing
|
||||
@@ -159,7 +160,7 @@ public:
|
||||
}
|
||||
|
||||
template <class K, class V, class H>
|
||||
void operator()(std::unordered_map<K, V, H> const & container, char const * /* name */ = nullptr)
|
||||
void operator()(ankerl::unordered_dense::map<K, V, H> const & container, char const * /* name */ = nullptr)
|
||||
{
|
||||
WriteVarUint(m_sink, static_cast<uint64_t>(container.size()));
|
||||
for (auto const & [key, val] : container)
|
||||
@@ -341,7 +342,7 @@ public:
|
||||
}
|
||||
|
||||
template <class K, class V, class H>
|
||||
void operator()(std::unordered_map<K, V, H> & container, char const * /* name */ = nullptr)
|
||||
void operator()(ankerl::unordered_dense::map<K, V, H> & container, char const * /* name */ = nullptr)
|
||||
{
|
||||
auto const size = static_cast<size_t>(ReadVarUint<uint64_t>(m_source));
|
||||
for (size_t i = 0; i < size; ++i)
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "3party/ankerl/unordered_dense.h"
|
||||
|
||||
namespace transit
|
||||
{
|
||||
@@ -16,7 +17,7 @@ public:
|
||||
std::string GetNearestColor(std::string const & rgb);
|
||||
|
||||
private:
|
||||
std::unordered_map<std::string, std::string> m_colorsToNames;
|
||||
ankerl::unordered_dense::map<std::string, std::string> m_colorsToNames;
|
||||
std::map<std::string, dp::Color> m_drapeClearColors;
|
||||
};
|
||||
} // namespace transit
|
||||
|
||||
@@ -466,7 +466,7 @@ void SubwayConverter::MinimizeReversedLinesCount()
|
||||
}
|
||||
|
||||
std::vector<LineSchemeData> SubwayConverter::GetLinesOnScheme(
|
||||
std::unordered_map<TransitId, LineSegmentInRegion> const & linesInRegion) const
|
||||
ankerl::unordered_dense::map<TransitId, LineSegmentInRegion> const & linesInRegion) const
|
||||
{
|
||||
// Color of line to shape link and one of line ids with this link.
|
||||
std::map<std::string, std::map<ShapeLink, TransitId>> colorsToLines;
|
||||
|
||||
@@ -15,15 +15,15 @@
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "3party/ankerl/unordered_dense.h"
|
||||
#include "3party/opening_hours/opening_hours.hpp"
|
||||
|
||||
namespace transit
|
||||
{
|
||||
using LineIdToStops = std::unordered_map<TransitId, IdList>;
|
||||
using LineIdToStops = ankerl::unordered_dense::map<TransitId, IdList>;
|
||||
// Converts public transport data from the MAPS.ME old transit.json format (which contains only
|
||||
// subway data) to the new line-by-line jsons used for handling data extracted from GTFS.
|
||||
class SubwayConverter
|
||||
@@ -50,7 +50,7 @@ private:
|
||||
// the route with same shapeLink. We keep only one of them. These line ids are used in
|
||||
// |PrepareLinesMetadata()|.
|
||||
std::vector<LineSchemeData> GetLinesOnScheme(
|
||||
std::unordered_map<TransitId, LineSegmentInRegion> const & linesInRegion) const;
|
||||
ankerl::unordered_dense::map<TransitId, LineSegmentInRegion> const & linesInRegion) const;
|
||||
// Finds common overlapping (parallel on the subway layer) segments on polylines. Motivation:
|
||||
// we shouldn't draw parallel lines of different routes on top of each other so the user can’t
|
||||
// tell which lines go where (the only visible line is the one that is drawn last). We need these
|
||||
@@ -79,7 +79,7 @@ private:
|
||||
// Destination feed for converted items from subway.
|
||||
WorldFeed & m_feed;
|
||||
// Mapping of subway stop id to transit stop id.
|
||||
std::unordered_map<routing::transit::StopId, TransitId> m_stopIdMapping;
|
||||
ankerl::unordered_dense::map<routing::transit::StopId, TransitId> m_stopIdMapping;
|
||||
// Subset of the |m_graphData| edges with no transfers.
|
||||
std::map<routing::transit::Edge, uint32_t> m_edgesSubway;
|
||||
// Subset of the |m_graphData| edges with transfers.
|
||||
|
||||
@@ -200,8 +200,9 @@ struct StopOnShape
|
||||
size_t m_index = 0;
|
||||
};
|
||||
|
||||
std::optional<size_t> GetStopIndex(std::unordered_map<transit::TransitId, std::vector<size_t>> const & stopIndexes,
|
||||
transit::TransitId id, size_t fromIndex, transit::Direction direction)
|
||||
std::optional<size_t> GetStopIndex(
|
||||
ankerl::unordered_dense::map<transit::TransitId, std::vector<size_t>> const & stopIndexes, transit::TransitId id,
|
||||
size_t fromIndex, transit::Direction direction)
|
||||
{
|
||||
auto it = stopIndexes.find(id);
|
||||
CHECK(it != stopIndexes.end(), (id));
|
||||
@@ -218,7 +219,7 @@ std::optional<size_t> GetStopIndex(std::unordered_map<transit::TransitId, std::v
|
||||
}
|
||||
|
||||
std::optional<std::pair<StopOnShape, StopOnShape>> GetStopPairOnShape(
|
||||
std::unordered_map<transit::TransitId, std::vector<size_t>> const & stopIndexes,
|
||||
ankerl::unordered_dense::map<transit::TransitId, std::vector<size_t>> const & stopIndexes,
|
||||
transit::StopsOnLines const & stopsOnLines, size_t index, size_t fromIndex, transit::Direction direction)
|
||||
{
|
||||
auto const & stopIds = stopsOnLines.m_stopSeq;
|
||||
@@ -264,7 +265,7 @@ Link::Link(transit::TransitId lineId, transit::TransitId shapeId, size_t shapeSi
|
||||
namespace transit
|
||||
{
|
||||
// Static fields.
|
||||
std::unordered_set<std::string> WorldFeed::m_agencyHashes;
|
||||
ankerl::unordered_dense::set<std::string> WorldFeed::m_agencyHashes;
|
||||
|
||||
EdgeTransferId::EdgeTransferId(TransitId fromStopId, TransitId toStopId)
|
||||
: m_fromStopId(fromStopId)
|
||||
@@ -566,7 +567,7 @@ bool WorldFeed::FillStopsEdges()
|
||||
std::sort(allStopTimes.begin(), allStopTimes.end(),
|
||||
[](gtfs::StopTime const & t1, gtfs::StopTime const & t2) { return t1.trip_id < t2.trip_id; });
|
||||
|
||||
std::vector<std::unordered_map<TransitId, LineData>::iterator> linesForRemoval;
|
||||
std::vector<ankerl::unordered_dense::map<TransitId, LineData>::iterator> linesForRemoval;
|
||||
|
||||
for (auto it = m_lines.m_data.begin(); it != m_lines.m_data.end(); ++it)
|
||||
{
|
||||
@@ -644,7 +645,7 @@ bool WorldFeed::FillStopsEdges()
|
||||
|
||||
bool WorldFeed::FillLinesAndShapes()
|
||||
{
|
||||
std::unordered_map<gtfs::Id, gtfs::Shape> shapes;
|
||||
ankerl::unordered_dense::map<gtfs::Id, gtfs::Shape> shapes;
|
||||
for (auto const & shape : m_feed.get_shapes())
|
||||
shapes[shape.shape_id].emplace_back(shape);
|
||||
|
||||
@@ -653,7 +654,7 @@ bool WorldFeed::FillLinesAndShapes()
|
||||
|
||||
auto const getShape = [&shapes](gtfs::Id const & gtfsShapeId) -> gtfs::Shape const & { return shapes[gtfsShapeId]; };
|
||||
|
||||
std::unordered_map<gtfs::Id, gtfs::StopTimes> stopTimes;
|
||||
ankerl::unordered_dense::map<gtfs::Id, gtfs::StopTimes> stopTimes;
|
||||
for (auto const & stop_time : m_feed.get_stop_times())
|
||||
stopTimes[stop_time.trip_id].emplace_back(stop_time);
|
||||
|
||||
@@ -743,7 +744,7 @@ void WorldFeed::ModifyLinesAndShapes()
|
||||
IdSet shapesForRemoval;
|
||||
|
||||
// Shape id matching to the line id linked to this shape id.
|
||||
std::unordered_map<TransitId, TransitId> matchingCache;
|
||||
ankerl::unordered_dense::map<TransitId, TransitId> matchingCache;
|
||||
|
||||
for (size_t i = 1; i < links.size(); ++i)
|
||||
{
|
||||
@@ -863,7 +864,7 @@ void WorldFeed::FillLinesSchedule()
|
||||
|
||||
std::optional<Direction> WorldFeed::ProjectStopsToShape(
|
||||
ShapesIter & itShape, StopsOnLines const & stopsOnLines,
|
||||
std::unordered_map<TransitId, std::vector<size_t>> & stopsToIndexes)
|
||||
ankerl::unordered_dense::map<TransitId, std::vector<size_t>> & stopsToIndexes)
|
||||
{
|
||||
IdList const & stopIds = stopsOnLines.m_stopSeq;
|
||||
TransitId const shapeId = itShape->first;
|
||||
@@ -934,10 +935,10 @@ std::optional<Direction> WorldFeed::ProjectStopsToShape(
|
||||
return {};
|
||||
}
|
||||
|
||||
std::unordered_map<TransitId, std::vector<StopsOnLines>> WorldFeed::GetStopsForShapeMatching()
|
||||
ankerl::unordered_dense::map<TransitId, std::vector<StopsOnLines>> WorldFeed::GetStopsForShapeMatching()
|
||||
{
|
||||
// Shape id and list of stop sequences matched to the corresponding lines.
|
||||
std::unordered_map<TransitId, std::vector<StopsOnLines>> stopsOnShapes;
|
||||
ankerl::unordered_dense::map<TransitId, std::vector<StopsOnLines>> stopsOnShapes;
|
||||
|
||||
// We build lists of stops relevant to corresponding shapes. There could be multiple different
|
||||
// stops lists linked to the same shape.
|
||||
@@ -982,7 +983,7 @@ std::pair<size_t, size_t> WorldFeed::ModifyShapes()
|
||||
auto itShape = m_shapes.m_data.find(shapeId);
|
||||
CHECK(itShape != m_shapes.m_data.end(), (shapeId));
|
||||
|
||||
std::unordered_map<TransitId, std::vector<size_t>> stopToShapeIndex;
|
||||
ankerl::unordered_dense::map<TransitId, std::vector<size_t>> stopToShapeIndex;
|
||||
|
||||
for (auto & stopsOnLines : stopsLists)
|
||||
{
|
||||
@@ -1124,7 +1125,7 @@ void WorldFeed::FillTransfers()
|
||||
|
||||
void WorldFeed::FillGates()
|
||||
{
|
||||
std::unordered_map<std::string, std::vector<GateData>> parentToGates;
|
||||
ankerl::unordered_dense::map<std::string, std::vector<GateData>> parentToGates;
|
||||
for (auto const & stop : m_feed.get_stops())
|
||||
{
|
||||
if (stop.location_type == gtfs::StopLocationType::EntranceExit && !stop.parent_station.empty())
|
||||
@@ -1193,11 +1194,11 @@ bool WorldFeed::SpeedExceedsMaxVal(EdgeId const & edgeId, EdgeData const & edgeD
|
||||
return speedExceedsMaxVal;
|
||||
}
|
||||
|
||||
bool WorldFeed::ClearFeedByLineIds(std::unordered_set<TransitId> const & corruptedLineIds)
|
||||
bool WorldFeed::ClearFeedByLineIds(ankerl::unordered_dense::set<TransitId> const & corruptedLineIds)
|
||||
{
|
||||
std::unordered_set<TransitId> corruptedRouteIds;
|
||||
std::unordered_set<TransitId> corruptedShapeIds;
|
||||
std::unordered_set<TransitId> corruptedNetworkIds;
|
||||
ankerl::unordered_dense::set<TransitId> corruptedRouteIds;
|
||||
ankerl::unordered_dense::set<TransitId> corruptedShapeIds;
|
||||
ankerl::unordered_dense::set<TransitId> corruptedNetworkIds;
|
||||
|
||||
for (auto lineId : corruptedLineIds)
|
||||
{
|
||||
@@ -1226,7 +1227,7 @@ bool WorldFeed::ClearFeedByLineIds(std::unordered_set<TransitId> const & corrupt
|
||||
DeleteAllEntriesByIds(m_networks.m_data, corruptedNetworkIds);
|
||||
DeleteAllEntriesByIds(m_lines.m_data, corruptedLineIds);
|
||||
|
||||
std::unordered_set<TransitId> corruptedStopIds;
|
||||
ankerl::unordered_dense::set<TransitId> corruptedStopIds;
|
||||
|
||||
// We fill |corruptedStopIds| and delete corresponding edges from |m_edges|.
|
||||
for (auto it = m_edges.m_data.begin(); it != m_edges.m_data.end();)
|
||||
@@ -1298,7 +1299,7 @@ bool WorldFeed::ClearFeedByLineIds(std::unordered_set<TransitId> const & corrupt
|
||||
|
||||
bool WorldFeed::UpdateEdgeWeights()
|
||||
{
|
||||
std::unordered_set<TransitId> corruptedLineIds;
|
||||
ankerl::unordered_dense::set<TransitId> corruptedLineIds;
|
||||
|
||||
for (auto & [edgeId, edgeData] : m_edges.m_data)
|
||||
{
|
||||
@@ -1449,7 +1450,8 @@ void Routes::Write(IdSet const & ids, std::ofstream & stream) const
|
||||
}
|
||||
}
|
||||
|
||||
void Lines::Write(std::unordered_map<TransitId, LineSegmentInRegion> const & ids, std::ofstream & stream) const
|
||||
void Lines::Write(ankerl::unordered_dense::map<TransitId, LineSegmentInRegion> const & ids,
|
||||
std::ofstream & stream) const
|
||||
{
|
||||
for (auto const & [lineId, data] : ids)
|
||||
{
|
||||
@@ -1468,7 +1470,7 @@ void Lines::Write(std::unordered_map<TransitId, LineSegmentInRegion> const & ids
|
||||
}
|
||||
}
|
||||
|
||||
void LinesMetadata::Write(std::unordered_map<TransitId, LineSegmentInRegion> const & linesInRegion,
|
||||
void LinesMetadata::Write(ankerl::unordered_dense::map<TransitId, LineSegmentInRegion> const & linesInRegion,
|
||||
std::ofstream & stream) const
|
||||
{
|
||||
for (auto const & [lineId, lineData] : linesInRegion)
|
||||
|
||||
@@ -16,11 +16,10 @@
|
||||
#include <fstream>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "3party/ankerl/unordered_dense.h"
|
||||
#include "3party/just_gtfs/just_gtfs.h"
|
||||
|
||||
namespace transit
|
||||
@@ -37,7 +36,7 @@ public:
|
||||
TransitId MakeId(std::string const & hash);
|
||||
|
||||
private:
|
||||
std::unordered_map<std::string, TransitId> m_hashToId;
|
||||
ankerl::unordered_dense::map<std::string, TransitId> m_hashToId;
|
||||
TransitId m_curId = 0;
|
||||
std::string m_idMappingPath;
|
||||
};
|
||||
@@ -50,7 +49,7 @@ struct Networks
|
||||
void Write(IdSet const & ids, std::ofstream & stream) const;
|
||||
|
||||
// Id to agency name mapping.
|
||||
std::unordered_map<TransitId, std::string> m_data;
|
||||
ankerl::unordered_dense::map<TransitId, std::string> m_data;
|
||||
};
|
||||
|
||||
struct RouteData
|
||||
@@ -65,7 +64,7 @@ struct Routes
|
||||
{
|
||||
void Write(IdSet const & ids, std::ofstream & stream) const;
|
||||
|
||||
std::unordered_map<TransitId, RouteData> m_data;
|
||||
ankerl::unordered_dense::map<TransitId, RouteData> m_data;
|
||||
};
|
||||
|
||||
struct LineData
|
||||
@@ -84,7 +83,7 @@ struct LineData
|
||||
// Fields not intended to be exported to json.
|
||||
TransitId m_shapeId = 0;
|
||||
std::string m_gtfsTripId;
|
||||
std::unordered_set<std::string> m_gtfsServiceIds;
|
||||
ankerl::unordered_dense::set<std::string> m_gtfsServiceIds;
|
||||
};
|
||||
|
||||
struct LineSegmentInRegion
|
||||
@@ -99,17 +98,18 @@ struct LineSegmentInRegion
|
||||
|
||||
struct Lines
|
||||
{
|
||||
void Write(std::unordered_map<TransitId, LineSegmentInRegion> const & ids, std::ofstream & stream) const;
|
||||
void Write(ankerl::unordered_dense::map<TransitId, LineSegmentInRegion> const & ids, std::ofstream & stream) const;
|
||||
|
||||
std::unordered_map<TransitId, LineData> m_data;
|
||||
ankerl::unordered_dense::map<TransitId, LineData> m_data;
|
||||
};
|
||||
|
||||
struct LinesMetadata
|
||||
{
|
||||
void Write(std::unordered_map<TransitId, LineSegmentInRegion> const & linesInRegion, std::ofstream & stream) const;
|
||||
void Write(ankerl::unordered_dense::map<TransitId, LineSegmentInRegion> const & linesInRegion,
|
||||
std::ofstream & stream) const;
|
||||
|
||||
// Line id to line additional data (e.g. for rendering).
|
||||
std::unordered_map<TransitId, LineSegmentsOrder> m_data;
|
||||
ankerl::unordered_dense::map<TransitId, LineSegmentsOrder> m_data;
|
||||
};
|
||||
|
||||
struct ShapeData
|
||||
@@ -122,13 +122,13 @@ struct ShapeData
|
||||
IdSet m_lineIds;
|
||||
};
|
||||
|
||||
using ShapesIter = std::unordered_map<TransitId, ShapeData>::iterator;
|
||||
using ShapesIter = ankerl::unordered_dense::map<TransitId, ShapeData>::iterator;
|
||||
|
||||
struct Shapes
|
||||
{
|
||||
void Write(IdSet const & ids, std::ofstream & stream) const;
|
||||
|
||||
std::unordered_map<TransitId, ShapeData> m_data;
|
||||
ankerl::unordered_dense::map<TransitId, ShapeData> m_data;
|
||||
};
|
||||
|
||||
struct StopData
|
||||
@@ -155,14 +155,14 @@ struct Stops
|
||||
{
|
||||
void Write(IdSet const & ids, std::ofstream & stream) const;
|
||||
|
||||
std::unordered_map<TransitId, StopData> m_data;
|
||||
ankerl::unordered_dense::map<TransitId, StopData> m_data;
|
||||
};
|
||||
|
||||
struct Edges
|
||||
{
|
||||
void Write(IdEdgeSet const & ids, std::ofstream & stream) const;
|
||||
|
||||
std::unordered_map<EdgeId, EdgeData, EdgeIdHasher> m_data;
|
||||
ankerl::unordered_dense::map<EdgeId, EdgeData, EdgeIdHasher> m_data;
|
||||
};
|
||||
|
||||
struct EdgeTransferId
|
||||
@@ -181,13 +181,13 @@ struct EdgeTransferIdHasher
|
||||
size_t operator()(EdgeTransferId const & key) const;
|
||||
};
|
||||
|
||||
using IdEdgeTransferSet = std::unordered_set<EdgeTransferId, EdgeTransferIdHasher>;
|
||||
using IdEdgeTransferSet = ankerl::unordered_dense::set<EdgeTransferId, EdgeTransferIdHasher>;
|
||||
|
||||
struct EdgesTransfer
|
||||
{
|
||||
void Write(IdEdgeTransferSet const & ids, std::ofstream & stream) const;
|
||||
// Key is pair of stops and value is |EdgeData|, containing weight (in seconds).
|
||||
std::unordered_map<EdgeTransferId, EdgeData, EdgeTransferIdHasher> m_data;
|
||||
ankerl::unordered_dense::map<EdgeTransferId, EdgeData, EdgeTransferIdHasher> m_data;
|
||||
};
|
||||
|
||||
struct TransferData
|
||||
@@ -200,7 +200,7 @@ struct Transfers
|
||||
{
|
||||
void Write(IdSet const & ids, std::ofstream & stream) const;
|
||||
|
||||
std::unordered_map<TransitId, TransferData> m_data;
|
||||
ankerl::unordered_dense::map<TransitId, TransferData> m_data;
|
||||
};
|
||||
|
||||
struct GateData
|
||||
@@ -219,7 +219,7 @@ struct Gates
|
||||
{
|
||||
void Write(IdSet const & ids, std::ofstream & stream) const;
|
||||
|
||||
std::unordered_map<TransitId, GateData> m_data;
|
||||
ankerl::unordered_dense::map<TransitId, GateData> m_data;
|
||||
};
|
||||
|
||||
// Indexes for WorldFeed |m_gtfsIdToHash| field. For each type of GTFS entity, e.g. agency or stop,
|
||||
@@ -234,7 +234,7 @@ enum FieldIdx
|
||||
IdxCount
|
||||
};
|
||||
|
||||
using GtfsIdToHash = std::unordered_map<std::string, std::string>;
|
||||
using GtfsIdToHash = ankerl::unordered_dense::map<std::string, std::string>;
|
||||
|
||||
struct StopsOnLines
|
||||
{
|
||||
@@ -246,10 +246,11 @@ struct StopsOnLines
|
||||
transit::Direction m_direction = Direction::Forward;
|
||||
};
|
||||
|
||||
using IdsInRegion = std::unordered_map<std::string, IdSet>;
|
||||
using LinesInRegion = std::unordered_map<std::string, std::unordered_map<TransitId, LineSegmentInRegion>>;
|
||||
using EdgeIdsInRegion = std::unordered_map<std::string, IdEdgeSet>;
|
||||
using EdgeTransferIdsInRegion = std::unordered_map<std::string, IdEdgeTransferSet>;
|
||||
using IdsInRegion = ankerl::unordered_dense::map<std::string, IdSet>;
|
||||
using LinesInRegion =
|
||||
ankerl::unordered_dense::map<std::string, ankerl::unordered_dense::map<TransitId, LineSegmentInRegion>>;
|
||||
using EdgeIdsInRegion = ankerl::unordered_dense::map<std::string, IdEdgeSet>;
|
||||
using EdgeTransferIdsInRegion = ankerl::unordered_dense::map<std::string, IdEdgeTransferSet>;
|
||||
|
||||
using Regions = std::vector<std::string>;
|
||||
|
||||
@@ -324,7 +325,7 @@ private:
|
||||
|
||||
TransitId GetSplineParent(TransitId lineId, std::string const & region) const;
|
||||
|
||||
std::unordered_map<TransitId, std::vector<StopsOnLines>> GetStopsForShapeMatching();
|
||||
ankerl::unordered_dense::map<TransitId, std::vector<StopsOnLines>> GetStopsForShapeMatching();
|
||||
|
||||
// Adds stops projections to shapes. Updates corresponding links to shapes. Returns number of
|
||||
// invalid and valid shapes.
|
||||
@@ -336,8 +337,9 @@ private:
|
||||
// Recalculates 0-weights of edges based on the shape length.
|
||||
bool UpdateEdgeWeights();
|
||||
|
||||
std::optional<Direction> ProjectStopsToShape(ShapesIter & itShape, StopsOnLines const & stopsOnLines,
|
||||
std::unordered_map<TransitId, std::vector<size_t>> & stopsToIndexes);
|
||||
std::optional<Direction> ProjectStopsToShape(
|
||||
ShapesIter & itShape, StopsOnLines const & stopsOnLines,
|
||||
ankerl::unordered_dense::map<TransitId, std::vector<size_t>> & stopsToIndexes);
|
||||
|
||||
// Splits data into regions.
|
||||
void SplitFeedIntoRegions();
|
||||
@@ -362,7 +364,7 @@ private:
|
||||
// contradicts maximum transit speed.
|
||||
bool SpeedExceedsMaxVal(EdgeId const & edgeId, EdgeData const & edgeData);
|
||||
// Removes entities from feed which are linked only to the |corruptedLineIds|.
|
||||
bool ClearFeedByLineIds(std::unordered_set<TransitId> const & corruptedLineIds);
|
||||
bool ClearFeedByLineIds(ankerl::unordered_dense::set<TransitId> const & corruptedLineIds);
|
||||
// Current GTFS feed which is being merged to the global feed.
|
||||
gtfs::Feed m_feed;
|
||||
|
||||
@@ -379,7 +381,7 @@ private:
|
||||
Gates m_gates;
|
||||
|
||||
// Mapping of the edge to its points on the shape polyline.
|
||||
std::unordered_map<EdgeId, std::vector<std::vector<m2::PointD>>, EdgeIdHasher> m_edgesOnShapes;
|
||||
ankerl::unordered_dense::map<EdgeId, std::vector<std::vector<m2::PointD>>, EdgeIdHasher> m_edgesOnShapes;
|
||||
|
||||
// Ids of entities for json'izing, split by regions.
|
||||
TransitByRegion m_splitting;
|
||||
@@ -401,11 +403,11 @@ private:
|
||||
std::string m_gtfsHash;
|
||||
|
||||
// Unique hashes of all agencies handled by WorldFeed.
|
||||
static std::unordered_set<std::string> m_agencyHashes;
|
||||
static ankerl::unordered_dense::set<std::string> m_agencyHashes;
|
||||
// Count of corrupted stops sequences which could not be projected to the shape polyline.
|
||||
static size_t m_badStopSeqCount;
|
||||
// Agencies which are already handled by WorldFeed and should be copied to the resulting jsons.
|
||||
std::unordered_set<std::string> m_agencySkipList;
|
||||
ankerl::unordered_dense::set<std::string> m_agencySkipList;
|
||||
|
||||
// If the feed explicitly specifies its language, we use its value. Otherwise set to default.
|
||||
std::string m_feedLanguage;
|
||||
|
||||
Reference in New Issue
Block a user