#include "testing/testing.hpp" #include "editor/feature_matcher.hpp" #include "editor/xml_feature.hpp" #include #include #include namespace { // This place on OSM map https://www.openstreetmap.org/relation/1359233. std::string const kSenatskiyDvorets = R"XXX( )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 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