23 lines
897 B
C++
23 lines
897 B
C++
#include "DatasetCategory.hpp"
|
||
|
||
namespace geopro::app {
|
||
|
||
CategoryBuckets splitByCategory(const std::vector<geopro::data::DsRow>& rows) {
|
||
const auto& cfg = categoryConfigs();
|
||
CategoryBuckets b;
|
||
b.segments.resize(cfg.size());
|
||
for (const auto& r : rows) {
|
||
int hit = -1;
|
||
// 先按 ddCode(三维体/切片)——它们无 dsTypeCode(来自 Api3dRepository mock 行)。
|
||
for (std::size_t i = 0; i < cfg.size() && hit < 0; ++i)
|
||
if (!cfg[i].ddCode.empty() && r.ddCode == cfg[i].ddCode) hit = static_cast<int>(i);
|
||
// 再按 dsTypeCode。
|
||
for (std::size_t i = 0; i < cfg.size() && hit < 0; ++i)
|
||
if (!cfg[i].dsTypeCode.empty() && r.dsTypeCode == cfg[i].dsTypeCode) hit = static_cast<int>(i);
|
||
if (hit >= 0) b.segments[static_cast<std::size_t>(hit)].push_back(r);
|
||
}
|
||
return b;
|
||
}
|
||
|
||
} // namespace geopro::app
|