Now I need to merge the closed-way admin polygons during the merge phase. Let me find where thread-local admin data is merged.


2054:                    std::vector<ClosedWayAdmin> closed_way_admins;
2259:                                                            local.closed_way_admins.push_back({
2393:                        local.way_geoms.clear();


  2382→                    total_interps += local.interp_count;
  2383→
  2384→                    // Merge way geometries for parallel admin assembly
  2385→                    if (parallel_admin) {
  2386→                        for (auto& wg : local.way_geoms) {
  2387→                            ParsedData::WayGeometry g;
  2388→                            g.coords = std::move(wg.coords);
  2389→                            g.first_node_id = wg.first_node_id;
  2390→                            g.last_node_id = wg.last_node_id;
  2391→                            data.way_geometries[wg.way_id] = std::move(g);
  2392→                        }
  2393→                        local.way_geoms.clear();
  2394→                        local.way_geoms.shrink_to_fit();
  2395→                    }
  2396→                }
  2397→                std::cerr << "  Merged: " << total_ways << " ways, "
  2398→                          << total_building_addrs << " building addrs, "
  2399→                          << total_interps << " interps from parallel processing." << std::endl;
  2400→
  2401→                // --- Parallel admin boundary assembly ---
  2402→                if (parallel_admin) {
  2403→                    std::cerr << "  Assembling admin polygons in parallel ("
  2404→                              << data.collected_relations.size() << " relations, "
  2405→                              << data.way_geometries.size() << " way geometries)..." << std::endl;
  2406→

                    total_interps += local.interp_count;

                    // Merge way geometries for parallel admin assembly
                    if (parallel_admin) {
                        for (auto& wg : local.way_geoms) {
                            ParsedData::WayGeometry g;
                            g.coords = std::move(wg.coords);
                            g.first_node_id = wg.first_node_id;
                            g.last_node_id = wg.last_node_id;
                            data.way_geometries[wg.way_id] = std::move(g);
                        }
                        local.way_geoms.clear();
                        local.way_geoms.shrink_to_fit();
                    }
                }
                std::cerr << "  Merged: " << total_ways << " ways, "
                          << total_building_addrs << " building addrs, "
                          << total_interps << " interps from parallel processing." << std::endl;

                // --- Parallel admin boundary assembly ---
                if (parallel_admin) {
                    std::cerr << "  Assembling admin polygons in parallel ("
                              << data.collected_relations.size() << " relations, "
                              << data.way_geometries.size() << " way geometries)..." << std::endl;


I need to add the closed-way admin merge after the way_geoms merge and before the parallel admin assembly starts.


Edit

                std::cerr << "  Merged: " << total_ways << " ways, "
                          << total_building_addrs << " building addrs, "
                          << total_interps << " interps from parallel processing." << std::endl;

                // --- Parallel admin boundary assembly ---
                if (parallel_admin) {

                std::cerr << "  Merged: " << total_ways << " ways, "
                          << total_building_addrs << " building addrs, "
                          << total_interps << " interps from parallel processing." << std::endl;

                // --- Merge closed-way admin polygons ---
                if (parallel_admin) {
                    uint64_t closed_way_admin_count = 0;
                    for (auto& local : tld) {
                        for (auto& cwa : local.closed_way_admins) {
                            const char* cc = cwa.country_code.empty() ? nullptr : cwa.country_code.c_str();
                            add_admin_polygon(data, cwa.vertices, cwa.name.c_str(),
                                              cwa.admin_level, cc, &admin_pool);
                            closed_way_admin_count++;
                        }
                        local.closed_way_admins.clear();
                    }
                    if (closed_way_admin_count > 0) {
                        std::cerr << "  Added " << closed_way_admin_count
                                  << " admin polygons from closed ways." << std::endl;
                    }
                }

                // --- Parallel admin boundary assembly ---
                if (parallel_admin) {