fix coding format

This commit is contained in:
Tomonobu Saito 2019-10-09 13:35:19 +09:00
parent 542c3ba872
commit 17f32f4ca1
3 changed files with 42 additions and 26 deletions

40
include/extractor/raster_source.hpp Executable file → Normal file
View File

@ -4,22 +4,22 @@
#include "util/coordinate.hpp" #include "util/coordinate.hpp"
#include "util/exception.hpp" #include "util/exception.hpp"
#include <boost/algorithm/string/trim.hpp>
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/trim.hpp>
#include <boost/assert.hpp> #include <boost/assert.hpp>
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp> #include <boost/filesystem/fstream.hpp>
#include <boost/foreach.hpp>
#include <boost/spirit/include/qi.hpp> #include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/qi_int.hpp> #include <boost/spirit/include/qi_int.hpp>
#include <boost/foreach.hpp>
#include <storage/io.hpp> #include <storage/io.hpp>
#include <iterator>
#include <unordered_map>
#include <string>
#include <list>
#include <iostream> #include <iostream>
#include <iterator>
#include <list>
#include <string>
#include <unordered_map>
using namespace std; using namespace std;
namespace osrm namespace osrm
@ -58,17 +58,21 @@ class RasterGrid
buf.resize(xdim * 11); // INT32_MAX = 2147483647 = 10 chars + 1 white space = 11 buf.resize(xdim * 11); // INT32_MAX = 2147483647 = 10 chars + 1 white space = 11
BOOST_ASSERT(xdim * 11 <= buf.size()); BOOST_ASSERT(xdim * 11 <= buf.size());
for (unsigned int y = 0 ; y < ydim ; y++) { for (unsigned int y = 0; y < ydim; y++)
{
// read one line from file. // read one line from file.
file_reader.ReadLine(&buf[0], xdim * 11); file_reader.ReadLine(&buf[0], xdim * 11);
boost::algorithm::trim(buf); boost::algorithm::trim(buf);
std::vector<std::string> result; std::vector<std::string> result;
boost::split(result, buf, boost::is_any_of(" \r\n\0"), boost::algorithm::token_compress_on); boost::split(
//boost::split(result, buf, boost::is_any_of(" \r\n\0")); result, buf, boost::is_any_of(" \r\n\0"), boost::algorithm::token_compress_on);
// boost::split(result, buf, boost::is_any_of(" \r\n\0"));
unsigned int x = 0; unsigned int x = 0;
BOOST_FOREACH(std::string s, result) { BOOST_FOREACH (std::string s, result)
if (x < xdim) _data[(y * xdim) + x] = atoi(s.c_str()); {
if (x < xdim)
_data[(y * xdim) + x] = atoi(s.c_str());
++x; ++x;
} }
BOOST_ASSERT(x == xdim); BOOST_ASSERT(x == xdim);
@ -146,18 +150,20 @@ class RasterContainer
// << singletone >> RasterCache // << singletone >> RasterCache
class RasterCache class RasterCache
{ {
public: public:
// class method to get the instance // class method to get the instance
static RasterCache& getInstance() { static RasterCache &getInstance()
if (NULL == g_instance) { {
if (NULL == g_instance)
{
g_instance = new RasterCache(); g_instance = new RasterCache();
} }
return *g_instance; return *g_instance;
} }
// get reference of cache // get reference of cache
std::vector<RasterSource>& getLoadedSources() { return LoadedSources; } std::vector<RasterSource> &getLoadedSources() { return LoadedSources; }
std::unordered_map<std::string, int>& getLoadedSourcePaths() { return LoadedSourcePaths; } std::unordered_map<std::string, int> &getLoadedSourcePaths() { return LoadedSourcePaths; }
private: private:
// constructor // constructor
RasterCache() = default; RasterCache() = default;
// member // member

View File

@ -62,20 +62,28 @@ class FileReader
std::size_t GetSize() std::size_t GetSize()
{ {
const boost::filesystem::path path(filepath); const boost::filesystem::path path(filepath);
try { try
return std::size_t(boost::filesystem::file_size(path)) - ((fingerprint == FingerprintFlag::VerifyFingerprint) ? sizeof(util::FingerPrint) : 0); {
return std::size_t(boost::filesystem::file_size(path)) -
((fingerprint == FingerprintFlag::VerifyFingerprint) ? sizeof(util::FingerPrint)
: 0);
} }
catch (boost::filesystem::filesystem_error& ex) { catch (boost::filesystem::filesystem_error &ex)
{
std::cout << ex.what() << std::endl; std::cout << ex.what() << std::endl;
throw; throw;
} }
} }
/* Read one line */ /* Read one line */
template <typename T> void ReadLine(T *dest, const std::size_t count) { template <typename T> void ReadLine(T *dest, const std::size_t count)
if (0 < count) { {
const auto &ios = input_stream.getline(reinterpret_cast<char *>(dest), count * sizeof(T)); if (0 < count)
for (std::size_t n = ios.gcount(); n < count; ++n) { {
const auto &ios =
input_stream.getline(reinterpret_cast<char *>(dest), count * sizeof(T));
for (std::size_t n = ios.gcount(); n < count; ++n)
{
reinterpret_cast<char *>(dest)[n] = '\0'; reinterpret_cast<char *>(dest)[n] = '\0';
} }
} }

6
src/extractor/raster_source.cpp Executable file → Normal file
View File

@ -130,7 +130,8 @@ RasterDatum RasterContainer::GetRasterDataFromSource(unsigned int source_id, dou
if (RasterCache::getInstance().getLoadedSources().size() < source_id + 1) if (RasterCache::getInstance().getLoadedSources().size() < source_id + 1)
{ {
throw util::exception("Attempted to access source " + std::to_string(source_id) + throw util::exception("Attempted to access source " + std::to_string(source_id) +
", but there are only " + std::to_string(RasterCache::getInstance().getLoadedSources().size()) + ", but there are only " +
std::to_string(RasterCache::getInstance().getLoadedSources().size()) +
" loaded" + SOURCE_REF); " loaded" + SOURCE_REF);
} }
@ -151,7 +152,8 @@ RasterContainer::GetRasterInterpolateFromSource(unsigned int source_id, double l
if (RasterCache::getInstance().getLoadedSources().size() < source_id + 1) if (RasterCache::getInstance().getLoadedSources().size() < source_id + 1)
{ {
throw util::exception("Attempted to access source " + std::to_string(source_id) + throw util::exception("Attempted to access source " + std::to_string(source_id) +
", but there are only " + std::to_string(RasterCache::getInstance().getLoadedSources().size()) + ", but there are only " +
std::to_string(RasterCache::getInstance().getLoadedSources().size()) +
" loaded" + SOURCE_REF); " loaded" + SOURCE_REF);
} }