mirror of
https://codeberg.org/comaps/comaps
synced 2026-01-03 19:33:49 +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
drape/tm_read_resources.hpp
Normal file
47
drape/tm_read_resources.hpp
Normal file
@@ -0,0 +1,47 @@
|
||||
#pragma once
|
||||
#include "platform/platform.hpp"
|
||||
|
||||
#include "coding/reader.hpp"
|
||||
#include "coding/reader_streambuf.hpp"
|
||||
|
||||
#include "base/buffer_vector.hpp"
|
||||
#include "base/logging.hpp"
|
||||
#include "base/string_utils.hpp"
|
||||
|
||||
namespace dp::impl
|
||||
{
|
||||
|
||||
template <typename ToDo>
|
||||
inline void ParsePatternsList(std::string const & patternsFile, ToDo && toDo)
|
||||
{
|
||||
ReaderStreamBuf buffer(GetPlatform().GetReader(patternsFile));
|
||||
std::istream is(&buffer);
|
||||
|
||||
std::string line;
|
||||
while (std::getline(is, line))
|
||||
{
|
||||
buffer_vector<double, 8> pattern;
|
||||
strings::Tokenize(line, " ", [&](std::string_view token)
|
||||
{
|
||||
double d = 0.0;
|
||||
VERIFY(strings::to_double(token, d), ());
|
||||
pattern.push_back(d);
|
||||
});
|
||||
|
||||
bool isValid = true;
|
||||
for (size_t i = 0; i < pattern.size(); i++)
|
||||
{
|
||||
if (fabs(pattern[i]) < 1e-5)
|
||||
{
|
||||
LOG(LWARNING, ("Pattern was skipped", line));
|
||||
isValid = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (isValid)
|
||||
toDo(pattern);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace dp::impl
|
||||
Reference in New Issue
Block a user