|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r72269 - in trunk: boost/geometry/extensions/algorithms boost/geometry/extensions/algorithms/buffer boost/geometry/extensions/strategies boost/geometry/strategies boost/geometry/strategies/agnostic boost/geometry/strategies/cartesian boost/geometry/strategies/spherical libs/geometry/test/algorithms/overlay libs/geometry/test/strategies libs/geometry/test_extensions/algorithms
From: barend.gehrels_at_[hidden]
Date: 2011-05-29 16:46:25
Author: barendgehrels
Date: 2011-05-29 16:46:22 EDT (Sun, 29 May 2011)
New Revision: 72269
URL: http://svn.boost.org/trac/boost/changeset/72269
Log:
Made side strategy consistent with distance etc (with services::default_strategy)
Updated test spherical_side.cpp now testing ssf, cross_track, cartesian
Text files modified:
trunk/boost/geometry/extensions/algorithms/buffer/segmenting_buffer.hpp | 2
trunk/boost/geometry/extensions/algorithms/dissolve.hpp | 2
trunk/boost/geometry/extensions/algorithms/mark_spikes.hpp | 2
trunk/boost/geometry/extensions/algorithms/remove_marked.hpp | 2
trunk/boost/geometry/extensions/algorithms/remove_spikes.hpp | 2
trunk/boost/geometry/extensions/strategies/buffer.hpp | 4
trunk/boost/geometry/strategies/agnostic/hull_graham_andrew.hpp | 4
trunk/boost/geometry/strategies/agnostic/point_in_poly_oriented_winding.hpp | 2
trunk/boost/geometry/strategies/agnostic/point_in_poly_winding.hpp | 2
trunk/boost/geometry/strategies/cartesian/side_by_triangle.hpp | 18 +++++--
trunk/boost/geometry/strategies/intersection.hpp | 2
trunk/boost/geometry/strategies/side.hpp | 13 +++++
trunk/boost/geometry/strategies/spherical/ssf.hpp | 20 +++++---
trunk/libs/geometry/test/algorithms/overlay/ccw_traverse.cpp | 2
trunk/libs/geometry/test/algorithms/overlay/traverse.cpp | 2
trunk/libs/geometry/test/algorithms/overlay/traverse_gmp.cpp | 2
trunk/libs/geometry/test/strategies/Jamfile.v2 | 1
trunk/libs/geometry/test/strategies/spherical_side.cpp | 85 +++++++++++++++++++++------------------
trunk/libs/geometry/test_extensions/algorithms/is_convex.cpp | 2
19 files changed, 98 insertions(+), 71 deletions(-)
Modified: trunk/boost/geometry/extensions/algorithms/buffer/segmenting_buffer.hpp
==============================================================================
--- trunk/boost/geometry/extensions/algorithms/buffer/segmenting_buffer.hpp (original)
+++ trunk/boost/geometry/extensions/algorithms/buffer/segmenting_buffer.hpp 2011-05-29 16:46:22 EDT (Sun, 29 May 2011)
@@ -94,7 +94,7 @@
typedef coordinate_type distance_type; // TODO promote to FP
typedef segment<point_type const> segment_type;
typedef typename geometry::ring_type<GeometryOut>::type ring_type;
- typedef typename strategy_side<typename cs_tag<point_type>::type>::type side;
+ typedef typename strategy::side::services::default_strategy<typename cs_tag<point_type>::type>::type side;
typedef typename boost::range_iterator<Range const>::type iterator_type;
Modified: trunk/boost/geometry/extensions/algorithms/dissolve.hpp
==============================================================================
--- trunk/boost/geometry/extensions/algorithms/dissolve.hpp (original)
+++ trunk/boost/geometry/extensions/algorithms/dissolve.hpp 2011-05-29 16:46:22 EDT (Sun, 29 May 2011)
@@ -76,7 +76,7 @@
out_vector rings;
// Enrich the turns
- typedef typename strategy_side
+ typedef typename strategy::side::services::default_strategy
<
typename cs_tag<Geometry>::type
>::type side_strategy_type;
Modified: trunk/boost/geometry/extensions/algorithms/mark_spikes.hpp
==============================================================================
--- trunk/boost/geometry/extensions/algorithms/mark_spikes.hpp (original)
+++ trunk/boost/geometry/extensions/algorithms/mark_spikes.hpp 2011-05-29 16:46:22 EDT (Sun, 29 May 2011)
@@ -159,7 +159,7 @@
{
typedef typename point_type<Range>::type point_type;
- typedef typename strategy_side
+ typedef typename strategy::side::services::default_strategy
<
typename cs_tag<Range>::type
>::type side_strategy_type;
Modified: trunk/boost/geometry/extensions/algorithms/remove_marked.hpp
==============================================================================
--- trunk/boost/geometry/extensions/algorithms/remove_marked.hpp (original)
+++ trunk/boost/geometry/extensions/algorithms/remove_marked.hpp 2011-05-29 16:46:22 EDT (Sun, 29 May 2011)
@@ -42,7 +42,7 @@
template <typename Range, typename MarkMap>
struct range_remove_marked
{
- typedef typename strategy_side
+ typedef typename strategy::side::services::default_strategy
<
typename cs_tag<Range>::type
>::type side_strategy_type;
Modified: trunk/boost/geometry/extensions/algorithms/remove_spikes.hpp
==============================================================================
--- trunk/boost/geometry/extensions/algorithms/remove_spikes.hpp (original)
+++ trunk/boost/geometry/extensions/algorithms/remove_spikes.hpp 2011-05-29 16:46:22 EDT (Sun, 29 May 2011)
@@ -64,7 +64,7 @@
template <typename Range, typename Policy>
struct range_remove_spikes
{
- typedef typename strategy_side
+ typedef typename strategy::side::services::default_strategy
<
typename cs_tag<Range>::type
>::type side_strategy_type;
Modified: trunk/boost/geometry/extensions/strategies/buffer.hpp
==============================================================================
--- trunk/boost/geometry/extensions/strategies/buffer.hpp (original)
+++ trunk/boost/geometry/extensions/strategies/buffer.hpp 2011-05-29 16:46:22 EDT (Sun, 29 May 2011)
@@ -116,7 +116,7 @@
{
#endif
- typedef typename strategy_side<typename cs_tag<PointIn>::type>::type side;
+ typedef typename strategy::side::services::default_strategy<typename cs_tag<PointIn>::type>::type side;
typedef typename coordinate_type<PointIn>::type coordinate_type;
@@ -252,7 +252,7 @@
{}
#endif
- typedef typename strategy_side<typename cs_tag<PointIn>::type>::type side;
+ typedef typename strategy::side::services::default_strategy<typename cs_tag<PointIn>::type>::type side;
typedef typename coordinate_type<PointOut>::type coordinate_type;
int m_max_level;
Modified: trunk/boost/geometry/strategies/agnostic/hull_graham_andrew.hpp
==============================================================================
--- trunk/boost/geometry/strategies/agnostic/hull_graham_andrew.hpp (original)
+++ trunk/boost/geometry/strategies/agnostic/hull_graham_andrew.hpp 2011-05-29 16:46:22 EDT (Sun, 29 May 2011)
@@ -301,7 +301,7 @@
range_type,
range_iterator,
container_type,
- typename strategy_side<cs_tag>::type
+ typename strategy::side::services::default_strategy<cs_tag>::type
> assigner(extremes.left, extremes.right);
geometry::detail::for_each_range(geometry, assigner);
@@ -358,7 +358,7 @@
template <int Factor>
static inline void add_to_hull(point_type const& p, container_type& output)
{
- typedef typename strategy_side<cs_tag>::type side;
+ typedef typename strategy::side::services::default_strategy<cs_tag>::type side;
output.push_back(p);
register std::size_t output_size = output.size();
Modified: trunk/boost/geometry/strategies/agnostic/point_in_poly_oriented_winding.hpp
==============================================================================
--- trunk/boost/geometry/strategies/agnostic/point_in_poly_oriented_winding.hpp (original)
+++ trunk/boost/geometry/strategies/agnostic/point_in_poly_oriented_winding.hpp 2011-05-29 16:46:22 EDT (Sun, 29 May 2011)
@@ -62,7 +62,7 @@
>::type calculation_type;
- typedef typename strategy_side
+ typedef typename strategy::side::services::default_strategy
<
typename cs_tag<Point>::type
>::type strategy_side_type;
Modified: trunk/boost/geometry/strategies/agnostic/point_in_poly_winding.hpp
==============================================================================
--- trunk/boost/geometry/strategies/agnostic/point_in_poly_winding.hpp (original)
+++ trunk/boost/geometry/strategies/agnostic/point_in_poly_winding.hpp 2011-05-29 16:46:22 EDT (Sun, 29 May 2011)
@@ -58,7 +58,7 @@
>::type calculation_type;
- typedef typename strategy_side
+ typedef typename strategy::side::services::default_strategy
<
typename cs_tag<Point>::type
>::type strategy_side_type;
Modified: trunk/boost/geometry/strategies/cartesian/side_by_triangle.hpp
==============================================================================
--- trunk/boost/geometry/strategies/cartesian/side_by_triangle.hpp (original)
+++ trunk/boost/geometry/strategies/cartesian/side_by_triangle.hpp 2011-05-29 16:46:22 EDT (Sun, 29 May 2011)
@@ -91,22 +91,28 @@
promoted_type const s = dx * dpy - dy * dpx;
promoted_type zero = promoted_type();
- return math::equals(s, zero) ? 0 : s > zero ? 1 : -1;
- //return s > 0 ? 1 : s < 0 ? -1 : 0;
+ return math::equals(s, zero) ? 0
+ : s > zero ? 1
+ : -1;
}
};
-}} // namespace strategy::side
-
#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
+namespace services
+{
+
template <typename CalculationType>
-struct strategy_side<cartesian_tag, CalculationType>
+struct default_strategy<cartesian_tag, CalculationType>
{
- typedef strategy::side::side_by_triangle<CalculationType> type;
+ typedef side_by_triangle<CalculationType> type;
};
+
+}
#endif
+}} // namespace strategy::side
+
}} // namespace boost::geometry
Modified: trunk/boost/geometry/strategies/intersection.hpp
==============================================================================
--- trunk/boost/geometry/strategies/intersection.hpp (original)
+++ trunk/boost/geometry/strategies/intersection.hpp 2011-05-29 16:46:22 EDT (Sun, 29 May 2011)
@@ -77,7 +77,7 @@
CalculationType
> segment_intersection_strategy_type;
- typedef typename strategy_side
+ typedef typename strategy::side::services::default_strategy
<
Tag,
CalculationType
Modified: trunk/boost/geometry/strategies/side.hpp
==============================================================================
--- trunk/boost/geometry/strategies/side.hpp (original)
+++ trunk/boost/geometry/strategies/side.hpp 2011-05-29 16:46:22 EDT (Sun, 29 May 2011)
@@ -21,6 +21,11 @@
namespace boost { namespace geometry
{
+namespace strategy { namespace side
+{
+
+namespace services
+{
/*!
\brief Traits class binding a side determination strategy to a coordinate system
@@ -29,12 +34,18 @@
\tparam CalculationType \tparam_calculation
*/
template <typename Tag, typename CalculationType = void>
-struct strategy_side
+struct default_strategy
{
typedef strategy::not_implemented type;
};
+} // namespace services
+
+
+}} // namespace strategy::side
+
+
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_STRATEGIES_SIDE_HPP
Modified: trunk/boost/geometry/strategies/spherical/ssf.hpp
==============================================================================
--- trunk/boost/geometry/strategies/spherical/ssf.hpp (original)
+++ trunk/boost/geometry/strategies/spherical/ssf.hpp 2011-05-29 16:46:22 EDT (Sun, 29 May 2011)
@@ -96,30 +96,34 @@
+ (c1z * c2x - c1x * c2z) * cos_delta * sin(lambda)
+ (c1x * c2y - c1y * c2x) * sin(delta);
- return dist > 0 ? 1
- : dist < 0 ? -1
+ ct zero = ct();
+ return dist > zero ? 1
+ : dist < zero ? -1
: 0;
}
};
-}} // namespace strategy::side
-
#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
+namespace services
+{
+
template <typename CalculationType>
-struct strategy_side<spherical_polar_tag, CalculationType>
+struct default_strategy<spherical_polar_tag, CalculationType>
{
- typedef strategy::side::spherical_side_formula<CalculationType> type;
+ typedef spherical_side_formula<CalculationType> type;
};
template <typename CalculationType>
-struct strategy_side<geographic_tag, CalculationType>
+struct default_strategy<geographic_tag, CalculationType>
{
- typedef strategy::side::spherical_side_formula<CalculationType> type;
+ typedef spherical_side_formula<CalculationType> type;
};
+}
#endif
+}} // namespace strategy::side
}} // namespace boost::geometry
Modified: trunk/libs/geometry/test/algorithms/overlay/ccw_traverse.cpp
==============================================================================
--- trunk/libs/geometry/test/algorithms/overlay/ccw_traverse.cpp (original)
+++ trunk/libs/geometry/test/algorithms/overlay/ccw_traverse.cpp 2011-05-29 16:46:22 EDT (Sun, 29 May 2011)
@@ -35,7 +35,7 @@
inline typename bg::coordinate_type<Geometry1>::type intersect(Geometry1 const& g1, Geometry2 const& g2, std::string const& name,
bg::detail::overlay::operation_type op)
{
- typedef typename bg::strategy_side
+ typedef typename bg::strategy::side::services::default_strategy
<
typename bg::cs_tag<Geometry1>::type
>::type side_strategy_type;
Modified: trunk/libs/geometry/test/algorithms/overlay/traverse.cpp
==============================================================================
--- trunk/libs/geometry/test/algorithms/overlay/traverse.cpp (original)
+++ trunk/libs/geometry/test/algorithms/overlay/traverse.cpp 2011-05-29 16:46:22 EDT (Sun, 29 May 2011)
@@ -134,7 +134,7 @@
//std::cout << bg::area(g1) << " " << bg::area(g2) << std::endl;
#endif
- typedef typename bg::strategy_side
+ typedef typename bg::strategy::side::services::default_strategy
<
typename bg::cs_tag<G1>::type
>::type side_strategy_type;
Modified: trunk/libs/geometry/test/algorithms/overlay/traverse_gmp.cpp
==============================================================================
--- trunk/libs/geometry/test/algorithms/overlay/traverse_gmp.cpp (original)
+++ trunk/libs/geometry/test/algorithms/overlay/traverse_gmp.cpp 2011-05-29 16:46:22 EDT (Sun, 29 May 2011)
@@ -62,7 +62,7 @@
typedef std::vector<ip> ip_vector;
ip_vector ips;
- typedef typename bg::strategy_side
+ typedef typename bg::strategy::side::services::default_strategy
<
typename bg::cs_tag<G1>::type
>::type strategy_type;
Modified: trunk/libs/geometry/test/strategies/Jamfile.v2
==============================================================================
--- trunk/libs/geometry/test/strategies/Jamfile.v2 (original)
+++ trunk/libs/geometry/test/strategies/Jamfile.v2 2011-05-29 16:46:22 EDT (Sun, 29 May 2011)
@@ -14,6 +14,7 @@
[ run haversine.cpp ]
[ run projected_point.cpp ]
[ run pythagoras.cpp ]
+ [ run spherical_side.cpp ]
[ run transformer.cpp ]
[ run within.cpp ]
;
Modified: trunk/libs/geometry/test/strategies/spherical_side.cpp
==============================================================================
--- trunk/libs/geometry/test/strategies/spherical_side.cpp (original)
+++ trunk/libs/geometry/test/strategies/spherical_side.cpp 2011-05-29 16:46:22 EDT (Sun, 29 May 2011)
@@ -15,7 +15,7 @@
#include <boost/geometry/strategies/spherical/side_by_cross_track.hpp>
-#include <boost/geometry/strategies/spherical/side_via_plane.hpp>
+//#include <boost/geometry/strategies/spherical/side_via_plane.hpp>
#include <boost/geometry/strategies/spherical/ssf.hpp>
#include <boost/geometry/strategies/cartesian/side_by_triangle.hpp>
@@ -48,23 +48,22 @@
template <typename Point>
void test_side1(std::string const& case_id, Point const& p1, Point const& p2, Point const& p3,
- int expected)
+ int expected, int expected_cartesian)
{
- std::cout << case_id << ": ";
+ // std::cout << case_id << ": ";
//int s = bg::strategy::side::side_via_plane<>::apply(p1, p2, p3);
- int side1 = bg::strategy::side::spherical_side_formula<>::apply(p1, p2, p3);
- int side2 = bg::strategy::side::side_via_plane<>::apply(p1, p2, p3);
- int side3 = bg::strategy::side::side_by_cross_track<>::apply(p1, p2, p3);
+ int side_ssf = bg::strategy::side::spherical_side_formula<>::apply(p1, p2, p3);
+ //int side2 = bg::strategy::side::side_via_plane<>::apply(p1, p2, p3);
+ int side_ct = bg::strategy::side::side_by_cross_track<>::apply(p1, p2, p3);
+
+ typedef bg::strategy::side::services::default_strategy<bg::cartesian_tag>::type cartesian_strategy;
+ int side_cart = cartesian_strategy::apply(p1, p2, p3);
- typedef bg::strategy_side<bg::spherical_equatorial_tag>::type spherical_strategy;
- //int side4 = spherical_strategy::apply(p1, p2, p3);
- typedef bg::strategy_side<bg::cartesian_tag>::type cartesian_strategy;
- int side5 = cartesian_strategy::apply(p1, p2, p3);
-
-
- //BOOST_CHECK_EQUAL(side1, expected);
- //BOOST_CHECK_EQUAL(side2, expected);
+ BOOST_CHECK_EQUAL(side_ssf, expected);
+ BOOST_CHECK_EQUAL(side_ct, expected);
+ BOOST_CHECK_EQUAL(side_cart, expected_cartesian);
+ /*
std::cout
<< "exp: " << side_char(expected)
<< " ssf: " << side_char(side1)
@@ -73,14 +72,19 @@
//<< " def: " << side_char(side4)
<< " cart: " << side_char(side5)
<< std::endl;
+ */
}
template <typename Point>
void test_side(std::string const& case_id, Point const& p1, Point const& p2, Point const& p3,
- int expected)
+ int expected, int expected_cartesian = -999)
{
- test_side1(case_id, p1, p2, p3, expected);
- //test_side1(case_id, p2, p1, p3, -expected);
+ if (expected_cartesian == -999)
+ {
+ expected_cartesian = expected;
+ }
+ test_side1(case_id, p1, p2, p3, expected, expected_cartesian);
+ test_side1(case_id, p2, p1, p3, -expected, -expected_cartesian);
}
@@ -94,7 +98,7 @@
Point paris(2.0, 48.0);
Point milan(7.0, 45.0);
- goto wrong;
+ //goto wrong;
test_side<Point>("bp-m", barcelona, paris, milan, -1);
test_side<Point>("bm-p", barcelona, milan, paris, 1);
@@ -103,35 +107,36 @@
test_side<Point>("am-p", amsterdam, milan, paris, -1);
test_side<Point>("pm-a", paris, milan, amsterdam, 1);
-wrong:
- Point blog_p1(10.0, 30.0);
- Point blog_p2(50.0, 50.0);
- Point blog_p(30.0, 39.0);
- test_side<Point>("blog1", blog_p1, blog_p2, blog_p, 1);
-return;
+ // http://www.gcmap.com/mapui?P=30N+10E-50N+50E,39N+30E
+ Point gcmap_p1(10.0, 30.0);
+ Point gcmap_p2(50.0, 50.0);
+ test_side<Point>("blog1", gcmap_p1, gcmap_p2, Point(30.0, 41.0), -1, 1);
+ test_side<Point>("blog1", gcmap_p1, gcmap_p2, Point(30.0, 42.0), -1, 1);
+ test_side<Point>("blog1", gcmap_p1, gcmap_p2, Point(30.0, 43.0), -1, 1);
+ test_side<Point>("blog1", gcmap_p1, gcmap_p2, Point(30.0, 44.0), 1);
// http://www.gcmap.com/mapui?P=50N+80E-60N+50W,65N+30E
- //Point blog_np1(80.0, 50.0);
- //Point blog_np2(-50.0, 60.0);
+ Point gcmap_np1(80.0, 50.0);
+ Point gcmap_np2(-50.0, 60.0);
// http://www.gcmap.com/mapui?P=50N+140E-60N+10E,65N+30E
- Point blog_np1(140.0, 50.0);
- Point blog_np2(10.0, 60.0);
- Point blog_np(30.0, 65.0);
- //test_side<Point>(blog_np1, blog_np2, blog_np, 1);
- test_side<Point>("40", blog_np1, blog_np2, Point(30.0, 40.0), 1);
- test_side<Point>("45", blog_np1, blog_np2, Point(30.0, 45.0), 1);
- test_side<Point>("50", blog_np1, blog_np2, Point(30.0, 50.0), 1);
- test_side<Point>("55", blog_np1, blog_np2, Point(30.0, 55.0), 1);
- test_side<Point>("60", blog_np1, blog_np2, Point(30.0, 60.0), 1);
- test_side<Point>("65", blog_np1, blog_np2, Point(30.0, 65.0), 1);
- test_side<Point>("70", blog_np1, blog_np2, Point(30.0, 70.0), 1);
- test_side<Point>("75", blog_np1, blog_np2, Point(30.0, 75.0), 1);
+ //Point gcmap_np1(140.0, 50.0);
+ //Point gcmap_np2(10.0, 60.0);
+ //test_side<Point>(gcmap_np1, gcmap_np2, gcmap_np, 1);
+ test_side<Point>("40", gcmap_np1, gcmap_np2, Point(30.0, 60.0), 1, -1);
+ test_side<Point>("45", gcmap_np1, gcmap_np2, Point(30.0, 65.0), 1, -1);
+ test_side<Point>("70", gcmap_np1, gcmap_np2, Point(30.0, 70.0), 1, -1);
+ test_side<Point>("75", gcmap_np1, gcmap_np2, Point(30.0, 75.0), -1);
}
int test_main(int, char* [])
{
- //test_all<bg::model::point<int, 2, bg::cs::spherical<bg::degree> > >();
- test_all<bg::model::point<double, 2, bg::cs::spherical<bg::degree> > >();
+ test_all<bg::model::point<int, 2, bg::cs::spherical<bg::degree> > >();
+ test_all<bg::model::point<double, 2, bg::cs::spherical_equatorial<bg::degree> > >();
+
+#if defined(HAVE_TTMATH)
+ typedef ttmath::Big<1,4> tt;
+ test_all<bg::model::point<tt, 2, bg::cs::spherical<bg::degree> > >();
+#endif
return 0;
}
Modified: trunk/libs/geometry/test_extensions/algorithms/is_convex.cpp
==============================================================================
--- trunk/libs/geometry/test_extensions/algorithms/is_convex.cpp (original)
+++ trunk/libs/geometry/test_extensions/algorithms/is_convex.cpp 2011-05-29 16:46:22 EDT (Sun, 29 May 2011)
@@ -46,7 +46,7 @@
bg::read_wkt(wkt, geometry);
typedef typename bg::point_type<Geometry>::type P;
- typename bg::strategy_side
+ typename bg::strategy::side::services::default_strategy
<
typename bg::cs_tag<P>::type
>::type side;
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk