From c5edec5aea0818ed21a58268c7b52ef68872bcb6 Mon Sep 17 00:00:00 2001 From: Vladimir Byko-Ianko Date: Wed, 4 Oct 2017 11:44:40 +0300 Subject: [PATCH] Changing invalid value for edge weight. --- generator/transit_generator.cpp | 5 +++++ routing_common/transit_serdes.hpp | 6 ++++-- routing_common/transit_types.hpp | 4 +++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/generator/transit_generator.cpp b/generator/transit_generator.cpp index 4258e192b9..707bb776af 100644 --- a/generator/transit_generator.cpp +++ b/generator/transit_generator.cpp @@ -120,6 +120,11 @@ void BuildTransit(string const & mwmPath, string const & transitDir) SerializeObject(root, "stops", serializer); header.m_gatesOffset = base::checked_cast(w.Pos() - startOffset); + // @TODO(bykoianko) Gates should be added after stops but before edges. + + SerializeObject(root, "edges", serializer); + header.m_transfersOffset = base::checked_cast(w.Pos() - startOffset); + // @TODO(bykoianko) It's necessary to serialize other transit graph data here. header.m_endOffset = base::checked_cast(w.Pos() - startOffset); diff --git a/routing_common/transit_serdes.hpp b/routing_common/transit_serdes.hpp index 244638cc1c..5c3ee3d0cf 100644 --- a/routing_common/transit_serdes.hpp +++ b/routing_common/transit_serdes.hpp @@ -1,5 +1,7 @@ #pragma once +#include "routing_common/transit_types.hpp" + #include "geometry/point2d.hpp" #include "coding/point_to_integer.hpp" @@ -26,7 +28,7 @@ namespace transit { // Note. For the time being double at transit section is used only for saving weight of edges (in seconds). // Let us assume that it takes less than 10^7 seconds (115 days) to get from one station to a neighboring one. -double constexpr kMinDoubleAtTransit = 0.0; +double constexpr kMinDoubleAtTransit = kInvalidWeight; double constexpr kMaxDoubleAtTransit = 10000000.0; template @@ -44,7 +46,7 @@ public: void operator()(double d, char const * name = nullptr) { - CHECK_GREATER_OR_EQUAL(d, 0, ()); + CHECK_GREATER_OR_EQUAL(d, kMinDoubleAtTransit, ()); CHECK_LESS_OR_EQUAL(d, kMaxDoubleAtTransit, ()); (*this)(DoubleToUint32(d, kMinDoubleAtTransit, kMaxDoubleAtTransit, POINT_COORD_BITS), name); } diff --git a/routing_common/transit_types.hpp b/routing_common/transit_types.hpp index 7ad7e0e610..493442398f 100644 --- a/routing_common/transit_types.hpp +++ b/routing_common/transit_types.hpp @@ -26,7 +26,9 @@ TransferId constexpr kInvalidTransferId = std::numeric_limits::max() NetworkId constexpr kInvalidNetworkId = std::numeric_limits::max(); FeatureId constexpr kInvalidFeatureId = std::numeric_limits::max(); ShapeId constexpr kInvalidShapeId = std::numeric_limits::max(); -Weight constexpr kInvalidWeight = std::numeric_limits::max(); +// Note. Weight may be a default param at json. The default value should be saved as uint32_t in mwm anyway. +// To convert double to uint32_t at better accuracy |kInvalidWeight| should be close to real weight. +Weight constexpr kInvalidWeight = -1.0; struct TransitHeader {