Compare commits

...
Sign in to create a new pull request.

15 commits

Author SHA1 Message Date
Fardeen Faisal
8e0f740307
Merge branch 'organicmaps:master' into public-transit 2022-06-19 00:52:50 -06:00
Fardeen Faisal
0b62d5acbd
Style Fix 2022-06-19 00:51:36 -06:00
Fardeen Faisal
d959956af3 gtfs converter fix
Signed-off-by: Fardeen Faisal <fardeenfaisal.fs@gmail.com>
2022-06-19 00:20:11 -06:00
Fardeen Faisal
6d7683ee64 gtfs converter fix
Signed-off-by: Fardeen Faisal <fardeenfaisal.fs@gmail.com>
2022-06-19 00:12:31 -06:00
Fardeen Faisal
04832554d9
Merge branch 'organicmaps:master' into public-transit 2022-06-16 22:57:33 -06:00
Fardeen Faisal
8cb86f91fc
Merge branch 'organicmaps:master' into public-transit 2022-06-08 17:21:08 -06:00
Fardeen Faisal
88510e726e
Merge branch 'organicmaps:master' into public-transit 2022-06-04 21:42:46 -06:00
Fardeen Faisal
569559e8f5
Merge branch 'organicmaps:master' into public-transit 2022-05-30 15:05:53 -06:00
Fardeen Faisal
0ef569e162 Bug Fixes
Signed-off-by: Fardeen Faisal <fardeenfaisal.fs@gmail.com>
2022-05-30 01:15:12 -06:00
Fardeen Faisal
4493f98e34
Merge pull request #3 from fardeenfs/gtfs-source-fix
Bug Fixes
2022-05-29 17:40:53 -06:00
Fardeen Faisal
e78ace8243 Bug Fixes
Signed-off-by: Fardeen Faisal <fardeenfaisal.fs@gmail.com>
2022-05-29 17:36:19 -06:00
Fardeen Faisal
b7982f1ed6 Source Fix
Signed-off-by: Fardeen Faisal <fardeenfaisal.fs@gmail.com>
2022-05-29 16:58:17 -06:00
Fardeen Faisal
3fc70d190d
Merge branch 'organicmaps:master' into gtfs-source-fix 2022-05-29 15:38:14 -06:00
Fardeen Faisal
a5a6f3317b
Merge branch 'organicmaps:master' into gtfs-source-fix 2022-05-29 01:38:32 -06:00
Fardeen Faisal
bfd22906fd Review Fixes
Signed-off-by: Fardeen Faisal <fardeenfaisal.fs@gmail.com>
2022-05-28 13:50:14 -06:00

View file

