diff --git a/generator/cities_boundaries_builder.cpp b/generator/cities_boundaries_builder.cpp index c401880e64..13d266ae7a 100644 --- a/generator/cities_boundaries_builder.cpp +++ b/generator/cities_boundaries_builder.cpp @@ -86,15 +86,21 @@ bool BuildCitiesBoundariesForTesting(string const & dataPath, TestIdToBoundaries void SerializeBoundariesTable(std::string const & path, OsmIdToBoundariesTable & table) { - vector> allIds; - vector> allBoundaries; - table.ForEachCluster( - [&](vector const & ids, vector const & boundaries) { - allIds.push_back(ids); - allBoundaries.push_back(boundaries); - }); + using GeoIDsT = vector; + using BoundariesT = vector; + vector allIds; + vector allBoundaries; - CHECK_EQUAL(allIds.size(), allBoundaries.size(), ()); + table.ForEachCluster([&](GeoIDsT & ids, BoundariesT const & boundaries) + { + CHECK(!ids.empty(), ()); + CHECK(!boundaries.empty(), ()); + + allIds.push_back(std::move(ids)); + allBoundaries.push_back(boundaries); + }); + + LOG(LINFO, ("Saved boundary clusters count =", allIds.size())); FileWriter sink(path); indexer::CitiesBoundariesSerDes::Serialize(sink, allBoundaries); @@ -111,6 +117,7 @@ bool DeserializeBoundariesTable(std::string const & path, OsmIdToBoundariesTable vector> allIds; vector> allBoundaries; + size_t count = 0; try { FileReader reader(path); @@ -119,8 +126,8 @@ bool DeserializeBoundariesTable(std::string const & path, OsmIdToBoundariesTable double precision; indexer::CitiesBoundariesSerDes::Deserialize(source, allBoundaries, precision); - auto const n = allBoundaries.size(); - allIds.resize(n); + count = allBoundaries.size(); + allIds.resize(count); for (auto & ids : allIds) { @@ -141,16 +148,15 @@ bool DeserializeBoundariesTable(std::string const & path, OsmIdToBoundariesTable return false; } - CHECK_EQUAL(allBoundaries.size(), allIds.size(), ()); table.Clear(); - for (size_t i = 0; i < allBoundaries.size(); ++i) + for (size_t i = 0; i < count; ++i) { auto const & ids = allIds[i]; CHECK(!ids.empty(), ()); auto const & id = ids.front(); - for (auto const & b : allBoundaries[i]) - table.Append(id, b); + for (auto & b : allBoundaries[i]) + table.Append(id, std::move(b)); for (size_t j = 1; j < ids.size(); ++j) table.Union(id, ids[j]); diff --git a/generator/final_processor_utils.cpp b/generator/final_processor_utils.cpp index b19a366fbf..95fe0c72c8 100644 --- a/generator/final_processor_utils.cpp +++ b/generator/final_processor_utils.cpp @@ -94,8 +94,9 @@ bool Less(FeatureBuilder const & lhs, FeatureBuilder const & rhs) auto const lGeomType = static_cast(lhs.GetGeomType()); auto const rGeomType = static_cast(rhs.GetGeomType()); - auto const lId = lhs.HasOsmIds() ? lhs.GetMostGenericOsmId() : base::GeoObjectId(); - auto const rId = rhs.HasOsmIds() ? rhs.GetMostGenericOsmId() : base::GeoObjectId(); + // may be empty IDs + auto const lId = lhs.GetMostGenericOsmId(); + auto const rId = rhs.GetMostGenericOsmId(); auto const lPointsCount = lhs.GetPointsCount(); auto const rPointsCount = rhs.GetPointsCount(); diff --git a/generator/place_processor.cpp b/generator/place_processor.cpp index f2f22d0421..1697d02ea1 100644 --- a/generator/place_processor.cpp +++ b/generator/place_processor.cpp @@ -198,7 +198,7 @@ void PlaceProcessor::FillTable(IterT start, IterT end, IterT best) const if (!fb.IsArea() || !isCityTownOrVillage(fb.GetTypes())) continue; - auto const id = fb.GetLastOsmId(); + auto const id = fb.GetMostGenericOsmId(); m_boundariesTable->Append(id, indexer::CityBoundary(fb.GetOuterGeometry())); if (lastId != base::GeoObjectId()) m_boundariesTable->Union(id, lastId);