MCPcopy Create free account
hub / github.com/PDAL/PDAL / ready

Method ready

io/TextWriter.cpp:159–207  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

157
158
159void TextWriter::ready(PointTableRef table)
160{
161 m_stream = FileStreamPtr(Utils::createFile(filename(), true), FileStreamDeleter());
162 if (!m_stream)
163 throwError("Couldn't open '" + filename() + "' for output.");
164
165 *m_stream << std::fixed;
166
167 m_xDim = { Dimension::Id::X, static_cast<size_t>(m_precision),
168 table.layout()->dimName(Dimension::Id::X) };
169 m_yDim = { Dimension::Id::Y, static_cast<size_t>(m_precision),
170 table.layout()->dimName(Dimension::Id::Y) };
171 m_zDim = { Dimension::Id::Z, static_cast<size_t>(m_precision),
172 table.layout()->dimName(Dimension::Id::Z) };
173
174 // Find the dimensions listed and put them on the id list.
175 StringList dimNames = Utils::split2(m_dimOrder, ',');
176 for (std::string dim : dimNames)
177 {
178 const DimSpec& spec = extractDim(dim, table);
179 if (spec.id == Dimension::Id::X)
180 m_xDim = spec;
181 else if (spec.id == Dimension::Id::Y)
182 m_yDim = spec;
183 else if (spec.id == Dimension::Id::Z)
184 m_zDim = spec;
185 m_dims.push_back(spec);
186 }
187
188 // Add the rest of the dimensions to the list if we're doing that.
189 // Yes, this isn't efficient when, but it's simple.
190 if (m_dimOrder.empty() || m_writeAllDims)
191 {
192 Dimension::IdList all = table.layout()->dims();
193 for (auto id : all)
194 {
195 DimSpec ds { id, static_cast<size_t>(m_precision),
196 table.layout()->dimName(id) };
197 if (!findDim(id, ds))
198 m_dims.push_back(ds);
199 }
200 }
201
202 if (!m_writeHeader)
203 log()->get(LogLevel::Debug) << "Not writing header" << std::endl;
204 else
205 writeHeader(table);
206 m_idx = 0;
207}
208
209
210void TextWriter::writeHeader(PointTableRef table)

Callers

nothing calls this directly

Calls 7

extractDimFunction · 0.85
dimNameMethod · 0.80
FileStreamDeleterClass · 0.70
createFileFunction · 0.50
logFunction · 0.50
emptyMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected