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

Method extractDim

io/TextWriter.cpp:115–145  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

113
114
115TextWriter::DimSpec TextWriter::extractDim(std::string dim, PointTableRef table)
116{
117 Utils::trim(dim);
118
119 size_t precision(0);
120 StringList s = Utils::split(dim, ':');
121 if (s.size() == 1)
122 precision = m_precision;
123 else if (s.size() == 2)
124 {
125 try
126 {
127 size_t pos;
128 int i = std::stoi(s[1], &pos);
129 if (i < 0 || pos != s[1].size())
130 throw pdal_error("Dummy"); // Throw to be caught below.
131 precision = static_cast<size_t>(i);
132 }
133 catch (...)
134 {
135 throwError("Can't convert dimension precision for '" + dim +
136 "'.");
137 }
138 }
139 else
140 throwError("Invalid dimension specification '" + dim + "'.");
141 Dimension::Id d = table.layout()->findDim(s[0]);
142 if (d == Dimension::Id::Unknown)
143 throwError("Dimension not found with name '" + dim + "'.");
144 return { d, precision, table.layout()->dimName(d) };
145}
146
147
148bool TextWriter::findDim(Dimension::Id id, DimSpec& ds)

Callers

nothing calls this directly

Calls 5

trimFunction · 0.85
splitFunction · 0.85
dimNameMethod · 0.80
sizeMethod · 0.45
findDimMethod · 0.45

Tested by

no test coverage detected