Repo created
This commit is contained in:
parent
4af19165ec
commit
68073add76
12458 changed files with 12350765 additions and 2 deletions
25
libs/editor/editor_tests/CMakeLists.txt
Normal file
25
libs/editor/editor_tests/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
project(editor_tests)
|
||||
|
||||
set(SRC
|
||||
config_loader_test.cpp
|
||||
editor_config_test.cpp
|
||||
editor_notes_test.cpp
|
||||
feature_matcher_test.cpp
|
||||
match_by_geometry_test.cpp
|
||||
new_feature_categories_test.cpp
|
||||
opening_hours_ui_test.cpp
|
||||
osm_editor_test.cpp
|
||||
osm_editor_test.hpp
|
||||
ui2oh_test.cpp
|
||||
xml_feature_test.cpp
|
||||
)
|
||||
|
||||
omim_add_test(${PROJECT_NAME} ${SRC})
|
||||
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
editor_tests_support
|
||||
platform_tests_support
|
||||
generator_tests_support
|
||||
search
|
||||
indexer
|
||||
)
|
||||
55
libs/editor/editor_tests/config_loader_test.cpp
Normal file
55
libs/editor/editor_tests/config_loader_test.cpp
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
#include "testing/testing.hpp"
|
||||
|
||||
#include "editor/config_loader.hpp"
|
||||
#include "editor/editor_config.hpp"
|
||||
|
||||
#include "platform/platform_tests_support/scoped_file.hpp"
|
||||
|
||||
#include "base/atomic_shared_ptr.hpp"
|
||||
|
||||
#include <pugixml.hpp>
|
||||
|
||||
namespace
|
||||
{
|
||||
using namespace editor;
|
||||
using platform::tests_support::ScopedFile;
|
||||
|
||||
void CheckGeneralTags(pugi::xml_document const & doc)
|
||||
{
|
||||
auto const types = doc.select_nodes("/comaps/editor/types");
|
||||
TEST(!types.empty(), ());
|
||||
auto const fields = doc.select_nodes("/comaps/editor/fields");
|
||||
TEST(!fields.empty(), ());
|
||||
}
|
||||
|
||||
UNIT_TEST(ConfigLoader_Base)
|
||||
{
|
||||
base::AtomicSharedPtr<EditorConfig> config;
|
||||
ConfigLoader loader(config);
|
||||
|
||||
TEST(!config.Get()->GetTypesThatCanBeAdded().empty(), ());
|
||||
}
|
||||
|
||||
// This functionality is not used and corresponding server is not working.
|
||||
// Uncomment it when server will be up.
|
||||
// UNIT_TEST(ConfigLoader_GetRemoteHash)
|
||||
//{
|
||||
// auto const hashStr = ConfigLoader::GetRemoteHash();
|
||||
// TEST_NOT_EQUAL(hashStr, "", ());
|
||||
// TEST_EQUAL(hashStr, ConfigLoader::GetRemoteHash(), ());
|
||||
//}
|
||||
//
|
||||
// UNIT_TEST(ConfigLoader_GetRemoteConfig)
|
||||
//{
|
||||
// pugi::xml_document doc;
|
||||
// ConfigLoader::GetRemoteConfig(doc);
|
||||
// CheckGeneralTags(doc);
|
||||
//}
|
||||
|
||||
UNIT_TEST(ConfigLoader_LoadFromLocal)
|
||||
{
|
||||
pugi::xml_document doc;
|
||||
ConfigLoader::LoadFromLocal(doc);
|
||||
CheckGeneralTags(doc);
|
||||
}
|
||||
} // namespace
|
||||
86
libs/editor/editor_tests/editor_config_test.cpp
Normal file
86
libs/editor/editor_tests/editor_config_test.cpp
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
#include "testing/testing.hpp"
|
||||
|
||||
#include "editor/config_loader.hpp"
|
||||
#include "editor/editor_config.hpp"
|
||||
|
||||
#include "base/stl_helpers.hpp"
|
||||
|
||||
UNIT_TEST(EditorConfig_TypeDescription)
|
||||
{
|
||||
using EType = feature::Metadata::EType;
|
||||
using Fields = editor::TypeAggregatedDescription::FeatureFields;
|
||||
|
||||
Fields const poiInternet = {
|
||||
EType::FMD_OPEN_HOURS, EType::FMD_PHONE_NUMBER, EType::FMD_WEBSITE, EType::FMD_INTERNET,
|
||||
EType::FMD_EMAIL, EType::FMD_LEVEL, EType::FMD_CONTACT_FACEBOOK, EType::FMD_CONTACT_INSTAGRAM,
|
||||
EType::FMD_CONTACT_TWITTER, EType::FMD_CONTACT_VK, EType::FMD_CONTACT_LINE, EType::FMD_CONTACT_FEDIVERSE,
|
||||
EType::FMD_CONTACT_BLUESKY,
|
||||
};
|
||||
|
||||
pugi::xml_document doc;
|
||||
editor::ConfigLoader::LoadFromLocal(doc);
|
||||
|
||||
editor::EditorConfig config;
|
||||
config.SetConfig(doc);
|
||||
|
||||
{
|
||||
editor::TypeAggregatedDescription desc;
|
||||
TEST(!config.GetTypeDescription({"death-star"}, desc), ());
|
||||
}
|
||||
{
|
||||
editor::TypeAggregatedDescription desc;
|
||||
TEST(config.GetTypeDescription({"amenity-hunting_stand"}, desc), ());
|
||||
TEST(desc.IsNameEditable(), ());
|
||||
TEST(!desc.IsAddressEditable(), ());
|
||||
TEST_EQUAL(desc.GetEditableFields(), Fields{EType::FMD_HEIGHT}, ());
|
||||
}
|
||||
{
|
||||
editor::TypeAggregatedDescription desc;
|
||||
TEST(config.GetTypeDescription({"shop-toys"}, desc), ());
|
||||
TEST(desc.IsNameEditable(), ());
|
||||
TEST(desc.IsAddressEditable(), ());
|
||||
TEST_EQUAL(desc.GetEditableFields(), poiInternet, ());
|
||||
}
|
||||
{
|
||||
// Test that amenity-bank is selected as it goes first in config.
|
||||
editor::TypeAggregatedDescription desc;
|
||||
TEST(config.GetTypeDescription({"amenity-bicycle_rental", "amenity-bank"}, desc), ());
|
||||
TEST(desc.IsNameEditable(), ());
|
||||
TEST(desc.IsAddressEditable(), ());
|
||||
TEST_EQUAL(desc.GetEditableFields(), poiInternet, ());
|
||||
}
|
||||
{
|
||||
// Testing type inheritance
|
||||
editor::TypeAggregatedDescription desc;
|
||||
TEST(config.GetTypeDescription({"amenity-place_of_worship-christian"}, desc), ());
|
||||
TEST(desc.IsNameEditable(), ());
|
||||
TEST_EQUAL(desc.GetEditableFields(), poiInternet, ());
|
||||
}
|
||||
{
|
||||
// Testing long type inheritance on a fake object
|
||||
editor::TypeAggregatedDescription desc;
|
||||
TEST(config.GetTypeDescription({"tourism-artwork-impresionism-monet"}, desc), ());
|
||||
TEST(desc.IsNameEditable(), ());
|
||||
TEST_EQUAL(desc.GetEditableFields(), Fields{}, ());
|
||||
}
|
||||
// TODO(mgsergio): Test case with priority="high" when there is one on editor.config.
|
||||
}
|
||||
|
||||
UNIT_TEST(EditorConfig_GetTypesThatCanBeAdded)
|
||||
{
|
||||
pugi::xml_document doc;
|
||||
editor::ConfigLoader::LoadFromLocal(doc);
|
||||
|
||||
editor::EditorConfig config;
|
||||
config.SetConfig(doc);
|
||||
|
||||
auto const types = config.GetTypesThatCanBeAdded();
|
||||
// A sample addable type.
|
||||
TEST(find(begin(types), end(types), "amenity-cafe") != end(types), ());
|
||||
// A sample line type.
|
||||
TEST(find(begin(types), end(types), "highway-primary") == end(types), ());
|
||||
// A sample type marked as can_add="no".
|
||||
TEST(find(begin(types), end(types), "landuse-cemetery") == end(types), ());
|
||||
// A sample type marked as editable="no".
|
||||
TEST(find(begin(types), end(types), "aeroway-airport") == end(types), ());
|
||||
}
|
||||
39
libs/editor/editor_tests/editor_notes_test.cpp
Normal file
39
libs/editor/editor_tests/editor_notes_test.cpp
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
#include "testing/testing.hpp"
|
||||
|
||||
#include "editor/editor_notes.hpp"
|
||||
|
||||
#include "geometry/mercator.hpp"
|
||||
|
||||
#include "platform/platform_tests_support/scoped_file.hpp"
|
||||
|
||||
#include "base/file_name_utils.hpp"
|
||||
#include "base/math.hpp"
|
||||
|
||||
using namespace editor;
|
||||
using platform::tests_support::ScopedFile;
|
||||
|
||||
UNIT_TEST(Notes_Smoke)
|
||||
{
|
||||
auto const fileName = "notes.xml";
|
||||
auto const fullFileName = base::JoinPath(GetPlatform().WritableDir(), fileName);
|
||||
ScopedFile sf(fileName, ScopedFile::Mode::DoNotCreate);
|
||||
{
|
||||
auto const notes = Notes::MakeNotes(fullFileName, true);
|
||||
notes->CreateNote(mercator::ToLatLon({1, 2}), "Some note1");
|
||||
notes->CreateNote(mercator::ToLatLon({2, 2}), "Some note2");
|
||||
notes->CreateNote(mercator::ToLatLon({1, 1}), "Some note3");
|
||||
}
|
||||
{
|
||||
auto const notes = Notes::MakeNotes(fullFileName, true);
|
||||
auto const result = notes->GetNotes();
|
||||
TEST_EQUAL(result.size(), 3, ());
|
||||
std::vector<Note> const expected{{mercator::ToLatLon({1, 2}), "Some note1"},
|
||||
{mercator::ToLatLon({2, 2}), "Some note2"},
|
||||
{mercator::ToLatLon({1, 1}), "Some note3"}};
|
||||
|
||||
auto const isEqual =
|
||||
std::equal(result.begin(), result.end(), expected.begin(), [](Note const & lhs, Note const & rhs)
|
||||
{ return lhs.m_point.EqualDxDy(rhs.m_point, Notes::kTolerance); });
|
||||
TEST(isEqual, ());
|
||||
}
|
||||
}
|
||||
530
libs/editor/editor_tests/feature_matcher_test.cpp
Normal file
530
libs/editor/editor_tests/feature_matcher_test.cpp
Normal file
|
|
@ -0,0 +1,530 @@
|
|||
#include "testing/testing.hpp"
|
||||
|
||||
#include "editor/feature_matcher.hpp"
|
||||
#include "editor/xml_feature.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <pugixml.hpp>
|
||||
|
||||
namespace
|
||||
{
|
||||
char const * const osmRawResponseWay = R"SEP(
|
||||
<osm version="0.6" generator="CGImap 0.4.0 (22123 thorn-03.openstreetmap.org)" copyright="OpenStreetMap and contributors">
|
||||
<bounds minlat="53.8976570" minlon="27.5576615" maxlat="53.8976570" maxlon="27.5576615"/>
|
||||
<node id="277171984" visible="true" version="2" changeset="20577443" timestamp="2014-02-15T14:37:39Z" user="iglezz" uid="450366" lat="53.8978034" lon="27.5577642"/>
|
||||
<node id="277171986" visible="true" version="2" changeset="20577443" timestamp="2014-02-15T14:37:39Z" user="iglezz" uid="450366" lat="53.8978710" lon="27.5576815"/>
|
||||
<node id="2673014345" visible="true" version="1" changeset="20577443" timestamp="2014-02-15T14:37:11Z" user="iglezz" uid="450366" lat="53.8977652" lon="27.5578039"/>
|
||||
<node id="277171999" visible="true" version="2" changeset="20577443" timestamp="2014-02-15T14:37:39Z" user="iglezz" uid="450366" lat="53.8977484" lon="27.5573596"/>
|
||||
<node id="277172019" visible="true" version="2" changeset="20577443" timestamp="2014-02-15T14:37:39Z" user="iglezz" uid="450366" lat="53.8977254" lon="27.5578377"/>
|
||||
<node id="277172022" visible="true" version="2" changeset="20577443" timestamp="2014-02-15T14:37:39Z" user="iglezz" uid="450366" lat="53.8976041" lon="27.5575181"/>
|
||||
<node id="277172096" visible="true" version="5" changeset="20577443" timestamp="2014-02-15T14:37:39Z" user="iglezz" uid="450366" lat="53.8972383" lon="27.5581521"/>
|
||||
<node id="277172108" visible="true" version="5" changeset="20577443" timestamp="2014-02-15T14:37:39Z" user="iglezz" uid="450366" lat="53.8971731" lon="27.5579751"/>
|
||||
<node id="420748954" visible="true" version="2" changeset="20577443" timestamp="2014-02-15T14:37:42Z" user="iglezz" uid="450366" lat="53.8973934" lon="27.5579876"/>
|
||||
<node id="420748956" visible="true" version="2" changeset="20577443" timestamp="2014-02-15T14:37:42Z" user="iglezz" uid="450366" lat="53.8976570" lon="27.5576615"/>
|
||||
<node id="420748957" visible="true" version="2" changeset="20577443" timestamp="2014-02-15T14:37:42Z" user="iglezz" uid="450366" lat="53.8973811" lon="27.5579541"/>
|
||||
<way id="25432677" visible="true" version="16" changeset="36051033" timestamp="2015-12-19T17:36:15Z" user="i+f" uid="3070773">
|
||||
<nd ref="277171999"/>
|
||||
<nd ref="277171986"/>
|
||||
<nd ref="277171984"/>
|
||||
<nd ref="2673014345"/>
|
||||
<nd ref="277172019"/>
|
||||
<nd ref="420748956"/>
|
||||
<nd ref="277172022"/>
|
||||
<nd ref="277171999"/>
|
||||
<tag k="addr:housenumber" v="16"/>
|
||||
<tag k="addr:postcode" v="220030"/>
|
||||
<tag k="addr:street" v="улица Карла Маркса"/>
|
||||
<tag k="building" v="yes"/>
|
||||
<tag k="name" v="Беллесбумпром"/>
|
||||
<tag k="office" v="company"/>
|
||||
<tag k="website" v="bellesbumprom.by"/>
|
||||
</way>
|
||||
<way id="35995664" visible="true" version="7" changeset="35318978" timestamp="2015-11-14T23:39:54Z" user="osm-belarus" uid="86479">
|
||||
<nd ref="420748956"/>
|
||||
<nd ref="420748957"/>
|
||||
<nd ref="420748954"/>
|
||||
<nd ref="277172096"/>
|
||||
<nd ref="277172108"/>
|
||||
<nd ref="277172022"/>
|
||||
<nd ref="420748956"/>
|
||||
<tag k="addr:housenumber" v="31"/>
|
||||
<tag k="addr:postcode" v="220030"/>
|
||||
<tag k="addr:street" v="Комсомольская улица"/>
|
||||
<tag k="building" v="residential"/>
|
||||
</way>
|
||||
</osm>
|
||||
)SEP";
|
||||
|
||||
char const * const osmRawResponseNode = R"SEP(
|
||||
<osm version="0.6" generator="CGImap 0.4.0 (5501 thorn-02.openstreetmap.org)" copyright="OpenStreetMap and contributors">
|
||||
<bounds minlat="53.8977000" minlon="27.5578900" maxlat="53.8977700" maxlon="27.5579800"/>
|
||||
<node id="2673014342" visible="true" version="1" changeset="20577443" timestamp="2014-02-15T14:37:11Z" user="iglezz" uid="450366" lat="53.8976095" lon="27.5579360"/>
|
||||
<node id="2673014343" visible="true" version="1" changeset="20577443" timestamp="2014-02-15T14:37:11Z" user="iglezz" uid="450366" lat="53.8977023" lon="27.5582512"/>
|
||||
<node id="2673014344" visible="true" version="1" changeset="20577443" timestamp="2014-02-15T14:37:11Z" user="iglezz" uid="450366" lat="53.8977366" lon="27.5579628"/>
|
||||
<node id="2673014345" visible="true" version="1" changeset="20577443" timestamp="2014-02-15T14:37:11Z" user="iglezz" uid="450366" lat="53.8977652" lon="27.5578039"/>
|
||||
<node id="2673014347" visible="true" version="1" changeset="20577443" timestamp="2014-02-15T14:37:11Z" user="iglezz" uid="450366" lat="53.8977970" lon="27.5579116"/>
|
||||
<node id="2673014349" visible="true" version="1" changeset="20577443" timestamp="2014-02-15T14:37:11Z" user="iglezz" uid="450366" lat="53.8977977" lon="27.5581702"/>
|
||||
<node id="277172019" visible="true" version="2" changeset="20577443" timestamp="2014-02-15T14:37:39Z" user="iglezz" uid="450366" lat="53.8977254" lon="27.5578377"/>
|
||||
<node id="3900254358" visible="true" version="1" changeset="36051033" timestamp="2015-12-19T17:36:14Z" user="i+f" uid="3070773" lat="53.8977398" lon="27.5579251">
|
||||
<tag k="name" v="Главное управление капитального строительства"/>
|
||||
<tag k="office" v="company"/>
|
||||
<tag k="website" v="guks.by"/>
|
||||
</node>
|
||||
<way id="261703253" visible="true" version="2" changeset="35318978" timestamp="2015-11-14T23:30:51Z" user="osm-belarus" uid="86479">
|
||||
<nd ref="2673014345"/>
|
||||
<nd ref="2673014347"/>
|
||||
<nd ref="2673014344"/>
|
||||
<nd ref="2673014349"/>
|
||||
<nd ref="2673014343"/>
|
||||
<nd ref="2673014342"/>
|
||||
<nd ref="277172019"/>
|
||||
<nd ref="2673014345"/>
|
||||
<tag k="addr:housenumber" v="16"/>
|
||||
<tag k="addr:postcode" v="220030"/>
|
||||
<tag k="addr:street" v="улица Карла Маркса"/>
|
||||
<tag k="building" v="residential"/>
|
||||
</way>
|
||||
</osm>
|
||||
)SEP";
|
||||
|
||||
char const * const osmRawResponseRelation = R"SEP(
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<osm version="0.6" generator="CGImap 0.4.0 (22560 thorn-01.openstreetmap.org)" copyright="OpenStreetMap and contributors">
|
||||
<bounds minlat="55.7509200" minlon="37.6397200" maxlat="55.7515400" maxlon="37.6411300"/>
|
||||
<node id="271892032" visible="true" version="4" changeset="8261156" timestamp="2011-05-27T10:18:35Z" user="Scondo" uid="421524" lat="55.7524913" lon="37.6397264"/>
|
||||
<node id="271892033" visible="true" version="4" changeset="8261156" timestamp="2011-05-27T10:18:17Z" user="Scondo" uid="421524" lat="55.7522475" lon="37.6391447"/>
|
||||
<node id="583193392" visible="true" version="2" changeset="4128036" timestamp="2010-03-14T18:31:07Z" user="Vovanium" uid="87682" lat="55.7507909" lon="37.6404902"/>
|
||||
<node id="583193432" visible="true" version="3" changeset="4128036" timestamp="2010-03-14T18:31:08Z" user="Vovanium" uid="87682" lat="55.7510964" lon="37.6397197"/>
|
||||
<node id="583193426" visible="true" version="3" changeset="4128036" timestamp="2010-03-14T18:31:08Z" user="Vovanium" uid="87682" lat="55.7510560" lon="37.6394035"/>
|
||||
<node id="583193429" visible="true" version="3" changeset="4128036" timestamp="2010-03-14T18:31:08Z" user="Vovanium" uid="87682" lat="55.7512865" lon="37.6396919"/>
|
||||
<node id="583193395" visible="true" version="2" changeset="4128036" timestamp="2010-03-14T18:31:08Z" user="Vovanium" uid="87682" lat="55.7509787" lon="37.6401799"/>
|
||||
<node id="583193415" visible="true" version="3" changeset="4128036" timestamp="2010-03-14T18:31:08Z" user="Vovanium" uid="87682" lat="55.7510898" lon="37.6403571"/>
|
||||
<node id="583193424" visible="true" version="3" changeset="4128036" timestamp="2010-03-14T18:31:08Z" user="Vovanium" uid="87682" lat="55.7508581" lon="37.6399029"/>
|
||||
<node id="583193422" visible="true" version="3" changeset="4128036" timestamp="2010-03-14T18:31:08Z" user="Vovanium" uid="87682" lat="55.7509689" lon="37.6400415"/>
|
||||
<node id="583193398" visible="true" version="2" changeset="4128036" timestamp="2010-03-14T18:31:08Z" user="Vovanium" uid="87682" lat="55.7514775" lon="37.6401937"/>
|
||||
<node id="583193416" visible="true" version="3" changeset="4128036" timestamp="2010-03-14T18:31:08Z" user="Vovanium" uid="87682" lat="55.7513532" lon="37.6405069"/>
|
||||
<node id="583193431" visible="true" version="3" changeset="4128036" timestamp="2010-03-14T18:31:08Z" user="Vovanium" uid="87682" lat="55.7512162" lon="37.6398695"/>
|
||||
<node id="583193390" visible="true" version="2" changeset="4128036" timestamp="2010-03-14T18:31:08Z" user="Vovanium" uid="87682" lat="55.7507783" lon="37.6410989"/>
|
||||
<node id="583193388" visible="true" version="2" changeset="4128036" timestamp="2010-03-14T18:31:08Z" user="Vovanium" uid="87682" lat="55.7509982" lon="37.6416194"/>
|
||||
<node id="583193405" visible="true" version="3" changeset="4128036" timestamp="2010-03-14T18:31:08Z" user="Vovanium" uid="87682" lat="55.7514149" lon="37.6406910"/>
|
||||
<node id="583193408" visible="true" version="2" changeset="4128036" timestamp="2010-03-14T18:31:08Z" user="Vovanium" uid="87682" lat="55.7509930" lon="37.6412441"/>
|
||||
<node id="583193410" visible="true" version="3" changeset="4128036" timestamp="2010-03-14T18:31:08Z" user="Vovanium" uid="87682" lat="55.7509124" lon="37.6406648"/>
|
||||
<node id="583193401" visible="true" version="2" changeset="4128036" timestamp="2010-03-14T18:31:09Z" user="Vovanium" uid="87682" lat="55.7516648" lon="37.6407506"/>
|
||||
<node id="666179513" visible="true" version="1" changeset="4128036" timestamp="2010-03-14T18:30:48Z" user="Vovanium" uid="87682" lat="55.7510740" lon="37.6401059"/>
|
||||
<node id="666179517" visible="true" version="1" changeset="4128036" timestamp="2010-03-14T18:30:48Z" user="Vovanium" uid="87682" lat="55.7511507" lon="37.6403206"/>
|
||||
<node id="666179519" visible="true" version="1" changeset="4128036" timestamp="2010-03-14T18:30:48Z" user="Vovanium" uid="87682" lat="55.7512863" lon="37.6403782"/>
|
||||
<node id="666179521" visible="true" version="1" changeset="4128036" timestamp="2010-03-14T18:30:48Z" user="Vovanium" uid="87682" lat="55.7512185" lon="37.6403206"/>
|
||||
<node id="666179522" visible="true" version="1" changeset="4128036" timestamp="2010-03-14T18:30:48Z" user="Vovanium" uid="87682" lat="55.7512214" lon="37.6400483"/>
|
||||
<node id="666179524" visible="true" version="1" changeset="4128036" timestamp="2010-03-14T18:30:48Z" user="Vovanium" uid="87682" lat="55.7513393" lon="37.6401111"/>
|
||||
<node id="666179526" visible="true" version="1" changeset="4128036" timestamp="2010-03-14T18:30:48Z" user="Vovanium" uid="87682" lat="55.7514337" lon="37.6402525"/>
|
||||
<node id="666179528" visible="true" version="1" changeset="4128036" timestamp="2010-03-14T18:30:48Z" user="Vovanium" uid="87682" lat="55.7507439" lon="37.6406349"/>
|
||||
<node id="666179530" visible="true" version="1" changeset="4128036" timestamp="2010-03-14T18:30:48Z" user="Vovanium" uid="87682" lat="55.7507291" lon="37.6407868"/>
|
||||
<node id="666179531" visible="true" version="1" changeset="4128036" timestamp="2010-03-14T18:30:48Z" user="Vovanium" uid="87682" lat="55.7507380" lon="37.6409544"/>
|
||||
<node id="666179540" visible="true" version="1" changeset="4128036" timestamp="2010-03-14T18:30:48Z" user="Vovanium" uid="87682" lat="55.7508736" lon="37.6408287"/>
|
||||
<node id="595699492" visible="true" version="2" changeset="4128036" timestamp="2010-03-14T18:31:08Z" user="Vovanium" uid="87682" lat="55.7508900" lon="37.6410015"/>
|
||||
<node id="271892037" visible="true" version="4" changeset="8261156" timestamp="2011-05-27T10:18:03Z" user="Scondo" uid="421524" lat="55.7519689" lon="37.6393462"/>
|
||||
<node id="666179544" visible="true" version="2" changeset="8261156" timestamp="2011-05-27T10:18:03Z" user="Scondo" uid="421524" lat="55.7523858" lon="37.6394615"/>
|
||||
<node id="271892040" visible="true" version="4" changeset="8261156" timestamp="2011-05-27T10:18:09Z" user="Scondo" uid="421524" lat="55.7518044" lon="37.6401900"/>
|
||||
<node id="271892039" visible="true" version="4" changeset="8261156" timestamp="2011-05-27T10:18:11Z" user="Scondo" uid="421524" lat="55.7518997" lon="37.6400631"/>
|
||||
<node id="271892031" visible="true" version="4" changeset="8261156" timestamp="2011-05-27T10:18:23Z" user="Scondo" uid="421524" lat="55.7517772" lon="37.6406618"/>
|
||||
<node id="271892036" visible="true" version="4" changeset="8261156" timestamp="2011-05-27T10:18:23Z" user="Scondo" uid="421524" lat="55.7521424" lon="37.6397730"/>
|
||||
<node id="271892035" visible="true" version="4" changeset="8261156" timestamp="2011-05-27T10:18:25Z" user="Scondo" uid="421524" lat="55.7522520" lon="37.6396264"/>
|
||||
<node id="666179542" visible="true" version="2" changeset="8261156" timestamp="2011-05-27T10:18:26Z" user="Scondo" uid="421524" lat="55.7523415" lon="37.6393631"/>
|
||||
<node id="271892038" visible="true" version="4" changeset="8261156" timestamp="2011-05-27T10:18:30Z" user="Scondo" uid="421524" lat="55.7517353" lon="37.6396389"/>
|
||||
<node id="666179545" visible="true" version="2" changeset="8261156" timestamp="2011-05-27T10:18:30Z" user="Scondo" uid="421524" lat="55.7523947" lon="37.6392844"/>
|
||||
<node id="271892041" visible="true" version="4" changeset="8261156" timestamp="2011-05-27T10:18:34Z" user="Scondo" uid="421524" lat="55.7516804" lon="37.6398672"/>
|
||||
<node id="666179548" visible="true" version="2" changeset="8261156" timestamp="2011-05-27T10:18:35Z" user="Scondo" uid="421524" lat="55.7524390" lon="37.6393828"/>
|
||||
<node id="271892030" visible="true" version="4" changeset="8261156" timestamp="2011-05-27T10:18:38Z" user="Scondo" uid="421524" lat="55.7515240" lon="37.6400640"/>
|
||||
<node id="271892034" visible="true" version="4" changeset="8261156" timestamp="2011-05-27T10:18:40Z" user="Scondo" uid="421524" lat="55.7521203" lon="37.6393028"/>
|
||||
<node id="2849850611" visible="true" version="2" changeset="33550372" timestamp="2015-08-24T15:55:36Z" user="vadp" uid="326091" lat="55.7507261" lon="37.6405934"/>
|
||||
<node id="2849850614" visible="true" version="1" changeset="22264538" timestamp="2014-05-11T07:26:43Z" user="Vadim Zudkin" uid="177747" lat="55.7509233" lon="37.6401297"/>
|
||||
<node id="3712207029" visible="true" version="1" changeset="33550372" timestamp="2015-08-24T15:55:35Z" user="vadp" uid="326091" lat="55.7510865" lon="37.6400013"/>
|
||||
<node id="3712207030" visible="true" version="1" changeset="33550372" timestamp="2015-08-24T15:55:35Z" user="vadp" uid="326091" lat="55.7512462" lon="37.6399456"/>
|
||||
<node id="3712207031" visible="true" version="2" changeset="33550412" timestamp="2015-08-24T15:57:10Z" user="vadp" uid="326091" lat="55.7514944" lon="37.6401534"/>
|
||||
<node id="3712207032" visible="true" version="2" changeset="33550412" timestamp="2015-08-24T15:57:10Z" user="vadp" uid="326091" lat="55.7516969" lon="37.6407362">
|
||||
<tag k="access" v="private"/>
|
||||
<tag k="barrier" v="gate"/>
|
||||
</node>
|
||||
<node id="3712207033" visible="true" version="2" changeset="33550412" timestamp="2015-08-24T15:57:10Z" user="vadp" uid="326091" lat="55.7517316" lon="37.6408217"/>
|
||||
<node id="3712207034" visible="true" version="2" changeset="33550412" timestamp="2015-08-24T15:57:10Z" user="vadp" uid="326091" lat="55.7517602" lon="37.6409066"/>
|
||||
<node id="2849850613" visible="true" version="3" changeset="33551686" timestamp="2015-08-24T16:50:21Z" user="vadp" uid="326091" lat="55.7507965" lon="37.6399611"/>
|
||||
<node id="338464706" visible="true" version="3" changeset="33551686" timestamp="2015-08-24T16:50:21Z" user="vadp" uid="326091" lat="55.7510322" lon="37.6393637"/>
|
||||
<node id="338464708" visible="true" version="7" changeset="33551686" timestamp="2015-08-24T16:50:21Z" user="vadp" uid="326091" lat="55.7515407" lon="37.6383137"/>
|
||||
<node id="3755931947" visible="true" version="1" changeset="34206452" timestamp="2015-09-23T13:58:11Z" user="trolleway" uid="397326" lat="55.7517090" lon="37.6407565"/>
|
||||
<way id="25009838" visible="true" version="14" changeset="28090002" timestamp="2015-01-12T16:15:21Z" user="midrug" uid="2417727">
|
||||
<nd ref="271892030"/>
|
||||
<nd ref="271892031"/>
|
||||
<nd ref="271892032"/>
|
||||
<nd ref="666179544"/>
|
||||
<nd ref="666179548"/>
|
||||
<nd ref="666179545"/>
|
||||
<nd ref="666179542"/>
|
||||
<nd ref="271892033"/>
|
||||
<nd ref="271892034"/>
|
||||
<nd ref="271892035"/>
|
||||
<nd ref="271892036"/>
|
||||
<nd ref="271892037"/>
|
||||
<nd ref="271892038"/>
|
||||
<nd ref="271892039"/>
|
||||
<nd ref="271892040"/>
|
||||
<nd ref="271892041"/>
|
||||
<nd ref="271892030"/>
|
||||
<tag k="addr:housenumber" v="12-14"/>
|
||||
<tag k="addr:street" v="улица Солянка"/>
|
||||
<tag k="building" v="yes"/>
|
||||
<tag k="building:colour" v="lightpink"/>
|
||||
<tag k="building:levels" v="3"/>
|
||||
<tag k="description:en" v="Housed the Board of Trustees, a public institution of the Russian Empire until 1917"/>
|
||||
<tag k="end_date" v="1826"/>
|
||||
<tag k="name" v="Опекунский совет"/>
|
||||
<tag k="name:de" v="Kuratorium"/>
|
||||
<tag k="name:en" v="Board of Trustees Building"/>
|
||||
<tag k="ref" v="7710784000"/>
|
||||
<tag k="roof:material" v="metal"/>
|
||||
<tag k="source:description:en" v="wikipedia:ru"/>
|
||||
<tag k="start_date" v="1823"/>
|
||||
<tag k="tourism" v="attraction"/>
|
||||
<tag k="wikipedia" v="ru:Опекунский совет (Москва)"/>
|
||||
</way>
|
||||
<way id="45814282" visible="true" version="3" changeset="4128036" timestamp="2010-03-14T18:31:24Z" user="Vovanium" uid="87682">
|
||||
<nd ref="583193405"/>
|
||||
<nd ref="583193408"/>
|
||||
<nd ref="595699492"/>
|
||||
<nd ref="666179540"/>
|
||||
<nd ref="583193410"/>
|
||||
<nd ref="583193415"/>
|
||||
<nd ref="666179517"/>
|
||||
<nd ref="666179521"/>
|
||||
<nd ref="666179519"/>
|
||||
<nd ref="583193416"/>
|
||||
<nd ref="583193405"/>
|
||||
</way>
|
||||
<way id="109538181" visible="true" version="7" changeset="34206452" timestamp="2015-09-23T13:58:11Z" user="trolleway" uid="397326">
|
||||
<nd ref="338464708"/>
|
||||
<nd ref="338464706"/>
|
||||
<nd ref="2849850613"/>
|
||||
<nd ref="2849850614"/>
|
||||
<nd ref="3712207029"/>
|
||||
<nd ref="3712207030"/>
|
||||
<nd ref="3712207031"/>
|
||||
<nd ref="3712207032"/>
|
||||
<nd ref="3755931947"/>
|
||||
<nd ref="3712207033"/>
|
||||
<nd ref="3712207034"/>
|
||||
<tag k="highway" v="service"/>
|
||||
</way>
|
||||
<way id="45814281" visible="true" version="6" changeset="9583527" timestamp="2011-10-17T16:38:55Z" user="luch86" uid="266092">
|
||||
<nd ref="583193388"/>
|
||||
<nd ref="583193390"/>
|
||||
<nd ref="666179531"/>
|
||||
<nd ref="666179530"/>
|
||||
<nd ref="666179528"/>
|
||||
<nd ref="583193392"/>
|
||||
<nd ref="583193395"/>
|
||||
<nd ref="666179513"/>
|
||||
<nd ref="666179522"/>
|
||||
<nd ref="666179524"/>
|
||||
<nd ref="666179526"/>
|
||||
<nd ref="583193398"/>
|
||||
<nd ref="583193401"/>
|
||||
<nd ref="583193388"/>
|
||||
</way>
|
||||
<way id="45814283" visible="true" version="3" changeset="28090002" timestamp="2015-01-12T16:15:23Z" user="midrug" uid="2417727">
|
||||
<nd ref="583193422"/>
|
||||
<nd ref="583193424"/>
|
||||
<nd ref="583193426"/>
|
||||
<nd ref="583193429"/>
|
||||
<nd ref="583193431"/>
|
||||
<nd ref="583193432"/>
|
||||
<nd ref="583193422"/>
|
||||
<tag k="addr:street" v="улица Солянка"/>
|
||||
<tag k="building" v="yes"/>
|
||||
<tag k="building:colour" v="goldenrod"/>
|
||||
<tag k="building:levels" v="2"/>
|
||||
<tag k="roof:colour" v="black"/>
|
||||
<tag k="roof:material" v="tar_paper"/>
|
||||
</way>
|
||||
<way id="367274913" visible="true" version="2" changeset="33550484" timestamp="2015-08-24T16:00:25Z" user="vadp" uid="326091">
|
||||
<nd ref="2849850614"/>
|
||||
<nd ref="2849850611"/>
|
||||
<tag k="highway" v="service"/>
|
||||
</way>
|
||||
<relation id="365808" visible="true" version="6" changeset="28090002" timestamp="2015-01-12T16:15:14Z" user="midrug" uid="2417727">
|
||||
<member type="way" ref="45814281" role="outer"/>
|
||||
<member type="way" ref="45814282" role="inner"/>
|
||||
<tag k="addr:housenumber" v="14/2"/>
|
||||
<tag k="addr:street" v="улица Солянка"/>
|
||||
<tag k="building" v="yes"/>
|
||||
<tag k="building:colour" v="gold"/>
|
||||
<tag k="building:levels" v="2"/>
|
||||
<tag k="roof:material" v="metal"/>
|
||||
<tag k="type" v="multipolygon"/>
|
||||
</relation>
|
||||
</osm>
|
||||
)SEP";
|
||||
|
||||
// Note: Geometry should not contain duplicates.
|
||||
|
||||
UNIT_TEST(GetBestOsmNode_Test)
|
||||
{
|
||||
{
|
||||
pugi::xml_document osmResponse;
|
||||
TEST(osmResponse.load_buffer(osmRawResponseNode, ::strlen(osmRawResponseNode)), ());
|
||||
|
||||
auto const bestNode = matcher::GetBestOsmNode(osmResponse, ms::LatLon(53.8977398, 27.5579251));
|
||||
TEST_EQUAL(editor::XMLFeature(bestNode).GetName(), "Главное управление капитального строительства", ());
|
||||
}
|
||||
{
|
||||
pugi::xml_document osmResponse;
|
||||
TEST(osmResponse.load_buffer(osmRawResponseNode, ::strlen(osmRawResponseNode)), ());
|
||||
|
||||
auto const bestNode = matcher::GetBestOsmNode(osmResponse, ms::LatLon(53.8977254, 27.5578377));
|
||||
TEST_EQUAL(bestNode.attribute("id").value(), std::string("277172019"), ());
|
||||
}
|
||||
}
|
||||
|
||||
UNIT_TEST(GetBestOsmWay_Test)
|
||||
{
|
||||
{
|
||||
pugi::xml_document osmResponse;
|
||||
TEST(osmResponse.load_buffer(osmRawResponseWay, ::strlen(osmRawResponseWay)), ());
|
||||
std::vector<m2::PointD> const geometry = {
|
||||
{27.557515856307106, 64.236609073256034}, {27.55784576801841, 64.236820967769773},
|
||||
{27.557352241556003, 64.236863883114324}, {27.55784576801841, 64.236820967769773},
|
||||
{27.557352241556003, 64.236863883114324}, {27.557765301747366, 64.236963124848614},
|
||||
{27.557352241556003, 64.236863883114324}, {27.557765301747366, 64.236963124848614},
|
||||
{27.55768215326728, 64.237078459837136}};
|
||||
|
||||
auto const bestWay = matcher::GetBestOsmWayOrRelation(osmResponse, geometry);
|
||||
TEST(bestWay, ());
|
||||
TEST_EQUAL(editor::XMLFeature(bestWay).GetName(), "Беллесбумпром", ());
|
||||
}
|
||||
{
|
||||
pugi::xml_document osmResponse;
|
||||
TEST(osmResponse.load_buffer(osmRawResponseWay, ::strlen(osmRawResponseWay)), ());
|
||||
// Each point is moved for 0.0001 on x and y. It is aboout a half of side length.
|
||||
std::vector<m2::PointD> const geometry = {
|
||||
{27.557615856307106, 64.236709073256034}, {27.55794576801841, 64.236920967769773},
|
||||
{27.557452241556003, 64.236963883114324}, {27.55794576801841, 64.236920967769773},
|
||||
{27.557452241556003, 64.236963883114324}, {27.557865301747366, 64.237063124848614},
|
||||
{27.557452241556003, 64.236963883114324}, {27.557865301747366, 64.237063124848614},
|
||||
{27.55778215326728, 64.237178459837136}};
|
||||
|
||||
auto const bestWay = matcher::GetBestOsmWayOrRelation(osmResponse, geometry);
|
||||
TEST(!bestWay, ());
|
||||
}
|
||||
}
|
||||
|
||||
UNIT_TEST(GetBestOsmRealtion_Test)
|
||||
{
|
||||
pugi::xml_document osmResponse;
|
||||
TEST(osmResponse.load_buffer(osmRawResponseRelation, ::strlen(osmRawResponseRelation)), ());
|
||||
std::vector<m2::PointD> const geometry = {
|
||||
{37.640253436865322, 67.455316241497655}, {37.64019442826654, 67.455394025559684},
|
||||
{37.640749645536772, 67.455726619480004}, {37.640253436865322, 67.455316241497655},
|
||||
{37.640749645536772, 67.455726619480004}, {37.64069063693799, 67.455281372780206},
|
||||
{37.640253436865322, 67.455316241497655}, {37.64069063693799, 67.455281372780206},
|
||||
{37.640505564514598, 67.455174084418815}, {37.640253436865322, 67.455316241497655},
|
||||
{37.640505564514598, 67.455174084418815}, {37.640376818480917, 67.455053385012263},
|
||||
{37.640253436865322, 67.455316241497655}, {37.640376818480917, 67.455053385012263},
|
||||
{37.640320492091178, 67.454932685605684}, {37.640253436865322, 67.455316241497655},
|
||||
{37.640320492091178, 67.454932685605684}, {37.640111279786453, 67.455147262328467},
|
||||
{37.640111279786453, 67.455147262328467}, {37.640320492091178, 67.454932685605684},
|
||||
{37.640046906769612, 67.454938050023742}, {37.640046906769612, 67.454938050023742},
|
||||
{37.640320492091178, 67.454932685605684}, {37.640320492091178, 67.454811986199104},
|
||||
{37.640046906769612, 67.454938050023742}, {37.640320492091178, 67.454811986199104},
|
||||
{37.640105915368395, 67.454677875747365}, {37.640105915368395, 67.454677875747365},
|
||||
{37.640320492091178, 67.454811986199104}, {37.64035804301767, 67.454704697837713},
|
||||
{37.640105915368395, 67.454677875747365}, {37.64035804301767, 67.454704697837713},
|
||||
{37.64018101722138, 67.454508896578176}, {37.64018101722138, 67.454508896578176},
|
||||
{37.64035804301767, 67.454704697837713}, {37.640663814847642, 67.454390879380639},
|
||||
{37.64018101722138, 67.454508896578176}, {37.640663814847642, 67.454390879380639},
|
||||
{37.640489471260366, 67.454173620448813}, {37.640489471260366, 67.454173620448813},
|
||||
{37.640663814847642, 67.454390879380639}, {37.640634310548251, 67.454090471968726},
|
||||
{37.640634310548251, 67.454090471968726}, {37.640663814847642, 67.454390879380639},
|
||||
{37.640827429598772, 67.454321141945741}, {37.640634310548251, 67.454090471968726},
|
||||
{37.640827429598772, 67.454321141945741}, {37.640787196463265, 67.454063649878378},
|
||||
{37.640787196463265, 67.454063649878378}, {37.640827429598772, 67.454321141945741},
|
||||
{37.64095349342341, 67.454079743132581}, {37.64095349342341, 67.454079743132581},
|
||||
{37.640827429598772, 67.454321141945741}, {37.641001773186048, 67.454350646245103},
|
||||
{37.64095349342341, 67.454079743132581}, {37.641001773186048, 67.454350646245103},
|
||||
{37.641098332711294, 67.454152162776523}, {37.641098332711294, 67.454152162776523},
|
||||
{37.641001773186048, 67.454350646245103}, {37.641243171999179, 67.45453303645948},
|
||||
{37.641098332711294, 67.454152162776523}, {37.641243171999179, 67.45453303645948},
|
||||
{37.641618681264049, 67.454541083086582}, {37.641618681264049, 67.454541083086582},
|
||||
{37.641243171999179, 67.45453303645948}, {37.64069063693799, 67.455281372780206},
|
||||
{37.641618681264049, 67.454541083086582}, {37.64069063693799, 67.455281372780206},
|
||||
{37.640749645536772, 67.455726619480004}};
|
||||
|
||||
auto const bestWay = matcher::GetBestOsmWayOrRelation(osmResponse, geometry);
|
||||
TEST_EQUAL(bestWay.attribute("id").value(), std::string("365808"), ());
|
||||
}
|
||||
|
||||
char const * const osmResponseBuildingMiss = R"SEP(
|
||||
<osm version="0.6" generator="CGImap 0.4.0 (8662 thorn-01.openstreetmap.org)">
|
||||
<bounds minlat="51.5342700" minlon="-0.2047000" maxlat="51.5343200" maxlon="-0.2046300"/>
|
||||
<node id="861357349" visible="true" version="3" changeset="31214483" timestamp="2015-05-16T23:10:03Z" user="Derick Rethans" uid="37137" lat="51.5342451" lon="-0.2046356"/>
|
||||
<node id="3522706827" visible="true" version="1" changeset="31214483" timestamp="2015-05-16T23:09:47Z" user="Derick Rethans" uid="37137" lat="51.5342834" lon="-0.2046544">
|
||||
<tag k="addr:housenumber" v="26a"/>
|
||||
<tag k="addr:street" v="Salusbury Road"/>
|
||||
</node>
|
||||
<node id="3522707171" visible="true" version="1" changeset="31214483" timestamp="2015-05-16T23:09:50Z" user="Derick Rethans" uid="37137" lat="51.5342161" lon="-0.2047884"/>
|
||||
<node id="3522707175" visible="true" version="1" changeset="31214483" timestamp="2015-05-16T23:09:50Z" user="Derick Rethans" uid="37137" lat="51.5342627" lon="-0.2048113"/>
|
||||
<node id="3522707179" visible="true" version="1" changeset="31214483" timestamp="2015-05-16T23:09:50Z" user="Derick Rethans" uid="37137" lat="51.5342918" lon="-0.2046585"/>
|
||||
<node id="3522707180" visible="true" version="1" changeset="31214483" timestamp="2015-05-16T23:09:50Z" user="Derick Rethans" uid="37137" lat="51.5343060" lon="-0.2048326"/>
|
||||
<node id="3522707185" visible="true" version="1" changeset="31214483" timestamp="2015-05-16T23:09:50Z" user="Derick Rethans" uid="37137" lat="51.5343350" lon="-0.2046798"/>
|
||||
<way id="345630057" visible="true" version="3" changeset="38374962" timestamp="2016-04-07T09:19:02Z" user="Derick Rethans" uid="37137">
|
||||
<nd ref="3522707179"/>
|
||||
<nd ref="3522707185"/>
|
||||
<nd ref="3522707180"/>
|
||||
<nd ref="3522707175"/>
|
||||
<nd ref="3522707179"/>
|
||||
<tag k="addr:housenumber" v="26"/>
|
||||
<tag k="addr:street" v="Salusbury Road"/>
|
||||
<tag k="building" v="yes"/>
|
||||
<tag k="building:levels" v="1"/>
|
||||
<tag k="name" v="Londis"/>
|
||||
<tag k="shop" v="convenience"/>
|
||||
</way>
|
||||
<way id="345630019" visible="true" version="2" changeset="38374962" timestamp="2016-04-07T09:19:02Z" user="Derick Rethans" uid="37137">
|
||||
<nd ref="861357349"/>
|
||||
<nd ref="3522706827"/>
|
||||
<nd ref="3522707179"/>
|
||||
<nd ref="3522707175"/>
|
||||
<nd ref="3522707171"/>
|
||||
<nd ref="861357349"/>
|
||||
<tag k="addr:housenumber" v="26"/>
|
||||
<tag k="addr:street" v="Salusbury Road"/>
|
||||
<tag k="building" v="yes"/>
|
||||
<tag k="building:levels" v="2"/>
|
||||
<tag k="name" v="Shampoo Hair Salon"/>
|
||||
<tag k="shop" v="hairdresser"/>
|
||||
</way>
|
||||
</osm>
|
||||
)SEP";
|
||||
|
||||
UNIT_TEST(HouseBuildingMiss_test)
|
||||
{
|
||||
pugi::xml_document osmResponse;
|
||||
TEST(osmResponse.load_buffer(osmResponseBuildingMiss, ::strlen(osmResponseBuildingMiss)), ());
|
||||
std::vector<m2::PointD> const geometry = {
|
||||
{-0.2048121407986514, 60.333984198674443}, {-0.20478800091734684, 60.333909096821458},
|
||||
{-0.20465925488366565, 60.334029796228037}, {-0.2048121407986514, 60.333984198674443},
|
||||
{-0.20478800091734684, 60.333909096821458}, {-0.20463511500236109, 60.333954694375052}};
|
||||
|
||||
auto const bestWay = matcher::GetBestOsmWayOrRelation(osmResponse, geometry);
|
||||
TEST_EQUAL(bestWay.attribute("id").value(), std::string("345630019"), ());
|
||||
}
|
||||
|
||||
std::string const kHouseWithSeveralEntrances = R"xxx("
|
||||
<osm version="0.6" generator="CGImap 0.6.0 (3589 thorn-03.openstreetmap.org)" copyright="OpenStreetMap and contributors" attribution="http://www.openstreetmap.org/copyright" license="http://opendatacommons.org/licenses/odbl/1-0/">
|
||||
<node id="339283610" visible="true" version="6" changeset="33699414" timestamp="2015-08-31T09:53:02Z" user="Lazy Ranma" uid="914471" lat="55.8184397" lon="37.5700770"/>
|
||||
<node id="339283612" visible="true" version="6" changeset="33699414" timestamp="2015-08-31T09:53:02Z" user="Lazy Ranma" uid="914471" lat="55.8184655" lon="37.5702599"/>
|
||||
<node id="339283614" visible="true" version="6" changeset="33699414" timestamp="2015-08-31T09:53:02Z" user="Lazy Ranma" uid="914471" lat="55.8190524" lon="37.5698027"/>
|
||||
<node id="339283615" visible="true" version="6" changeset="33699414" timestamp="2015-08-31T09:53:02Z" user="Lazy Ranma" uid="914471" lat="55.8190782" lon="37.5699856"/>
|
||||
<node id="1131238558" visible="true" version="7" changeset="33699414" timestamp="2015-08-31T09:52:50Z" user="Lazy Ranma" uid="914471" lat="55.8188226" lon="37.5699055">
|
||||
<tag k="entrance" v="yes"/>
|
||||
<tag k="ref" v="2"/>
|
||||
</node>
|
||||
<node id="1131238581" visible="true" version="7" changeset="33699414" timestamp="2015-08-31T09:52:51Z" user="Lazy Ranma" uid="914471" lat="55.8185163" lon="37.5700427">
|
||||
<tag k="entrance" v="yes"/>
|
||||
<tag k="ref" v="4"/>
|
||||
</node>
|
||||
<node id="1131238623" visible="true" version="7" changeset="33699414" timestamp="2015-08-31T09:52:51Z" user="Lazy Ranma" uid="914471" lat="55.8189758" lon="37.5698370">
|
||||
<tag k="entrance" v="yes"/>
|
||||
<tag k="ref" v="1"/>
|
||||
</node>
|
||||
<node id="1131238704" visible="true" version="7" changeset="33699414" timestamp="2015-08-31T09:52:52Z" user="Lazy Ranma" uid="914471" lat="55.8186694" lon="37.5699741">
|
||||
<tag k="entrance" v="yes"/>
|
||||
<tag k="ref" v="3"/>
|
||||
</node>
|
||||
<way id="30680719" visible="true" version="10" changeset="25301783" timestamp="2014-09-08T07:52:43Z" user="Felis Pimeja" uid="260756">
|
||||
<nd ref="339283614"/>
|
||||
<nd ref="339283615"/>
|
||||
<nd ref="339283612"/>
|
||||
<nd ref="339283610"/>
|
||||
<nd ref="1131238581"/>
|
||||
<nd ref="1131238704"/>
|
||||
<nd ref="1131238558"/>
|
||||
<nd ref="1131238623"/>
|
||||
<nd ref="339283614"/>
|
||||
<tag k="addr:city" v="Москва"/>
|
||||
<tag k="addr:country" v="RU"/>
|
||||
<tag k="addr:housenumber" v="14 к1"/>
|
||||
<tag k="addr:street" v="Ивановская улица"/>
|
||||
<tag k="building" v="yes"/>
|
||||
</way>
|
||||
</osm>
|
||||
)xxx";
|
||||
|
||||
UNIT_TEST(HouseWithSeveralEntrances)
|
||||
{
|
||||
pugi::xml_document osmResponse;
|
||||
TEST(osmResponse.load_buffer(kHouseWithSeveralEntrances.c_str(), kHouseWithSeveralEntrances.size()), ());
|
||||
|
||||
std::vector<m2::PointD> geometry = {
|
||||
{37.570076119676798, 67.574481424499169}, {37.570258509891175, 67.574527022052763},
|
||||
{37.569802534355233, 67.575570401367315}, {37.570258509891175, 67.574527022052763},
|
||||
{37.569802534355233, 67.575570401367315}, {37.56998492456961, 67.57561599892091}};
|
||||
|
||||
auto const bestWay = matcher::GetBestOsmWayOrRelation(osmResponse, geometry);
|
||||
TEST_EQUAL(bestWay.attribute("id").value(), std::string("30680719"), ());
|
||||
}
|
||||
|
||||
std::string const kRelationWithSingleWay = R"XXX(
|
||||
<osm version="0.6" generator="CGImap 0.6.0 (2191 thorn-01.openstreetmap.org)" copyright="OpenStreetMap and contributors" attribution="http://www.openstreetmap.org/copyright" license="http://opendatacommons.org/licenses/odbl/1-0/">
|
||||
<node id="287253844" visible="true" version="6" changeset="41744272" timestamp="2016-08-27T20:57:16Z" user="Vadiм" uid="326091" lat="55.7955735" lon="37.5399204"/>
|
||||
<node id="287253846" visible="true" version="6" changeset="41744272" timestamp="2016-08-27T20:57:16Z" user="Vadiм" uid="326091" lat="55.7952597" lon="37.5394774"/>
|
||||
<node id="287253848" visible="true" version="6" changeset="41744272" timestamp="2016-08-27T20:57:16Z" user="Vadiм" uid="326091" lat="55.7947419" lon="37.5406379"/>
|
||||
<node id="287253850" visible="true" version="7" changeset="41744272" timestamp="2016-08-27T20:57:16Z" user="Vadiм" uid="326091" lat="55.7950556" lon="37.5410809"/>
|
||||
<node id="3481651579" visible="true" version="2" changeset="41744272" timestamp="2016-08-27T20:57:16Z" user="Vadiм" uid="326091" lat="55.7946855" lon="37.5407643"/>
|
||||
<node id="3481651621" visible="true" version="2" changeset="41744272" timestamp="2016-08-27T20:57:16Z" user="Vadiм" uid="326091" lat="55.7949992" lon="37.5412073"/>
|
||||
<node id="4509122916" visible="true" version="1" changeset="43776534" timestamp="2016-11-18T19:35:01Z" user="aq123" uid="4289510" lat="55.7954158" lon="37.5396978">
|
||||
<tag k="entrance" v="main"/>
|
||||
</node>
|
||||
<way id="26232961" visible="true" version="10" changeset="43776534" timestamp="2016-11-18T19:35:01Z" user="aq123" uid="4289510">
|
||||
<nd ref="287253844"/>
|
||||
<nd ref="4509122916"/>
|
||||
<nd ref="287253846"/>
|
||||
<nd ref="287253848"/>
|
||||
<nd ref="3481651579"/>
|
||||
<nd ref="3481651621"/>
|
||||
<nd ref="287253850"/>
|
||||
<nd ref="287253844"/>
|
||||
<tag k="building" v="yes"/>
|
||||
<tag k="leisure" v="sports_centre"/>
|
||||
</way>
|
||||
<relation id="111" visible="true" version="6" changeset="222" timestamp="2015-01-12T16:15:14Z" user="test" uid="333">
|
||||
<member type="way" ref="26232961"/>
|
||||
<tag k="building" v="yes"/>
|
||||
<tag k="type" v="multipolygon"/>
|
||||
</relation>
|
||||
</osm>
|
||||
)XXX";
|
||||
|
||||
UNIT_TEST(RelationWithSingleWay)
|
||||
{
|
||||
pugi::xml_document osmResponse;
|
||||
TEST(osmResponse.load_buffer(kRelationWithSingleWay.c_str(), kRelationWithSingleWay.size()), ());
|
||||
|
||||
std::vector<m2::PointD> geometry = {
|
||||
{37.539920043497688, 67.533792313440074}, {37.539477479006933, 67.533234413960827},
|
||||
{37.541207503834414, 67.532770391797811}, {37.539477479006933, 67.533234413960827},
|
||||
{37.541207503834414, 67.532770391797811}, {37.54076493934366, 67.532212492318536}};
|
||||
|
||||
auto const bestWay = matcher::GetBestOsmWayOrRelation(osmResponse, geometry);
|
||||
TEST_EQUAL(bestWay.attribute("id").value(), std::string("26232961"), ());
|
||||
}
|
||||
|
||||
UNIT_TEST(ScoreTriangulatedGeometries)
|
||||
{
|
||||
std::vector<m2::PointD> lhs = {{0, 0}, {10, 10}, {10, 0}, {0, 0}, {10, 10}, {0, 10}};
|
||||
|
||||
std::vector<m2::PointD> rhs = {{-1, -1}, {9, 9}, {9, -1}, {-1, -1}, {9, 9}, {-1, 9}};
|
||||
|
||||
auto const score = matcher::ScoreTriangulatedGeometries(lhs, rhs);
|
||||
TEST_GREATER(score, 0.6, ());
|
||||
}
|
||||
} // namespace
|
||||
205
libs/editor/editor_tests/match_by_geometry_test.cpp
Normal file
205
libs/editor/editor_tests/match_by_geometry_test.cpp
Normal file
|
|
@ -0,0 +1,205 @@
|
|||
#include "testing/testing.hpp"
|
||||
|
||||
#include "editor/feature_matcher.hpp"
|
||||
#include "editor/xml_feature.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <pugixml.hpp>
|
||||
|
||||
namespace
|
||||
{
|
||||
// This place on OSM map https://www.openstreetmap.org/relation/1359233.
|
||||
std::string const kSenatskiyDvorets = R"XXX(
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<osm version="0.6" generator="CGImap 0.6.0 (31854 thorn-01.openstreetmap.org)" copyright="OpenStreetMap and contributors" attribution="http://www.openstreetmap.org/copyright" license="http://opendatacommons.org/licenses/odbl/1-0/">
|
||||
<node id="271895281" visible="true" version="9" changeset="39264478" timestamp="2016-05-12T13:15:43Z" user="Felis Pimeja" uid="260756" lat="55.7578113" lon="37.6220187" />
|
||||
<node id="271895282" visible="true" version="6" changeset="6331881" timestamp="2010-11-09T21:58:31Z" user="Felis Pimeja" uid="260756" lat="55.7587478" lon="37.6223438" />
|
||||
<node id="271895283" visible="true" version="9" changeset="39264478" timestamp="2016-05-12T14:00:50Z" user="Felis Pimeja" uid="260756" lat="55.7590475" lon="37.6221887" />
|
||||
<node id="271895284" visible="true" version="9" changeset="39264478" timestamp="2016-05-12T14:00:50Z" user="Felis Pimeja" uid="260756" lat="55.7587811" lon="37.6206936" />
|
||||
<node id="271895285" visible="true" version="9" changeset="39264478" timestamp="2016-05-12T14:00:50Z" user="Felis Pimeja" uid="260756" lat="55.7585581" lon="37.6208892" />
|
||||
<node id="271895287" visible="true" version="8" changeset="39264478" timestamp="2016-05-12T13:15:44Z" user="Felis Pimeja" uid="260756" lat="55.7579401" lon="37.6212370" />
|
||||
<node id="271895288" visible="true" version="8" changeset="39264478" timestamp="2016-05-12T13:15:44Z" user="Felis Pimeja" uid="260756" lat="55.7580549" lon="37.6218815" />
|
||||
<node id="353142031" visible="true" version="5" changeset="39264478" timestamp="2016-05-12T13:11:39Z" user="Felis Pimeja" uid="260756" lat="55.7582873" lon="37.6213727" />
|
||||
<node id="353142032" visible="true" version="5" changeset="39264478" timestamp="2016-05-12T13:11:40Z" user="Felis Pimeja" uid="260756" lat="55.7581121" lon="37.6214459" />
|
||||
<node id="353142033" visible="true" version="5" changeset="39264478" timestamp="2016-05-12T13:11:40Z" user="Felis Pimeja" uid="260756" lat="55.7583325" lon="37.6216261" />
|
||||
<node id="353142034" visible="true" version="5" changeset="39264478" timestamp="2016-05-12T13:11:40Z" user="Felis Pimeja" uid="260756" lat="55.7581614" lon="37.6217225" />
|
||||
<node id="353142039" visible="true" version="7" changeset="39264478" timestamp="2016-05-12T14:00:50Z" user="Felis Pimeja" uid="260756" lat="55.7585468" lon="37.6208256" />
|
||||
<node id="353142040" visible="true" version="4" changeset="6331881" timestamp="2010-11-09T21:48:55Z" user="Felis Pimeja" uid="260756" lat="55.7587047" lon="37.6217831" />
|
||||
<node id="353142041" visible="true" version="4" changeset="6331881" timestamp="2010-11-09T22:01:20Z" user="Felis Pimeja" uid="260756" lat="55.7585349" lon="37.6218703" />
|
||||
<node id="353142042" visible="true" version="5" changeset="39264478" timestamp="2016-05-12T14:03:22Z" user="Felis Pimeja" uid="260756" lat="55.7585608" lon="37.6220405" />
|
||||
<node id="353142043" visible="true" version="4" changeset="6331881" timestamp="2010-11-09T21:58:14Z" user="Felis Pimeja" uid="260756" lat="55.7587140" lon="37.6220934" />
|
||||
<node id="353142044" visible="true" version="4" changeset="6331881" timestamp="2010-11-09T21:51:38Z" user="Felis Pimeja" uid="260756" lat="55.7587923" lon="37.6220481" />
|
||||
<node id="353142045" visible="true" version="4" changeset="6331881" timestamp="2010-11-09T21:49:59Z" user="Felis Pimeja" uid="260756" lat="55.7587555" lon="37.6218406" />
|
||||
<node id="353142046" visible="true" version="4" changeset="39264478" timestamp="2016-05-12T14:03:22Z" user="Felis Pimeja" uid="260756" lat="55.7587009" lon="37.6218191" />
|
||||
<node id="353142049" visible="true" version="5" changeset="39264478" timestamp="2016-05-12T13:11:40Z" user="Felis Pimeja" uid="260756" lat="55.7582228" lon="37.6220672" />
|
||||
<node id="353142050" visible="true" version="3" changeset="6331881" timestamp="2010-11-09T21:48:58Z" user="Felis Pimeja" uid="260756" lat="55.7582714" lon="37.6220589" />
|
||||
<node id="353142051" visible="true" version="4" changeset="6331881" timestamp="2010-11-09T22:01:30Z" user="Felis Pimeja" uid="260756" lat="55.7584225" lon="37.6221015" />
|
||||
<node id="671182909" visible="true" version="4" changeset="39264478" timestamp="2016-05-12T13:15:44Z" user="Felis Pimeja" uid="260756" lat="55.7578298" lon="37.6221226" />
|
||||
<node id="983727885" visible="true" version="2" changeset="39264478" timestamp="2016-05-12T13:11:46Z" user="Felis Pimeja" uid="260756" lat="55.7584302" lon="37.6220342" />
|
||||
<node id="983728327" visible="true" version="2" changeset="39264478" timestamp="2016-05-12T14:03:22Z" user="Felis Pimeja" uid="260756" lat="55.7587356" lon="37.6218592" />
|
||||
<node id="983728709" visible="true" version="2" changeset="39264478" timestamp="2016-05-12T13:11:46Z" user="Felis Pimeja" uid="260756" lat="55.7582566" lon="37.6213646" />
|
||||
<node id="983730214" visible="true" version="2" changeset="39264478" timestamp="2016-05-12T13:11:46Z" user="Felis Pimeja" uid="260756" lat="55.7582607" lon="37.6213877" />
|
||||
<node id="983730647" visible="true" version="1" changeset="6331881" timestamp="2010-11-09T21:43:48Z" user="Felis Pimeja" uid="260756" lat="55.7582481" lon="37.6220778" />
|
||||
<node id="983731126" visible="true" version="2" changeset="39264478" timestamp="2016-05-12T14:03:22Z" user="Felis Pimeja" uid="260756" lat="55.7587086" lon="37.6220650" />
|
||||
<node id="983731305" visible="true" version="2" changeset="39264478" timestamp="2016-05-12T13:11:46Z" user="Felis Pimeja" uid="260756" lat="55.7583984" lon="37.6218559" />
|
||||
<node id="983732911" visible="true" version="2" changeset="39264478" timestamp="2016-05-12T13:11:47Z" user="Felis Pimeja" uid="260756" lat="55.7582046" lon="37.6219650" />
|
||||
<node id="4181167714" visible="true" version="2" changeset="39264478" timestamp="2016-05-12T13:15:44Z" user="Felis Pimeja" uid="260756" lat="55.7580204" lon="37.6216881">
|
||||
<tag k="entrance" v="yes" />
|
||||
</node>
|
||||
<node id="4181259382" visible="true" version="1" changeset="39264478" timestamp="2016-05-12T14:03:16Z" user="Felis Pimeja" uid="260756" lat="55.7588440" lon="37.6222940" />
|
||||
<node id="4420391892" visible="true" version="1" changeset="42470341" timestamp="2016-09-27T13:17:17Z" user="literan" uid="830106" lat="55.7588469" lon="37.6210627">
|
||||
<tag k="entrance" v="main" />
|
||||
</node>
|
||||
<way id="25010101" visible="true" version="12" changeset="42470341" timestamp="2016-09-27T13:17:18Z" user="literan" uid="830106">
|
||||
<nd ref="271895283" />
|
||||
<nd ref="4420391892" />
|
||||
<nd ref="271895284" />
|
||||
<nd ref="353142039" />
|
||||
<nd ref="271895285" />
|
||||
<nd ref="271895287" />
|
||||
<nd ref="4181167714" />
|
||||
<nd ref="271895288" />
|
||||
<nd ref="271895281" />
|
||||
<nd ref="671182909" />
|
||||
</way>
|
||||
<way id="31560451" visible="true" version="2" changeset="6331881" timestamp="2010-11-09T22:01:05Z" user="Felis Pimeja" uid="260756">
|
||||
<nd ref="353142031" />
|
||||
<nd ref="353142033" />
|
||||
<nd ref="353142034" />
|
||||
<nd ref="353142032" />
|
||||
<nd ref="983728709" />
|
||||
<nd ref="983730214" />
|
||||
<nd ref="353142031" />
|
||||
</way>
|
||||
<way id="31560453" visible="true" version="2" changeset="6331881" timestamp="2010-11-09T22:00:32Z" user="Felis Pimeja" uid="260756">
|
||||
<nd ref="353142040" />
|
||||
<nd ref="353142041" />
|
||||
<nd ref="353142042" />
|
||||
<nd ref="983731126" />
|
||||
<nd ref="353142043" />
|
||||
<nd ref="353142044" />
|
||||
<nd ref="353142045" />
|
||||
<nd ref="983728327" />
|
||||
<nd ref="353142046" />
|
||||
<nd ref="353142040" />
|
||||
</way>
|
||||
<way id="31560454" visible="true" version="3" changeset="39264478" timestamp="2016-05-12T13:11:32Z" user="Felis Pimeja" uid="260756">
|
||||
<nd ref="353142049" />
|
||||
<nd ref="983730647" />
|
||||
<nd ref="353142050" />
|
||||
<nd ref="353142051" />
|
||||
<nd ref="983727885" />
|
||||
</way>
|
||||
<way id="417596299" visible="true" version="2" changeset="39264478" timestamp="2016-05-12T14:03:19Z" user="Felis Pimeja" uid="260756">
|
||||
<nd ref="671182909" />
|
||||
<nd ref="271895282" />
|
||||
<nd ref="4181259382" />
|
||||
<nd ref="271895283" />
|
||||
</way>
|
||||
<way id="417596307" visible="true" version="1" changeset="39264478" timestamp="2016-05-12T13:11:18Z" user="Felis Pimeja" uid="260756">
|
||||
<nd ref="983727885" />
|
||||
<nd ref="983731305" />
|
||||
<nd ref="983732911" />
|
||||
<nd ref="353142049" />
|
||||
</way>
|
||||
<relation id="85761" visible="true" version="15" changeset="44993517" timestamp="2017-01-08T04:43:37Z" user="Alexander-II" uid="3580412">
|
||||
<member type="way" ref="25010101" role="outer" />
|
||||
<member type="way" ref="417596299" role="outer" />
|
||||
<member type="way" ref="31560451" role="inner" />
|
||||
<member type="way" ref="31560453" role="inner" />
|
||||
<member type="way" ref="417596307" role="inner" />
|
||||
<member type="way" ref="31560454" role="inner" />
|
||||
<tag k="addr:city" v="Москва" />
|
||||
<tag k="addr:country" v="RU" />
|
||||
<tag k="addr:housenumber" v="2" />
|
||||
<tag k="addr:street" v="Театральный проезд" />
|
||||
<tag k="building" v="yes" />
|
||||
<tag k="building:colour" v="tan" />
|
||||
<tag k="building:levels" v="5" />
|
||||
<tag k="contact:phone" v="+7 499 5017800" />
|
||||
<tag k="contact:website" v="http://metmos.ru" />
|
||||
<tag k="int_name" v="Hotel Metropol" />
|
||||
<tag k="name" v="Метрополь" />
|
||||
<tag k="name:de" v="Hotel Metropol" />
|
||||
<tag k="name:el" v="Ξενοδοχείο Μετροπόλ" />
|
||||
<tag k="name:en" v="Hotel Metropol" />
|
||||
<tag k="name:pl" v="Hotel Metropol" />
|
||||
<tag k="opening_hours" v="24/7" />
|
||||
<tag k="roof:material" v="metal" />
|
||||
<tag k="tourism" v="hotel" />
|
||||
<tag k="type" v="multipolygon" />
|
||||
<tag k="wikidata" v="Q2034313" />
|
||||
<tag k="wikipedia" v="ru:Метрополь (гостиница, Москва)" />
|
||||
</relation>
|
||||
</osm>
|
||||
)XXX";
|
||||
|
||||
UNIT_TEST(MatchByGeometry)
|
||||
{
|
||||
pugi::xml_document osmResponse;
|
||||
TEST(osmResponse.load_buffer(kSenatskiyDvorets.c_str(), kSenatskiyDvorets.size()), ());
|
||||
|
||||
// It is a triangulated polygon. Every triangle is presented as three points.
|
||||
// For simplification, you can visualize it as a single sequence of points
|
||||
// by using, for ex. Gnuplot.
|
||||
std::vector<m2::PointD> geometry = {
|
||||
{37.621818614168603, 67.468231078000599}, {37.621858847304139, 67.468292768808396},
|
||||
{37.621783745451154, 67.468236442418657}, {37.621783745451154, 67.468236442418657},
|
||||
{37.621858847304139, 67.468292768808396}, {37.621840071840893, 67.468327637525846},
|
||||
{37.621783745451154, 67.468236442418657}, {37.621840071840893, 67.468327637525846},
|
||||
{37.620694768582979, 67.46837323507944}, {37.621783745451154, 67.468236442418657},
|
||||
{37.620694768582979, 67.46837323507944}, {37.620887887633501, 67.46797626814228},
|
||||
{37.620887887633501, 67.46797626814228}, {37.620694768582979, 67.46837323507944},
|
||||
{37.620826196825703, 67.467957492679034}, {37.621783745451154, 67.468236442418657},
|
||||
{37.620887887633501, 67.46797626814228}, {37.621625495118082, 67.467576618996077},
|
||||
{37.621625495118082, 67.467576618996077}, {37.620887887633501, 67.46797626814228},
|
||||
{37.621373367468806, 67.467496152725033}, {37.621373367468806, 67.467496152725033},
|
||||
{37.620887887633501, 67.46797626814228}, {37.621365320841704, 67.467439826335323},
|
||||
{37.621373367468806, 67.467496152725033}, {37.621365320841704, 67.467439826335323},
|
||||
{37.621386778513994, 67.467447872962424}, {37.621783745451154, 67.468236442418657},
|
||||
{37.621625495118082, 67.467576618996077}, {37.621869576140256, 67.467936035006772},
|
||||
{37.621869576140256, 67.467936035006772}, {37.621625495118082, 67.467576618996077},
|
||||
{37.621856165095096, 67.467691953984598}, {37.621856165095096, 67.467691953984598},
|
||||
{37.621625495118082, 67.467576618996077}, {37.621966135665531, 67.467348631228134},
|
||||
{37.621966135665531, 67.467348631228134}, {37.621625495118082, 67.467576618996077},
|
||||
{37.621722054643357, 67.467270847166105}, {37.621966135665531, 67.467348631228134},
|
||||
{37.621722054643357, 67.467270847166105}, {37.621880304976401, 67.46708309253367},
|
||||
{37.621880304976401, 67.46708309253367}, {37.621722054643357, 67.467270847166105},
|
||||
{37.621445787112748, 67.467185016477004}, {37.621880304976401, 67.46708309253367},
|
||||
{37.621445787112748, 67.467185016477004}, {37.621236574808023, 67.466879244647032},
|
||||
{37.621236574808023, 67.466879244647032}, {37.621445787112748, 67.467185016477004},
|
||||
{37.621365320841704, 67.467439826335323}, {37.621236574808023, 67.466879244647032},
|
||||
{37.621365320841704, 67.467439826335323}, {37.620887887633501, 67.46797626814228},
|
||||
{37.621966135665531, 67.467348631228134}, {37.621880304976401, 67.46708309253367},
|
||||
{37.622068059608836, 67.46738081773654}, {37.622068059608836, 67.46738081773654},
|
||||
{37.621880304976401, 67.46708309253367}, {37.622121703789531, 67.466683443387467},
|
||||
{37.622121703789531, 67.466683443387467}, {37.621880304976401, 67.46708309253367},
|
||||
{37.622019779846227, 67.466648574670018}, {37.622068059608836, 67.46738081773654},
|
||||
{37.622121703789531, 67.466683443387467}, {37.622078788444981, 67.467426415290134},
|
||||
{37.621869576140256, 67.467936035006772}, {37.621856165095096, 67.467691953984598},
|
||||
{37.622033190891386, 67.467748280374309}, {37.621869576140256, 67.467936035006772},
|
||||
{37.622033190891386, 67.467748280374309}, {37.622041237518488, 67.467981632560367},
|
||||
{37.622041237518488, 67.467981632560367}, {37.622033190891386, 67.467748280374309},
|
||||
{37.62210024611727, 67.467734869329149}, {37.622041237518488, 67.467981632560367},
|
||||
{37.62210024611727, 67.467734869329149}, {37.622344327139444, 67.468314226480686},
|
||||
{37.622344327139444, 67.468314226480686}, {37.62210024611727, 67.467734869329149},
|
||||
{37.622078788444981, 67.467426415290134}, {37.622078788444981, 67.467426415290134},
|
||||
{37.62210024611727, 67.467734869329149}, {37.622060012981734, 67.46746664842567},
|
||||
{37.622344327139444, 67.468314226480686}, {37.622078788444981, 67.467426415290134},
|
||||
{37.622121703789531, 67.466683443387467}, {37.622041237518488, 67.467981632560367},
|
||||
{37.622344327139444, 67.468314226480686}, {37.622092199490169, 67.468252535672889},
|
||||
{37.622092199490169, 67.468252535672889}, {37.622344327139444, 67.468314226480686},
|
||||
{37.622049284145589, 67.468392010542686}, {37.622049284145589, 67.468392010542686},
|
||||
{37.622344327139444, 67.468314226480686}, {37.622188759015415, 67.468845303869585},
|
||||
{37.622049284145589, 67.468392010542686}, {37.622188759015415, 67.468845303869585},
|
||||
{37.621840071840893, 67.468327637525846}, {37.621840071840893, 67.468327637525846},
|
||||
{37.622188759015415, 67.468845303869585}, {37.620694768582979, 67.46837323507944},
|
||||
{37.622041237518488, 67.467981632560367}, {37.622092199490169, 67.468252535672889},
|
||||
{37.622065377399821, 67.468244489045759}};
|
||||
|
||||
auto const matched = matcher::GetBestOsmWayOrRelation(osmResponse, geometry);
|
||||
TEST_EQUAL(matched.attribute("id").value(), std::string("85761"), ());
|
||||
}
|
||||
} // namespace
|
||||
38
libs/editor/editor_tests/new_feature_categories_test.cpp
Normal file
38
libs/editor/editor_tests/new_feature_categories_test.cpp
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
#include "testing/testing.hpp"
|
||||
|
||||
#include "editor/editor_config.hpp"
|
||||
#include "editor/new_feature_categories.hpp"
|
||||
|
||||
#include "indexer/classificator_loader.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
|
||||
UNIT_TEST(NewFeatureCategories_UniqueNames)
|
||||
{
|
||||
classificator::Load();
|
||||
|
||||
editor::EditorConfig config;
|
||||
osm::NewFeatureCategories categories(config);
|
||||
|
||||
for (auto const & locale : CategoriesHolder::kLocaleMapping)
|
||||
{
|
||||
std::string const lang(locale.m_name);
|
||||
categories.AddLanguage(lang);
|
||||
auto names = categories.GetAllCreatableTypeNames();
|
||||
std::sort(names.begin(), names.end());
|
||||
auto result = std::unique(names.begin(), names.end());
|
||||
|
||||
if (result != names.end())
|
||||
{
|
||||
LOG(LWARNING, ("Types duplication detected! The following types are duplicated:"));
|
||||
do
|
||||
{
|
||||
LOG(LWARNING, (*result));
|
||||
}
|
||||
while (++result != names.end());
|
||||
|
||||
TEST(false, ("Please look at output above"));
|
||||
}
|
||||
}
|
||||
}
|
||||
267
libs/editor/editor_tests/opening_hours_ui_test.cpp
Normal file
267
libs/editor/editor_tests/opening_hours_ui_test.cpp
Normal file
|
|
@ -0,0 +1,267 @@
|
|||
#include "testing/testing.hpp"
|
||||
|
||||
#include "editor/opening_hours_ui.hpp"
|
||||
|
||||
#include <set>
|
||||
|
||||
using namespace editor::ui;
|
||||
|
||||
UNIT_TEST(TestTimeTable)
|
||||
{
|
||||
{
|
||||
TimeTable tt = TimeTable::GetUninitializedTimeTable();
|
||||
TEST(!tt.IsValid(), ());
|
||||
}
|
||||
{
|
||||
auto tt = TimeTable::GetPredefinedTimeTable();
|
||||
TEST(tt.IsValid(), ());
|
||||
TEST(tt.IsTwentyFourHours(), ());
|
||||
|
||||
TEST(tt.RemoveWorkingDay(osmoh::Weekday::Sunday), ());
|
||||
TEST(tt.RemoveWorkingDay(osmoh::Weekday::Monday), ());
|
||||
TEST(tt.RemoveWorkingDay(osmoh::Weekday::Tuesday), ());
|
||||
TEST(tt.RemoveWorkingDay(osmoh::Weekday::Wednesday), ());
|
||||
TEST(tt.RemoveWorkingDay(osmoh::Weekday::Thursday), ());
|
||||
TEST(tt.RemoveWorkingDay(osmoh::Weekday::Friday), ());
|
||||
TEST(!tt.RemoveWorkingDay(osmoh::Weekday::Saturday), ());
|
||||
|
||||
TEST_EQUAL(tt.GetOpeningDays(), (std::set<osmoh::Weekday>{osmoh::Weekday::Saturday}), ());
|
||||
}
|
||||
}
|
||||
|
||||
UNIT_TEST(TestTimeTable_ExcludeTime)
|
||||
{
|
||||
using osmoh::operator""_h;
|
||||
using osmoh::operator""_min;
|
||||
using osmoh::HourMinutes;
|
||||
|
||||
{
|
||||
auto tt = TimeTable::GetPredefinedTimeTable();
|
||||
tt.SetTwentyFourHours(false);
|
||||
|
||||
tt.SetOpeningTime({8_h + 15_min, 18_h + 30_min});
|
||||
TEST(tt.AddExcludeTime({10_h, 11_h}), ());
|
||||
TEST(tt.AddExcludeTime({12_h, 13_h}), ());
|
||||
TEST(tt.AddExcludeTime({15_h, 17_h}), ());
|
||||
TEST_EQUAL(tt.GetExcludeTime().size(), 3, ());
|
||||
|
||||
TEST(tt.SetOpeningTime({8_h + 15_min, 12_h + 30_min}), ());
|
||||
TEST_EQUAL(tt.GetExcludeTime().size(), 1, ());
|
||||
}
|
||||
{
|
||||
auto tt = TimeTable::GetPredefinedTimeTable();
|
||||
tt.SetTwentyFourHours(false);
|
||||
|
||||
tt.SetOpeningTime({8_h + 15_min, 18_h + 30_min});
|
||||
TEST(tt.AddExcludeTime({10_h, 12_h}), ());
|
||||
TEST(tt.AddExcludeTime({11_h, 13_h}), ());
|
||||
TEST(tt.AddExcludeTime({15_h, 17_h}), ());
|
||||
TEST_EQUAL(tt.GetExcludeTime().size(), 2, ());
|
||||
}
|
||||
{
|
||||
auto tt = TimeTable::GetPredefinedTimeTable();
|
||||
tt.SetTwentyFourHours(false);
|
||||
|
||||
tt.SetOpeningTime({8_h + 15_min, 18_h + 30_min});
|
||||
TEST(tt.AddExcludeTime({10_h, 17_h}), ());
|
||||
TEST(tt.AddExcludeTime({11_h, 13_h}), ());
|
||||
TEST(tt.AddExcludeTime({15_h, 17_h}), ());
|
||||
TEST_EQUAL(tt.GetExcludeTime().size(), 1, ());
|
||||
TEST_EQUAL(tt.GetExcludeTime()[0].GetStart().GetHourMinutes().GetHoursCount(), 10, ());
|
||||
TEST_EQUAL(tt.GetExcludeTime()[0].GetEnd().GetHourMinutes().GetHoursCount(), 17, ());
|
||||
}
|
||||
{
|
||||
auto tt = TimeTable::GetPredefinedTimeTable();
|
||||
tt.SetTwentyFourHours(false);
|
||||
|
||||
tt.SetOpeningTime({11_h + 15_min, 18_h + 30_min});
|
||||
TEST(!tt.AddExcludeTime({10_h, 12_h}), ());
|
||||
TEST(!tt.AddExcludeTime({11_h, 13_h}), ());
|
||||
TEST(tt.AddExcludeTime({15_h, 17_h}), ());
|
||||
TEST_EQUAL(tt.GetExcludeTime().size(), 1, ());
|
||||
}
|
||||
{
|
||||
auto tt = TimeTable::GetPredefinedTimeTable();
|
||||
tt.SetTwentyFourHours(false);
|
||||
|
||||
tt.SetOpeningTime({8_h + 15_min, 2_h + 30_min});
|
||||
TEST(tt.AddExcludeTime({10_h, 15_h}), ());
|
||||
TEST(tt.AddExcludeTime({16_h, 2_h}), ());
|
||||
TEST(tt.AddExcludeTime({16_h, 22_h}), ());
|
||||
TEST_EQUAL(tt.GetExcludeTime().size(), 2, ());
|
||||
TEST_EQUAL(tt.GetExcludeTime()[0].GetStart().GetHourMinutes().GetHoursCount(), 10, ());
|
||||
TEST_EQUAL(tt.GetExcludeTime()[0].GetEnd().GetHourMinutes().GetHoursCount(), 15, ());
|
||||
TEST_EQUAL(tt.GetExcludeTime()[1].GetStart().GetHourMinutes().GetHoursCount(), 16, ());
|
||||
TEST_EQUAL(tt.GetExcludeTime()[1].GetEnd().GetHourMinutes().GetHoursCount(), 2, ());
|
||||
}
|
||||
{
|
||||
auto tt = TimeTable::GetPredefinedTimeTable();
|
||||
tt.SetTwentyFourHours(false);
|
||||
|
||||
tt.SetOpeningTime({8_h + 15_min, 15_h + 30_min});
|
||||
TEST(!tt.AddExcludeTime({10_h, 16_h}), ());
|
||||
TEST(!tt.AddExcludeTime({7_h, 14_h}), ());
|
||||
}
|
||||
{
|
||||
auto tt = TimeTable::GetPredefinedTimeTable();
|
||||
tt.SetTwentyFourHours(false);
|
||||
|
||||
tt.SetOpeningTime({8_h + 15_min, 18_h + 30_min});
|
||||
TEST(tt.AddExcludeTime({10_h, 11_h}), ());
|
||||
TEST(tt.AddExcludeTime({12_h, 13_h}), ());
|
||||
TEST(tt.AddExcludeTime({15_h, 17_h}), ());
|
||||
TEST(tt.ReplaceExcludeTime({13_h, 14_h}, 1), ());
|
||||
TEST(tt.ReplaceExcludeTime({10_h + 30_min, 14_h}, 1), ());
|
||||
TEST_EQUAL(tt.GetExcludeTime().size(), 2, ());
|
||||
TEST_EQUAL(tt.GetExcludeTime()[0].GetStart().GetHourMinutes().GetHoursCount(), 10, ());
|
||||
TEST_EQUAL(tt.GetExcludeTime()[0].GetEnd().GetHourMinutes().GetHoursCount(), 14, ());
|
||||
TEST_EQUAL(tt.GetExcludeTime()[1].GetStart().GetHourMinutes().GetHoursCount(), 15, ());
|
||||
TEST_EQUAL(tt.GetExcludeTime()[1].GetEnd().GetHourMinutes().GetHoursCount(), 17, ());
|
||||
}
|
||||
{
|
||||
auto tt = TimeTable::GetPredefinedTimeTable();
|
||||
tt.SetTwentyFourHours(false);
|
||||
|
||||
tt.SetOpeningTime({8_h + 15_min, 23_h + 30_min});
|
||||
TEST(tt.AddExcludeTime({10_h, 11_h}), ());
|
||||
TEST(tt.AddExcludeTime({12_h, 13_h}), ());
|
||||
TEST(tt.AddExcludeTime({15_h, 17_h}), ());
|
||||
TEST_EQUAL(tt.GetPredefinedExcludeTime().GetStart().GetHourMinutes().GetHoursCount(), 20, ());
|
||||
TEST_EQUAL(tt.GetPredefinedExcludeTime().GetStart().GetHourMinutes().GetMinutesCount(), 0, ());
|
||||
TEST_EQUAL(tt.GetPredefinedExcludeTime().GetEnd().GetHourMinutes().GetHoursCount(), 21, ());
|
||||
TEST_EQUAL(tt.GetPredefinedExcludeTime().GetEnd().GetHourMinutes().GetMinutesCount(), 0, ());
|
||||
|
||||
TEST(tt.AddExcludeTime({18_h, 23_h}), ());
|
||||
auto const predefinedStart = tt.GetPredefinedExcludeTime().GetStart().GetHourMinutes();
|
||||
auto const predefinedEnd = tt.GetPredefinedExcludeTime().GetEnd().GetHourMinutes();
|
||||
TEST(predefinedStart.GetHours() == HourMinutes::THours::zero(), ());
|
||||
TEST(predefinedStart.GetMinutes() == HourMinutes::TMinutes::zero(), ());
|
||||
TEST(predefinedEnd.GetHours() == HourMinutes::THours::zero(), ());
|
||||
TEST(predefinedEnd.GetMinutes() == HourMinutes::TMinutes::zero(), ());
|
||||
}
|
||||
{
|
||||
auto tt = TimeTable::GetPredefinedTimeTable();
|
||||
tt.SetTwentyFourHours(false);
|
||||
|
||||
tt.SetOpeningTime({8_h, 7_h});
|
||||
auto const predefinedStart = tt.GetPredefinedExcludeTime().GetStart().GetHourMinutes();
|
||||
auto const predefinedEnd = tt.GetPredefinedExcludeTime().GetEnd().GetHourMinutes();
|
||||
TEST(predefinedStart.GetHours() == HourMinutes::THours::zero(), ());
|
||||
TEST(predefinedStart.GetMinutes() == HourMinutes::TMinutes::zero(), ());
|
||||
TEST(predefinedEnd.GetHours() == HourMinutes::THours::zero(), ());
|
||||
TEST(predefinedEnd.GetMinutes() == HourMinutes::TMinutes::zero(), ());
|
||||
}
|
||||
{
|
||||
auto tt = TimeTable::GetPredefinedTimeTable();
|
||||
tt.SetTwentyFourHours(false);
|
||||
|
||||
tt.SetOpeningTime({7_h, 8_h + 45_min});
|
||||
TEST(!tt.CanAddExcludeTime(), ());
|
||||
}
|
||||
{
|
||||
auto tt = TimeTable::GetPredefinedTimeTable();
|
||||
tt.SetTwentyFourHours(false);
|
||||
|
||||
tt.SetOpeningTime({19_h, 18_h});
|
||||
auto const predefinedStart = tt.GetPredefinedExcludeTime().GetStart().GetHourMinutes();
|
||||
auto const predefinedEnd = tt.GetPredefinedExcludeTime().GetEnd().GetHourMinutes();
|
||||
TEST(predefinedStart.GetHours() == HourMinutes::THours::zero(), ());
|
||||
TEST(predefinedStart.GetMinutes() == HourMinutes::TMinutes::zero(), ());
|
||||
TEST(predefinedEnd.GetHours() == HourMinutes::THours::zero(), ());
|
||||
TEST(predefinedEnd.GetMinutes() == HourMinutes::TMinutes::zero(), ());
|
||||
}
|
||||
}
|
||||
|
||||
UNIT_TEST(TestAppendTimeTable)
|
||||
{
|
||||
{
|
||||
TimeTableSet tts;
|
||||
TEST(!tts.Empty(), ());
|
||||
|
||||
{
|
||||
auto tt = tts.Back();
|
||||
|
||||
TEST(tt.RemoveWorkingDay(osmoh::Weekday::Sunday), ());
|
||||
TEST(tt.RemoveWorkingDay(osmoh::Weekday::Saturday), ());
|
||||
TEST(tt.Commit(), ());
|
||||
|
||||
TEST(tts.Append(tts.GetComplementTimeTable()), ());
|
||||
TEST_EQUAL(tts.Back().GetOpeningDays(),
|
||||
(std::set<osmoh::Weekday>{osmoh::Weekday::Sunday, osmoh::Weekday::Saturday}), ());
|
||||
}
|
||||
|
||||
{
|
||||
auto tt = tts.Front();
|
||||
TEST(tt.RemoveWorkingDay(osmoh::Weekday::Monday), ());
|
||||
TEST(tt.RemoveWorkingDay(osmoh::Weekday::Tuesday), ());
|
||||
TEST(tt.Commit(), ());
|
||||
}
|
||||
|
||||
TEST(tts.Append(tts.GetComplementTimeTable()), ());
|
||||
TEST_EQUAL(tts.Back().GetOpeningDays(), (std::set<osmoh::Weekday>{osmoh::Weekday::Monday, osmoh::Weekday::Tuesday}),
|
||||
());
|
||||
|
||||
TEST(!tts.GetComplementTimeTable().IsValid(), ());
|
||||
TEST(!tts.Append(tts.GetComplementTimeTable()), ());
|
||||
TEST_EQUAL(tts.Size(), 3, ());
|
||||
|
||||
TEST(tts.Remove(0), ());
|
||||
TEST(tts.Remove(1), ());
|
||||
TEST_EQUAL(tts.Size(), 1, ());
|
||||
TEST_EQUAL(tts.GetUnhandledDays(),
|
||||
(std::set<osmoh::Weekday>{osmoh::Weekday::Monday, osmoh::Weekday::Tuesday, osmoh::Weekday::Wednesday,
|
||||
osmoh::Weekday::Thursday, osmoh::Weekday::Friday}),
|
||||
());
|
||||
}
|
||||
{
|
||||
TimeTableSet tts;
|
||||
auto tt = tts.GetComplementTimeTable();
|
||||
tt.AddWorkingDay(osmoh::Weekday::Friday);
|
||||
tt.AddWorkingDay(osmoh::Weekday::Saturday);
|
||||
tt.AddWorkingDay(osmoh::Weekday::Sunday);
|
||||
|
||||
TEST(tts.Append(tt), ());
|
||||
|
||||
TEST_EQUAL(tts.Size(), 2, ());
|
||||
TEST_EQUAL(tts.Front().GetOpeningDays().size(), 4, ());
|
||||
TEST_EQUAL(tts.Back().GetOpeningDays().size(), 3, ());
|
||||
|
||||
TEST(!tts.GetComplementTimeTable().IsValid(), ());
|
||||
}
|
||||
{
|
||||
TimeTableSet tts;
|
||||
auto tt = tts.GetComplementTimeTable();
|
||||
tt.AddWorkingDay(osmoh::Weekday::Friday);
|
||||
|
||||
TEST(tts.Append(tt), ());
|
||||
|
||||
TEST_EQUAL(tts.Size(), 2, ());
|
||||
TEST_EQUAL(tts.Front().GetOpeningDays().size(), 6, ());
|
||||
TEST_EQUAL(tts.Back().GetOpeningDays().size(), 1, ());
|
||||
|
||||
TEST(!tts.GetComplementTimeTable().IsValid(), ());
|
||||
|
||||
tt = tts.Front();
|
||||
tt.AddWorkingDay(osmoh::Weekday::Friday);
|
||||
TEST(!tts.Append(tt), ());
|
||||
TEST_EQUAL(tts.Front().GetOpeningDays().size(), 6, ());
|
||||
TEST_EQUAL(tts.Back().GetOpeningDays().size(), 1, ());
|
||||
}
|
||||
{
|
||||
TimeTableSet tts;
|
||||
|
||||
{
|
||||
auto tt = tts.GetComplementTimeTable();
|
||||
tt.AddWorkingDay(osmoh::Weekday::Friday);
|
||||
TEST(tts.Append(tt), ());
|
||||
}
|
||||
|
||||
TEST_EQUAL(tts.Size(), 2, ());
|
||||
TEST_EQUAL(tts.Front().GetOpeningDays().size(), 6, ());
|
||||
TEST_EQUAL(tts.Back().GetOpeningDays().size(), 1, ());
|
||||
|
||||
auto tt = tts.Front();
|
||||
tt.AddWorkingDay(osmoh::Weekday::Friday);
|
||||
TEST(!tt.Commit(), ());
|
||||
}
|
||||
}
|
||||
1399
libs/editor/editor_tests/osm_editor_test.cpp
Normal file
1399
libs/editor/editor_tests/osm_editor_test.cpp
Normal file
File diff suppressed because it is too large
Load diff
92
libs/editor/editor_tests/osm_editor_test.hpp
Normal file
92
libs/editor/editor_tests/osm_editor_test.hpp
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
#pragma once
|
||||
|
||||
#include "generator/generator_tests_support/test_mwm_builder.hpp"
|
||||
|
||||
#include "editor/editable_data_source.hpp"
|
||||
|
||||
#include "indexer/mwm_set.hpp"
|
||||
|
||||
#include "storage/country_info_getter.hpp"
|
||||
|
||||
#include "platform/local_country_file_utils.hpp"
|
||||
|
||||
#include "base/assert.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace editor
|
||||
{
|
||||
namespace testing
|
||||
{
|
||||
class EditorTest
|
||||
{
|
||||
public:
|
||||
EditorTest();
|
||||
~EditorTest();
|
||||
|
||||
void GetFeatureTypeInfoTest();
|
||||
void GetEditedFeatureTest();
|
||||
void SetIndexTest();
|
||||
void GetEditedFeatureStreetTest();
|
||||
void GetFeatureStatusTest();
|
||||
void IsFeatureUploadedTest();
|
||||
void DeleteFeatureTest();
|
||||
void ClearAllLocalEditsTest();
|
||||
void GetFeaturesByStatusTest();
|
||||
void OnMapDeregisteredTest();
|
||||
void RollBackChangesTest();
|
||||
void HaveMapEditsOrNotesToUploadTest();
|
||||
void HaveMapEditsToUploadTest();
|
||||
void GetStatsTest();
|
||||
void IsCreatedFeatureTest();
|
||||
void ForEachFeatureInMwmRectAndScaleTest();
|
||||
void CreateNoteTest();
|
||||
void LoadMapEditsTest();
|
||||
void SaveEditedFeatureTest();
|
||||
void SaveTransactionTest();
|
||||
void LoadExistingEditsXml();
|
||||
|
||||
private:
|
||||
template <typename BuildFn>
|
||||
MwmSet::MwmId ConstructTestMwm(BuildFn && fn)
|
||||
{
|
||||
return BuildMwm("TestCountry", std::forward<BuildFn>(fn));
|
||||
}
|
||||
|
||||
template <typename BuildFn>
|
||||
MwmSet::MwmId BuildMwm(std::string const & name, BuildFn && fn, int64_t version = 0)
|
||||
{
|
||||
m_mwmFiles.emplace_back(GetPlatform().WritableDir(), platform::CountryFile(name), version);
|
||||
auto & file = m_mwmFiles.back();
|
||||
Cleanup(file);
|
||||
|
||||
{
|
||||
generator::tests_support::TestMwmBuilder builder(file, feature::DataHeader::MapType::Country);
|
||||
fn(builder);
|
||||
}
|
||||
|
||||
auto result = m_dataSource.RegisterMap(file);
|
||||
CHECK_EQUAL(result.second, MwmSet::RegResult::Success, ());
|
||||
|
||||
auto const & id = result.first;
|
||||
|
||||
auto const & info = id.GetInfo();
|
||||
if (info)
|
||||
m_infoGetter.AddCountry(storage::CountryDef(name, info->m_bordersRect));
|
||||
|
||||
CHECK(id.IsAlive(), ());
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
void Cleanup(platform::LocalCountryFile const & map);
|
||||
bool RemoveMwm(MwmSet::MwmId const & mwmId);
|
||||
|
||||
EditableDataSource m_dataSource;
|
||||
storage::CountryInfoGetterForTesting m_infoGetter;
|
||||
std::vector<platform::LocalCountryFile> m_mwmFiles;
|
||||
};
|
||||
} // namespace testing
|
||||
} // namespace editor
|
||||
538
libs/editor/editor_tests/ui2oh_test.cpp
Normal file
538
libs/editor/editor_tests/ui2oh_test.cpp
Normal file
|
|
@ -0,0 +1,538 @@
|
|||
#include "testing/testing.hpp"
|
||||
|
||||
#include "editor/ui2oh.hpp"
|
||||
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
using namespace osmoh;
|
||||
using namespace editor;
|
||||
using namespace editor::ui;
|
||||
|
||||
UNIT_TEST(OpeningHours2TimeTableSet)
|
||||
{
|
||||
{
|
||||
OpeningHours oh("08:00-22:00");
|
||||
TEST(oh.IsValid(), ());
|
||||
|
||||
TimeTableSet tts;
|
||||
|
||||
TEST(MakeTimeTableSet(oh, tts), ());
|
||||
TEST_EQUAL(tts.Size(), 1, ());
|
||||
|
||||
auto const tt = tts.Front();
|
||||
TEST(!tt.IsTwentyFourHours(), ());
|
||||
TEST_EQUAL(tt.GetOpeningDays().size(), 7, ());
|
||||
TEST_EQUAL(tt.GetOpeningTime().GetStart().GetHourMinutes().GetHoursCount(), 8, ());
|
||||
TEST_EQUAL(tt.GetOpeningTime().GetEnd().GetHourMinutes().GetHoursCount(), 22, ());
|
||||
}
|
||||
{
|
||||
OpeningHours oh("Mo-Su 11:00-23:00;");
|
||||
TEST(oh.IsValid(), ());
|
||||
|
||||
TimeTableSet tts;
|
||||
|
||||
TEST(MakeTimeTableSet(oh, tts), ());
|
||||
TEST_EQUAL(tts.Size(), 1, ());
|
||||
|
||||
auto const tt = tts.Front();
|
||||
TEST(!tt.IsTwentyFourHours(), ());
|
||||
TEST_EQUAL(tt.GetOpeningDays().size(), 7, ());
|
||||
TEST_EQUAL(tt.GetOpeningTime().GetStart().GetHourMinutes().GetHoursCount(), 11, ());
|
||||
TEST_EQUAL(tt.GetOpeningTime().GetEnd().GetHourMinutes().GetHoursCount(), 23, ());
|
||||
}
|
||||
{
|
||||
OpeningHours oh(
|
||||
"Mo-Su 12:00-15:30, 19:30-23:00;"
|
||||
"Fr-Sa 12:00-15:30, 19:30-23:30;");
|
||||
TEST(oh.IsValid(), ());
|
||||
|
||||
TimeTableSet tts;
|
||||
|
||||
TEST(MakeTimeTableSet(oh, tts), ());
|
||||
TEST_EQUAL(tts.Size(), 2, ());
|
||||
{
|
||||
auto const tt = tts.Front();
|
||||
TEST(!tt.IsTwentyFourHours(), ());
|
||||
TEST_EQUAL(tt.GetOpeningDays().size(), 5, ());
|
||||
TEST_EQUAL(tt.GetOpeningTime().GetStart().GetHourMinutes().GetHoursCount(), 12, ());
|
||||
TEST_EQUAL(tt.GetOpeningTime().GetEnd().GetHourMinutes().GetHoursCount(), 23, ());
|
||||
|
||||
TEST_EQUAL(tt.GetExcludeTime().size(), 1, ());
|
||||
TEST_EQUAL(tt.GetExcludeTime()[0].GetStart().GetHourMinutes().GetHoursCount(), 15, ());
|
||||
TEST_EQUAL(tt.GetExcludeTime()[0].GetStart().GetHourMinutes().GetMinutesCount(), 30, ());
|
||||
TEST_EQUAL(tt.GetExcludeTime()[0].GetEnd().GetHourMinutes().GetHoursCount(), 19, ());
|
||||
TEST_EQUAL(tt.GetExcludeTime()[0].GetEnd().GetHourMinutes().GetMinutesCount(), 30, ());
|
||||
}
|
||||
{
|
||||
auto const tt = tts.Back();
|
||||
TEST(!tt.IsTwentyFourHours(), ());
|
||||
TEST_EQUAL(tt.GetOpeningDays().size(), 2, ());
|
||||
TEST_EQUAL(tt.GetOpeningTime().GetStart().GetHourMinutes().GetHoursCount(), 12, ());
|
||||
TEST_EQUAL(tt.GetOpeningTime().GetEnd().GetHourMinutes().GetHoursCount(), 23, ());
|
||||
TEST_EQUAL(tt.GetOpeningTime().GetEnd().GetHourMinutes().GetMinutesCount(), 30, ());
|
||||
|
||||
TEST_EQUAL(tt.GetExcludeTime().size(), 1, ());
|
||||
TEST_EQUAL(tt.GetExcludeTime()[0].GetStart().GetHourMinutes().GetHoursCount(), 15, ());
|
||||
TEST_EQUAL(tt.GetExcludeTime()[0].GetStart().GetHourMinutes().GetMinutesCount(), 30, ());
|
||||
TEST_EQUAL(tt.GetExcludeTime()[0].GetEnd().GetHourMinutes().GetHoursCount(), 19, ());
|
||||
TEST_EQUAL(tt.GetExcludeTime()[0].GetEnd().GetHourMinutes().GetMinutesCount(), 30, ());
|
||||
}
|
||||
}
|
||||
{
|
||||
OpeningHours oh("Mo-Fr 08:00-22:00");
|
||||
TEST(oh.IsValid(), ());
|
||||
|
||||
TimeTableSet tts;
|
||||
|
||||
TEST(MakeTimeTableSet(oh, tts), ());
|
||||
TEST_EQUAL(tts.Size(), 1, ());
|
||||
|
||||
auto const tt = tts.Front();
|
||||
TEST(!tt.IsTwentyFourHours(), ());
|
||||
TEST_EQUAL(tt.GetOpeningDays().size(), 5, ());
|
||||
TEST_EQUAL(tt.GetOpeningTime().GetStart().GetHourMinutes().GetHoursCount(), 8, ());
|
||||
TEST_EQUAL(tt.GetOpeningTime().GetEnd().GetHourMinutes().GetHoursCount(), 22, ());
|
||||
}
|
||||
{
|
||||
OpeningHours oh("Mo-Fr 08:00-12:00, 13:00-22:00");
|
||||
TEST(oh.IsValid(), ());
|
||||
|
||||
TimeTableSet tts;
|
||||
|
||||
TEST(MakeTimeTableSet(oh, tts), ());
|
||||
TEST_EQUAL(tts.Size(), 1, ());
|
||||
|
||||
auto const tt = tts.Front();
|
||||
TEST(!tt.IsTwentyFourHours(), ());
|
||||
TEST_EQUAL(tt.GetOpeningDays().size(), 5, ());
|
||||
TEST_EQUAL(tt.GetOpeningTime().GetStart().GetHourMinutes().GetHoursCount(), 8, ());
|
||||
TEST_EQUAL(tt.GetOpeningTime().GetEnd().GetHourMinutes().GetHoursCount(), 22, ());
|
||||
|
||||
TEST_EQUAL(tt.GetExcludeTime().size(), 1, ());
|
||||
TEST_EQUAL(tt.GetExcludeTime()[0].GetStart().GetHourMinutes().GetHoursCount(), 12, ());
|
||||
TEST_EQUAL(tt.GetExcludeTime()[0].GetEnd().GetHourMinutes().GetHoursCount(), 13, ());
|
||||
}
|
||||
{
|
||||
OpeningHours oh("Mo-Fr 08:00-10:00, 11:00-12:30, 13:00-22:00");
|
||||
TEST(oh.IsValid(), ());
|
||||
|
||||
TimeTableSet tts;
|
||||
|
||||
TEST(MakeTimeTableSet(oh, tts), ());
|
||||
TEST_EQUAL(tts.Size(), 1, ());
|
||||
|
||||
auto const tt = tts.Front();
|
||||
TEST(!tt.IsTwentyFourHours(), ());
|
||||
TEST_EQUAL(tt.GetOpeningDays().size(), 5, ());
|
||||
TEST_EQUAL(tt.GetOpeningTime().GetStart().GetHourMinutes().GetHoursCount(), 8, ());
|
||||
TEST_EQUAL(tt.GetOpeningTime().GetEnd().GetHourMinutes().GetHoursCount(), 22, ());
|
||||
|
||||
TEST_EQUAL(tt.GetExcludeTime().size(), 2, ());
|
||||
TEST_EQUAL(tt.GetExcludeTime()[0].GetStart().GetHourMinutes().GetHoursCount(), 10, ());
|
||||
TEST_EQUAL(tt.GetExcludeTime()[0].GetEnd().GetHourMinutes().GetHoursCount(), 11, ());
|
||||
TEST_EQUAL(tt.GetExcludeTime()[1].GetStart().GetHourMinutes().GetHoursCount(), 12, ());
|
||||
TEST_EQUAL(tt.GetExcludeTime()[1].GetEnd().GetHourMinutes().GetHoursCount(), 13, ());
|
||||
TEST_EQUAL(tt.GetExcludeTime()[1].GetStart().GetHourMinutes().GetMinutesCount(), 30, ());
|
||||
TEST_EQUAL(tt.GetExcludeTime()[1].GetEnd().GetHourMinutes().GetMinutesCount(), 0, ());
|
||||
}
|
||||
{
|
||||
OpeningHours oh("Mo-Fr 08:00-10:00; Su, Sa 13:00-22:00");
|
||||
TEST(oh.IsValid(), ());
|
||||
|
||||
TimeTableSet tts;
|
||||
|
||||
TEST(MakeTimeTableSet(oh, tts), ());
|
||||
TEST_EQUAL(tts.Size(), 2, ());
|
||||
|
||||
{
|
||||
auto const tt = tts.Get(0);
|
||||
TEST(!tt.IsTwentyFourHours(), ());
|
||||
TEST_EQUAL(tt.GetOpeningDays().size(), 5, ());
|
||||
}
|
||||
|
||||
{
|
||||
auto const tt = tts.Get(1);
|
||||
TEST(!tt.IsTwentyFourHours(), ());
|
||||
TEST_EQUAL(tt.GetOpeningDays().size(), 2, ());
|
||||
}
|
||||
}
|
||||
{
|
||||
OpeningHours oh("Jan Mo-Fr 08:00-10:00");
|
||||
TEST(oh.IsValid(), ());
|
||||
|
||||
TimeTableSet tts;
|
||||
|
||||
TEST(!MakeTimeTableSet(oh, tts), ());
|
||||
}
|
||||
{
|
||||
OpeningHours oh("2016 Mo-Fr 08:00-10:00");
|
||||
TEST(!oh.IsValid(), ());
|
||||
|
||||
TimeTableSet tts;
|
||||
|
||||
TEST(!MakeTimeTableSet(oh, tts), ());
|
||||
}
|
||||
{
|
||||
OpeningHours oh("week 30 Mo-Fr 08:00-10:00");
|
||||
TEST(oh.IsValid(), ());
|
||||
|
||||
TimeTableSet tts;
|
||||
|
||||
TEST(!MakeTimeTableSet(oh, tts), ());
|
||||
}
|
||||
{
|
||||
OpeningHours oh("Mo-Su 11:00-24:00");
|
||||
TEST(oh.IsValid(), ());
|
||||
|
||||
TimeTableSet tts;
|
||||
|
||||
TEST(MakeTimeTableSet(oh, tts), ());
|
||||
TEST_EQUAL(tts.Size(), 1, ());
|
||||
|
||||
auto const tt = tts.Front();
|
||||
TEST(!tt.IsTwentyFourHours(), ());
|
||||
TEST_EQUAL(tt.GetOpeningDays().size(), 7, ());
|
||||
TEST_EQUAL(tt.GetOpeningTime().GetStart().GetHourMinutes().GetHoursCount(), 11, ());
|
||||
TEST_EQUAL(tt.GetOpeningTime().GetEnd().GetHourMinutes().GetHoursCount(), 24, ());
|
||||
}
|
||||
{
|
||||
OpeningHours oh("Mo-Fr 08:00-10:00; Su, Sa 13:00-22:00");
|
||||
TEST(oh.IsValid(), ());
|
||||
|
||||
TimeTableSet tts;
|
||||
|
||||
TEST(MakeTimeTableSet(oh, tts), ());
|
||||
TEST_EQUAL(tts.Size(), 2, ());
|
||||
|
||||
{
|
||||
auto const tt = tts.Get(0);
|
||||
TEST(!tt.IsTwentyFourHours(), ());
|
||||
TEST_EQUAL(tt.GetOpeningDays().size(), 5, ());
|
||||
}
|
||||
|
||||
{
|
||||
auto const tt = tts.Get(1);
|
||||
TEST(!tt.IsTwentyFourHours(), ());
|
||||
TEST_EQUAL(tt.GetOpeningDays().size(), 2, ());
|
||||
}
|
||||
}
|
||||
{
|
||||
OpeningHours oh("Mo-Fr 08:00-13:00,14:00-20:00; Sa 09:00-13:00,14:00-18:00");
|
||||
TEST(oh.IsValid(), ());
|
||||
|
||||
TimeTableSet tts;
|
||||
|
||||
TEST(MakeTimeTableSet(oh, tts), ());
|
||||
TEST_EQUAL(tts.Size(), 2, ());
|
||||
|
||||
{
|
||||
auto const tt = tts.Get(0);
|
||||
TEST(!tt.IsTwentyFourHours(), ());
|
||||
TEST_EQUAL(tt.GetOpeningDays().size(), 5, ());
|
||||
}
|
||||
|
||||
{
|
||||
auto const tt = tts.Get(1);
|
||||
TEST(!tt.IsTwentyFourHours(), ());
|
||||
TEST_EQUAL(tt.GetOpeningDays().size(), 1, ());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UNIT_TEST(OpeningHours2TimeTableSet_off)
|
||||
{
|
||||
{
|
||||
OpeningHours oh("Mo-Fr 08:00-13:00,14:00-20:00; Su off");
|
||||
TEST(oh.IsValid(), ());
|
||||
|
||||
TimeTableSet tts;
|
||||
|
||||
TEST(MakeTimeTableSet(oh, tts), ());
|
||||
}
|
||||
{
|
||||
OpeningHours oh("Mo-Su 08:00-13:00,14:00-20:00; Sa off");
|
||||
TEST(oh.IsValid(), ());
|
||||
|
||||
TimeTableSet tts;
|
||||
|
||||
TEST(MakeTimeTableSet(oh, tts), ());
|
||||
TEST_EQUAL(tts.GetUnhandledDays(), OpeningDays({osmoh::Weekday::Saturday}), ());
|
||||
}
|
||||
{
|
||||
OpeningHours oh("Sa; Su; Sa off");
|
||||
TEST(oh.IsValid(), ());
|
||||
|
||||
TimeTableSet tts;
|
||||
|
||||
TEST(MakeTimeTableSet(oh, tts), ());
|
||||
TEST_EQUAL(tts.GetUnhandledDays(),
|
||||
OpeningDays({osmoh::Weekday::Monday, osmoh::Weekday::Tuesday, osmoh::Weekday::Wednesday,
|
||||
osmoh::Weekday::Thursday, osmoh::Weekday::Friday, osmoh::Weekday::Saturday}),
|
||||
());
|
||||
}
|
||||
{
|
||||
OpeningHours oh("Mo-Su 08:00-13:00,14:00-20:00; Sa 10:00-11:00 off");
|
||||
TEST(oh.IsValid(), ());
|
||||
|
||||
TimeTableSet tts;
|
||||
|
||||
TEST(MakeTimeTableSet(oh, tts), ());
|
||||
TEST_EQUAL(tts.Size(), 2, ());
|
||||
|
||||
auto const tt = tts.Get(1);
|
||||
TEST_EQUAL(tt.GetOpeningDays(), OpeningDays({osmoh::Weekday::Saturday}), ());
|
||||
TEST_EQUAL(tt.GetOpeningTime().GetStart().GetHourMinutes().GetHoursCount(), 8, ());
|
||||
TEST_EQUAL(tt.GetOpeningTime().GetEnd().GetHourMinutes().GetHoursCount(), 20, ());
|
||||
TEST_EQUAL(tt.GetExcludeTime()[0].GetStart().GetHourMinutes().GetHoursCount(), 10, ());
|
||||
TEST_EQUAL(tt.GetExcludeTime()[0].GetEnd().GetHourMinutes().GetHoursCount(), 11, ());
|
||||
TEST_EQUAL(tt.GetExcludeTime()[1].GetStart().GetHourMinutes().GetHoursCount(), 13, ());
|
||||
TEST_EQUAL(tt.GetExcludeTime()[1].GetEnd().GetHourMinutes().GetHoursCount(), 14, ());
|
||||
}
|
||||
{
|
||||
OpeningHours oh("Mo-Su; Sa 10:00-11:00 off");
|
||||
TEST(oh.IsValid(), ());
|
||||
|
||||
TimeTableSet tts;
|
||||
|
||||
TEST(MakeTimeTableSet(oh, tts), ());
|
||||
TEST_EQUAL(tts.Size(), 2, ());
|
||||
|
||||
auto const tt = tts.Get(1);
|
||||
|
||||
TEST_EQUAL(tt.GetOpeningTime().GetStart().GetHourMinutes().GetHoursCount(), 0, ());
|
||||
TEST_EQUAL(tt.GetOpeningTime().GetEnd().GetHourMinutes().GetHoursCount(), 24, ());
|
||||
|
||||
TEST_EQUAL(tt.GetOpeningDays(), OpeningDays({osmoh::Weekday::Saturday}), ());
|
||||
TEST_EQUAL(tt.GetExcludeTime()[0].GetStart().GetHourMinutes().GetHoursCount(), 10, ());
|
||||
TEST_EQUAL(tt.GetExcludeTime()[0].GetEnd().GetHourMinutes().GetHoursCount(), 11, ());
|
||||
}
|
||||
{
|
||||
OpeningHours oh("Mo-Fr 11:00-17:00; Sa-Su 12:00-16:00; Tu off");
|
||||
TEST(oh.IsValid(), ());
|
||||
|
||||
TimeTableSet tts;
|
||||
|
||||
TEST(MakeTimeTableSet(oh, tts), ());
|
||||
TEST_EQUAL(tts.Size(), 2, ());
|
||||
TEST_EQUAL(tts.GetUnhandledDays(), OpeningDays({osmoh::Weekday::Tuesday}), ());
|
||||
}
|
||||
{
|
||||
OpeningHours oh("Mo-Fr 11:00-17:00; Sa-Su 12:00-16:00; Mo-Fr off");
|
||||
TEST(oh.IsValid(), ());
|
||||
|
||||
TimeTableSet tts;
|
||||
|
||||
TEST(MakeTimeTableSet(oh, tts), ());
|
||||
TEST_EQUAL(tts.Size(), 1, ());
|
||||
|
||||
TEST_EQUAL(tts.GetUnhandledDays(),
|
||||
OpeningDays({osmoh::Weekday::Monday, osmoh::Weekday::Tuesday, osmoh::Weekday::Wednesday,
|
||||
osmoh::Weekday::Thursday, osmoh::Weekday::Friday}),
|
||||
());
|
||||
}
|
||||
{
|
||||
OpeningHours oh("Mo-Fr 11:00-17:00; Sa-Su 12:00-16:00; Mo-Fr 11:00-13:00 off");
|
||||
TEST(oh.IsValid(), ());
|
||||
|
||||
TimeTableSet tts;
|
||||
|
||||
TEST(MakeTimeTableSet(oh, tts), ());
|
||||
TEST_EQUAL(tts.Size(), 2, ());
|
||||
|
||||
auto const tt = tts.Get(0);
|
||||
TEST_EQUAL(tts.GetUnhandledDays(), OpeningDays(), ());
|
||||
|
||||
TEST_EQUAL(tt.GetOpeningTime().GetStart().GetHourMinutes().GetHoursCount(), 11, ());
|
||||
TEST_EQUAL(tt.GetOpeningTime().GetEnd().GetHourMinutes().GetHoursCount(), 17, ());
|
||||
TEST_EQUAL(tt.GetExcludeTime()[0].GetStart().GetHourMinutes().GetHoursCount(), 11, ());
|
||||
TEST_EQUAL(tt.GetExcludeTime()[0].GetEnd().GetHourMinutes().GetHoursCount(), 13, ());
|
||||
}
|
||||
{
|
||||
OpeningHours oh("Mo off; Tu-Su 09:00-17:00");
|
||||
TEST(oh.IsValid(), ());
|
||||
|
||||
TimeTableSet tts;
|
||||
|
||||
TEST(MakeTimeTableSet(oh, tts), ());
|
||||
TEST_EQUAL(tts.Size(), 1, ());
|
||||
|
||||
TEST_EQUAL(tts.GetUnhandledDays(), OpeningDays({osmoh::Weekday::Monday}), ());
|
||||
|
||||
auto const tt = tts.Get(0);
|
||||
|
||||
TEST_EQUAL(tt.GetOpeningTime().GetStart().GetHourMinutes().GetHoursCount(), 9, ());
|
||||
TEST_EQUAL(tt.GetOpeningTime().GetEnd().GetHourMinutes().GetHoursCount(), 17, ());
|
||||
}
|
||||
}
|
||||
|
||||
UNIT_TEST(OpeningHours2TimeTableSet_plus)
|
||||
{
|
||||
OpeningHours oh("Mo-Su 11:00+");
|
||||
TEST(oh.IsValid(), ());
|
||||
|
||||
TimeTableSet tts;
|
||||
|
||||
TEST(MakeTimeTableSet(oh, tts), ());
|
||||
TEST_EQUAL(tts.Size(), 1, ());
|
||||
|
||||
auto const tt = tts.Get(0);
|
||||
TEST_EQUAL(tts.GetUnhandledDays(), OpeningDays(), ());
|
||||
|
||||
TEST_EQUAL(tt.GetOpeningTime().GetStart().GetHourMinutes().GetHoursCount(), 11, ());
|
||||
TEST_EQUAL(tt.GetOpeningTime().GetEnd().GetHourMinutes().GetHoursCount(), 24, ());
|
||||
}
|
||||
|
||||
UNIT_TEST(TimeTableSt2OpeningHours)
|
||||
{
|
||||
{
|
||||
TimeTableSet tts;
|
||||
TEST_EQUAL(ToString(MakeOpeningHours(tts)), "24/7", ());
|
||||
}
|
||||
{
|
||||
TimeTableSet tts;
|
||||
auto tt = tts.Front();
|
||||
TEST(tt.SetOpeningDays({osmoh::Weekday::Monday, osmoh::Weekday::Tuesday, osmoh::Weekday::Wednesday,
|
||||
osmoh::Weekday::Thursday, osmoh::Weekday::Friday, osmoh::Weekday::Saturday,
|
||||
osmoh::Weekday::Sunday}),
|
||||
());
|
||||
|
||||
tt.SetTwentyFourHours(false);
|
||||
TEST(tt.SetOpeningTime({8_h, 22_h}), ());
|
||||
TEST(tt.Commit(), ());
|
||||
|
||||
TEST_EQUAL(ToString(MakeOpeningHours(tts)), "Mo-Su 08:00-22:00", ());
|
||||
}
|
||||
{
|
||||
TimeTableSet tts;
|
||||
auto tt = tts.Front();
|
||||
TEST(tt.SetOpeningDays({osmoh::Weekday::Monday, osmoh::Weekday::Tuesday, osmoh::Weekday::Wednesday,
|
||||
osmoh::Weekday::Thursday, osmoh::Weekday::Friday}),
|
||||
());
|
||||
|
||||
tt.SetTwentyFourHours(false);
|
||||
TEST(tt.SetOpeningTime({8_h, 22_h}), ());
|
||||
TEST(tt.Commit(), ());
|
||||
|
||||
TEST_EQUAL(ToString(MakeOpeningHours(tts)), "Mo-Fr 08:00-22:00", ());
|
||||
}
|
||||
{
|
||||
TimeTableSet tts;
|
||||
|
||||
auto tt = tts.Front();
|
||||
TEST(tt.SetOpeningDays({osmoh::Weekday::Monday, osmoh::Weekday::Tuesday, osmoh::Weekday::Wednesday,
|
||||
osmoh::Weekday::Thursday, osmoh::Weekday::Friday}),
|
||||
());
|
||||
|
||||
tt.SetTwentyFourHours(false);
|
||||
TEST(tt.SetOpeningTime({8_h, 22_h}), ());
|
||||
TEST(tt.AddExcludeTime({12_h, 13_h}), ());
|
||||
TEST(tt.Commit(), ());
|
||||
|
||||
TEST_EQUAL(ToString(MakeOpeningHours(tts)), "Mo-Fr 08:00-12:00, 13:00-22:00", ());
|
||||
}
|
||||
{
|
||||
TimeTableSet tts;
|
||||
|
||||
auto tt = tts.Front();
|
||||
TEST(tt.SetOpeningDays({osmoh::Weekday::Monday, osmoh::Weekday::Tuesday, osmoh::Weekday::Wednesday,
|
||||
osmoh::Weekday::Thursday, osmoh::Weekday::Friday}),
|
||||
());
|
||||
|
||||
tt.SetTwentyFourHours(false);
|
||||
TEST(tt.SetOpeningTime({8_h, 22_h}), ());
|
||||
TEST(tt.AddExcludeTime({10_h, 11_h}), ());
|
||||
TEST(tt.AddExcludeTime({12_h + 30_min, 13_h}), ());
|
||||
TEST(tt.Commit(), ());
|
||||
|
||||
TEST_EQUAL(ToString(MakeOpeningHours(tts)), "Mo-Fr 08:00-10:00, 11:00-12:30, 13:00-22:00", ());
|
||||
}
|
||||
{
|
||||
TimeTableSet tts;
|
||||
|
||||
{
|
||||
auto tt = tts.Front();
|
||||
TEST(tt.SetOpeningDays({osmoh::Weekday::Tuesday, osmoh::Weekday::Wednesday, osmoh::Weekday::Thursday}), ());
|
||||
|
||||
tt.SetTwentyFourHours(false);
|
||||
TEST(tt.SetOpeningTime({8_h, 10_h}), ());
|
||||
TEST(tt.Commit(), ());
|
||||
}
|
||||
{
|
||||
TimeTable tt = TimeTable::GetUninitializedTimeTable();
|
||||
TEST(tt.SetOpeningDays(
|
||||
{osmoh::Weekday::Monday, osmoh::Weekday::Friday, osmoh::Weekday::Saturday, osmoh::Weekday::Sunday}),
|
||||
());
|
||||
|
||||
tt.SetTwentyFourHours(false);
|
||||
TEST(tt.SetOpeningTime({13_h, 22_h}), ());
|
||||
TEST(tts.Append(tt), ());
|
||||
}
|
||||
|
||||
TEST_EQUAL(ToString(MakeOpeningHours(tts)), "Tu-Th 08:00-10:00; Fr-Mo 13:00-22:00", ());
|
||||
}
|
||||
{
|
||||
TimeTableSet tts;
|
||||
|
||||
{
|
||||
auto tt = tts.Front();
|
||||
TEST(tt.SetOpeningDays({osmoh::Weekday::Monday, osmoh::Weekday::Wednesday, osmoh::Weekday::Friday}), ());
|
||||
|
||||
tt.SetTwentyFourHours(false);
|
||||
TEST(tt.SetOpeningTime({8_h, 10_h}), ());
|
||||
TEST(tt.Commit(), ());
|
||||
}
|
||||
{
|
||||
TimeTable tt = TimeTable::GetUninitializedTimeTable();
|
||||
TEST(tt.SetOpeningDays({osmoh::Weekday::Saturday, osmoh::Weekday::Sunday}), ());
|
||||
|
||||
tt.SetTwentyFourHours(false);
|
||||
TEST(tt.SetOpeningTime({13_h, 22_h}), ());
|
||||
TEST(tts.Append(tt), ());
|
||||
}
|
||||
|
||||
TEST_EQUAL(ToString(MakeOpeningHours(tts)), "Mo, We, Fr 08:00-10:00; Sa-Su 13:00-22:00", ());
|
||||
}
|
||||
{
|
||||
TimeTableSet tts;
|
||||
|
||||
auto tt = tts.Front();
|
||||
TEST(tt.SetOpeningDays({osmoh::Weekday::Sunday, osmoh::Weekday::Monday, osmoh::Weekday::Tuesday,
|
||||
osmoh::Weekday::Wednesday, osmoh::Weekday::Thursday, osmoh::Weekday::Friday,
|
||||
osmoh::Weekday::Saturday}),
|
||||
());
|
||||
|
||||
tt.SetTwentyFourHours(false);
|
||||
TEST(tt.SetOpeningTime({11_h, 24_h}), ());
|
||||
TEST(tt.Commit(), ());
|
||||
|
||||
TEST_EQUAL(ToString(MakeOpeningHours(tts)), "Mo-Su 11:00-24:00", ());
|
||||
}
|
||||
{
|
||||
TimeTableSet tts;
|
||||
|
||||
{
|
||||
auto tt = tts.Front();
|
||||
TEST(tt.SetOpeningDays({osmoh::Weekday::Monday, osmoh::Weekday::Wednesday, osmoh::Weekday::Thursday}), ());
|
||||
|
||||
tt.SetTwentyFourHours(false);
|
||||
TEST(tt.SetOpeningTime({8_h, 20_h}), ());
|
||||
TEST(tt.AddExcludeTime({13_h, 14_h}), ());
|
||||
TEST(tt.Commit(), ());
|
||||
}
|
||||
{
|
||||
TimeTable tt = TimeTable::GetUninitializedTimeTable();
|
||||
TEST(tt.SetOpeningDays({osmoh::Weekday::Saturday}), ());
|
||||
|
||||
tt.SetTwentyFourHours(false);
|
||||
TEST(tt.SetOpeningTime({9_h, 18_h}), ());
|
||||
TEST(tt.AddExcludeTime({13_h, 14_h}), ());
|
||||
TEST(tts.Append(tt), ());
|
||||
}
|
||||
|
||||
TEST_EQUAL(ToString(MakeOpeningHours(tts)),
|
||||
"Mo, We-Th 08:00-13:00, 14:00-20:00; "
|
||||
"Sa 09:00-13:00, 14:00-18:00",
|
||||
());
|
||||
}
|
||||
}
|
||||
531
libs/editor/editor_tests/xml_feature_test.cpp
Normal file
531
libs/editor/editor_tests/xml_feature_test.cpp
Normal file
|
|
@ -0,0 +1,531 @@
|
|||
#include "testing/testing.hpp"
|
||||
|
||||
#include "editor/xml_feature.hpp"
|
||||
|
||||
#include "indexer/classificator_loader.hpp"
|
||||
#include "indexer/editable_map_object.hpp"
|
||||
|
||||
#include "geometry/mercator.hpp"
|
||||
|
||||
#include "base/timer.hpp"
|
||||
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <pugixml.hpp>
|
||||
|
||||
using namespace editor;
|
||||
|
||||
UNIT_TEST(XMLFeature_RawGetSet)
|
||||
{
|
||||
XMLFeature feature(XMLFeature::Type::Node);
|
||||
TEST(!feature.HasTag("opening_hours"), ());
|
||||
TEST(!feature.HasAttribute("center"), ());
|
||||
|
||||
feature.SetAttribute("FooBar", "foobar");
|
||||
TEST_EQUAL(feature.GetAttribute("FooBar"), "foobar", ());
|
||||
|
||||
feature.SetAttribute("FooBar", "foofoo");
|
||||
TEST_EQUAL(feature.GetAttribute("FooBar"), "foofoo", ());
|
||||
|
||||
feature.SetTagValue("opening_hours", "18:20-18:21");
|
||||
TEST_EQUAL(feature.GetTagValue("opening_hours"), "18:20-18:21", ());
|
||||
|
||||
feature.SetTagValue("opening_hours", "18:20-19:21");
|
||||
TEST_EQUAL(feature.GetTagValue("opening_hours"), "18:20-19:21", ());
|
||||
|
||||
auto const expected = R"(<?xml version="1.0"?>
|
||||
<node FooBar="foofoo">
|
||||
<tag k="opening_hours" v="18:20-19:21" />
|
||||
</node>
|
||||
)";
|
||||
|
||||
std::stringstream sstr;
|
||||
feature.Save(sstr);
|
||||
TEST_EQUAL(expected, sstr.str(), ());
|
||||
}
|
||||
|
||||
UNIT_TEST(XMLFeature_Setters)
|
||||
{
|
||||
XMLFeature feature(XMLFeature::Type::Node);
|
||||
|
||||
feature.SetCenter(mercator::FromLatLon(55.7978998, 37.4745280));
|
||||
feature.SetModificationTime(base::StringToTimestamp("2015-11-27T21:13:32Z"));
|
||||
|
||||
feature.SetName("Gorki Park");
|
||||
feature.SetName("en", "Gorki Park");
|
||||
feature.SetName("ru", "Парк Горького");
|
||||
feature.SetName("int_name", "Gorky Park");
|
||||
|
||||
feature.SetHouse("10");
|
||||
feature.SetTagValue("opening_hours", "Mo-Fr 08:15-17:30");
|
||||
feature.SetTagValue("amenity", "atm");
|
||||
|
||||
std::stringstream sstr;
|
||||
feature.Save(sstr);
|
||||
|
||||
auto const expectedString = R"(<?xml version="1.0"?>
|
||||
<node lat="55.7978998" lon="37.474528" timestamp="2015-11-27T21:13:32Z">
|
||||
<tag k="name" v="Gorki Park" />
|
||||
<tag k="name:en" v="Gorki Park" />
|
||||
<tag k="name:ru" v="Парк Горького" />
|
||||
<tag k="int_name" v="Gorky Park" />
|
||||
<tag k="addr:housenumber" v="10" />
|
||||
<tag k="opening_hours" v="Mo-Fr 08:15-17:30" />
|
||||
<tag k="amenity" v="atm" />
|
||||
</node>
|
||||
)";
|
||||
|
||||
TEST_EQUAL(sstr.str(), expectedString, ());
|
||||
}
|
||||
|
||||
UNIT_TEST(XMLFeature_UintLang)
|
||||
{
|
||||
XMLFeature feature(XMLFeature::Type::Node);
|
||||
|
||||
feature.SetCenter(mercator::FromLatLon(55.79, 37.47));
|
||||
feature.SetModificationTime(base::StringToTimestamp("2015-11-27T21:13:32Z"));
|
||||
|
||||
feature.SetName(StringUtf8Multilang::kDefaultCode, "Gorki Park");
|
||||
feature.SetName(StringUtf8Multilang::GetLangIndex("ru"), "Парк Горького");
|
||||
feature.SetName(StringUtf8Multilang::kInternationalCode, "Gorky Park");
|
||||
std::stringstream sstr;
|
||||
feature.Save(sstr);
|
||||
|
||||
auto const expectedString = R"(<?xml version="1.0"?>
|
||||
<node lat="55.79" lon="37.47" timestamp="2015-11-27T21:13:32Z">
|
||||
<tag k="name" v="Gorki Park" />
|
||||
<tag k="name:ru" v="Парк Горького" />
|
||||
<tag k="int_name" v="Gorky Park" />
|
||||
</node>
|
||||
)";
|
||||
|
||||
TEST_EQUAL(sstr.str(), expectedString, ());
|
||||
|
||||
XMLFeature f2(expectedString);
|
||||
TEST_EQUAL(f2.GetName(StringUtf8Multilang::kDefaultCode), "Gorki Park", ());
|
||||
TEST_EQUAL(f2.GetName(StringUtf8Multilang::GetLangIndex("ru")), "Парк Горького", ());
|
||||
TEST_EQUAL(f2.GetName(StringUtf8Multilang::kInternationalCode), "Gorky Park", ());
|
||||
|
||||
TEST_EQUAL(f2.GetName(), "Gorki Park", ());
|
||||
TEST_EQUAL(f2.GetName("default"), "Gorki Park", ());
|
||||
TEST_EQUAL(f2.GetName("ru"), "Парк Горького", ());
|
||||
TEST_EQUAL(f2.GetName("int_name"), "Gorky Park", ());
|
||||
}
|
||||
|
||||
UNIT_TEST(XMLFeature_ToOSMString)
|
||||
{
|
||||
XMLFeature feature(XMLFeature::Type::Node);
|
||||
feature.SetCenter(mercator::FromLatLon(55.7978998, 37.4745280));
|
||||
feature.SetName("OSM");
|
||||
feature.SetTagValue("amenity", "atm");
|
||||
|
||||
auto const expectedString = R"(<?xml version="1.0"?>
|
||||
<osm>
|
||||
<node lat="55.7978998" lon="37.474528">
|
||||
<tag k="name" v="OSM" />
|
||||
<tag k="amenity" v="atm" />
|
||||
</node>
|
||||
</osm>
|
||||
)";
|
||||
TEST_EQUAL(expectedString, feature.ToOSMString(), ());
|
||||
}
|
||||
|
||||
UNIT_TEST(XMLFeature_HasTags)
|
||||
{
|
||||
auto const taggedNode = R"(
|
||||
<node lat="55.7978998" lon="37.474528" timestamp="2015-11-27T21:13:32Z">
|
||||
<tag k="name" v="OSM" />
|
||||
<tag k="amenity" v="atm" />
|
||||
</node>
|
||||
)";
|
||||
XMLFeature taggedFeature(taggedNode);
|
||||
TEST(taggedFeature.HasAnyTags(), ());
|
||||
TEST(taggedFeature.HasTag("amenity"), ());
|
||||
TEST(taggedFeature.HasKey("amenity"), ());
|
||||
TEST(!taggedFeature.HasTag("name:en"), ());
|
||||
TEST(taggedFeature.HasKey("lon"), ());
|
||||
TEST(!taggedFeature.HasTag("lon"), ());
|
||||
TEST_EQUAL(taggedFeature.GetTagValue("name"), "OSM", ());
|
||||
TEST_EQUAL(taggedFeature.GetTagValue("nope"), "", ());
|
||||
|
||||
constexpr char const * emptyWay = R"(
|
||||
<way timestamp="2015-11-27T21:13:32Z"/>
|
||||
)";
|
||||
XMLFeature emptyFeature(emptyWay);
|
||||
TEST(!emptyFeature.HasAnyTags(), ());
|
||||
TEST(emptyFeature.HasAttribute("timestamp"), ());
|
||||
}
|
||||
|
||||
UNIT_TEST(XMLFeature_FromXml)
|
||||
{
|
||||
// Do not space-align this string literal constant. It will be compared below.
|
||||
auto const kTestNode = R"(<?xml version="1.0"?>
|
||||
<node lat="55.7978998" lon="37.474528" timestamp="2015-11-27T21:13:32Z">
|
||||
<tag k="name" v="Gorki Park" />
|
||||
<tag k="name:en" v="Gorki Park" />
|
||||
<tag k="name:ru" v="Парк Горького" />
|
||||
<tag k="int_name" v="Gorky Park" />
|
||||
<tag k="addr:housenumber" v="10" />
|
||||
<tag k="opening_hours" v="Mo-Fr 08:15-17:30" />
|
||||
<tag k="amenity" v="atm" />
|
||||
</node>
|
||||
)";
|
||||
|
||||
std::map<std::string_view, std::string_view> kTestNames{
|
||||
{"default", "Gorki Park"}, {"en", "Gorki Park"}, {"ru", "Парк Горького"}, {"int_name", "Gorky Park"}};
|
||||
|
||||
XMLFeature feature(kTestNode);
|
||||
|
||||
std::stringstream sstr;
|
||||
feature.Save(sstr);
|
||||
TEST_EQUAL(kTestNode, sstr.str(), ());
|
||||
|
||||
TEST(feature.HasKey("opening_hours"), ());
|
||||
TEST(feature.HasKey("lat"), ());
|
||||
TEST(feature.HasKey("lon"), ());
|
||||
TEST(!feature.HasKey("FooBarBaz"), ());
|
||||
|
||||
TEST_EQUAL(feature.GetHouse(), "10", ());
|
||||
TEST_EQUAL(feature.GetCenter(), ms::LatLon(55.7978998, 37.4745280), ());
|
||||
TEST_EQUAL(feature.GetName(), kTestNames["default"], ());
|
||||
TEST_EQUAL(feature.GetName("default"), kTestNames["default"], ());
|
||||
TEST_EQUAL(feature.GetName("en"), kTestNames["en"], ());
|
||||
TEST_EQUAL(feature.GetName("ru"), kTestNames["ru"], ());
|
||||
TEST_EQUAL(feature.GetName("int_name"), kTestNames["int_name"], ());
|
||||
TEST_EQUAL(feature.GetName("No such language"), "", ());
|
||||
|
||||
TEST_EQUAL(feature.GetTagValue("opening_hours"), "Mo-Fr 08:15-17:30", ());
|
||||
TEST_EQUAL(feature.GetTagValue("amenity"), "atm", ());
|
||||
TEST_EQUAL(base::TimestampToString(feature.GetModificationTime()), "2015-11-27T21:13:32Z", ());
|
||||
|
||||
std::map<std::string_view, std::string_view> names;
|
||||
feature.ForEachName([&names](std::string_view lang, std::string_view name) { names.emplace(lang, name); });
|
||||
TEST_EQUAL(names, kTestNames, ());
|
||||
}
|
||||
|
||||
UNIT_TEST(XMLFeature_FromOSM)
|
||||
{
|
||||
auto const kTestNodeWay = R"(<?xml version="1.0"?>
|
||||
<osm>
|
||||
<node id="4" lat="55.7978998" lon="37.474528" timestamp="2015-11-27T21:13:32Z">
|
||||
<tag k="test" v="value"/>
|
||||
</node>
|
||||
<node id="5" lat="55.7977777" lon="37.474528" timestamp="2015-11-27T21:13:33Z"/>
|
||||
<way id="3" timestamp="2015-11-27T21:13:34Z">
|
||||
<nd ref="4"/>
|
||||
<nd ref="5"/>
|
||||
<tag k="hi" v="test"/>
|
||||
</way>
|
||||
</osm>
|
||||
)";
|
||||
|
||||
TEST_ANY_THROW(XMLFeature::FromOSM(""), ());
|
||||
TEST_ANY_THROW(XMLFeature::FromOSM("This is not XML"), ());
|
||||
TEST_ANY_THROW(XMLFeature::FromOSM("<?xml version=\"1.0\"?>"), ());
|
||||
TEST_NO_THROW(XMLFeature::FromOSM("<?xml version=\"1.0\"?><osm></osm>"), ());
|
||||
TEST_ANY_THROW(XMLFeature::FromOSM("<?xml version=\"1.0\"?><osm><node lat=\"11.11\"/></osm>"), ());
|
||||
std::vector<XMLFeature> features;
|
||||
TEST_NO_THROW(features = XMLFeature::FromOSM(kTestNodeWay), ());
|
||||
TEST_EQUAL(3, features.size(), ());
|
||||
XMLFeature const & node = features[0];
|
||||
TEST_EQUAL(node.GetAttribute("id"), "4", ());
|
||||
TEST_EQUAL(node.GetTagValue("test"), "value", ());
|
||||
TEST_EQUAL(features[2].GetTagValue("hi"), "test", ());
|
||||
}
|
||||
|
||||
UNIT_TEST(XMLFeature_FromXmlNode)
|
||||
{
|
||||
auto const kTestNode = R"(<?xml version="1.0"?>
|
||||
<osm>
|
||||
<node id="4" lat="55.7978998" lon="37.474528" timestamp="2015-11-27T21:13:32Z">
|
||||
<tag k="amenity" v="fountain"/>
|
||||
</node>
|
||||
</osm>
|
||||
)";
|
||||
|
||||
pugi::xml_document doc;
|
||||
doc.load_string(kTestNode);
|
||||
XMLFeature const feature(doc.child("osm").child("node"));
|
||||
TEST_EQUAL(feature.GetAttribute("id"), "4", ());
|
||||
TEST_EQUAL(feature.GetTagValue("amenity"), "fountain", ());
|
||||
XMLFeature const copy(feature);
|
||||
TEST_EQUAL(copy.GetAttribute("id"), "4", ());
|
||||
TEST_EQUAL(copy.GetTagValue("amenity"), "fountain", ());
|
||||
}
|
||||
|
||||
UNIT_TEST(XMLFeature_Geometry)
|
||||
{
|
||||
std::vector<m2::PointD> const geometry = {
|
||||
{28.7206411, 3.7182409}, {46.7569003, 47.0774689}, {22.5909217, 41.6994874}, {14.7537008, 17.7788229},
|
||||
{55.1261701, 10.3199476}, {28.6519654, 50.0305930}, {28.7206411, 3.7182409}};
|
||||
|
||||
XMLFeature feature(XMLFeature::Type::Way);
|
||||
feature.SetGeometry(geometry);
|
||||
TEST_EQUAL(feature.GetGeometry(), geometry, ());
|
||||
}
|
||||
|
||||
UNIT_TEST(XMLFeature_ApplyPatch)
|
||||
{
|
||||
auto const kOsmFeature = R"(<?xml version="1.0"?>
|
||||
<osm>
|
||||
<node id="1" lat="1" lon="2" timestamp="2015-11-27T21:13:32Z" version="1">
|
||||
<tag k="amenity" v="cafe"/>
|
||||
</node>
|
||||
</osm>
|
||||
)";
|
||||
|
||||
auto const kPatch = R"(<?xml version="1.0"?>
|
||||
<node lat="1" lon="2" timestamp="2015-11-27T21:13:32Z">
|
||||
<tag k="website" v="maps.me"/>
|
||||
</node>
|
||||
)";
|
||||
|
||||
XMLFeature const baseOsmFeature = XMLFeature::FromOSM(kOsmFeature).front();
|
||||
|
||||
{
|
||||
XMLFeature noAnyTags = baseOsmFeature;
|
||||
noAnyTags.ApplyPatch(XMLFeature(kPatch));
|
||||
TEST(noAnyTags.HasKey("website"), ());
|
||||
}
|
||||
|
||||
{
|
||||
XMLFeature hasMainTag = baseOsmFeature;
|
||||
hasMainTag.SetTagValue("website", "mapswith.me");
|
||||
hasMainTag.ApplyPatch(XMLFeature(kPatch));
|
||||
TEST_EQUAL(hasMainTag.GetTagValue("website"), "maps.me", ());
|
||||
size_t tagsCount = 0;
|
||||
hasMainTag.ForEachTag([&tagsCount](std::string const &, std::string const &) { ++tagsCount; });
|
||||
TEST_EQUAL(2, tagsCount, ("website should be replaced, not duplicated."));
|
||||
}
|
||||
|
||||
{
|
||||
XMLFeature hasAltTag = baseOsmFeature;
|
||||
hasAltTag.SetTagValue("contact:website", "mapswith.me");
|
||||
hasAltTag.ApplyPatch(XMLFeature(kPatch));
|
||||
TEST(!hasAltTag.HasTag("website"), ("Existing alt tag should be used."));
|
||||
TEST_EQUAL(hasAltTag.GetTagValue("contact:website"), "maps.me", ());
|
||||
}
|
||||
|
||||
{
|
||||
XMLFeature hasAltTag = baseOsmFeature;
|
||||
hasAltTag.SetTagValue("url", "mapswithme.com");
|
||||
hasAltTag.ApplyPatch(XMLFeature(kPatch));
|
||||
TEST(!hasAltTag.HasTag("website"), ("Existing alt tag should be used."));
|
||||
TEST_EQUAL(hasAltTag.GetTagValue("url"), "maps.me", ());
|
||||
}
|
||||
|
||||
{
|
||||
XMLFeature hasTwoAltTags = baseOsmFeature;
|
||||
hasTwoAltTags.SetTagValue("contact:website", "mapswith.me");
|
||||
hasTwoAltTags.SetTagValue("url", "mapswithme.com");
|
||||
hasTwoAltTags.ApplyPatch(XMLFeature(kPatch));
|
||||
TEST(!hasTwoAltTags.HasTag("website"), ("Existing alt tag should be used."));
|
||||
TEST_EQUAL(hasTwoAltTags.GetTagValue("contact:website"), "maps.me", ());
|
||||
TEST_EQUAL(hasTwoAltTags.GetTagValue("url"), "mapswithme.com", ());
|
||||
}
|
||||
|
||||
{
|
||||
XMLFeature hasMainAndAltTag = baseOsmFeature;
|
||||
hasMainAndAltTag.SetTagValue("website", "osmrulezz.com");
|
||||
hasMainAndAltTag.SetTagValue("url", "mapswithme.com");
|
||||
hasMainAndAltTag.ApplyPatch(XMLFeature(kPatch));
|
||||
TEST_EQUAL(hasMainAndAltTag.GetTagValue("website"), "maps.me", ());
|
||||
TEST_EQUAL(hasMainAndAltTag.GetTagValue("url"), "mapswithme.com", ());
|
||||
}
|
||||
}
|
||||
|
||||
UNIT_TEST(XMLFeature_FromXMLAndBackToXML)
|
||||
{
|
||||
classificator::Load();
|
||||
|
||||
std::string const xmlNoTypeStr = R"(<?xml version="1.0"?>
|
||||
<node lat="55.7978998" lon="37.474528" timestamp="2015-11-27T21:13:32Z">
|
||||
<tag k="name" v="Gorki Park" />
|
||||
<tag k="name:en" v="Gorki Park" />
|
||||
<tag k="name:ru" v="Парк Горького" />
|
||||
<tag k="addr:housenumber" v="10" />
|
||||
</node>
|
||||
)";
|
||||
|
||||
char const kTimestamp[] = "2015-11-27T21:13:32Z";
|
||||
|
||||
editor::XMLFeature xmlNoType(xmlNoTypeStr);
|
||||
editor::XMLFeature xmlWithType = xmlNoType;
|
||||
xmlWithType.SetTagValue("amenity", "atm");
|
||||
|
||||
osm::EditableMapObject emo;
|
||||
editor::FromXML(xmlWithType, emo);
|
||||
auto fromFtWithType = editor::ToXML(emo, true);
|
||||
fromFtWithType.SetAttribute("timestamp", kTimestamp);
|
||||
TEST_EQUAL(fromFtWithType, xmlWithType, ());
|
||||
|
||||
auto fromFtWithoutType = editor::ToXML(emo, false);
|
||||
fromFtWithoutType.SetAttribute("timestamp", kTimestamp);
|
||||
TEST_EQUAL(fromFtWithoutType, xmlNoType, ());
|
||||
}
|
||||
|
||||
UNIT_TEST(XMLFeature_AmenityRecyclingFromAndToXml)
|
||||
{
|
||||
classificator::Load();
|
||||
{
|
||||
std::string const recyclingCentreStr = R"(<?xml version="1.0"?>
|
||||
<node lat="55.8047445" lon="37.5865532" timestamp="2018-07-11T13:24:41Z">
|
||||
<tag k="amenity" v="recycling" />
|
||||
<tag k="recycling_type" v="centre" />
|
||||
</node>
|
||||
)";
|
||||
|
||||
char const kTimestamp[] = "2018-07-11T13:24:41Z";
|
||||
|
||||
editor::XMLFeature xmlFeature(recyclingCentreStr);
|
||||
|
||||
osm::EditableMapObject emo;
|
||||
editor::FromXML(xmlFeature, emo);
|
||||
|
||||
auto const th = emo.GetTypes();
|
||||
TEST_EQUAL(th.Size(), 1, ());
|
||||
TEST_EQUAL(th.front(), classif().GetTypeByPath({"amenity", "recycling", "centre"}), ());
|
||||
|
||||
auto convertedFt = editor::ToXML(emo, true);
|
||||
convertedFt.SetAttribute("timestamp", kTimestamp);
|
||||
TEST_EQUAL(xmlFeature, convertedFt, ());
|
||||
}
|
||||
{
|
||||
std::string const recyclingContainerStr = R"(<?xml version="1.0"?>
|
||||
<node lat="55.8047445" lon="37.5865532" timestamp="2018-07-11T13:24:41Z">
|
||||
<tag k="amenity" v="recycling" />
|
||||
<tag k="recycling_type" v="container" />
|
||||
</node>
|
||||
)";
|
||||
|
||||
char const kTimestamp[] = "2018-07-11T13:24:41Z";
|
||||
|
||||
editor::XMLFeature xmlFeature(recyclingContainerStr);
|
||||
|
||||
osm::EditableMapObject emo;
|
||||
editor::FromXML(xmlFeature, emo);
|
||||
|
||||
auto const th = emo.GetTypes();
|
||||
TEST_EQUAL(th.Size(), 1, ());
|
||||
TEST_EQUAL(th.front(), classif().GetTypeByPath({"amenity", "recycling", "container"}), ());
|
||||
|
||||
auto convertedFt = editor::ToXML(emo, true);
|
||||
convertedFt.SetAttribute("timestamp", kTimestamp);
|
||||
TEST_EQUAL(xmlFeature, convertedFt, ());
|
||||
}
|
||||
/*
|
||||
{
|
||||
std::string const recyclingStr = R"(<?xml version="1.0"?>
|
||||
<node lat="55.8047445" lon="37.5865532" timestamp="2018-07-11T13:24:41Z">
|
||||
<tag k="amenity" v="recycling" />
|
||||
</node>
|
||||
)";
|
||||
|
||||
editor::XMLFeature xmlFeature(recyclingStr);
|
||||
|
||||
osm::EditableMapObject emo;
|
||||
editor::FromXML(xmlFeature, emo);
|
||||
|
||||
auto const th = emo.GetTypes();
|
||||
TEST_EQUAL(th.Size(), 1, ());
|
||||
TEST_EQUAL(*th.begin(), classif().GetTypeByPath({"amenity", "recycling"}), ());
|
||||
|
||||
auto convertedFt = editor::ToXML(emo, true);
|
||||
|
||||
// We save recycling container with "recycling_type"="container" tag.
|
||||
TEST(convertedFt.HasTag("recycling_type"), ());
|
||||
TEST_EQUAL(convertedFt.GetTagValue("recycling_type"), "container", ());
|
||||
|
||||
TEST(convertedFt.HasTag("amenity"), ());
|
||||
TEST_EQUAL(convertedFt.GetTagValue("amenity"), "recycling", ());
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
UNIT_TEST(XMLFeature_Diet)
|
||||
{
|
||||
XMLFeature ft(XMLFeature::Type::Node);
|
||||
TEST(ft.GetCuisine().empty(), ());
|
||||
|
||||
ft.SetCuisine("vegan;vegetarian");
|
||||
TEST_EQUAL(ft.GetCuisine(), "vegan;vegetarian", ());
|
||||
|
||||
ft.SetCuisine("vegan;pasta;vegetarian");
|
||||
TEST_EQUAL(ft.GetCuisine(), "pasta;vegan;vegetarian", ());
|
||||
|
||||
ft.SetCuisine("vegetarian");
|
||||
TEST_EQUAL(ft.GetCuisine(), "vegetarian", ());
|
||||
|
||||
ft.SetCuisine("vegan");
|
||||
TEST_EQUAL(ft.GetCuisine(), "vegan", ());
|
||||
|
||||
ft.SetCuisine("");
|
||||
TEST_EQUAL(ft.GetCuisine(), "", ());
|
||||
}
|
||||
|
||||
UNIT_TEST(XMLFeature_SocialContactsProcessing)
|
||||
{
|
||||
{
|
||||
std::string const nightclubStr = R"(<?xml version="1.0"?>
|
||||
<node lat="50.4082862" lon="30.5130017" timestamp="2022-02-24T05:07:00Z">
|
||||
<tag k="amenity" v="nightclub" />
|
||||
<tag k="name" v="Stereo Plaza" />
|
||||
<tag k="contact:facebook" v="http://www.facebook.com/pages/Stereo-Plaza/118100041593935" />
|
||||
<tag k="contact:instagram" v="https://www.instagram.com/p/CSy87IhMhfm/" />
|
||||
<tag k="contact:line" v="liff.line.me/1645278921-kWRPP32q/?accountId=673watcr" />
|
||||
</node>
|
||||
)";
|
||||
|
||||
editor::XMLFeature xmlFeature(nightclubStr);
|
||||
|
||||
osm::EditableMapObject emo;
|
||||
editor::FromXML(xmlFeature, emo);
|
||||
|
||||
auto convertedFt = editor::ToXML(emo, true);
|
||||
|
||||
TEST(convertedFt.HasTag("contact:facebook"), ());
|
||||
TEST_EQUAL(convertedFt.GetTagValue("contact:facebook"), "https://facebook.com/pages/Stereo-Plaza/118100041593935",
|
||||
());
|
||||
|
||||
TEST(convertedFt.HasTag("contact:instagram"), ());
|
||||
TEST_EQUAL(convertedFt.GetTagValue("contact:instagram"), "https://instagram.com/p/CSy87IhMhfm", ());
|
||||
|
||||
TEST(convertedFt.HasTag("contact:line"), ());
|
||||
TEST_EQUAL(convertedFt.GetTagValue("contact:line"), "https://liff.line.me/1645278921-kWRPP32q/?accountId=673watcr",
|
||||
());
|
||||
}
|
||||
}
|
||||
|
||||
UNIT_TEST(XMLFeature_SocialContactsProcessing_clean)
|
||||
{
|
||||
{
|
||||
std::string const nightclubStr = R"(<?xml version="1.0"?>
|
||||
<node lat="40.82862" lon="20.30017" timestamp="2022-02-24T05:07:00Z">
|
||||
<tag k="amenity" v="bar" />
|
||||
<tag k="name" v="Irish Pub" />
|
||||
<tag k="contact:facebook" v="https://www.facebook.com/PierreCardinPeru.oficial/" />
|
||||
<tag k="contact:instagram" v="https://www.instagram.com/fraback.genusswelt/" />
|
||||
<tag k="contact:line" v="https://line.me/R/ti/p/%40015qevdv" />
|
||||
</node>
|
||||
)";
|
||||
|
||||
editor::XMLFeature xmlFeature(nightclubStr);
|
||||
|
||||
osm::EditableMapObject emo;
|
||||
editor::FromXML(xmlFeature, emo);
|
||||
|
||||
auto convertedFt = editor::ToXML(emo, true);
|
||||
|
||||
TEST(convertedFt.HasTag("contact:facebook"), ());
|
||||
TEST_EQUAL(convertedFt.GetTagValue("contact:facebook"), "PierreCardinPeru.oficial", ());
|
||||
|
||||
TEST(convertedFt.HasTag("contact:instagram"), ());
|
||||
TEST_EQUAL(convertedFt.GetTagValue("contact:instagram"), "fraback.genusswelt", ());
|
||||
|
||||
TEST(convertedFt.HasTag("contact:line"), ());
|
||||
TEST_EQUAL(convertedFt.GetTagValue("contact:line"), "015qevdv", ());
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue