From 6a23b0ff808f2c0a4fe61f9763ce89dcd2b6e744 Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Fri, 25 Apr 2014 22:57:55 +0200 Subject: [PATCH 1/2] [overlay] added metafunction rescale_overlay_policy_type to use rescaling only for areal/areal --- .../boost/geometry/algorithms/difference.hpp | 8 ++-- .../geometry/algorithms/intersection.hpp | 5 +- .../geometry/algorithms/sym_difference.hpp | 5 +- include/boost/geometry/algorithms/union.hpp | 5 +- .../robustness/get_rescale_policy.hpp | 46 +++++++++++++++++++ 5 files changed, 59 insertions(+), 10 deletions(-) diff --git a/include/boost/geometry/algorithms/difference.hpp b/include/boost/geometry/algorithms/difference.hpp index bd919f5af..780436f01 100644 --- a/include/boost/geometry/algorithms/difference.hpp +++ b/include/boost/geometry/algorithms/difference.hpp @@ -148,11 +148,11 @@ inline void difference(Geometry1 const& geometry1, typedef typename boost::range_value::type geometry_out; concept::check(); - typedef typename geometry::rescale_policy_type + typedef typename geometry::rescale_overlay_policy_type < - typename geometry::point_type::type // TODO from both - >::type - rescale_policy_type; + Geometry1, + Geometry2 + >::type rescale_policy_type; rescale_policy_type robust_policy = geometry::get_rescale_policy(geometry1, geometry2); diff --git a/include/boost/geometry/algorithms/intersection.hpp b/include/boost/geometry/algorithms/intersection.hpp index 484b399ca..500cacc9f 100644 --- a/include/boost/geometry/algorithms/intersection.hpp +++ b/include/boost/geometry/algorithms/intersection.hpp @@ -196,9 +196,10 @@ inline bool intersection(Geometry1 const& geometry1, concept::check(); concept::check(); - typedef typename geometry::rescale_policy_type + typedef typename geometry::rescale_overlay_policy_type < - typename geometry::point_type::type // TODO from both + Geometry1, + Geometry2 >::type rescale_policy_type; rescale_policy_type robust_policy diff --git a/include/boost/geometry/algorithms/sym_difference.hpp b/include/boost/geometry/algorithms/sym_difference.hpp index d151b624d..de34c9c7b 100644 --- a/include/boost/geometry/algorithms/sym_difference.hpp +++ b/include/boost/geometry/algorithms/sym_difference.hpp @@ -156,9 +156,10 @@ inline void sym_difference(Geometry1 const& geometry1, typedef typename boost::range_value::type geometry_out; concept::check(); - typedef typename geometry::rescale_policy_type + typedef typename geometry::rescale_overlay_policy_type < - typename geometry::point_type::type // TODO from both + Geometry1, + Geometry2 >::type rescale_policy_type; rescale_policy_type robust_policy diff --git a/include/boost/geometry/algorithms/union.hpp b/include/boost/geometry/algorithms/union.hpp index a0d7db01b..ca9b8ff11 100644 --- a/include/boost/geometry/algorithms/union.hpp +++ b/include/boost/geometry/algorithms/union.hpp @@ -270,9 +270,10 @@ inline OutputIterator union_insert(Geometry1 const& geometry1, concept::check(); concept::check(); - typedef typename geometry::rescale_policy_type + typedef typename geometry::rescale_overlay_policy_type < - typename geometry::point_type::type // TODO from both + Geometry1, + Geometry2 >::type rescale_policy_type; typedef strategy_intersection diff --git a/include/boost/geometry/policies/robustness/get_rescale_policy.hpp b/include/boost/geometry/policies/robustness/get_rescale_policy.hpp index 6c0d8bd32..b3c8333db 100644 --- a/include/boost/geometry/policies/robustness/get_rescale_policy.hpp +++ b/include/boost/geometry/policies/robustness/get_rescale_policy.hpp @@ -17,6 +17,8 @@ #include +#include + #include #include #include @@ -95,6 +97,7 @@ static inline void init_rescale_policy(Geometry1 const& geometry1, num_type const two = 2; boost::long_long_type const min_coordinate = boost::numeric_cast(-range / two); +std::cout << "rescale from " << min_coordinate << " " << factor << std::endl; assign_values(min_robust_point, min_coordinate, min_coordinate); } @@ -221,6 +224,49 @@ struct rescale_policy_type #endif }; + +template +< + typename Geometry1, + typename Geometry2, + typename Tag1 = typename tag_cast + < + typename tag::type, + pointlike_tag, + linear_tag, + areal_tag + >::type, + typename Tag2 = typename tag_cast + < + typename tag::type, + pointlike_tag, + linear_tag, + areal_tag + >::type +> +struct rescale_overlay_policy_type + // Default: no rescaling + : public detail::get_rescale_policy::rescale_policy_type + < + typename geometry::point_type::type, + false + > +{}; + +// Areal/areal: get rescale policy based on coordinate type +template +< + typename Geometry1, + typename Geometry2 +> +struct rescale_overlay_policy_type + : public rescale_policy_type + < + typename geometry::point_type::type + > +{}; + + template inline Policy get_rescale_policy(Geometry const& geometry) { From b007b85c17236ed5cc90505d91c8d6420b8f4a27 Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Fri, 25 Apr 2014 23:05:31 +0200 Subject: [PATCH 2/2] removed debug statement --- .../boost/geometry/policies/robustness/get_rescale_policy.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/include/boost/geometry/policies/robustness/get_rescale_policy.hpp b/include/boost/geometry/policies/robustness/get_rescale_policy.hpp index b3c8333db..4c3e4c73f 100644 --- a/include/boost/geometry/policies/robustness/get_rescale_policy.hpp +++ b/include/boost/geometry/policies/robustness/get_rescale_policy.hpp @@ -97,7 +97,6 @@ static inline void init_rescale_policy(Geometry1 const& geometry1, num_type const two = 2; boost::long_long_type const min_coordinate = boost::numeric_cast(-range / two); -std::cout << "rescale from " << min_coordinate << " " << factor << std::endl; assign_values(min_robust_point, min_coordinate, min_coordinate); }