Make Tile plugin validate its parameters, fixes #2109
This commit is contained in:
parent
843a4b8eae
commit
5beaab97da
@ -28,6 +28,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#ifndef ENGINE_API_TILE_PARAMETERS_HPP
|
#ifndef ENGINE_API_TILE_PARAMETERS_HPP
|
||||||
#define ENGINE_API_TILE_PARAMETERS_HPP
|
#define ENGINE_API_TILE_PARAMETERS_HPP
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
namespace osrm
|
namespace osrm
|
||||||
{
|
{
|
||||||
namespace engine
|
namespace engine
|
||||||
@ -41,8 +43,16 @@ struct TileParameters final
|
|||||||
unsigned y;
|
unsigned y;
|
||||||
unsigned z;
|
unsigned z;
|
||||||
|
|
||||||
// FIXME check if x and y work with z
|
bool IsValid() const
|
||||||
bool IsValid() { return z < 20; };
|
{
|
||||||
|
// https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames#Zoom_levels
|
||||||
|
// https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames#X_and_Y
|
||||||
|
const auto valid_x = x <= static_cast<unsigned>(std::pow(2., z)) - 1;
|
||||||
|
const auto valid_y = y <= static_cast<unsigned>(std::pow(2., z)) - 1;
|
||||||
|
const auto valid_z = z < 20;
|
||||||
|
|
||||||
|
return valid_x && valid_y && valid_z;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -168,6 +168,8 @@ FixedLine coordinatesToTileLine(const util::Coordinate start,
|
|||||||
|
|
||||||
Status TilePlugin::HandleRequest(const api::TileParameters ¶meters, std::string &pbf_buffer)
|
Status TilePlugin::HandleRequest(const api::TileParameters ¶meters, std::string &pbf_buffer)
|
||||||
{
|
{
|
||||||
|
BOOST_ASSERT(parameters.IsValid());
|
||||||
|
|
||||||
using namespace util::coordinate_calculation;
|
using namespace util::coordinate_calculation;
|
||||||
double min_lon, min_lat, max_lon, max_lat;
|
double min_lon, min_lat, max_lon, max_lat;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user