From 91d461100c294e882d2682aed708b36bac0e8e87 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Fri, 16 May 2014 14:17:48 +0300 Subject: [PATCH 01/22] [test][length] do not test the variant-related code if GEOMETRY_TEST_DEBUG is defined (the variant-related code does not compile when GEOMETRY_TEST_DEBUG is defined) --- test/algorithms/test_length.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/algorithms/test_length.hpp b/test/algorithms/test_length.hpp index 713479d76..485c38056 100644 --- a/test/algorithms/test_length.hpp +++ b/test/algorithms/test_length.hpp @@ -44,7 +44,9 @@ void test_geometry(std::string const& wkt, double expected_length) Geometry geometry; bg::read_wkt(wkt, geometry); test_length(geometry, expected_length); +#if !defined(GEOMETRY_TEST_DEBUG) test_length(boost::variant(geometry), expected_length); +#endif } template From b992ddf185023bf78e3c4eac1cc5e91b832f7d10 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Fri, 16 May 2014 14:24:32 +0300 Subject: [PATCH 02/22] [test][perimeter] do not test the variant-related code if GEOMETRY_TEST_DEBUG is defined (the variant-related code does not compile when GEOMETRY_TEST_DEBUG is defined); replace bg::perimeter_result (non-existing) by bg::default_lentgh_result (error produced when compiling with -DGEOMETRY_TEST_DEBUG) --- test/algorithms/test_perimeter.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/algorithms/test_perimeter.hpp b/test/algorithms/test_perimeter.hpp index 7680e9860..74f04648a 100644 --- a/test/algorithms/test_perimeter.hpp +++ b/test/algorithms/test_perimeter.hpp @@ -29,7 +29,7 @@ void test_perimeter(Geometry const& geometry, long double expected_perimeter) std::ostringstream out; out << typeid(typename bg::coordinate_type::type).name() << std::endl - << typeid(typename bg::perimeter_result::type).name() + << typeid(typename bg::default_length_result::type).name() << std::endl << "perimeter : " << bg::perimeter(geometry) << std::endl; @@ -48,7 +48,9 @@ void test_geometry(std::string const& wkt, double expected_perimeter) boost::variant v(geometry); test_perimeter(geometry, expected_perimeter); +#if !defined(GEOMETRY_TEST_DEBUG) test_perimeter(v, expected_perimeter); +#endif } template From 422c6c7129e618fde5636c5006b6f35ed5f7fa20 Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Fri, 16 May 2014 23:00:13 +0200 Subject: [PATCH 03/22] [doc] Added Samuel and fixed some doc issues for distance --- doc/doxy/Doxyfile | 11 ++++++++--- doc/geometry.qbk | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/doc/doxy/Doxyfile b/doc/doxy/Doxyfile index 8c6ec4b8d..c64ecaa9a 100644 --- a/doc/doxy/Doxyfile +++ b/doc/doxy/Doxyfile @@ -57,7 +57,6 @@ ALIASES = qbk{1}="\xmlonly \1 \endxmlonly" \ tparam_radius="numeric type for radius (of sphere, earth)" \ tparam_container="container type, for example std::vector, std::deque" \ tparam_dimension_required="Dimension, this template parameter is required. Should contain \\[0 .. n-1\\] for an n-dimensional geometry" \ - tparam_first_point="first point type" \ tparam_functor="Function or class with operator()" \ tparam_output_collection="output collection, either a multi-geometry, or a std::vector / std::deque etc" \ tparam_geometry="Any type fulfilling a Geometry Concept" \ @@ -67,8 +66,10 @@ ALIASES = qbk{1}="\xmlonly \1 \endxmlonly" \ tparam_out{1}="A valid output iterator type, accepting geometries of \1 Concept" \ tparam_point="Any type fulfilling a Point Concept" \ tparam_range_point="Any type fulfilling a Range Concept where it range_value type fulfills the Point Concept" \ - tparam_first_point="point type" \ + tparam_first_point="first point type" \ + tparam_first_box="first box type" \ tparam_second_point="second point type" \ + tparam_second_box="second box type" \ tparam_segment_point="segment point type" \ tparam_strategy{1}="Any type fulfilling a \1 Strategy Concept" \ tparam_strategy_overlay="Compound strategy for segment intersection" \ @@ -176,9 +177,13 @@ WARN_LOGFILE = INPUT = . .. ../../../../boost/geometry/core \ ../../../../boost/geometry/algorithms \ ../../../../boost/geometry/algorithms/detail \ - ../../../../boost/geometry/algorithms/detail/overlay \ + ../../../../boost/geometry/algorithms/detail/distance \ ../../../../boost/geometry/algorithms/detail/equals \ + ../../../../boost/geometry/algorithms/detail/overlay \ + ../../../../boost/geometry/algorithms/detail/relate \ ../../../../boost/geometry/algorithms/detail/sections \ + ../../../../boost/geometry/algorithms/detail/turns \ + ../../../../boost/geometry/algorithms/detail/within \ ../../../../boost/geometry/arithmetic \ ../../../../boost/geometry/geometries/concepts \ ../../../../boost/geometry/geometries \ diff --git a/doc/geometry.qbk b/doc/geometry.qbk index 7ff1d6512..d57e3cfaa 100644 --- a/doc/geometry.qbk +++ b/doc/geometry.qbk @@ -113,6 +113,7 @@ Boost.Geometry contains contributions by: * Federico Fern\u00E1ndez (preliminary version of R-tree spatial index) * Karsten Ahnert (patch for cross-track distance) * Mats Taraldsvik (documentation: adapting a legacy model) +* Samuel Debionne (variant support for distance) [include imports.qbk] From d0cf100a654759436f026783dad0ffc528d1b080 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Sat, 17 May 2014 14:10:34 +0200 Subject: [PATCH 04/22] [get_turns][relate][test][index] Fix unused variable warnings. In the rtree/pack_create replace (void)variable to boost::ignore_unused_variable_warning(). --- .../detail/overlay/get_turn_info_for_endpoint.hpp | 6 ++++-- .../detail/overlay/get_turn_info_helpers.hpp | 2 +- .../algorithms/detail/overlay/get_turn_info_la.hpp | 12 +++++++----- .../algorithms/detail/relate/linear_areal.hpp | 9 +++------ .../algorithms/detail/relate/linear_linear.hpp | 11 ++++------- .../geometry/algorithms/detail/relate/result.hpp | 2 +- .../geometry/index/detail/rtree/pack_create.hpp | 2 +- test/algorithms/assign.cpp | 2 +- test/algorithms/test_convex_hull.hpp | 2 +- 9 files changed, 23 insertions(+), 25 deletions(-) diff --git a/include/boost/geometry/algorithms/detail/overlay/get_turn_info_for_endpoint.hpp b/include/boost/geometry/algorithms/detail/overlay/get_turn_info_for_endpoint.hpp index cd07e784a..e7df458fa 100644 --- a/include/boost/geometry/algorithms/detail/overlay/get_turn_info_for_endpoint.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/get_turn_info_for_endpoint.hpp @@ -394,8 +394,8 @@ struct get_turn_info_for_endpoint typename TurnInfo, typename IntersectionInfo > - static inline bool handle_internal(Point1 const& i1, Point1 const& j1, Point1 const& /*k1*/, - Point2 const& i2, Point2 const& j2, Point2 const& k2, + static inline bool handle_internal(Point1 const& /*i1*/, Point1 const& /*j1*/, Point1 const& /*k1*/, + Point2 const& i2, Point2 const& j2, Point2 const& /*k2*/, RobustPoint1 const& ri1, RobustPoint1 const& rj1, RobustPoint1 const& /*rk1*/, RobustPoint2 const& ri2, RobustPoint2 const& rj2, RobustPoint2 const& rk2, bool first1, bool last1, bool first2, bool last2, @@ -403,6 +403,8 @@ struct get_turn_info_for_endpoint IntersectionInfo const& inters, int ip_index, operation_type & op1, operation_type & op2) { + boost::ignore_unused_variable_warning(i2); + boost::ignore_unused_variable_warning(j2); boost::ignore_unused_variable_warning(ip_index); boost::ignore_unused_variable_warning(tp_model); diff --git a/include/boost/geometry/algorithms/detail/overlay/get_turn_info_helpers.hpp b/include/boost/geometry/algorithms/detail/overlay/get_turn_info_helpers.hpp index 6b3c54d5f..3f0d5da1f 100644 --- a/include/boost/geometry/algorithms/detail/overlay/get_turn_info_helpers.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/get_turn_info_helpers.hpp @@ -160,7 +160,7 @@ public: intersection_info_base(Point1 const& pi, Point1 const& pj, Point1 const& pk, Point2 const& qi, Point2 const& qj, Point2 const& qk, - no_rescale_policy const& robust_policy) + no_rescale_policy const& /*robust_policy*/) : m_side_calc(pi, pj, pk, qi, qj, qk) {} diff --git a/include/boost/geometry/algorithms/detail/overlay/get_turn_info_la.hpp b/include/boost/geometry/algorithms/detail/overlay/get_turn_info_la.hpp index 9556dbfaa..374c82082 100644 --- a/include/boost/geometry/algorithms/detail/overlay/get_turn_info_la.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/get_turn_info_la.hpp @@ -446,7 +446,7 @@ struct get_turn_info_linear_areal typename OutIt> static inline bool append_collinear_spikes(TurnInfo & tp, IntersectionInfo const& inters, - bool is_p_last, bool is_q_last, + bool is_p_last, bool /*is_q_last*/, method_type method, append_version_c version, OutIt out) { @@ -489,7 +489,7 @@ struct get_turn_info_linear_areal typename OutIt> static inline bool append_opposite_spikes(TurnInfo & tp, IntersectionInfo const& inters, - bool is_p_last, bool is_q_last, + bool is_p_last, bool /*is_q_last*/, OutIt out) { bool is_p_spike = ( Version == append_touches ? @@ -635,10 +635,10 @@ struct get_turn_info_linear_areal typename IntersectionInfo, typename OutputIterator> static inline bool get_turn_info_for_endpoint( - Point1 const& pi, Point1 const& pj, Point1 const& pk, - Point2 const& qi, Point2 const& qj, Point2 const& qk, + Point1 const& pi, Point1 const& /*pj*/, Point1 const& /*pk*/, + Point2 const& qi, Point2 const& /*qj*/, Point2 const& /*qk*/, bool is_p_first, bool is_p_last, - bool is_q_first, bool is_q_last, + bool /*is_q_first*/, bool is_q_last, TurnInfo const& tp_model, IntersectionInfo const& inters, method_type /*method*/, @@ -659,6 +659,8 @@ struct get_turn_info_linear_areal if ( !is_p_first && !is_p_last ) return false; +// TODO: is_q_last could probably be replaced by false and removed from parameters + linear_intersections intersections(pi, qi, inters.result(), is_p_last, is_q_last); linear_intersections::ip_info const& ip0 = intersections.template get<0>(); linear_intersections::ip_info const& ip1 = intersections.template get<1>(); diff --git a/include/boost/geometry/algorithms/detail/relate/linear_areal.hpp b/include/boost/geometry/algorithms/detail/relate/linear_areal.hpp index 0bf667eb2..26750de3b 100644 --- a/include/boost/geometry/algorithms/detail/relate/linear_areal.hpp +++ b/include/boost/geometry/algorithms/detail/relate/linear_areal.hpp @@ -464,14 +464,11 @@ struct linear_areal typename Geometry, typename OtherGeometry, typename BoundaryChecker> - void apply(Result & res, - TurnIt first, TurnIt it, TurnIt last, + void apply(Result & res, TurnIt it, Geometry const& geometry, OtherGeometry const& other_geometry, BoundaryChecker const& boundary_checker) { - //BOOST_ASSERT( it != last ); - overlay::operation_type op = it->operations[op_id].operation; if ( op != overlay::operation_union @@ -769,7 +766,7 @@ struct linear_areal void apply(Result & res, TurnIt first, TurnIt last, Geometry const& geometry, - OtherGeometry const& other_geometry, + OtherGeometry const& /*other_geometry*/, BoundaryChecker const& boundary_checker) { //BOOST_ASSERT( first != last ); @@ -966,7 +963,7 @@ struct linear_areal for ( TurnIt it = first ; it != last ; ++it ) { - analyser.apply(res, first, it, last, + analyser.apply(res, it, geometry, other_geometry, boundary_checker); diff --git a/include/boost/geometry/algorithms/detail/relate/linear_linear.hpp b/include/boost/geometry/algorithms/detail/relate/linear_linear.hpp index fc424fff5..3476a4178 100644 --- a/include/boost/geometry/algorithms/detail/relate/linear_linear.hpp +++ b/include/boost/geometry/algorithms/detail/relate/linear_linear.hpp @@ -257,15 +257,12 @@ struct linear_linear typename OtherGeometry, typename BoundaryChecker, typename OtherBoundaryChecker> - void apply(Result & res, - TurnIt first, TurnIt it, TurnIt last, + void apply(Result & res, TurnIt it, Geometry const& geometry, OtherGeometry const& other_geometry, BoundaryChecker const& boundary_checker, OtherBoundaryChecker const& other_boundary_checker) { - //BOOST_ASSERT( it != last ); - overlay::operation_type op = it->operations[op_id].operation; segment_identifier const& seg_id = it->operations[op_id].seg_id; @@ -563,7 +560,7 @@ struct linear_linear Geometry const& geometry, OtherGeometry const& /*other_geometry*/, BoundaryChecker const& boundary_checker, - OtherBoundaryChecker const& other_boundary_checker) + OtherBoundaryChecker const& /*other_boundary_checker*/) { //BOOST_ASSERT( first != last ); @@ -621,7 +618,7 @@ struct linear_linear Geometry const& geometry, OtherGeometry const& other_geometry, BoundaryChecker const& boundary_checker, - OtherBoundaryChecker const& other_boundary_checker, + OtherBoundaryChecker const& /*other_boundary_checker*/, bool first_in_range) { typename detail::single_geometry_return_type::type @@ -747,7 +744,7 @@ struct linear_linear for ( TurnIt it = first ; it != last ; ++it ) { - analyser.apply(res, first, it, last, + analyser.apply(res, it, geometry, other_geometry, boundary_checker, other_boundary_checker); diff --git a/include/boost/geometry/algorithms/detail/relate/result.hpp b/include/boost/geometry/algorithms/detail/relate/result.hpp index 1064246e4..0479a6440 100644 --- a/include/boost/geometry/algorithms/detail/relate/result.hpp +++ b/include/boost/geometry/algorithms/detail/relate/result.hpp @@ -911,7 +911,7 @@ struct static_check_dispatch return el == mask_el; } // else - static inline bool apply_dispatch(char el, integral_constant) + static inline bool apply_dispatch(char /*el*/, integral_constant) { return true; } diff --git a/include/boost/geometry/index/detail/rtree/pack_create.hpp b/include/boost/geometry/index/detail/rtree/pack_create.hpp index 232f4654f..e3ac16aef 100644 --- a/include/boost/geometry/index/detail/rtree/pack_create.hpp +++ b/include/boost/geometry/index/detail/rtree/pack_create.hpp @@ -294,7 +294,7 @@ private: inline static subtree_elements_counts calculate_subtree_elements_counts(std::size_t elements_count, parameters_type const& parameters, size_type & leafs_level) { - (void)parameters; + boost::ignore_unused_variable_warning(parameters); subtree_elements_counts res(1, 1); leafs_level = 0; diff --git a/test/algorithms/assign.cpp b/test/algorithms/assign.cpp index 52d935f93..a64f4010d 100644 --- a/test/algorithms/assign.cpp +++ b/test/algorithms/assign.cpp @@ -38,7 +38,7 @@ void check_geometry(Geometry const& geometry, std::string const& expected) } template -void check_assign_points(Points const& points, std::string const& expected) +void check_assign_points(Points const& points, std::string const& /*expected*/) { Geometry geometry; bg::assign_points(geometry, points); diff --git a/test/algorithms/test_convex_hull.hpp b/test/algorithms/test_convex_hull.hpp index edf4db48b..a11b42dd7 100644 --- a/test/algorithms/test_convex_hull.hpp +++ b/test/algorithms/test_convex_hull.hpp @@ -27,7 +27,7 @@ template void check_convex_hull(Geometry const& geometry, Hull const& hull, - std::size_t size_original, std::size_t size_hull, + std::size_t /*size_original*/, std::size_t size_hull, double expected_area, bool reverse) { std::size_t n = bg::num_points(hull); From 5007f1debba988a77d50659fe024c50ffd448e3c Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Sat, 17 May 2014 21:09:07 +0200 Subject: [PATCH 05/22] [extensions][dissolve] repaired dissolve w.r.t. turn changes --- .../extensions/algorithms/detail/overlay/dissolver.hpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/boost/geometry/extensions/algorithms/detail/overlay/dissolver.hpp b/include/boost/geometry/extensions/algorithms/detail/overlay/dissolver.hpp index 7d36d6dd2..ac4fdb40c 100644 --- a/include/boost/geometry/extensions/algorithms/detail/overlay/dissolver.hpp +++ b/include/boost/geometry/extensions/algorithms/detail/overlay/dissolver.hpp @@ -125,7 +125,12 @@ class plusmin_policy //negative = true; typedef typename geometry::point_type::type point_type; - typedef overlay::turn_info turn_info; + + typedef overlay::turn_info + < + point_type, + typename segment_ratio_type::type + > turn_info; std::deque turns; // Get (and stop on) any intersection From dee255ad5e24aa71c4ae32ecb44b4994fabb440b Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Sun, 18 May 2014 00:02:43 +0200 Subject: [PATCH 06/22] [extensions][dissolve] added extra unit tests for cw/ccw check --- extensions/test/algorithms/dissolve.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/extensions/test/algorithms/dissolve.cpp b/extensions/test/algorithms/dissolve.cpp index 46fae52d0..2c6da16d8 100644 --- a/extensions/test/algorithms/dissolve.cpp +++ b/extensions/test/algorithms/dissolve.cpp @@ -273,6 +273,13 @@ void test_all() "POLYGON((5 0,2.5 9,9.5 3.5,0.5 3.5,7.5 9,5 0))", 0, 11, 25.6158412); + // CCW polygons should turn CW after dissolve + test_one("cw", + "POLYGON((2 8,8 8,8 0,0 0,0 6,4 6,4 4,2 4,2 8))", + 0, 7, 60); + test_one("ccw", + "POLYGON((2 8,2 4,4 4,4 6,0 6,0 0,8 0,8 8,2 8))", + 0, 12, 64); // TODO: should have the same, 7, 60. The polygon is dissolved (splitted) but the extra polygon is still on top of the other // Multi-geometries { From c4ca605bab126ef5d5047ec540c6b3386e9ca022 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Sun, 18 May 2014 00:20:36 +0200 Subject: [PATCH 07/22] [overlay][relate][within][test] Fix unused variable warnings. --- .../algorithms/detail/overlay/get_intersection_points.hpp | 4 ++-- include/boost/geometry/algorithms/detail/relate/result.hpp | 4 ++-- .../geometry/algorithms/detail/within/point_in_geometry.hpp | 4 +++- include/boost/geometry/algorithms/for_each.hpp | 2 +- test/algorithms/test_envelope.hpp | 4 ++-- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/include/boost/geometry/algorithms/detail/overlay/get_intersection_points.hpp b/include/boost/geometry/algorithms/detail/overlay/get_intersection_points.hpp index 3e27a0490..d9c423ca4 100644 --- a/include/boost/geometry/algorithms/detail/overlay/get_intersection_points.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/get_intersection_points.hpp @@ -38,8 +38,8 @@ struct get_turn_without_info { template static inline OutputIterator apply( - Point1 const& pi, Point1 const& pj, Point1 const& pk, - Point2 const& qi, Point2 const& qj, Point2 const& qk, + Point1 const& pi, Point1 const& pj, Point1 const& /*pk*/, + Point2 const& qi, Point2 const& qj, Point2 const& /*qk*/, bool /*is_p_first*/, bool /*is_p_last*/, bool /*is_q_first*/, bool /*is_q_last*/, TurnInfo const& , diff --git a/include/boost/geometry/algorithms/detail/relate/result.hpp b/include/boost/geometry/algorithms/detail/relate/result.hpp index 0479a6440..1bcb5275d 100644 --- a/include/boost/geometry/algorithms/detail/relate/result.hpp +++ b/include/boost/geometry/algorithms/detail/relate/result.hpp @@ -823,7 +823,7 @@ template struct static_may_update_sequence { template - static inline bool apply(Matrix const& matrix) + static inline bool apply(Matrix const& /*matrix*/) { return false; } @@ -943,7 +943,7 @@ template struct static_check_sequence { template - static inline bool apply(Matrix const& matrix) + static inline bool apply(Matrix const& /*matrix*/) { return false; } diff --git a/include/boost/geometry/algorithms/detail/within/point_in_geometry.hpp b/include/boost/geometry/algorithms/detail/within/point_in_geometry.hpp index 36ac44d36..a3841496f 100644 --- a/include/boost/geometry/algorithms/detail/within/point_in_geometry.hpp +++ b/include/boost/geometry/algorithms/detail/within/point_in_geometry.hpp @@ -37,15 +37,17 @@ namespace boost { namespace geometry { #ifndef DOXYGEN_NO_DETAIL namespace detail { namespace within { +// TODO: is this needed? inline int check_result_type(int result) { return result; } template -inline void check_result_type(T result) +inline T check_result_type(T result) { BOOST_ASSERT(false); + return result; } template inline diff --git a/include/boost/geometry/algorithms/for_each.hpp b/include/boost/geometry/algorithms/for_each.hpp index 24d38d3d8..2da04674c 100644 --- a/include/boost/geometry/algorithms/for_each.hpp +++ b/include/boost/geometry/algorithms/for_each.hpp @@ -54,7 +54,7 @@ struct fe_point_per_point struct fe_point_per_segment { template - static inline void apply(Point& , Functor& f) + static inline void apply(Point& , Functor& /*f*/) { // TODO: if non-const, we should extract the points from the segment // and call the functor on those two points diff --git a/test/algorithms/test_envelope.hpp b/test/algorithms/test_envelope.hpp index cc19fb9dc..bf00d1282 100644 --- a/test/algorithms/test_envelope.hpp +++ b/test/algorithms/test_envelope.hpp @@ -36,8 +36,8 @@ struct check_result ctype >::type type; - static void apply(Box const& b, const type& x1, const type& y1, const type& z1, - const type& x2, const type& y2, const type& z2) + static void apply(Box const& b, const type& x1, const type& y1, const type& /*z1*/, + const type& x2, const type& y2, const type& /*z2*/) { BOOST_CHECK_CLOSE((bg::get(b)), x1, 0.001); BOOST_CHECK_CLOSE((bg::get(b)), y1, 0.001); From d6326c634351673dcaefe4cb77c657a8c8959289 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Sun, 18 May 2014 16:08:48 +0200 Subject: [PATCH 08/22] [index/example] Add the visualization of knn Box/Box and Seg/Box to glut_vis example --- index/example/glut_vis.cpp | 57 ++++++++++++++++++++++++++++++++------ 1 file changed, 49 insertions(+), 8 deletions(-) diff --git a/index/example/glut_vis.cpp b/index/example/glut_vis.cpp index ee74a69fa..6402f886d 100644 --- a/index/example/glut_vis.cpp +++ b/index/example/glut_vis.cpp @@ -58,7 +58,7 @@ LS search_linestring; LS search_path; enum query_mode_type { - qm_knn, qm_c, qm_d, qm_i, qm_o, qm_w, qm_nc, qm_nd, qm_ni, qm_no, qm_nw, qm_all, qm_ri, qm_pi, qm_mpi, qm_si, qm_lsi, qm_path + qm_knn, qm_knnb, qm_knns, qm_c, qm_d, qm_i, qm_o, qm_w, qm_nc, qm_nd, qm_ni, qm_no, qm_nw, qm_all, qm_ri, qm_pi, qm_mpi, qm_si, qm_lsi, qm_path } query_mode = qm_knn; bool search_valid = false; @@ -68,15 +68,46 @@ void query_knn() float x = ( rand() % 1000 ) / 10.0f; float y = ( rand() % 1000 ) / 10.0f; - search_point = P(x, y); nearest_boxes.clear(); - found_count = t.query( - bgi::nearest(search_point, count), - std::back_inserter(nearest_boxes) - ); + + if ( query_mode == qm_knn ) + { + search_point = P(x, y); + found_count = t.query( + bgi::nearest(search_point, count), + std::back_inserter(nearest_boxes) + ); + } + else if ( query_mode == qm_knnb ) + { + float w = 5 + ( rand() % 1000 ) / 200.0f; + float h = 5 + ( rand() % 1000 ) / 200.0f; + search_box = B(P(x - w, y - h), P(x + w, y + h)); + found_count = t.query( + bgi::nearest(search_box, count), + std::back_inserter(nearest_boxes) + ); + } + else if ( query_mode == qm_knns ) + { + int signx = rand() % 2 ? 1 : -1; + int signy = rand() % 2 ? 1 : -1; + float w = (10 + ( rand() % 1000 ) / 100.0f) * signx; + float h = (10 + ( rand() % 1000 ) / 100.0f) * signy; + search_segment = S(P(x - w, y - h), P(x + w, y + h)); + found_count = t.query( + bgi::nearest(search_segment, count), + std::back_inserter(nearest_boxes) + ); + } + else + { + BOOST_ASSERT(false); + } if ( found_count > 0 ) { +// TODO: print the correct indexable! std::cout << "search point: "; bgi::detail::utilities::print_indexable(std::cout, search_point); std::cout << "\nfound: "; @@ -419,7 +450,7 @@ void search() { namespace d = bgi::detail; - if ( query_mode == qm_knn ) + if ( query_mode == qm_knn || query_mode == qm_knnb || query_mode == qm_knns ) query_knn(); else if ( query_mode == qm_c ) query< d::spatial_predicate >(); @@ -575,10 +606,14 @@ void render_scene(void) if ( search_valid ) { - glColor3f(1.0f, 0.5f, 0.0f); + glColor3f(0.0f, 0.0f, 1.0f); if ( query_mode == qm_knn ) draw_knn_area(0, 0); + else if ( query_mode == qm_knnb ) + draw_box(search_box); + else if ( query_mode == qm_knns ) + draw_segment(search_segment); else if ( query_mode == qm_ri ) draw_ring(search_ring); else if ( query_mode == qm_pi ) @@ -594,6 +629,8 @@ void render_scene(void) else draw_box(search_box); + glColor3f(1.0f, 0.5f, 0.0f); + for ( size_t i = 0 ; i < nearest_boxes.size() ; ++i ) bgi::detail::utilities::gl_draw_indexable( nearest_boxes[i], @@ -760,6 +797,10 @@ void keyboard(unsigned char key, int /*x*/, int /*y*/) { if ( current_line == "knn" ) query_mode = qm_knn; + else if ( current_line == "knnb" ) + query_mode = qm_knnb; + else if ( current_line == "knns" ) + query_mode = qm_knns; else if ( current_line == "c" ) query_mode = qm_c; else if ( current_line == "d" ) From c51cdc4bb9d9d84aaba33de1784f4581b61de6bf Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Sun, 18 May 2014 19:29:16 +0200 Subject: [PATCH 09/22] [doc][example] Update the knn queries section in docs. Improve knn query visualization in glut_vis. --- doc/html/img/index/rtree/knn_box_box.png | Bin 0 -> 2189 bytes doc/html/img/index/rtree/knn_pt_box.png | Bin 0 -> 2174 bytes doc/html/img/index/rtree/knn_seg_box.png | Bin 0 -> 2304 bytes doc/index/rtree/query.qbk | 13 ++++++----- index/example/glut_vis.cpp | 27 +++++++++++++++-------- 5 files changed, 26 insertions(+), 14 deletions(-) create mode 100644 doc/html/img/index/rtree/knn_box_box.png create mode 100644 doc/html/img/index/rtree/knn_pt_box.png create mode 100644 doc/html/img/index/rtree/knn_seg_box.png diff --git a/doc/html/img/index/rtree/knn_box_box.png b/doc/html/img/index/rtree/knn_box_box.png new file mode 100644 index 0000000000000000000000000000000000000000..6f70f884dee76c5be27710b57546c5ca33e2a162 GIT binary patch literal 2189 zcmeAS@N?(olHy`uVBq!ia0y~yU^olH9Bd2>4AOhPWHK-?uqAoByD>oW{978H@y}cV-^;kooHF3`J@1_~4dFy>% zO|8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3HaL(uiTn6L z-2zCiouIY6(yn@+S|_{TYm@AAE*iqkm-jqSV`&bml$))otYpbMOWfxb=fCUM>W`GK zSv{vcX8+e9tqn&ti{7TrDV?=b?E-(%+B?~^91WH(W9s%RmTh}vmGdYf$Uo!#x3GKB z8AVbi?(eK!zH%JMY&o3S&xlVq<)550}TRXmXs`*!!e!E&@`AMB? z)3_Mj>-JCjrWE$pZeY+JVkHLq+K`p z#h>?B@Is3$a31Vn1DBmLM;`Sxtm9XllOUem$JcMM@N$W|q0g@461?zFOT z@?%zb;dVIiK<2i9Xmb&fcP5sQ@`xov>efxA54Cm4;0AGy8o2tL}tU{VyOis-|i@% z%)HQ&Fz;mKm4_ydSJ#LhTeZOQ+Cw{=ClmfGTy*E8!BLjVs^yB4zA3j|d0kK>6>|RG z>&_x66XiL3uL)c7I)Ewy*N;Vhn?o7{daVrB*}u-cG~fB%&g_6cdtUvnJhSh1>Amp9ie}SZ^3yP+1k0 R^$64|@O1TaS?83{1OSl*9W(#{ literal 0 HcmV?d00001 diff --git a/doc/html/img/index/rtree/knn_pt_box.png b/doc/html/img/index/rtree/knn_pt_box.png new file mode 100644 index 0000000000000000000000000000000000000000..af9c14874009511314cf553ddc45c35f4d848ba9 GIT binary patch literal 2174 zcmeAS@N?(olHy`uVBq!ia0y~yU^olH9Bd2>4AOhPWHK-?uqAoByD`d z|4!`jpItk)ZPfd9!TxX6oS%Q~IocB9M143Ek3{D@zS#Ee>DK?*XZiaKqjs%WKW z=d$f4&zbLk{oY(&+4Rta!D-=DkRK3Jx@(;sK#VzP6@Yl{`O(z);rTLGq^Ad@H&_< zTx3vRwBuDIXY862pKlh+)JcSfGeh_XmjJAc1w zb#vr7hqr#tA{w%m5F4RZcd#i)HDoksWh^`WGkyQ9Yv!Le%w5{|V(Ij~S+7`rX80Op z+pA1bp0V=$gv)OZ)Na3|TFVnW_u}2Pvr8x6veUQZEl6ALSesbVTOjpD%Z;$0!`WiPy-Z2&`b+}@uu;Is?WvoH^lm6@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H1n6#hfSBa z?3=LZeA%(eInQot?)bnuC#~_JmC605JSQ?678gq`DEang;uDh$CxiYcI^&z8Eq+}; z7Wr)sX$k%_q)QZfIqul{VqJa&pP&n^3sHBb^Movju)F>`F6LYFyZX= zd9OG4KQ}4Pb24Zt7MZ-i_RfPFhZUAHmYvUhXZRqb$KvbXqP9|N@mERLGUfQYuN`S# yd(P(FcDH$4%B5|)3$51e?s@!TtIq@0f2{BK9G%_r+wT{s8Q|&a=d#Wzp$PzYa1_4) literal 0 HcmV?d00001 diff --git a/doc/html/img/index/rtree/knn_seg_box.png b/doc/html/img/index/rtree/knn_seg_box.png new file mode 100644 index 0000000000000000000000000000000000000000..13288d1ac4fb5d368c929d525feada689d279736 GIT binary patch literal 2304 zcmeAS@N?(olHy`uVBq!ia0y~yU^olH9Bd2>4AOhPWHK-?uqAoByD;o|{+{huo;-n8P;v&_Q0$e=#qP zWfo*TyfSZdfz*Ps<&`0FL7T%)-Kny>ATHGB&MQ9W+2p31zf2WdE{F;h@lWp#J(l@z zg4MIPd70^90euQ3bcQ7dBUcRN*qHV`(H*-r~KUuwZ zJ1_dWGx)u3s#X^FV=jz%-^BJ?B_AF}^7W?#P z?{=#hPkFAqGjVCWH1RTn3$p;Pg9*b$1{Y?i{VST%cFn2(w)$G%jU1nPL@qGfAd(LWwa^Nj=eNLah>t5-KE`mLARf)E@wRV#$<(l&pJWB=EH}c zsb*>2DUhm(vDkW6>4C|CiGIPS_$Fq*;+SwI^Vgwk&q8e8Y|RvTZc;1mB*Q%`Lg@Ct z1$l;Tx0@y}^ICHEhVJrAH-pvHZj1OjZn3k7&A+_G;g##B`A4N6uS+c1{O+IflbCGT zTf*~%c$WWMlMq+X8D7}Wzx=1g%11w*%dNh`UH)3PkmYcu-}z}O@mnWc4)N`qTepMn zexJqH@A>~`ZvQ!vtrggmFd2m z5_7?FbzuJ6JJ&y^idQ|qe{H185Cv(@8;=X)8|@d&N2a%E~c+!zPh=qVySt~p1b>>OF8YRzrVdC zY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...); diff --git a/index/example/glut_vis.cpp b/index/example/glut_vis.cpp index 6402f886d..755f4d300 100644 --- a/index/example/glut_vis.cpp +++ b/index/example/glut_vis.cpp @@ -80,8 +80,8 @@ void query_knn() } else if ( query_mode == qm_knnb ) { - float w = 5 + ( rand() % 1000 ) / 200.0f; - float h = 5 + ( rand() % 1000 ) / 200.0f; + float w = 2 + ( rand() % 1000 ) / 500.0f; + float h = 2 + ( rand() % 1000 ) / 500.0f; search_box = B(P(x - w, y - h), P(x + w, y + h)); found_count = t.query( bgi::nearest(search_box, count), @@ -490,18 +490,27 @@ void search() search_valid = true; } +void draw_point(P const& p) +{ + float x = boost::geometry::get<0>(p); + float y = boost::geometry::get<1>(p); + float z = bgi::detail::rtree::utilities::view(t).depth(); + + glBegin(GL_QUADS); + glVertex3f(x+1, y, z); + glVertex3f(x, y+1, z); + glVertex3f(x-1, y, z); + glVertex3f(x, y-1, z); + glEnd(); +} + void draw_knn_area(float min_distance, float max_distance) { float x = boost::geometry::get<0>(search_point); float y = boost::geometry::get<1>(search_point); float z = bgi::detail::rtree::utilities::view(t).depth(); - // search point - glBegin(GL_TRIANGLES); - glVertex3f(x, y, z); - glVertex3f(x + 1, y, z); - glVertex3f(x + 1, y + 1, z); - glEnd(); + draw_point(search_point); // search min circle @@ -606,7 +615,7 @@ void render_scene(void) if ( search_valid ) { - glColor3f(0.0f, 0.0f, 1.0f); + glColor3f(1.0f, 0.25f, 0.0f); if ( query_mode == qm_knn ) draw_knn_area(0, 0); From 82304fdeef7657520f1be93cb7a8068b58f2ba6b Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Sun, 18 May 2014 19:39:38 +0200 Subject: [PATCH 10/22] [doc] Fix quickref.xml to support new parameter name of nearest(). Also improve the knn examples info. --- doc/index/rtree/query.qbk | 2 +- doc/quickref.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/index/rtree/query.qbk b/doc/index/rtree/query.qbk index cbca27787..db90db102 100644 --- a/doc/index/rtree/query.qbk +++ b/doc/index/rtree/query.qbk @@ -95,7 +95,7 @@ Nearest neighbours queries returns `__value__`s which are closest to some Geomet The examples of k-NN queries are presented below. 5 `__value__`s nearest to the Geometry are orange. [table -[[nearest(Point)] [nearest(Box)] [nearest(Segment)]] +[[nearest(Point, k)] [nearest(Box, k)] [nearest(Segment, k)]] [[[$img/index/rtree/knn_pt_box.png]] [[$img/index/rtree/knn_box_box.png]] [[$img/index/rtree/knn_seg_box.png]]] ] diff --git a/doc/quickref.xml b/doc/quickref.xml index fff476c40..9e20847d3 100644 --- a/doc/quickref.xml +++ b/doc/quickref.xml @@ -741,7 +741,7 @@ overlaps(Geometry const &) within(Geometry const &) satisfies(UnaryPredicate const &) - nearest(Point const &, unsigned) + nearest(Geometry const &, unsigned)