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

Method execute

dimbuilder/DimBuilder.cpp:121–172  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

119
120
121bool DimBuilder::execute()
122{
123 std::ifstream in(m_input);
124
125 if (!in)
126 throw dimbuilder_error("Can't open input file.");
127
128 NL::json root;
129 try
130 {
131 in >> root;
132 }
133 catch (NL::json::parse_error& err)
134 {
135 throw dimbuilder_error(err.what());
136 }
137
138 NL::json dims;
139 auto it = root.find("dimensions");
140 if (it != root.end())
141 dims = *it;
142 if (root.size() != 1 || !dims.is_array())
143 {
144 std::ostringstream oss;
145
146 oss << "Root node must contain a single 'dimensions' array.";
147 throw dimbuilder_error(oss.str());
148 }
149 for (auto& dim : dims)
150 {
151 if (!dim.is_object())
152 {
153 std::ostringstream oss;
154
155 oss << "Found a dimension that is not an object: " <<
156 dim.get<std::string>();
157 throw dimbuilder_error(oss.str());
158 }
159 extractDim(dim);
160 }
161
162 std::ofstream out(m_output);
163 if (!out)
164 {
165 std::ostringstream oss;
166
167 oss << "Unable to open output file '" << m_output << "'.";
168 throw dimbuilder_error(oss.str());
169 }
170 writeOutput(out);
171 return true;
172}
173
174
175void DimBuilder::extractDim(NL::json& dim)

Callers 1

mainFunction · 0.45

Calls 7

dimbuilder_errorClass · 0.85
extractDimFunction · 0.85
strMethod · 0.80
whatMethod · 0.45
findMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected