diff options
author | Sergey Yershov <yershov@corp.mail.ru> | 2015-08-13 11:27:17 +0300 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 03:01:25 +0300 |
commit | 0c4336a2a081a0f19c6e5441c280ab83cb010790 (patch) | |
tree | 2d20483b9a9114e86f0398d7df20d4e159d03dac /generator | |
parent | 2066aa34b8f8a9f82e8ef4cb5902403f1e8a8b9d (diff) |
Some fixes for XMLElement
Diffstat (limited to 'generator')
-rw-r--r-- | generator/generator_tests/source_to_element_test.cpp | 6 | ||||
-rw-r--r-- | generator/xml_element.cpp | 18 | ||||
-rw-r--r-- | generator/xml_element.hpp | 7 |
3 files changed, 27 insertions, 4 deletions
diff --git a/generator/generator_tests/source_to_element_test.cpp b/generator/generator_tests/source_to_element_test.cpp index 2dd97cf0a4..c4f2bff576 100644 --- a/generator/generator_tests/source_to_element_test.cpp +++ b/generator/generator_tests/source_to_element_test.cpp @@ -30,7 +30,7 @@ UNIT_TEST(Source_To_Element_create_from_xml_test) UNIT_TEST(Source_To_Element_create_from_o5m_test) { - string src(begin(way_o5m_data), end(way_o5m_data)); + string src(begin(relation_o5m_data), end(relation_o5m_data)); istringstream ss(src); SourceReader reader(ss); @@ -39,7 +39,9 @@ UNIT_TEST(Source_To_Element_create_from_o5m_test) { elements.push_back(*e); }); - TEST_EQUAL(elements.size(), 10, (elements)); + TEST_EQUAL(elements.size(), 11, (elements)); + + cout << DebugPrint(elements); } UNIT_TEST(Source_To_Element_check_equivalence) diff --git a/generator/xml_element.cpp b/generator/xml_element.cpp index 80e3f1bc7e..28646dff38 100644 --- a/generator/xml_element.cpp +++ b/generator/xml_element.cpp @@ -62,10 +62,24 @@ string XMLElement::ToString(string const & shift) const ss << "Nd ref: " << ref; break; case EntityType::Way: - ss << "Way: " << id << " subelements: " << childs.size(); + ss << "Way: " << id << " nds: " << m_nds.size() << " subelements: " << childs.size(); + if (!m_nds.empty()) + { + string shift2 = shift; + shift2 += shift2.empty() ? "\n " : " "; + for ( auto const & e : m_nds ) + ss << shift2 << e; + } break; case EntityType::Relation: - ss << "Relation: " << id << " subelements: " << childs.size(); + ss << "Relation: " << id << " members: " << m_members.size() << " subelements: " << childs.size(); + if (!m_members.empty()) + { + string shift2 = shift; + shift2 += shift2.empty() ? "\n " : " "; + for ( auto const & e : m_members ) + ss << shift2 << e.ref << " " << DebugPrint(e.type) << " " << e.role; + } break; case EntityType::Tag: ss << "Tag: " << k << " = " << v; diff --git a/generator/xml_element.hpp b/generator/xml_element.hpp index f256a8fc64..0f3c1c391c 100644 --- a/generator/xml_element.hpp +++ b/generator/xml_element.hpp @@ -40,6 +40,11 @@ struct XMLElement uint64_t ref; EntityType type; string role; + + bool operator == (Member const & e) const + { + return ref == e.ref && type == e.type && role == e.role; + } }; @@ -118,6 +123,8 @@ struct XMLElement && v == e.v && memberType == e.memberType && role == e.role + && m_nds == e.m_nds + && m_members == e.m_members && childs == e.childs ); } |