[topography_generator] Review fix.

This commit is contained in:
Daria Volvenkova 2020-01-27 14:37:10 +03:00
parent 99fb4ceed8
commit 337f9d5543
3 changed files with 8 additions and 14 deletions

View file

@ -13,7 +13,6 @@ namespace generator
{
namespace
{
double constexpr kTileSizeInDegree = 1.0;
size_t constexpr kArcSecondsInDegree = 60 * 60;
size_t constexpr kSrtmTileSize = (kArcSecondsInDegree + 1) * (kArcSecondsInDegree + 1) * 2;
@ -131,8 +130,7 @@ std::string SrtmTile::GetPath(std::string const & dir, std::string const & base)
// static
ms::LatLon SrtmTile::GetCenter(ms::LatLon const & coord)
{
return {floor(coord.m_lat) + kTileSizeInDegree / 2.0,
floor(coord.m_lon) + kTileSizeInDegree / 2.0};
return {floor(coord.m_lat) + 0.5, floor(coord.m_lon) + 0.5};
}
// static

View file

@ -18,7 +18,6 @@
namespace topography_generator
{
double const kEps = 1e-7;
double constexpr kTileSizeInDegree = 1.0;
size_t constexpr kArcSecondsInDegree = 60 * 60;
int constexpr kAsterTilesLatTop = 60;
int constexpr kAsterTilesLatBottom = -60;
@ -55,11 +54,8 @@ private:
// Try to prevent loading a new tile if the position can be found in the loaded one.
auto const latDist = pos.m_lat - m_leftBottomOfPreferredTile.m_lat;
auto const lonDist = pos.m_lon - m_leftBottomOfPreferredTile.m_lon;
if (latDist >= 0.0 && latDist <= kTileSizeInDegree &&
lonDist >= 0.0 && lonDist <= kTileSizeInDegree)
{
if (latDist >= 0.0 && latDist <= 1.0 && lonDist >= 0.0 && lonDist <= 1.0)
return m_preferredTile->GetHeight(pos);
}
}
return m_srtmManager.GetHeight(pos);
@ -72,7 +68,7 @@ private:
// Look around the position with invalid altitude
// and return median of surrounding valid altitudes.
double const step = kTileSizeInDegree / kArcSecondsInDegree;
double const step = 1.0 / kArcSecondsInDegree;
int const kMaxKernelRadius = 3;
std::vector<Altitude> kernel;
int kernelRadius = 0;
@ -216,7 +212,7 @@ private:
LOG(LINFO, ("Begin generating isolines for tile", tileName));
m_srtmProvider.SetPrefferedTile({lat + kTileSizeInDegree / 2.0, lon + kTileSizeInDegree / 2.0});
m_srtmProvider.SetPrefferedTile({lat + 0.5, lon + 0.5});
Contours<Altitude> contours;
if (!m_params.m_filters.empty() && (lat >= kAsterTilesLatTop || lat < kAsterTilesLatBottom))
@ -282,8 +278,8 @@ private:
Contours<Altitude> & contours)
{
auto const leftBottom = ms::LatLon(lat, lon);
auto const rightTop = ms::LatLon(lat + kTileSizeInDegree, lon + kTileSizeInDegree);
auto const squaresStep = kTileSizeInDegree / kArcSecondsInDegree * m_params.m_latLonStepFactor;
auto const rightTop = ms::LatLon(lat + 1.0, lon + 1.0);
auto const squaresStep = 1.0 / kArcSecondsInDegree * m_params.m_latLonStepFactor;
MarchingSquares<Altitude> squares(leftBottom, rightTop,
squaresStep, m_params.m_alitudesStep,

View file

@ -17,7 +17,7 @@ struct TileIsolinesParams
{
Altitude m_alitudesStep = 10;
size_t m_latLonStepFactor = 1;
int m_simplificationZoom = 17;
int m_simplificationZoom = 17; // Value == 0 disables simplification.
FiltersSequence<Altitude> m_filters;
std::string m_outputDir;
};
@ -25,7 +25,7 @@ struct TileIsolinesParams
struct CountryIsolinesParams
{
size_t m_maxIsolineLength = 1000;
int m_simplificationZoom = 17;
int m_simplificationZoom = 17; // Value == 0 disables simplification.
size_t m_alitudesStepFactor = 1;
std::string m_isolinesTilesPath;
};