Build the list of dimensions for the output schema. Placing this here allows validation of dimensions before execution begins.
| 45 | // Build the list of dimensions for the output schema. |
| 46 | // Placing this here allows validation of dimensions before execution begins. |
| 47 | void DbWriter::prepared(PointTableRef table) |
| 48 | { |
| 49 | using namespace Dimension; |
| 50 | |
| 51 | PointLayoutPtr layout = table.layout(); |
| 52 | |
| 53 | if (m_outputDims.empty()) |
| 54 | { |
| 55 | for (auto& dimType : layout->dimTypes()) |
| 56 | m_dbDims.push_back(XMLDim(dimType, layout->dimName(dimType.m_id))); |
| 57 | return; |
| 58 | } |
| 59 | |
| 60 | DimTypeList dims; |
| 61 | for (std::string& s : m_outputDims) |
| 62 | { |
| 63 | DimType dt = layout->findDimType(s); |
| 64 | if (dt.m_id == Id::Unknown) |
| 65 | { |
| 66 | std::ostringstream oss; |
| 67 | oss << "Invalid dimension '" << s << "' specified for " |
| 68 | "'output_dims' option."; |
| 69 | throw pdal_error(oss.str()); |
| 70 | } |
| 71 | m_dbDims.push_back(XMLDim(dt, layout->dimName(dt.m_id))); |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | |
| 76 | void DbWriter::ready(PointTableRef /*table*/) |