Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladimir Byko-Ianko <v.bykoianko@corp.mail.ru>2017-10-27 14:15:15 +0300
committerDaria Volvenkova <d.volvenkova@corp.mail.ru>2017-10-27 16:04:18 +0300
commit021ba8bfd63a0825ba8d57276f039a3e7b0e710e (patch)
tree083f1e8b12bd1766a7df67fcdb1a5401113298d6
parentee0653fa6035ab530c113320eb61f02467d4e387 (diff)
Adding line color type.
-rw-r--r--generator/generator_tests/transit_test.cpp12
-rw-r--r--routing_common/routing_common_tests/transit_test.cpp8
-rw-r--r--routing_common/transit_types.cpp10
-rw-r--r--routing_common/transit_types.hpp15
4 files changed, 28 insertions, 17 deletions
diff --git a/generator/generator_tests/transit_test.cpp b/generator/generator_tests/transit_test.cpp
index 54f8462a00..7fac1b725a 100644
--- a/generator/generator_tests/transit_test.cpp
+++ b/generator/generator_tests/transit_test.cpp
@@ -30,7 +30,7 @@ void TestDeserializerFromJson(string const & jsonBuffer, OsmIdToFeatureIdsMap co
TEST_EQUAL(objects.size(), expected.size(), ());
for (size_t i = 0; i < objects.size(); ++i)
- TEST(objects[i].IsEqualForTesting(expected[i]), (objects[i], expected[i]));
+ TEST(objects[i].IsEqualForTesting(expected[i]), (i, objects[i], expected[i]));
}
template <typename Obj>
@@ -229,7 +229,8 @@ UNIT_TEST(DeserializerFromJson_Lines)
2947858576
],
"title": "Московская линия",
- "type": "subway"
+ "type": "subway",
+ "color": "green"
},
{
"id": 19207937,
@@ -245,15 +246,16 @@ UNIT_TEST(DeserializerFromJson_Lines)
209191851
],
"title": "Московская линия",
- "type": "subway"
+ "type": "subway",
+ "color": "red"
}
]})";
vector<Line> const expected = {Line(19207936 /* line id */, "1" /* number */, "Московская линия" /* title */,
- "subway" /* type */, 2 /* network id */,
+ "subway" /* type */, "green" /* color */, 2 /* network id */,
{{343262691, 343259523, 343252898, 209191847, 2947858576}} /* stop ids */),
Line(19207937 /* line id */, "2" /* number */, "Московская линия" /* title */,
- "subway" /* type */, 2 /* network id */,
+ "subway" /* type */, "red" /* color */, 2 /* network id */,
{{246659391, 246659390, 209191855, 209191854, 209191853,
209191852, 209191851}} /* stop ids */)};
diff --git a/routing_common/routing_common_tests/transit_test.cpp b/routing_common/routing_common_tests/transit_test.cpp
index 8c7ef47682..2aec35460c 100644
--- a/routing_common/routing_common_tests/transit_test.cpp
+++ b/routing_common/routing_common_tests/transit_test.cpp
@@ -119,17 +119,19 @@ UNIT_TEST(Transit_LineSerialization)
{
{
Line line(1 /* line id */, "2" /* number */, "Линия" /* title */,
- "subway" /* type */, 3 /* network id */, {} /* stop ids */);
+ "subway" /* type */, "red" /* color */, 3 /* network id */, {} /* stop ids */);
TestSerialization(line);
}
{
Line line(10 /* line id */, "11" /* number */, "Линия" /* title */,
- "subway" /* type */, 12 /* network id */, {{13, 14, 15}} /* stop ids */);
+ "subway" /* type */, "green" /* color */, 12 /* network id */,
+ {{13, 14, 15}} /* stop ids */);
TestSerialization(line);
}
{
Line line(100 /* line id */, "101" /* number */, "Линия" /* title */,
- "subway" /* type */, 103 /* network id */, {{1, 2, 3}, {7, 8, 9}} /* stop ids */);
+ "subway" /* type */, "blue" /* color */, 103 /* network id */,
+ {{1, 2, 3}, {7, 8, 9}} /* stop ids */);
TestSerialization(line);
}
}
diff --git a/routing_common/transit_types.cpp b/routing_common/transit_types.cpp
index e949846034..5410e7a4ce 100644
--- a/routing_common/transit_types.cpp
+++ b/routing_common/transit_types.cpp
@@ -224,11 +224,13 @@ bool Transfer::IsValid() const
// Line -------------------------------------------------------------------------------------------
Line::Line(LineId id, std::string const & number, std::string const & title,
- std::string const & type, NetworkId networkId, Ranges const & stopIds)
+ std::string const & type, std::string const & color, NetworkId networkId,
+ Ranges const & stopIds)
: m_id(id)
, m_number(number)
, m_title(title)
, m_type(type)
+ , m_color(color)
, m_networkId(networkId)
, m_stopIds(stopIds)
{
@@ -237,12 +239,14 @@ Line::Line(LineId id, std::string const & number, std::string const & title,
bool Line::IsEqualForTesting(Line const & line) const
{
return m_id == line.m_id && m_number == line.m_number && m_title == line.m_title &&
- m_type == line.m_type && m_networkId == line.m_networkId && m_stopIds == line.m_stopIds;
+ m_color == line.m_color && m_type == line.m_type && m_networkId == line.m_networkId &&
+ m_stopIds == line.m_stopIds;
}
bool Line::IsValid() const
{
- return m_id != kInvalidLineId && m_networkId != kInvalidNetworkId && m_stopIds.IsValid();
+ return m_id != kInvalidLineId && m_color != kInvalidColor && m_networkId != kInvalidNetworkId &&
+ m_stopIds.IsValid();
}
// Shape ------------------------------------------------------------------------------------------
diff --git a/routing_common/transit_types.hpp b/routing_common/transit_types.hpp
index 6c77b1ab23..3891563b60 100644
--- a/routing_common/transit_types.hpp
+++ b/routing_common/transit_types.hpp
@@ -25,16 +25,17 @@ using TransferId = uint64_t;
using Weight = double;
using Ranges = std::vector<std::vector<StopId>>;
+Anchor constexpr kInvalidAnchor = std::numeric_limits<Anchor>::max();
+std::string const kInvalidColor = std::string("");
+FeatureId constexpr kInvalidFeatureId = std::numeric_limits<FeatureId>::max();
LineId constexpr kInvalidLineId = std::numeric_limits<LineId>::max();
-StopId constexpr kInvalidStopId = std::numeric_limits<StopId>::max();
-TransferId constexpr kInvalidTransferId = std::numeric_limits<TransferId>::max();
NetworkId constexpr kInvalidNetworkId = std::numeric_limits<NetworkId>::max();
-FeatureId constexpr kInvalidFeatureId = std::numeric_limits<FeatureId>::max();
OsmId constexpr kInvalidOsmId = std::numeric_limits<OsmId>::max();
+StopId constexpr kInvalidStopId = std::numeric_limits<StopId>::max();
+TransferId constexpr kInvalidTransferId = std::numeric_limits<TransferId>::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;
-Anchor constexpr kInvalidAnchor = std::numeric_limits<Anchor>::max();
#define DECLARE_TRANSIT_TYPE_FRIENDS \
template<class Sink> friend class Serializer; \
@@ -330,7 +331,7 @@ class Line
public:
Line() = default;
Line(LineId id, std::string const & number, std::string const & title, std::string const & type,
- NetworkId networkId, Ranges const & stopIds);
+ std::string const & color, NetworkId networkId, Ranges const & stopIds);
bool IsEqualForTesting(Line const & line) const;
bool IsValid() const;
@@ -339,6 +340,7 @@ public:
std::string const & GetNumber() const { return m_number; }
std::string const & GetTitle() const { return m_title; }
std::string const & GetType() const { return m_type; }
+ std::string const & GetColor() const { return m_color; }
NetworkId GetNetworkId() const { return m_networkId; }
Ranges const & GetStopIds() const { return m_stopIds.GetIds(); }
@@ -346,13 +348,14 @@ private:
DECLARE_TRANSIT_TYPE_FRIENDS
DECLARE_VISITOR_AND_DEBUG_PRINT(Line, visitor(m_id, "id"), visitor(m_number, "number"),
visitor(m_title, "title"), visitor(m_type, "type"),
- visitor(m_networkId, "network_id"),
+ visitor(m_color, "color"), visitor(m_networkId, "network_id"),
visitor(m_stopIds, "stop_ids"))
LineId m_id = kInvalidLineId;
std::string m_number;
std::string m_title;
std::string m_type;
+ std::string m_color = kInvalidColor;
NetworkId m_networkId = kInvalidNetworkId;
StopIdRanges m_stopIds;
};