First round of lat,lng -> lng,lat switcheroo
This commit is contained in:
@@ -4,8 +4,7 @@
|
||||
#include "engine/geospatial_query.hpp"
|
||||
#include "util/timing_util.hpp"
|
||||
#include "mocks/mock_datafacade.hpp"
|
||||
|
||||
#include "osrm/coordinate.hpp"
|
||||
#include "util/coordinate.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <random>
|
||||
@@ -25,23 +24,23 @@ constexpr int32_t WORLD_MIN_LON = -180 * COORDINATE_PRECISION;
|
||||
constexpr int32_t WORLD_MAX_LON = 180 * COORDINATE_PRECISION;
|
||||
|
||||
using RTreeLeaf = extractor::EdgeBasedNode;
|
||||
using FixedPointCoordinateListPtr = std::shared_ptr<std::vector<util::FixedPointCoordinate>>;
|
||||
using CoordinateListPtr = std::shared_ptr<std::vector<util::Coordinate>>;
|
||||
using BenchStaticRTree =
|
||||
util::StaticRTree<RTreeLeaf, util::ShM<util::FixedPointCoordinate, false>::vector, false>;
|
||||
util::StaticRTree<RTreeLeaf, util::ShM<util::Coordinate, false>::vector, false>;
|
||||
using BenchQuery = engine::GeospatialQuery<BenchStaticRTree, MockDataFacade>;
|
||||
|
||||
FixedPointCoordinateListPtr loadCoordinates(const boost::filesystem::path &nodes_file)
|
||||
CoordinateListPtr loadCoordinates(const boost::filesystem::path &nodes_file)
|
||||
{
|
||||
boost::filesystem::ifstream nodes_input_stream(nodes_file, std::ios::binary);
|
||||
|
||||
extractor::QueryNode current_node;
|
||||
unsigned coordinate_count = 0;
|
||||
nodes_input_stream.read((char *)&coordinate_count, sizeof(unsigned));
|
||||
auto coords = std::make_shared<std::vector<FixedPointCoordinate>>(coordinate_count);
|
||||
auto coords = std::make_shared<std::vector<Coordinate>>(coordinate_count);
|
||||
for (unsigned i = 0; i < coordinate_count; ++i)
|
||||
{
|
||||
nodes_input_stream.read((char *)¤t_node, sizeof(extractor::QueryNode));
|
||||
coords->at(i) = FixedPointCoordinate(current_node.lat, current_node.lon);
|
||||
coords->at(i) = util::Coordinate(current_node.lon, current_node.lat);
|
||||
BOOST_ASSERT((std::abs(coords->at(i).lat) >> 30) == 0);
|
||||
BOOST_ASSERT((std::abs(coords->at(i).lon) >> 30) == 0);
|
||||
}
|
||||
@@ -49,7 +48,7 @@ FixedPointCoordinateListPtr loadCoordinates(const boost::filesystem::path &nodes
|
||||
}
|
||||
|
||||
template <typename QueryT>
|
||||
void benchmarkQuery(const std::vector<FixedPointCoordinate> &queries,
|
||||
void benchmarkQuery(const std::vector<util::Coordinate> &queries,
|
||||
const std::string &name,
|
||||
QueryT query)
|
||||
{
|
||||
@@ -75,38 +74,35 @@ void benchmark(BenchStaticRTree &rtree, BenchQuery &geo_query, unsigned num_quer
|
||||
std::mt19937 mt_rand(RANDOM_SEED);
|
||||
std::uniform_int_distribution<> lat_udist(WORLD_MIN_LAT, WORLD_MAX_LAT);
|
||||
std::uniform_int_distribution<> lon_udist(WORLD_MIN_LON, WORLD_MAX_LON);
|
||||
std::vector<FixedPointCoordinate> queries;
|
||||
std::vector<util::Coordinate> queries;
|
||||
for (unsigned i = 0; i < num_queries; i++)
|
||||
{
|
||||
queries.emplace_back(lat_udist(mt_rand), lon_udist(mt_rand));
|
||||
}
|
||||
|
||||
benchmarkQuery(queries, "raw RTree queries (1 result)", [&rtree](const FixedPointCoordinate &q)
|
||||
benchmarkQuery(queries, "raw RTree queries (1 result)", [&rtree](const util::Coordinate &q)
|
||||
{
|
||||
return rtree.Nearest(q, 1);
|
||||
});
|
||||
benchmarkQuery(queries, "raw RTree queries (10 results)",
|
||||
[&rtree](const FixedPointCoordinate &q)
|
||||
benchmarkQuery(queries, "raw RTree queries (10 results)", [&rtree](const util::Coordinate &q)
|
||||
{
|
||||
return rtree.Nearest(q, 10);
|
||||
});
|
||||
|
||||
benchmarkQuery(queries, "big component alternative queries",
|
||||
[&geo_query](const FixedPointCoordinate &q)
|
||||
[&geo_query](const util::Coordinate &q)
|
||||
{
|
||||
return geo_query.NearestPhantomNodeWithAlternativeFromBigComponent(q);
|
||||
});
|
||||
benchmarkQuery(queries, "max distance 1000", [&geo_query](const FixedPointCoordinate &q)
|
||||
benchmarkQuery(queries, "max distance 1000", [&geo_query](const util::Coordinate &q)
|
||||
{
|
||||
return geo_query.NearestPhantomNodesInRange(q, 1000);
|
||||
});
|
||||
benchmarkQuery(queries, "PhantomNode query (1 result)",
|
||||
[&geo_query](const FixedPointCoordinate &q)
|
||||
benchmarkQuery(queries, "PhantomNode query (1 result)", [&geo_query](const util::Coordinate &q)
|
||||
{
|
||||
return geo_query.NearestPhantomNodes(q, 1);
|
||||
});
|
||||
benchmarkQuery(queries, "PhantomNode query (10 result)",
|
||||
[&geo_query](const FixedPointCoordinate &q)
|
||||
benchmarkQuery(queries, "PhantomNode query (10 result)", [&geo_query](const util::Coordinate &q)
|
||||
{
|
||||
return geo_query.NearestPhantomNodes(q, 10);
|
||||
});
|
||||
@@ -130,7 +126,8 @@ int main(int argc, char **argv)
|
||||
auto coords = osrm::benchmarks::loadCoordinates(nodes_path);
|
||||
|
||||
osrm::benchmarks::BenchStaticRTree rtree(ram_path, file_path, coords);
|
||||
std::unique_ptr<osrm::benchmarks::MockDataFacade> mockfacade_ptr(new osrm::benchmarks::MockDataFacade);
|
||||
std::unique_ptr<osrm::benchmarks::MockDataFacade> mockfacade_ptr(
|
||||
new osrm::benchmarks::MockDataFacade);
|
||||
osrm::benchmarks::BenchQuery query(rtree, coords, *mockfacade_ptr);
|
||||
|
||||
osrm::benchmarks::benchmark(rtree, query, 10000);
|
||||
|
||||
Reference in New Issue
Block a user