Dump water polygons into file

This commit is contained in:
Sergey Yershov 2015-07-10 15:52:44 +03:00 committed by Alex Zolotarev
parent 213c93b49a
commit 33364f793e
2 changed files with 19 additions and 3 deletions

View file

@ -19,8 +19,8 @@ class FeatureBuilder1
friend string DebugPrint(FeatureBuilder1 const & f);
public:
typedef vector<m2::PointD> TRing;
typedef list<TRing> TPolygon;
typedef vector<m2::PointD> TPointSeq;
typedef list<TPointSeq> TGeometry;
FeatureBuilder1();
@ -43,7 +43,7 @@ public:
//@}
inline feature::Metadata const & GetMetadata() const { return m_params.GetMetadata(); }
// inline list<vector<m2::PointD>> const & GetGeometry() { return m_polygons; }
inline TGeometry const & GetGeometry() const { return m_polygons; }
inline feature::EGeomType GetGeomType() const { return m_params.GetGeomType(); }
inline void AddType(uint32_t type) { m_params.AddType(type); }

View file

@ -41,6 +41,8 @@ FeaturesCollector::~FeaturesCollector()
FlushBuffer();
/// Check file size
(void)GetFileSize(m_datFile);
uint64_t terminator = 0;
m_dumpFileStream.write(reinterpret_cast<char *>(&terminator), sizeof(terminator));
m_dumpFileStream.close();
}
@ -117,7 +119,18 @@ uint32_t FeaturesCollector::WriteFeatureBase(vector<char> const & bytes, Feature
void FeaturesCollector::DumpFeatureGeometry(FeatureBuilder1 const & fb)
{
FeatureBuilder1::TGeometry const & geom = fb.GetGeometry();
if (geom.empty())
return;
uint64_t num_geometries = geom.size();
m_dumpFileStream.write(reinterpret_cast<char *>(&num_geometries), sizeof(num_geometries));
for (FeatureBuilder1::TPointSeq const & points : geom)
{
uint64_t num_points = points.size();
m_dumpFileStream.write(reinterpret_cast<char *>(&num_points), sizeof(num_points));
m_dumpFileStream.write(reinterpret_cast<char const *>(points.data()), sizeof(FeatureBuilder1::TPointSeq::value_type) * points.size());
}
}
void FeaturesCollector::operator() (FeatureBuilder1 const & fb)
@ -125,6 +138,9 @@ void FeaturesCollector::operator() (FeatureBuilder1 const & fb)
FeatureBuilder1::buffer_t bytes;
fb.Serialize(bytes);
(void)WriteFeatureBase(bytes, fb);
if (!m_dumpFileName.empty())
DumpFeatureGeometry(fb);
}