Fix naming convention in RasterSource

This commit is contained in:
Patrick Niklaus 2016-04-29 00:26:13 +02:00
parent e504128587
commit e470d1ae1c
No known key found for this signature in database
GPG Key ID: E426891B5F978B1B
4 changed files with 24 additions and 24 deletions

View File

@ -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<RasterSource> LoadedSources;

View File

@ -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<float>(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<int>(util::toFixed(util::FloatLongitude(lon))),
return found.GetRasterData(static_cast<int>(util::toFixed(util::FloatLongitude(lon))),
static_cast<int>(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<int>(util::toFixed(util::FloatLongitude(lon))),
return found.GetRasterInterpolate(static_cast<int>(util::toFixed(util::FloatLongitude(lon))),
static_cast<int>(util::toFixed(util::FloatLatitude(lat))));
}
}

View File

@ -87,9 +87,9 @@ void ScriptingEnvironment::InitContext(ScriptingEnvironment::Context &context)
luabind::value("route", TRAVEL_MODE_ROUTE)],
luabind::class_<SourceContainer>("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_<const float>("constants")
.enum_("enums")[luabind::value("precision", COORDINATE_PRECISION)],

View File

@ -15,15 +15,15 @@ using namespace osrm::extractor;
int normalize(double coord) { return static_cast<int>(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);
}