diff --git a/include/extractor/raster_source.hpp b/include/extractor/raster_source.hpp index 4cc7e0202..fe56b4572 100644 --- a/include/extractor/raster_source.hpp +++ b/include/extractor/raster_source.hpp @@ -104,7 +104,7 @@ class RasterSource const float xstep; const float ystep; - float calcSize(int min, int max, std::size_t count) const; + float CalcSize(int min, int max, std::size_t count) const; public: RasterGrid raster_data; @@ -116,9 +116,9 @@ class RasterSource const int ymin; const int ymax; - RasterDatum getRasterData(const int lon, const int lat) const; + RasterDatum GetRasterData(const int lon, const int lat) const; - RasterDatum getRasterInterpolate(const int lon, const int lat) const; + RasterDatum GetRasterInterpolate(const int lon, const int lat) const; RasterSource(RasterGrid _raster_data, std::size_t width, @@ -134,7 +134,7 @@ class SourceContainer public: SourceContainer() = default; - int loadRasterSource(const std::string &path_string, + int LoadRasterSource(const std::string &path_string, double xmin, double xmax, double ymin, @@ -142,9 +142,9 @@ class SourceContainer std::size_t nrows, std::size_t ncols); - RasterDatum getRasterDataFromSource(unsigned int source_id, double lon, double lat); + RasterDatum GetRasterDataFromSource(unsigned int source_id, double lon, double lat); - RasterDatum getRasterInterpolateFromSource(unsigned int source_id, double lon, double lat); + RasterDatum GetRasterInterpolateFromSource(unsigned int source_id, double lon, double lat); private: std::vector LoadedSources; diff --git a/src/extractor/raster_source.cpp b/src/extractor/raster_source.cpp index 16e41f987..66a50792d 100644 --- a/src/extractor/raster_source.cpp +++ b/src/extractor/raster_source.cpp @@ -17,7 +17,7 @@ RasterSource::RasterSource(RasterGrid _raster_data, int _xmax, int _ymin, int _ymax) - : xstep(calcSize(_xmin, _xmax, _width)), ystep(calcSize(_ymin, _ymax, _height)), + : xstep(CalcSize(_xmin, _xmax, _width)), ystep(CalcSize(_ymin, _ymax, _height)), raster_data(std::move(_raster_data)), width(_width), height(_height), xmin(_xmin), xmax(_xmax), ymin(_ymin), ymax(_ymax) { @@ -25,14 +25,14 @@ RasterSource::RasterSource(RasterGrid _raster_data, BOOST_ASSERT(ystep != 0); } -float RasterSource::calcSize(int min, int max, std::size_t count) const +float RasterSource::CalcSize(int min, int max, std::size_t count) const { BOOST_ASSERT(count > 0); return (max - min) / (static_cast(count) - 1); } // Query raster source for nearest data point -RasterDatum RasterSource::getRasterData(const int lon, const int lat) const +RasterDatum RasterSource::GetRasterData(const int lon, const int lat) const { if (lon < xmin || lon > xmax || lat < ymin || lat > ymax) { @@ -46,7 +46,7 @@ RasterDatum RasterSource::getRasterData(const int lon, const int lat) const } // Query raster source using bilinear interpolation -RasterDatum RasterSource::getRasterInterpolate(const int lon, const int lat) const +RasterDatum RasterSource::GetRasterInterpolate(const int lon, const int lat) const { if (lon < xmin || lon > xmax || lat < ymin || lat > ymax) { @@ -74,7 +74,7 @@ RasterDatum RasterSource::getRasterInterpolate(const int lon, const int lat) con } // Load raster source into memory -int SourceContainer::loadRasterSource(const std::string &path_string, +int SourceContainer::LoadRasterSource(const std::string &path_string, double xmin, double xmax, double ymin, @@ -120,7 +120,7 @@ int SourceContainer::loadRasterSource(const std::string &path_string, } // External function for looking up nearest data point from a specified source -RasterDatum SourceContainer::getRasterDataFromSource(unsigned int source_id, double lon, double lat) +RasterDatum SourceContainer::GetRasterDataFromSource(unsigned int source_id, double lon, double lat) { if (LoadedSources.size() < source_id + 1) { @@ -133,13 +133,13 @@ RasterDatum SourceContainer::getRasterDataFromSource(unsigned int source_id, dou BOOST_ASSERT(lon > -180); const auto &found = LoadedSources[source_id]; - return found.getRasterData(static_cast(util::toFixed(util::FloatLongitude(lon))), + return found.GetRasterData(static_cast(util::toFixed(util::FloatLongitude(lon))), static_cast(util::toFixed(util::FloatLatitude(lat)))); } // External function for looking up interpolated data from a specified source RasterDatum -SourceContainer::getRasterInterpolateFromSource(unsigned int source_id, double lon, double lat) +SourceContainer::GetRasterInterpolateFromSource(unsigned int source_id, double lon, double lat) { if (LoadedSources.size() < source_id + 1) { @@ -152,7 +152,7 @@ SourceContainer::getRasterInterpolateFromSource(unsigned int source_id, double l BOOST_ASSERT(lon > -180); const auto &found = LoadedSources[source_id]; - return found.getRasterInterpolate(static_cast(util::toFixed(util::FloatLongitude(lon))), + return found.GetRasterInterpolate(static_cast(util::toFixed(util::FloatLongitude(lon))), static_cast(util::toFixed(util::FloatLatitude(lat)))); } } diff --git a/src/extractor/scripting_environment.cpp b/src/extractor/scripting_environment.cpp index 0840f7d1d..beca3ba66 100644 --- a/src/extractor/scripting_environment.cpp +++ b/src/extractor/scripting_environment.cpp @@ -87,9 +87,9 @@ void ScriptingEnvironment::InitContext(ScriptingEnvironment::Context &context) luabind::value("route", TRAVEL_MODE_ROUTE)], luabind::class_("sources") .def(luabind::constructor<>()) - .def("load", &SourceContainer::loadRasterSource) - .def("query", &SourceContainer::getRasterDataFromSource) - .def("interpolate", &SourceContainer::getRasterInterpolateFromSource), + .def("load", &SourceContainer::LoadRasterSource) + .def("query", &SourceContainer::GetRasterDataFromSource) + .def("interpolate", &SourceContainer::GetRasterInterpolateFromSource), luabind::class_("constants") .enum_("enums")[luabind::value("precision", COORDINATE_PRECISION)], diff --git a/unit_tests/extractor/raster_source.cpp b/unit_tests/extractor/raster_source.cpp index c2f1b1b10..606f2733f 100644 --- a/unit_tests/extractor/raster_source.cpp +++ b/unit_tests/extractor/raster_source.cpp @@ -15,15 +15,15 @@ using namespace osrm::extractor; int normalize(double coord) { return static_cast(coord * COORDINATE_PRECISION); } #define CHECK_QUERY(source_id, lon, lat, expected) \ - BOOST_CHECK_EQUAL(sources.getRasterDataFromSource(source_id, lon, lat).datum, expected) + BOOST_CHECK_EQUAL(sources.GetRasterDataFromSource(source_id, lon, lat).datum, expected) #define CHECK_INTERPOLATE(source_id, lon, lat, expected) \ - BOOST_CHECK_EQUAL(sources.getRasterInterpolateFromSource(source_id, lon, lat).datum, expected) + BOOST_CHECK_EQUAL(sources.GetRasterInterpolateFromSource(source_id, lon, lat).datum, expected) BOOST_AUTO_TEST_CASE(raster_test) { SourceContainer sources; - int source_id = sources.loadRasterSource("../unit_tests/fixtures/raster_data.asc", 0, 0.09, 0, + int source_id = sources.LoadRasterSource("../unit_tests/fixtures/raster_data.asc", 0, 0.09, 0, 0.09, 10, 10); BOOST_CHECK_EQUAL(source_id, 0); @@ -67,15 +67,15 @@ BOOST_AUTO_TEST_CASE(raster_test) CHECK_INTERPOLATE(0, 0.056, 0.028, 68); CHECK_INTERPOLATE(0, 0.05, 0.028, 56); - int source_already_loaded_id = sources.loadRasterSource( + int source_already_loaded_id = sources.LoadRasterSource( "../unit_tests/fixtures/raster_data.asc", 0, 0.09, 0, 0.09, 10, 10); BOOST_CHECK_EQUAL(source_already_loaded_id, 0); - BOOST_CHECK_THROW(sources.getRasterDataFromSource(1, normalize(0.02), normalize(0.02)), + BOOST_CHECK_THROW(sources.GetRasterDataFromSource(1, normalize(0.02), normalize(0.02)), util::exception); BOOST_CHECK_THROW( - sources.loadRasterSource("../unit_tests/fixtures/nonexistent.asc", 0, 0.1, 0, 0.1, 7, 7), + sources.LoadRasterSource("../unit_tests/fixtures/nonexistent.asc", 0, 0.1, 0, 0.1, 7, 7), util::exception); }