Skip to content

Commit b0dc2c4

Browse files
tananaevclaude
andcommitted
Deduplicate cell-way pairs per way during collection
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 5d43870 commit b0dc2c4

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

builder/src/build_index.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,7 @@ class BuildHandler : public osmium::handler::Handler {
547547
iw.interpolation = interp_type;
548548
interp_ways.push_back(iw);
549549

550+
std::unordered_set<uint64_t> interp_cells;
550551
for (size_t i = 0; i + 1 < wnodes.size(); i++) {
551552
double lat1 = wnodes[i].location().lat();
552553
double lng1 = wnodes[i].location().lon();
@@ -555,9 +556,12 @@ class BuildHandler : public osmium::handler::Handler {
555556

556557
auto cell_ids = cover_edge(lat1, lng1, lat2, lng2);
557558
for (const auto& cell_id : cell_ids) {
558-
cell_to_interps[cell_id.id()].push_back(interp_id);
559+
interp_cells.insert(cell_id.id());
559560
}
560561
}
562+
for (uint64_t cell_id : interp_cells) {
563+
cell_to_interps[cell_id].push_back(interp_id);
564+
}
561565

562566
interp_count_++;
563567
}
@@ -586,6 +590,7 @@ class BuildHandler : public osmium::handler::Handler {
586590
header.name_id = strings.intern(name);
587591
ways.push_back(header);
588592

593+
std::unordered_set<uint64_t> way_cells;
589594
for (size_t i = 0; i + 1 < wnodes.size(); i++) {
590595
double lat1 = wnodes[i].location().lat();
591596
double lng1 = wnodes[i].location().lon();
@@ -594,9 +599,12 @@ class BuildHandler : public osmium::handler::Handler {
594599

595600
auto cell_ids = cover_edge(lat1, lng1, lat2, lng2);
596601
for (const auto& cell_id : cell_ids) {
597-
cell_to_ways[cell_id.id()].push_back(way_id);
602+
way_cells.insert(cell_id.id());
598603
}
599604
}
605+
for (uint64_t cell_id : way_cells) {
606+
cell_to_ways[cell_id].push_back(way_id);
607+
}
600608

601609
way_count_++;
602610
if (way_count_ % 1000000 == 0) {

0 commit comments

Comments
 (0)