[search] Added some debug functions.
This commit is contained in:
parent
00cac24997
commit
e7a0ed8300
2 changed files with 100 additions and 21 deletions
|
@ -10,10 +10,83 @@
|
|||
#include "../std/set.hpp"
|
||||
#include "../std/bind.hpp"
|
||||
|
||||
#ifdef DEBUG
|
||||
#include "../platform/platform.hpp"
|
||||
|
||||
#include "../std/iostream.hpp"
|
||||
#include "../std/fstream.hpp"
|
||||
#endif
|
||||
|
||||
|
||||
namespace search
|
||||
{
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
#ifdef DEBUG
|
||||
void Houses2KML(ostream & s, map<search::House, double> const & m)
|
||||
{
|
||||
for (map<search::House, double>::const_iterator it = m.begin(); it != m.end(); ++it)
|
||||
{
|
||||
m2::PointD const & pt = it->first.GetPosition();
|
||||
|
||||
s << "<Placemark>"
|
||||
<< "<name>" << it->first.GetNumber() << "</name>"
|
||||
|
||||
<< "<Point><coordinates>"
|
||||
<< MercatorBounds::XToLon(pt.x)
|
||||
<< ","
|
||||
<< MercatorBounds::YToLat(pt.y)
|
||||
|
||||
<< "</coordinates></Point>"
|
||||
<< "</Placemark>" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
void Street2KML(ostream & s, vector<m2::PointD> const & pts, char const * color)
|
||||
{
|
||||
s << "<Placemark>" << endl;
|
||||
s << "<Style><LineStyle><color>" << color << "</color></LineStyle></Style>" << endl;
|
||||
|
||||
s << "<LineString><coordinates>" << endl;
|
||||
for (size_t i = 0; i < pts.size(); ++i)
|
||||
{
|
||||
s << MercatorBounds::XToLon(pts[i].x) << "," << MercatorBounds::YToLat(pts[i].y) << "," << "0.0" << endl;
|
||||
}
|
||||
s << "</coordinates></LineString>" << endl;
|
||||
|
||||
s << "</Placemark>" << endl;
|
||||
}
|
||||
|
||||
void Streets2KML(ostream & s, vector<Street *> const & v, char const * color)
|
||||
{
|
||||
for (size_t i = 0; i < v.size(); ++i)
|
||||
Street2KML(s, v[i]->m_points, color);
|
||||
}
|
||||
|
||||
class KMLFileGuard
|
||||
{
|
||||
ofstream m_file;
|
||||
public:
|
||||
KMLFileGuard(string const & name)
|
||||
{
|
||||
m_file.open(GetPlatform().WritablePathForFile(name).c_str());
|
||||
|
||||
m_file << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << endl;
|
||||
m_file << "<kml xmlns=\"http://earth.google.com/kml/2.2\">" << endl;
|
||||
m_file << "<Document>" << endl;
|
||||
}
|
||||
|
||||
ostream & GetStream() { return m_file; }
|
||||
|
||||
~KMLFileGuard()
|
||||
{
|
||||
m_file << "</Document></kml>" << endl;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
/// @todo Move prefixes, suffixes into separate file (autogenerated).
|
||||
|
||||
string affics1[] =
|
||||
|
@ -49,6 +122,9 @@ void GetStreetName(strings::SimpleTokenizer iter, string & streetName)
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
double const STREET_CONNECTION_LENGTH_M = 100.0;
|
||||
|
||||
void House::InitHouseNumberAndSuffix()
|
||||
|
@ -200,6 +276,8 @@ void HouseDetector::Bfs(Street * st)
|
|||
|
||||
int HouseDetector::LoadStreets(vector<FeatureID> & ids)
|
||||
{
|
||||
//LOG(LDEBUG, ("IDs = ", ids));
|
||||
|
||||
int count = 0;
|
||||
for (size_t i = 0; i < ids.size(); ++i)
|
||||
{
|
||||
|
@ -243,17 +321,36 @@ int HouseDetector::LoadStreets(vector<FeatureID> & ids)
|
|||
|
||||
int HouseDetector::MergeStreets()
|
||||
{
|
||||
LOG(LDEBUG, ("MergeStreets() called", m_end2st.size()));
|
||||
LOG(LDEBUG, ("MergeStreets() called", m_id2st.size()));
|
||||
|
||||
//#ifdef DEBUG
|
||||
// KMLFileGuard file("dbg_merged_streets.kml");
|
||||
// char const * color = "FF000000";
|
||||
//#endif
|
||||
|
||||
for (IterT it = m_end2st.begin(); it != m_end2st.end(); ++it)
|
||||
{
|
||||
if (it->second->m_number == -1)
|
||||
Street * st = it->second;
|
||||
|
||||
//#ifdef DEBUG
|
||||
// Street2KML(file.GetStream(), st->m_points, color);
|
||||
//#endif
|
||||
|
||||
if (st->m_number == -1)
|
||||
{
|
||||
Street * st = it->second;
|
||||
++m_streetNum;
|
||||
Bfs(st);
|
||||
}
|
||||
}
|
||||
|
||||
//#ifdef DEBUG
|
||||
// char const * arrColor[] = { "FFFF0000", "FF00FF00", "FF0000FF" };
|
||||
// for (size_t i = 0; i < m_streets.size(); ++i)
|
||||
// {
|
||||
// Streets2KML(file.GetStream(), m_streets[i], arrColor[i % ARRAY_SIZE(arrColor)]);
|
||||
// }
|
||||
//#endif
|
||||
|
||||
return m_streetNum;
|
||||
}
|
||||
|
||||
|
@ -542,23 +639,6 @@ bool CheckOddEven(search::HouseProjection const & h, bool isOdd)
|
|||
return ((x % 2 == 1) == isOdd);
|
||||
}
|
||||
|
||||
void CreateKMLString(ostream & s, map<search::House, double> const & m)
|
||||
{
|
||||
for (map<search::House, double>::const_iterator it = m.begin(); it != m.end(); ++it)
|
||||
{
|
||||
s << "<Placemark>"
|
||||
<< "<name>" << it->first.GetNumber() << "</name>"
|
||||
|
||||
<< "<Point><coordinates>"
|
||||
<< MercatorBounds::XToLon(it->first.GetPosition().x)
|
||||
<< ","
|
||||
<< MercatorBounds::YToLat(it->first.GetPosition().y)
|
||||
|
||||
<< "</coordinates></Point>"
|
||||
<< "</Placemark>" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
void ProccessHouses(vector<search::HouseProjection> & houses,
|
||||
vector<search::HouseProjection> & result,
|
||||
bool isOdd, HouseMapT & m)
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
#include "../std/string.hpp"
|
||||
#include "../std/queue.hpp"
|
||||
#include "../std/iostream.hpp"
|
||||
|
||||
|
||||
namespace search
|
||||
|
|
Reference in a new issue