mirror of
https://github.com/boostorg/geometry.git
synced 2025-05-09 23:24:02 +00:00
geometry.index test,example: added benchmark and test for segment path queries.
[SVN r84293]
This commit is contained in:
parent
a5695c8311
commit
82b4c79441
@ -18,6 +18,7 @@
|
||||
|
||||
#include <boost/geometry/index/rtree.hpp>
|
||||
#include <boost/geometry/geometries/linestring.hpp>
|
||||
#include <boost/geometry/geometries/segment.hpp>
|
||||
|
||||
namespace bg = boost::geometry;
|
||||
namespace bgi = bg::index;
|
||||
@ -25,6 +26,7 @@ namespace bgi = bg::index;
|
||||
typedef bg::model::point<double, 2, bg::cs::cartesian> P;
|
||||
typedef bg::model::box<P> B;
|
||||
typedef bg::model::linestring<P> LS;
|
||||
typedef bg::model::segment<P> S;
|
||||
|
||||
template <typename I1, typename I2, typename O>
|
||||
void mycopy(I1 first, I2 last, O o)
|
||||
@ -283,7 +285,7 @@ int main()
|
||||
temp += result.size();
|
||||
}
|
||||
dur_t time = clock_t::now() - start;
|
||||
std::cout << time << " - query(path(LS, " << path_values_count << ")) " << path_queries_count << " found " << temp << '\n';
|
||||
std::cout << time << " - query(path(LS6, " << path_values_count << ")) " << path_queries_count << " found " << temp << '\n';
|
||||
}
|
||||
|
||||
{
|
||||
@ -303,7 +305,23 @@ int main()
|
||||
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';
|
||||
std::cout << time << " - query(path(LS2, " << path_values_count << ")) " << path_queries_count2 << " found " << temp << '\n';
|
||||
}
|
||||
|
||||
{
|
||||
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;
|
||||
S seg(P(x, y), P(x+max_val/100, y+max_val/100));
|
||||
result.clear();
|
||||
t.query(bgi::path(seg, path_values_count), std::back_inserter(result));
|
||||
temp += result.size();
|
||||
}
|
||||
dur_t time = clock_t::now() - start;
|
||||
std::cout << time << " - query(path(S, " << path_values_count << ")) " << path_queries_count2 << " found " << temp << '\n';
|
||||
}
|
||||
#endif
|
||||
{
|
||||
|
@ -11,6 +11,12 @@
|
||||
|
||||
#include <boost/geometry/index/detail/algorithms/path_intersection.hpp>
|
||||
|
||||
#include <boost/geometry/geometries/point_xy.hpp>
|
||||
#include <boost/geometry/geometries/point.hpp>
|
||||
#include <boost/geometry/geometries/box.hpp>
|
||||
#include <boost/geometry/geometries/linestring.hpp>
|
||||
#include <boost/geometry/geometries/segment.hpp>
|
||||
|
||||
//#include <boost/geometry/io/wkt/read.hpp>
|
||||
|
||||
template <typename Box, typename Linestring>
|
||||
@ -18,11 +24,24 @@ void test_path_intersection(Box const& box, Linestring const& path,
|
||||
bool expected_result,
|
||||
typename bg::default_length_result<Linestring>::type expected_dist)
|
||||
{
|
||||
typename bg::default_length_result<Linestring>::type dist;
|
||||
typename bgi::detail::default_path_intersection_distance_type<Box, Linestring>::type dist;
|
||||
|
||||
bool value = bgi::detail::path_intersection(box, path, dist);
|
||||
BOOST_CHECK(value == expected_result);
|
||||
if ( value && expected_result )
|
||||
BOOST_CHECK_CLOSE(dist, expected_dist, 0.0001);
|
||||
|
||||
if ( ::boost::size(path) == 2 )
|
||||
{
|
||||
typedef typename ::boost::range_value<Linestring>::type P;
|
||||
typedef bg::model::segment<P> Seg;
|
||||
typename bgi::detail::default_path_intersection_distance_type<Box, Seg>::type dist;
|
||||
Seg seg(*::boost::begin(path), *(::boost::begin(path)+1));
|
||||
bool value = bgi::detail::path_intersection(box, seg, dist);
|
||||
BOOST_CHECK(value == expected_result);
|
||||
if ( value && expected_result )
|
||||
BOOST_CHECK_CLOSE(dist, expected_dist, 0.0001);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Box, typename Linestring>
|
||||
@ -37,11 +56,6 @@ void test_geometry(std::string const& wkt_g, std::string const& wkt_path,
|
||||
test_path_intersection(box, path, expected_result, expected_dist);
|
||||
}
|
||||
|
||||
#include <boost/geometry/geometries/point_xy.hpp>
|
||||
#include <boost/geometry/geometries/point.hpp>
|
||||
#include <boost/geometry/geometries/box.hpp>
|
||||
#include <boost/geometry/geometries/linestring.hpp>
|
||||
|
||||
void test_large_integers()
|
||||
{
|
||||
typedef bg::model::point<int, 2, bg::cs::cartesian> int_point_type;
|
||||
|
Loading…
x
Reference in New Issue
Block a user