From fd8fde4210fee9bef68161f4341a9168f9c5c978 Mon Sep 17 00:00:00 2001 From: tatiana-yan Date: Wed, 11 Jul 2018 13:44:02 +0300 Subject: [PATCH] [generator] Fix test mwms build --- generator/borders_loader.cpp | 16 +++++++++++----- generator/borders_loader.hpp | 2 +- generator/feature_sorter.cpp | 6 +++++- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/generator/borders_loader.cpp b/generator/borders_loader.cpp index 7daa361981..7d71f09905 100644 --- a/generator/borders_loader.cpp +++ b/generator/borders_loader.cpp @@ -196,15 +196,21 @@ void UnpackBorders(std::string const & baseDir, std::string const & targetDir) } } -m2::RectD GetLimitRect(std::string const & baseDir, std::string const & country) +bool GetBordersRect(std::string const & baseDir, std::string const & country, m2::RectD & bordersRect) { std::string const bordersFile = my::JoinPath(baseDir, BORDERS_DIR, country + BORDERS_EXTENSION); - CHECK(Platform::IsFileExistsByFullPath(bordersFile), ("Cannot read borders file", bordersFile)); + if (!Platform::IsFileExistsByFullPath(bordersFile)) + { + LOG(LWARNING, ("File with borders does not exist:", bordersFile)); + return false; + } + std::vector borders; CHECK(osm::LoadBorders(bordersFile, borders), ()); - m2::RectD rect; + bordersRect.MakeEmpty(); for (auto const & border : borders) - rect.Add(border.GetRect()); - return rect; + bordersRect.Add(border.GetRect()); + + return true; } } // namespace borders diff --git a/generator/borders_loader.hpp b/generator/borders_loader.hpp index 03bfc8d487..9c2b4f8fca 100644 --- a/generator/borders_loader.hpp +++ b/generator/borders_loader.hpp @@ -37,5 +37,5 @@ namespace borders void GeneratePackedBorders(std::string const & baseDir); void UnpackBorders(std::string const & baseDir, std::string const & targetDir); - m2::RectD GetLimitRect(std::string const & baseDir, std::string const & country); + bool GetBordersRect(std::string const & baseDir, std::string const & country, m2::RectD & bordersRect); } diff --git a/generator/feature_sorter.cpp b/generator/feature_sorter.cpp index 025b35b286..a1fb6fcdba 100644 --- a/generator/feature_sorter.cpp +++ b/generator/feature_sorter.cpp @@ -366,7 +366,11 @@ bool GenerateFinalFeatures(feature::GenerateInfo const & info, string const & na // Update bounds with the limit rect corresponding to region borders. // Bounds before update can be too big because of big invisible features like a // relation that contains an entire country's border. - collector.SetBounds(borders::GetLimitRect(info.m_targetDir, name)); + // Borders file may be unavailable when building test mwms. + m2::RectD bordersRect; + if (borders::GetBordersRect(info.m_targetDir, name, bordersRect)) + collector.SetBounds(bordersRect); + collector.Finish(); } catch (RootException const & ex)