Implements a vector tileserver so you can see what's going on inside
OSRM.
This commit is contained in:
committed by
Patrick Niklaus
parent
33403efc8e
commit
5dc7b79bb6
@@ -4,6 +4,8 @@
|
||||
#include "extractor/query_node.hpp"
|
||||
#include "extractor/edge_based_node.hpp"
|
||||
#include "util/typedefs.hpp"
|
||||
#include "util/rectangle.hpp"
|
||||
#include "util/exception.hpp"
|
||||
|
||||
#include <boost/functional/hash.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
@@ -455,4 +457,42 @@ BOOST_AUTO_TEST_CASE(bearing_tests)
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(bbox_search_tests)
|
||||
{
|
||||
using Coord = std::pair<double, double>;
|
||||
using Edge = std::pair<unsigned, unsigned>;
|
||||
|
||||
GraphFixture fixture(
|
||||
{
|
||||
Coord(0.0,0.0),
|
||||
Coord(1.0,1.0),
|
||||
Coord(2.0,2.0),
|
||||
Coord(3.0,3.0),
|
||||
Coord(4.0,4.0),
|
||||
},
|
||||
{Edge(0,1), Edge(1,2), Edge(2,3), Edge(3,4)});
|
||||
|
||||
std::string leaves_path;
|
||||
std::string nodes_path;
|
||||
build_rtree<GraphFixture, MiniStaticRTree>("test_bbox", &fixture, leaves_path, nodes_path);
|
||||
MiniStaticRTree rtree(nodes_path, leaves_path, fixture.coords);
|
||||
engine::GeospatialQuery<MiniStaticRTree> query(rtree, fixture.coords);
|
||||
|
||||
{
|
||||
RectangleInt2D bbox = {static_cast<uint32_t>(0.5 * COORDINATE_PRECISION), static_cast<uint32_t>(1.5 * COORDINATE_PRECISION),
|
||||
static_cast<uint32_t>(0.5 * COORDINATE_PRECISION), static_cast<uint32_t>(1.5 * COORDINATE_PRECISION)};
|
||||
auto results = query.Search(bbox);
|
||||
BOOST_CHECK_EQUAL(results.size(), 2);
|
||||
}
|
||||
|
||||
{
|
||||
RectangleInt2D bbox = {static_cast<uint32_t>(1.5 * COORDINATE_PRECISION), static_cast<uint32_t>(3.5 * COORDINATE_PRECISION),
|
||||
static_cast<uint32_t>(1.5 * COORDINATE_PRECISION), static_cast<uint32_t>(3.5 * COORDINATE_PRECISION)};
|
||||
auto results = query.Search(bbox);
|
||||
BOOST_CHECK_EQUAL(results.size(), 3);
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
#include "util/tile_bbox.hpp"
|
||||
#include "util/rectangle.hpp"
|
||||
|
||||
#include <boost/functional/hash.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <boost/test/test_case_template.hpp>
|
||||
#include <iostream>
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(tile_to_bbox_test)
|
||||
|
||||
using namespace osrm;
|
||||
using namespace osrm::util;
|
||||
|
||||
// Check that this osm tile to coordinate bbox converter works
|
||||
struct R
|
||||
{
|
||||
bool operator()(const RectangleInt2D lhs, const RectangleInt2D rhs)
|
||||
{
|
||||
return std::tie(lhs.min_lon, lhs.max_lon, lhs.min_lat, lhs.max_lat) == std::tie(rhs.min_lon, rhs.max_lon, rhs.min_lat, rhs.max_lat);
|
||||
}
|
||||
};
|
||||
|
||||
BOOST_AUTO_TEST_CASE(tile_to_bbox_test)
|
||||
{
|
||||
R equal;
|
||||
RectangleInt2D expected(-180000000,0,85051128,0);
|
||||
BOOST_CHECK_EQUAL(true, equal(expected, TileToBBOX(1,0,0)));
|
||||
|
||||
expected = RectangleInt2D(13051757,13095703,52402418,52375599);
|
||||
BOOST_CHECK_EQUAL(true, equal(expected, TileToBBOX(13,4393,2691)));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
Reference in New Issue
Block a user