mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-23 14:43:43 +00:00
Organic Maps sources as of 02.04.2025 (fad26bbf22ac3da75e01e62aa01e5c8e11861005)
To expand with full Organic Maps and Maps.ME commits history run: git remote add om-historic [om-historic.git repo url] git fetch --tags om-historic git replace squashed-history historic-commits
This commit is contained in:
47
poly_borders/poly_borders_tests/tools.cpp
Normal file
47
poly_borders/poly_borders_tests/tools.cpp
Normal file
@@ -0,0 +1,47 @@
|
||||
#include "poly_borders/poly_borders_tests/tools.hpp"
|
||||
|
||||
#include "poly_borders/borders_data.hpp"
|
||||
|
||||
#include "generator/borders.hpp"
|
||||
|
||||
#include "geometry/region2d.hpp"
|
||||
|
||||
#include "base/file_name_utils.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
using namespace platform::tests_support;
|
||||
|
||||
namespace
|
||||
{
|
||||
std::vector<m2::RegionD> ConvertFromPointsVector(
|
||||
std::vector<std::vector<m2::PointD>> const & polygons)
|
||||
{
|
||||
std::vector<m2::RegionD> res;
|
||||
res.reserve(polygons.size());
|
||||
for (auto const & polygon : polygons)
|
||||
res.emplace_back(polygon);
|
||||
|
||||
return res;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace poly_borders
|
||||
{
|
||||
std::shared_ptr<ScopedFile> CreatePolyBorderFileByPolygon(
|
||||
std::string const & relativeDirPath, std::string const & name,
|
||||
std::vector<std::vector<m2::PointD>> const & polygons)
|
||||
{
|
||||
std::string path = base::JoinPath(relativeDirPath, name + BordersData::kBorderExtension);
|
||||
|
||||
auto file = std::make_shared<ScopedFile>(path, ScopedFile::Mode::Create);
|
||||
|
||||
auto const targetDir = base::GetDirectory(file->GetFullPath());
|
||||
|
||||
auto const regions = ConvertFromPointsVector(polygons);
|
||||
borders::DumpBorderToPolyFile(targetDir, name, regions);
|
||||
|
||||
return file;
|
||||
}
|
||||
} // namespace poly_borders
|
||||
Reference in New Issue
Block a user