initial commit

This commit is contained in:
Kirill Zhdanovich 2013-12-03 15:05:50 +03:00 committed by Alex Zolotarev
parent 7cf60b7aa5
commit 11a1f6f7d1
5 changed files with 144 additions and 4 deletions

View file

@ -0,0 +1,6 @@
#include "house_detector.hpp"
search::HouseDetector::HouseDetector()
{
}

70
search/house_detector.hpp Normal file
View file

@ -0,0 +1,70 @@
#pragma once
#include "../geometry/point2d.hpp"
#include "../std/string.hpp"
namespace search
{
const double s_epsilon = 10.0 * 360.0 / 40E6;
class FeatureLoader
{
public:
};
class House
{
string m_number;
m2::PointD m_point;
public:
};
// many features combines to street
class Street
{
string m_name;
vector<m2::PointD> m_points;
vector<House> m_houses;
bool m_housesReaded;
};
class HouseDetector
{
FeatureLoader m_loader;
// id -> street
//map<FeatureID, Street *> m_id2st;
public:
struct LessWithEpsilon
{
//static double s_epsilon;
bool operator() (m2::PointD const & p1, m2::PointD const & p2) const
{
if (p1.x + s_epsilon < p2.x)
return true;
else if (p2.x + s_epsilon < p1.x)
return false;
else
{
return (p1.y + s_epsilon < p2.y);
}
}
};
private:
// start, end point -> street
multimap<m2::PointD, Street *, LessWithEpsilon> m_end2st;
Street * GetNext(Street const *);
Street * GetPrev(Street const *);
public:
HouseDetector();
};
}

View file

@ -20,6 +20,7 @@ HEADERS += \
feature_offset_match.hpp \
keyword_lang_matcher.hpp \
params.hpp \
house_detector.hpp
SOURCES += \
search_engine.cpp \
@ -31,3 +32,4 @@ SOURCES += \
approximate_string_match.cpp \
keyword_lang_matcher.cpp \
params.cpp \
house_detector.cpp

View file

@ -0,0 +1,61 @@
#include "../../testing/testing.hpp"
#include "../house_detector.hpp"
UNIT_TEST(LESS_WITH_EPSILON)
{
search::HouseDetector::LessWithEpsilon compare;
{
m2::PointD a(1, 1);
m2::PointD b(2, 2);
TEST(compare(a, b), ());
TEST(!compare(b, a), ());
}
{
m2::PointD a(1, 1);
m2::PointD b(1, 1);
TEST(!compare(a, b), ());
TEST(!compare(b, a), ());
}
{
m2::PointD a(1, 1);
m2::PointD b(1.1, 1.1);
TEST(compare(a, b), ());
TEST(!compare(b, a), ());
}
{
m2::PointD a(1, 1);
m2::PointD b(1 + search::s_epsilon, 1);
TEST(!compare(a, b), ());
TEST(!compare(b, a), ());
}
{
m2::PointD a(1, 1);
m2::PointD b(1 + search::s_epsilon, 1 - search::s_epsilon);
TEST(!compare(a, b), ());
TEST(!compare(b, a), ());
}
{
m2::PointD a(1, 1 - search::s_epsilon);
m2::PointD b(1 + search::s_epsilon, 1);
TEST(!compare(a, b), ());
TEST(!compare(b, a), ());
}
{
m2::PointD a(1 - search::s_epsilon, 1 - search::s_epsilon);
m2::PointD b(1, 1);
TEST(!compare(a, b), ());
TEST(!compare(b, a), ());
}
{
m2::PointD a(1, 1);
m2::PointD b(1 + search::s_epsilon, 1 + search::s_epsilon);
TEST(!compare(a, b), ());
TEST(!compare(b, a), ());
}
{
m2::PointD a(1, 1);
m2::PointD b(1 + 2 * search::s_epsilon, 1 + search::s_epsilon);
TEST(compare(a, b), ());
TEST(!compare(b, a), ());
}
}

View file

@ -19,10 +19,11 @@ win32 {
SOURCES += \
../../testing/testingmain.cpp \
keyword_matcher_test.cpp \
keyword_lang_matcher_test.cpp \
latlon_match_test.cpp \
string_match_test.cpp \
#keyword_matcher_test.cpp \
#keyword_lang_matcher_test.cpp \
#latlon_match_test.cpp \
#string_match_test.cpp \
house_detector_tests.cpp \
HEADERS += \
match_cost_mock.hpp \