@ -31,9 +31,6 @@ namespace
// TODO(o.khlopkova) Set average speed for each type of transit separately - trains, buses, etc.
// Average transit speed. Approximately 40 km/h.
static double constexpr kAvgTransitSpeedMpS = 11.1;
// If count of corrupted shapes in feed exceeds this value we skip feed and don't save it. The shape
// is corrupted if we cant't properly project all stops from the trip to its polyline.
static size_t constexpr kMaxInvalidShapesCount = 5;
::transit::TransitId constexpr kInvalidLineId = std::numeric_limits<::transit::TransitId>::max();
@ -596,9 +593,9 @@ std::pair<TransitId, std::string> WorldFeed::GetStopIdAndHash(std::string const
bool WorldFeed::FillStopsEdges()
{
gtfs::StopTimes allStopTimes = m_feed.get_stop_times();
std::sort(
allStopTimes.begin(), allStopTimes.end(),
[](const gtfs::StopTime & t1, const gtfs::StopTime & t2) { return t1.trip_id < t2.trip_id; });
std::sort(allStopTimes.begin(), allStopTimes.end(),
[](const gtfs::StopTime & t1, const gtfs::StopTime & t2)
{ return t1.trip_id < t2.trip_id; });
std::vector<std::unordered_map<TransitId, LineData>::iterator> linesForRemoval;
@ -691,9 +688,8 @@ bool WorldFeed::FillLinesAndShapes()
base::LessBy(&gtfs::ShapePoint::shape_pt_sequence));
}
auto const getShape = [&shapes](gtfs::Id const & gtfsShapeId) -> gtfs::Shape const & {
return shapes[gtfsShapeId];
};
auto const getShape = [&shapes](gtfs::Id const & gtfsShapeId) -> gtfs::Shape const &
{ return shapes[gtfsShapeId]; };
std::unordered_map<gtfs::Id, gtfs::StopTimes> stopTimes;
for (const auto & stop_time : m_feed.get_stop_times())
@ -782,9 +778,9 @@ void WorldFeed::ModifyLinesAndShapes()
// We sort links by shape length so we could search for shapes in which i-th shape is included
// only in the left part of the array [0, i).
std::sort(links.begin(), links.end(), [](Link const & link1, Link const & link2) {
return link1.m_shapeSize > link2.m_shapeSize;
});
std::sort(links.begin(), links.end(),
[](Link const & link1, Link const & link2)
{ return link1.m_shapeSize > link2.m_shapeSize; });
size_t subShapesCount = 0;
@ -921,7 +917,8 @@ std::optional<Direction> WorldFeed::ProjectStopsToShape(
IdList const & stopIds = stopsOnLines.m_stopSeq;
TransitId const shapeId = itShape->first;
auto const tryProject = [&](Direction direction) {
auto const tryProject = [&](Direction direction)
{
auto shape = itShape->second.m_points;
std::optional<m2::PointD> prevPoint = std::nullopt;
for (size_t i = 0; i < stopIds.size(); ++i)
@ -1059,9 +1056,6 @@ std::pair<size_t, size_t> WorldFeed::ModifyShapes()
stopsOnLines.m_isValid = false;
++invalidStopSequences;
}
if (invalidStopSequences > kMaxInvalidShapesCount)
return {invalidStopSequences, validStopSequences};
}
for (auto & stopsOnLines : stopsLists)
@ -1080,9 +1074,6 @@ std::pair<size_t, size_t> WorldFeed::ModifyShapes()
stopsOnLines.m_isValid = false;
++invalidStopSequences;
--validStopSequences;
if (invalidStopSequences > kMaxInvalidShapesCount)
return {invalidStopSequences, validStopSequences};
}
for (auto const lineId : lineIds)
@ -1466,7 +1457,7 @@ bool WorldFeed::SetFeed(gtfs::Feed && feed)
auto const [badShapesCount, goodShapesCount] = ModifyShapes();
LOG(LINFO, ("Modified shapes."));
if (badShapesCount > kMaxInvalidShapesCount || (goodShapesCount == 0 && badShapesCount > 0))
if (goodShapesCount == 0 && badShapesCount >= 0)
{
LOG(LINFO, ("Corrupted shapes count exceeds allowable limit."));
return false;
@ -1649,7 +1640,7 @@ void Edges::Write(IdEdgeSet const & ids, std::ofstream & stream) const
ToJSONObject(*node, "stop_id_to", edgeId.m_toStopId);
CHECK_NOT_EQUAL(edge.m_featureId, std::numeric_limits<uint32_t>::max(),
(edgeId.m_lineId, edgeId.m_fromStopId, edgeId.m_toStopId));
(edgeId.m_lineId, edgeId.m_fromStopId, edgeId.m_toStopId));
ToJSONObject(*node, "feature_id", edge.m_featureId);
CHECK_GREATER(edge.m_weight, 0, (edgeId.m_fromStopId, edgeId.m_toStopId, edgeId.m_lineId));
@ -1673,7 +1664,7 @@ void EdgesTransfer::Write(IdEdgeTransferSet const & ids, std::ofstream & stream)
ToJSONObject(*node, "weight", edgeData.m_weight);
CHECK_NOT_EQUAL(edgeData.m_featureId, std::numeric_limits<uint32_t>::max(),
(edgeTransferId.m_fromStopId, edgeTransferId.m_toStopId));
(edgeTransferId.m_fromStopId, edgeTransferId.m_toStopId));
ToJSONObject(*node, "feature_id", edgeData.m_featureId);
WriteJson(node.get(), stream);
@ -1863,14 +1854,16 @@ bool WorldFeed::PrepareEdgesInRegion(std::string const & region)
FindPointsOnShape(shapePoints, it->second[0].front(), it->second[0].back());
}
CHECK(edgeData.m_shapeLink.m_startIndex != 0 || edgeData.m_shapeLink.m_endIndex != 0, (edgeData.m_shapeLink.m_shapeId));
CHECK(edgeData.m_shapeLink.m_startIndex != 0 || edgeData.m_shapeLink.m_endIndex != 0,
(edgeData.m_shapeLink.m_shapeId));
auto const & pointOnShapeStart = shapePoints[edgeData.m_shapeLink.m_startIndex];
auto const & pointOnShapeEnd = shapePoints[edgeData.m_shapeLink.m_endIndex];
auto const & pointStopStart = m_stops.m_data.at(edgeId.m_fromStopId).m_point;
if (mercator::DistanceOnEarth(pointOnShapeStart, pointStopStart) > mercator::DistanceOnEarth(pointOnShapeEnd, pointStopStart))
if (mercator::DistanceOnEarth(pointOnShapeStart, pointStopStart) >
mercator::DistanceOnEarth(pointOnShapeEnd, pointStopStart))
{
std::swap(edgeData.m_shapeLink.m_startIndex, edgeData.m_shapeLink.m_endIndex);
}