From 127b880343232810df16592ec1d872abbefbb802 Mon Sep 17 00:00:00 2001 From: Olga Khlopkova Date: Mon, 26 Oct 2020 10:12:44 +0300 Subject: [PATCH] [transit] Changed default feature id for edgeData. --- transit/experimental/transit_data.cpp | 2 +- transit/transit_entities.hpp | 2 +- transit/world_feed/world_feed.cpp | 10 ++++++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/transit/experimental/transit_data.cpp b/transit/experimental/transit_data.cpp index 8a7525a054f..a94c1ae53a1 100644 --- a/transit/experimental/transit_data.cpp +++ b/transit/experimental/transit_data.cpp @@ -425,7 +425,7 @@ void Read(base::Json const & obj, std::vector & edges, EdgeIdToFeatureId & FromJSONObjectOptionalField(obj.get(), "line_id", lineId); TransitId featureId = kInvalidFeatureId; - FromJSONObjectOptionalField(obj.get(), "feature_id", featureId); + FromJSONObject(obj.get(), "feature_id", featureId); if (lineId == 0) { diff --git a/transit/transit_entities.hpp b/transit/transit_entities.hpp index 1e53674f700..58c9d494996 100644 --- a/transit/transit_entities.hpp +++ b/transit/transit_entities.hpp @@ -158,7 +158,7 @@ struct EdgeData // Feature id for cross-mwm transit section. It is used in Segment class as a feature id for // transit routing case. - uint32_t m_featureId = 0; + uint32_t m_featureId = std::numeric_limits::max(); }; struct LineSegment diff --git a/transit/world_feed/world_feed.cpp b/transit/world_feed/world_feed.cpp index 9370a13f137..8b9de3c060f 100644 --- a/transit/world_feed/world_feed.cpp +++ b/transit/world_feed/world_feed.cpp @@ -1569,8 +1569,9 @@ void Edges::Write(IdEdgeSet const & ids, std::ofstream & stream) const ToJSONObject(*node, "stop_id_from", edgeId.m_fromStopId); ToJSONObject(*node, "stop_id_to", edgeId.m_toStopId); - if (edge.m_featureId != 0) - ToJSONObject(*node, "feature_id", edge.m_featureId); + CHECK_NOT_EQUAL(edge.m_featureId, std::numeric_limits::max(), + (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)); ToJSONObject(*node, "weight", edge.m_weight); @@ -1592,8 +1593,9 @@ void EdgesTransfer::Write(IdEdgeTransferSet const & ids, std::ofstream & stream) ToJSONObject(*node, "stop_id_to", edgeTransferId.m_toStopId); ToJSONObject(*node, "weight", edgeData.m_weight); - if (edgeData.m_featureId != 0) - ToJSONObject(*node, "feature_id", edgeData.m_featureId); + CHECK_NOT_EQUAL(edgeData.m_featureId, std::numeric_limits::max(), + (edgeTransferId.m_fromStopId, edgeTransferId.m_toStopId)); + ToJSONObject(*node, "feature_id", edgeData.m_featureId); WriteJson(node.get(), stream); }