diff --git a/include/boost/geometry/algorithms/buffer.hpp b/include/boost/geometry/algorithms/buffer.hpp index eb502c70a..7447ffd57 100644 --- a/include/boost/geometry/algorithms/buffer.hpp +++ b/include/boost/geometry/algorithms/buffer.hpp @@ -58,7 +58,7 @@ inline void buffer_box(BoxIn const& box_in, T const& distance, BoxOut& box_out) static const std::size_t N = dimension::value; box_loop::apply(box_in, -distance, box_out); - box_loop::apply(box_in, +distance, box_out); + box_loop::apply(box_in, distance, box_out); } diff --git a/include/boost/geometry/algorithms/centroid.hpp b/include/boost/geometry/algorithms/centroid.hpp index 33d4e7f04..2b44c3640 100644 --- a/include/boost/geometry/algorithms/centroid.hpp +++ b/include/boost/geometry/algorithms/centroid.hpp @@ -230,18 +230,22 @@ struct centroid_linestring typedef typename boost::range_iterator::type point_iterator_type; typedef segment_returning_iterator segment_iterator; - double length = double(); - std::pair average_sum; + typedef geometry::distance_result::type distance_type; + distance_type length = distance_type(); + std::pair average_sum; segment_iterator it(boost::begin(line), boost::end(line)); segment_iterator end(boost::end(line)); while (it != end) { - double const d = geometry::distance(it->first, it->second); + + distance_type const d = geometry::distance(it->first, it->second); length += d; - double const mx = (get<0>(it->first) + get<0>(it->second)) / 2; - double const my = (get<1>(it->first) + get<1>(it->second)) / 2; + distance_type two(2); + + distance_type const mx = (get<0>(it->first) + get<0>(it->second)) / two; + distance_type const my = (get<1>(it->first) + get<1>(it->second)) / two; average_sum.first += d * mx; average_sum.second += d * my; ++it; diff --git a/include/boost/geometry/algorithms/difference.hpp b/include/boost/geometry/algorithms/difference.hpp index 43e74a406..e2aafdcbf 100644 --- a/include/boost/geometry/algorithms/difference.hpp +++ b/include/boost/geometry/algorithms/difference.hpp @@ -20,7 +20,7 @@ namespace boost { namespace geometry \brief_calc2{difference} \brief_strategy \ingroup difference \details \details_calc2{difference_inserter, spatial set theoretic difference} - \brief_strategy. details_inserter{difference} + \brief_strategy. \details_inserter{difference} \tparam GeometryOut output geometry type, must be specified \tparam Geometry1 \tparam_geometry \tparam Geometry2 \tparam_geometry @@ -60,7 +60,7 @@ inline OutputIterator difference_inserter(Geometry1 const& geometry1, \brief_calc2{difference} \ingroup difference \details \details_calc2{difference_inserter, spatial set theoretic difference}. - details_inserter{difference} + \details_inserter{difference} \tparam GeometryOut output geometry type, must be specified \tparam Geometry1 \tparam_geometry \tparam Geometry2 \tparam_geometry @@ -70,11 +70,7 @@ inline OutputIterator difference_inserter(Geometry1 const& geometry1, \param out \param_out{difference} \return \return_out -\qbk{[include reference/algorithms/difference.qbk]} -\qbk{ -[heading Example] -[difference] [difference_output] -} +\qbk{[include reference/algorithms/difference_inserter.qbk]} */ template < @@ -109,17 +105,12 @@ inline OutputIterator difference_inserter(Geometry1 const& geometry1, \details \details_calc2{difference, spatial set theoretic difference}. \tparam Geometry1 \tparam_geometry \tparam Geometry2 \tparam_geometry -\tparam Collection output collection, either a multi-geometry, - or a std::vector / std::deque etc +\tparam Collection \tparam_output_collection \param geometry1 \param_geometry \param geometry2 \param_geometry \param output_collection the output collection \qbk{[include reference/algorithms/difference.qbk]} -\qbk{ -[heading Example] -[difference_inserter] [difference_inserter_output] -} */ template < @@ -142,8 +133,6 @@ inline void difference(Geometry1 const& geometry1, } - - }} // namespace boost::geometry diff --git a/include/boost/geometry/algorithms/sym_difference.hpp b/include/boost/geometry/algorithms/sym_difference.hpp index e9b2aad99..58d0a1e01 100644 --- a/include/boost/geometry/algorithms/sym_difference.hpp +++ b/include/boost/geometry/algorithms/sym_difference.hpp @@ -22,7 +22,7 @@ namespace boost { namespace geometry \brief \brief_calc2{symmetric difference} \brief_strategy \ingroup sym_difference \details \details_calc2{symmetric difference, spatial set theoretic symmetric difference (XOR)} - \brief_strategy. details_inserter{sym_difference} + \brief_strategy. \details_inserter{sym_difference} \tparam GeometryOut output geometry type, must be specified \tparam Geometry1 \tparam_geometry \tparam Geometry2 \tparam_geometry diff --git a/include/boost/geometry/extensions/contrib/ttmath_stub.hpp b/include/boost/geometry/extensions/contrib/ttmath_stub.hpp index ee1580920..d0b3ef03f 100644 --- a/include/boost/geometry/extensions/contrib/ttmath_stub.hpp +++ b/include/boost/geometry/extensions/contrib/ttmath_stub.hpp @@ -64,6 +64,12 @@ namespace ttmath return ATan(v); } + template + inline Big acos(Big const& v) + { + return ACos(v); + } + template inline Big atan2(Big const& y, Big const& x) diff --git a/include/boost/geometry/strategies/strategy_transform.hpp b/include/boost/geometry/strategies/strategy_transform.hpp index 612f1cc2c..070141028 100644 --- a/include/boost/geometry/strategies/strategy_transform.hpp +++ b/include/boost/geometry/strategies/strategy_transform.hpp @@ -41,7 +41,8 @@ template > struct transform_coordinates { - static inline void transform(Src const& source, Dst& dest, double value) + template + static inline void transform(Src const& source, Dst& dest, T value) { typedef typename select_coordinate_type::type coordinate_type; @@ -59,7 +60,8 @@ template > struct transform_coordinates { - static inline void transform(Src const& source, Dst& dest, double value) + template + static inline void transform(Src const& source, Dst& dest, T value) { } }; @@ -147,22 +149,31 @@ namespace detail { /// Helper function for conversion, phi/theta are in radians - template - inline void spherical_to_cartesian(double phi, double theta, double r, P& p) + template + inline void spherical_to_cartesian(T phi, T theta, R r, P& p) { assert_dimension(); // http://en.wikipedia.org/wiki/List_of_canonical_coordinate_transformations#From_spherical_coordinates // Phi = first, theta is second, r is third, see documentation on cs::spherical - double const sin_theta = sin(theta); - set<0>(p, r * sin_theta * cos(phi)); - set<1>(p, r * sin_theta * sin(phi)); - set<2>(p, r * cos(theta)); + + // (calculations are splitted to implement ttmath) + + T r_sin_theta = r; + r_sin_theta *= sin(theta); + + set<0>(p, r_sin_theta * cos(phi)); + set<1>(p, r_sin_theta * sin(phi)); + + T r_cos_theta = r; + r_cos_theta *= cos(theta); + + set<2>(p, r_cos_theta); } /// Helper function for conversion - template - inline bool cartesian_to_spherical2(double x, double y, double z, P& p) + template + inline bool cartesian_to_spherical2(T x, T y, T z, P& p) { assert_dimension(); @@ -170,10 +181,10 @@ namespace detail #if defined(BOOST_GEOMETRY_TRANSFORM_CHECK_UNIT_SPHERE) // TODO: MAYBE ONLY IF TO BE CHECKED? - double const r = /*sqrt not necessary, sqrt(1)=1*/ (x * x + y * y + z * z); + T const r = /*sqrt not necessary, sqrt(1)=1*/ (x * x + y * y + z * z); // Unit sphere, so r should be 1 - if (geometry::math::abs(r - 1.0) > double(1e-6)) + if (geometry::math::abs(r - 1.0) > T(1e-6)) { return false; } @@ -185,13 +196,13 @@ namespace detail return true; } - template - inline bool cartesian_to_spherical3(double x, double y, double z, P& p) + template + inline bool cartesian_to_spherical3(T x, T y, T z, P& p) { assert_dimension(); // http://en.wikipedia.org/wiki/List_of_canonical_coordinate_transformations#From_Cartesian_coordinates - double const r = sqrt(x * x + y * y + z * z); + T const r = sqrt(x * x + y * y + z * z); set<2>(p, r); set_from_radian<0>(p, atan2(y, x)); if (r > 0.0)