| 80 | |
| 81 | |
| 82 | int DeltaKernel::execute() |
| 83 | { |
| 84 | ColumnPointTable srcTable; |
| 85 | ColumnPointTable candTable; |
| 86 | DimIndexMap dims; |
| 87 | |
| 88 | PointViewPtr srcView = loadSet(m_sourceFile, srcTable); |
| 89 | PointViewPtr candView = loadSet(m_candidateFile, candTable); |
| 90 | |
| 91 | PointLayoutPtr srcLayout = srcTable.layout(); |
| 92 | PointLayoutPtr candLayout = candTable.layout(); |
| 93 | |
| 94 | Dimension::IdList ids = srcLayout->dims(); |
| 95 | for (Dimension::Id dim : ids) |
| 96 | { |
| 97 | std::string name = srcLayout->dimName(dim); |
| 98 | if (!m_allDims) |
| 99 | if (name != "X" && name != "Y" && name != "Z") |
| 100 | continue; |
| 101 | DimIndex d; |
| 102 | d.m_name = name; |
| 103 | d.m_srcId = dim; |
| 104 | dims[name] = d; |
| 105 | } |
| 106 | ids = candLayout->dims(); |
| 107 | for (Dimension::Id dim : ids) |
| 108 | { |
| 109 | std::string name = candLayout->dimName(dim); |
| 110 | auto di = dims.find(name); |
| 111 | if (di == dims.end()) |
| 112 | continue; |
| 113 | DimIndex& d = di->second; |
| 114 | d.m_candId = dim; |
| 115 | } |
| 116 | |
| 117 | // Remove dimensions that aren't in both the source and candidate lists. |
| 118 | for (auto di = dims.begin(); di != dims.end();) |
| 119 | { |
| 120 | DimIndex& d = di->second; |
| 121 | if (d.m_candId == Dimension::Id::Unknown) |
| 122 | dims.erase(di++); |
| 123 | else |
| 124 | ++di; |
| 125 | } |
| 126 | |
| 127 | // Index the candidate data. |
| 128 | KD3Index index(*candView); |
| 129 | index.build(); |
| 130 | |
| 131 | MetadataNode root; |
| 132 | |
| 133 | if (m_detail) |
| 134 | root = dumpDetail(srcView, candView, index, dims); |
| 135 | else |
| 136 | root = dump(srcView, candView, index, dims); |
| 137 | Utils::toJSON(root, std::cout); |
| 138 | |
| 139 | return 0; |