MCPcopy Create free account
hub / github.com/comaps/comaps / Finish

Method Finish

generator/feature_sorter.cpp:66–143  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64 }
65
66 void Finish() override
67 {
68 // write version information
69 {
70 FilesContainerW writer(m_filename);
71 auto w = writer.GetWriter(VERSION_FILE_TAG);
72 version::WriteVersion(*w, m_versionDate);
73 }
74
75 // write own mwm header
76 m_header.SetBounds(m_bounds);
77 {
78 FilesContainerW writer(m_filename, FileWriter::OP_WRITE_EXISTING);
79 auto w = writer.GetWriter(HEADER_FILE_TAG);
80 m_header.Save(*w);
81 }
82
83 // write region info
84 {
85 FilesContainerW writer(m_filename, FileWriter::OP_WRITE_EXISTING);
86 auto w = writer.GetWriter(REGION_INFO_FILE_TAG);
87 m_regionData.Serialize(*w);
88 }
89
90 // assume like we close files
91 Flush();
92
93 {
94 FilesContainerW writer(m_filename, FileWriter::OP_WRITE_EXISTING);
95 auto w = writer.GetWriter(FEATURES_FILE_TAG);
96
97 size_t const startOffset = w->Pos();
98 CHECK(coding::IsAlign8(startOffset), ());
99
100 feature::DatSectionHeader header;
101 header.Serialize(*w);
102
103 uint64_t bytesWritten = static_cast<uint64_t>(w->Pos());
104 coding::WritePadding(*w, bytesWritten);
105
106 header.m_featuresOffset = base::asserted_cast<uint32_t>(w->Pos() - startOffset);
107 ReaderSource<ModelReaderPtr> src(std::make_unique<FileReader>(m_dataFile.GetName()));
108 rw::ReadAndWrite(src, *w);
109 header.m_featuresSize = base::asserted_cast<uint32_t>(w->Pos() - header.m_featuresOffset - startOffset);
110
111 auto const endOffset = w->Pos();
112 w->Seek(startOffset);
113 header.Serialize(*w);
114 w->Seek(endOffset);
115 }
116
117 // File Writer finalization function with adding section to the main mwm file.
118 auto const finalizeFn = [this](std::unique_ptr<TmpFile> && tmpFile, std::string const & tag)
119 {
120 auto & w = tmpFile->GetWriter();
121 w.Flush();
122 FilesContainerW writer(m_filename, FileWriter::OP_WRITE_EXISTING);
123 writer.Write(w.GetName(), tag);

Callers 1

GenerateFinalFeaturesFunction · 0.45

Calls 15

IsAlign8Function · 0.85
WritePaddingFunction · 0.85
ReadAndWriteFunction · 0.85
GetTagForIndexFunction · 0.85
GetWriterMethod · 0.80
WriteVersionFunction · 0.50
SetBoundsMethod · 0.45
SaveMethod · 0.45
SerializeMethod · 0.45
PosMethod · 0.45
GetNameMethod · 0.45
SeekMethod · 0.45

Tested by

no test coverage detected