diff --git a/include/extractor/raster_source.hpp b/include/extractor/raster_source.hpp index 4f7c31713..4f39314f3 100755 --- a/include/extractor/raster_source.hpp +++ b/include/extractor/raster_source.hpp @@ -50,13 +50,13 @@ class RasterGrid xdim = _xdim; ydim = _ydim; _data.reserve(ydim * xdim); - BOOST_ASSERT(_data.capacity() >= ydim * xdim); + BOOST_ASSERT(ydim * xdim <= _data.capacity()); // Construct FileReader storage::io::FileReader file_reader(filepath, storage::io::FileReader::HasNoFingerprint); std::string buf; buf.resize(xdim * 11); // INT32_MAX = 2147483647 = 10 chars + 1 white space = 11 - BOOST_ASSERT(buf.size() >= xdim * 11); + BOOST_ASSERT(xdim * 11 <= buf.size()); for (unsigned int y = 0 ; y < ydim ; y++) { // read one line from file. @@ -74,37 +74,6 @@ class RasterGrid } BOOST_ASSERT(x == xdim); } -/* - std::string buffer; - buffer.resize(file_reader.GetSize()); - - BOOST_ASSERT(buffer.size() > 1); - - file_reader.ReadInto(&buffer[0], buffer.size()); - - boost::algorithm::trim(buffer); - - auto itr = buffer.begin(); - auto end = buffer.end(); - - bool r = false; - try - { - r = boost::spirit::qi::parse( - itr, end, +boost::spirit::qi::int_ % +boost::spirit::qi::space, _data); - } - catch (std::exception const &ex) - { - throw util::exception("Failed to read from raster source " + filepath.string() + ": " + - ex.what() + SOURCE_REF); - } - - if (!r || itr != end) - { - throw util::exception("Failed to parse raster source: " + filepath.string() + - SOURCE_REF); - } -*/ } RasterGrid(const RasterGrid &) = default; diff --git a/include/storage/io.hpp b/include/storage/io.hpp index fcb4dedd7..0a6eb0775 100755 --- a/include/storage/io.hpp +++ b/include/storage/io.hpp @@ -70,35 +70,7 @@ class FileReader throw; } } -/* - std::size_t GetSize() - { - const boost::filesystem::ifstream::pos_type position = input_stream.tellg(); - input_stream.seekg(0, std::ios::end); - const boost::filesystem::ifstream::pos_type file_size = input_stream.tellg(); - if (file_size == boost::filesystem::ifstream::pos_type(-1)) - { - throw util::RuntimeError("Unable to determine file size for " + - std::string(filepath.string()), - ErrorCode::FileIOError, - SOURCE_REF, - std::strerror(errno)); - } - - // restore the current position - input_stream.seekg(position, std::ios::beg); - - if (fingerprint == FingerprintFlag::VerifyFingerprint) - { - return std::size_t(file_size) - sizeof(util::FingerPrint); - } - else - { - return file_size; - } - } -*/ /* Read one line */ template void ReadLine(T *dest, const std::size_t count) { if (0 < count) { diff --git a/src/extractor/raster_source.cpp b/src/extractor/raster_source.cpp index 0788ac71c..befae77b7 100755 --- a/src/extractor/raster_source.cpp +++ b/src/extractor/raster_source.cpp @@ -95,13 +95,7 @@ int RasterContainer::LoadRasterSource(const std::string &path_string, const auto _xmax = static_cast(util::toFixed(util::FloatLongitude{xmax})); const auto _ymin = static_cast(util::toFixed(util::FloatLatitude{ymin})); const auto _ymax = static_cast(util::toFixed(util::FloatLatitude{ymax})); -/* - // for debug : list up all keys and values - util::Log() << "Num of Raster Sources : " << LoadedSourcePaths.size(); - for (auto i = LoadedSourcePaths.begin(); i != LoadedSourcePaths.end(); ++i) { - util::Log() << "Key : " << i->first << " Value: " << i->second; - } -*/ + const auto itr = LoadedSourcePaths.find(path_string); if (itr != LoadedSourcePaths.end()) { @@ -130,13 +124,7 @@ int RasterContainer::LoadRasterSource(const std::string &path_string, LoadedSources.push_back(std::move(source)); util::Log() << "[source loader] ok, after " << TIMER_SEC(loading_source) << "s"; -/* - // for debug : list up all keys and values - util::Log() << "Num of Raster Sources : " << LoadedSourcePaths.size(); - for (auto i = LoadedSourcePaths.begin(); i != LoadedSourcePaths.end(); ++i) { - util::Log() << "Key : " << i->first << " Value: " << i->second; - } -*/ + return source_id; }