geometry.index test, example: updated tests and benchmark_experimental for path_intersection of 2-point linestring.

[SVN r84238]
This commit is contained in:
Adam Wulkiewicz 2013-05-11 22:38:36 +00:00
parent 5703291505
commit 29efffb3f0
3 changed files with 43 additions and 20 deletions

View File

@ -42,7 +42,8 @@ int main()
size_t queries_count = 100000;
size_t nearest_queries_count = 10000;
unsigned neighbours_count = 10;
size_t path_queries_count = 1000;
size_t path_queries_count = 2000;
size_t path_queries_count2 = 10000;
unsigned path_values_count = 10;
float max_val = static_cast<float>(values_count / 2);
@ -284,6 +285,26 @@ int main()
dur_t time = clock_t::now() - start;
std::cout << time << " - query(path(LS, " << path_values_count << ")) " << path_queries_count << " found " << temp << '\n';
}
{
LS ls;
ls.resize(2);
clock_t::time_point start = clock_t::now();
size_t temp = 0;
for (size_t i = 0 ; i < path_queries_count2 ; ++i )
{
float x = coords[i].first;
float y = coords[i].second;
ls[0] = P(x, y);
ls[1] = P(x+max_val/100, y+max_val/100);
result.clear();
t.query(bgi::path(ls, path_values_count), std::back_inserter(result));
temp += result.size();
}
dur_t time = clock_t::now() - start;
std::cout << time << " - query(path(LS, " << path_values_count << ")) " << path_queries_count2 << " found " << temp << '\n';
}
#endif
{
clock_t::time_point start = clock_t::now();

View File

@ -89,12 +89,14 @@ int test_main(int, char* [])
typedef bg::model::linestring<P3fc> L3fc;
typedef bg::model::linestring<P3dc> L3dc;
test_geometry<bg::model::box<P2ic>, L2ic>("POLYGON((0 1,2 4))", "LINESTRING(0 0, 2 5)", true, ::sqrt(29.0f)/5);
test_geometry<bg::model::box<P2fc>, L2fc>("POLYGON((0 1,2 4))", "LINESTRING(0 0, 2 5)", true, ::sqrt(29.0f)/5);
test_geometry<bg::model::box<P2dc>, L2dc>("POLYGON((0 1,2 4))", "LINESTRING(0 0, 2 5)", true, ::sqrt(29.0)/5);
test_geometry<bg::model::box<P3ic>, L3ic>("POLYGON((0 1 2,2 4 6))", "LINESTRING(0 0 0, 2 5 7)", true, ::sqrt(78.0f)*2.0f/7);
test_geometry<bg::model::box<P3fc>, L3fc>("POLYGON((0 1 2,2 4 6))", "LINESTRING(0 0 0, 2 5 7)", true, ::sqrt(78.0f)*2.0f/7);
test_geometry<bg::model::box<P3dc>, L3dc>("POLYGON((0 1 2,2 4 6))", "LINESTRING(0 0 0, 2 5 7)", true, ::sqrt(78.0)*2.0/7);
// IMPORTANT! For 2-point linestrings comparable distance optimization is enabled!
test_geometry<bg::model::box<P2ic>, L2ic>("POLYGON((0 1,2 4))", "LINESTRING(0 0, 2 5)", true, 1.0f/5);
test_geometry<bg::model::box<P2fc>, L2fc>("POLYGON((0 1,2 4))", "LINESTRING(0 0, 2 5)", true, 1.0f/5);
test_geometry<bg::model::box<P2dc>, L2dc>("POLYGON((0 1,2 4))", "LINESTRING(0 0, 2 5)", true, 1.0/5);
test_geometry<bg::model::box<P3ic>, L3ic>("POLYGON((0 1 2,2 4 6))", "LINESTRING(0 0 0, 2 5 7)", true, 2.0f/7);
test_geometry<bg::model::box<P3fc>, L3fc>("POLYGON((0 1 2,2 4 6))", "LINESTRING(0 0 0, 2 5 7)", true, 2.0f/7);
test_geometry<bg::model::box<P3dc>, L3dc>("POLYGON((0 1 2,2 4 6))", "LINESTRING(0 0 0, 2 5 7)", true, 2.0/7);
test_geometry<bg::model::box<P2fc>, L2fc>("POLYGON((0 1,2 4))", "LINESTRING(0 0, 1 0, 1 5)", true, 2);
test_geometry<bg::model::box<P2fc>, L2fc>("POLYGON((0 1,2 4))", "LINESTRING(0 0, 3 0, 3 2, 0 2)", true, 6);
@ -107,8 +109,8 @@ int test_main(int, char* [])
typedef bg::model::linestring<P2ttmc> L2ttmc;
typedef bg::model::linestring<P3ttmc> L3ttmc;
test_geometry<bg::model::box<P2ttmc>, L2ttmc>("POLYGON((0 1,2 4))", "LINESTRING(0 0, 2 5)", true, ::sqrt(29.0f)/5);
test_geometry<bg::model::box<P3ttmc>, L3ttmc>("POLYGON((0 1 2,2 4 6))", "LINESTRING(0 0 0, 2 5 7)", true, ::sqrt(78.0f)*2.0f/7);
test_geometry<bg::model::box<P2ttmc>, L2ttmc>("POLYGON((0 1,2 4))", "LINESTRING(0 0, 2 5)", true, 1.0/5);
test_geometry<bg::model::box<P3ttmc>, L3ttmc>("POLYGON((0 1 2,2 4 6))", "LINESTRING(0 0 0, 2 5 7)", true, 2.0/7);
#endif
test_large_integers();

View File

@ -13,22 +13,22 @@
//#include <boost/geometry/io/wkt/read.hpp>
template <typename Box, typename Point>
template <typename Box, typename Point, typename RelativeDistance>
void test_segment_intersection(Box const& box, Point const& p0, Point const& p1,
bool expected_result,
typename bgi::detail::default_relative_distance_type<Box, Point>::type expected_rel_dist)
RelativeDistance expected_rel_dist)
{
typename bgi::detail::default_relative_distance_type<Box, Point>::type rel_dist;
RelativeDistance rel_dist;
bool value = bgi::detail::segment_intersection(box, p0, p1, rel_dist);
BOOST_CHECK(value == expected_result);
if ( value && expected_result )
BOOST_CHECK_CLOSE(rel_dist, expected_rel_dist, 0.0001);
}
template <typename Box, typename Point>
template <typename Box, typename Point, typename RelativeDistance>
void test_geometry(std::string const& wkt_g, std::string const& wkt_p0, std::string const& wkt_p1,
bool expected_result,
typename bgi::detail::default_relative_distance_type<Box, Point>::type expected_rel_dist)
RelativeDistance expected_rel_dist)
{
Box box;
bg::read_wkt(wkt_g, box);
@ -106,14 +106,14 @@ int test_main(int, char* [])
test_geometry<bg::model::box<P2fc>, P2fc>("POLYGON((0 1,2 4))", "POINT(0 5)", "POINT(0 0)", true, 0.2f);
test_geometry<bg::model::box<P2dc>, P2dc>("POLYGON((0 1,2 4))", "POINT(0 0)", "POINT(0 5)", true, 0.2);
test_geometry<bg::model::box<P2ic>, P2ic>("POLYGON((0 1,2 4))", "POINT(3 0)", "POINT(3 5)", false, 0);
test_geometry<bg::model::box<P2fc>, P2fc>("POLYGON((0 1,2 4))", "POINT(3 5)", "POINT(3 0)", false, 0);
test_geometry<bg::model::box<P2dc>, P2dc>("POLYGON((0 1,2 4))", "POINT(3 0)", "POINT(3 5)", false, 0);
test_geometry<bg::model::box<P2ic>, P2ic>("POLYGON((0 1,2 4))", "POINT(3 0)", "POINT(3 5)", false, 0.0f);
test_geometry<bg::model::box<P2fc>, P2fc>("POLYGON((0 1,2 4))", "POINT(3 5)", "POINT(3 0)", false, 0.0f);
test_geometry<bg::model::box<P2dc>, P2dc>("POLYGON((0 1,2 4))", "POINT(3 0)", "POINT(3 5)", false, 0.0);
test_geometry<bg::model::box<P2fc>, P2fc>("POLYGON((0 1,2 4))", "POINT(1 0)", "POINT(1 1)", true, 1);
test_geometry<bg::model::box<P2fc>, P2fc>("POLYGON((0 1,2 4))", "POINT(1 4)", "POINT(1 5)", true, 0);
test_geometry<bg::model::box<P2fc>, P2fc>("POLYGON((0 1,2 4))", "POINT(1 0)", "POINT(1 1)", true, 1.0f);
test_geometry<bg::model::box<P2fc>, P2fc>("POLYGON((0 1,2 4))", "POINT(1 4)", "POINT(1 5)", true, 0.0f);
test_geometry<bg::model::box<P2fc>, P2fc>("POLYGON((0 1,2 4))", "POINT(0.5 2)", "POINT(1.5 3)", true, 0);
test_geometry<bg::model::box<P2fc>, P2fc>("POLYGON((0 1,2 4))", "POINT(0.5 2)", "POINT(1.5 3)", true, 0.0f);
#ifdef HAVE_TTMATH
typedef bg::model::point<ttmath_big, 2, bg::cs::cartesian> P2ttmc;