Merge branch 'develop'

This commit is contained in:
Vissarion Fisikopoulos 2025-03-18 15:37:44 +02:00
commit 2ef239ce3b
29 changed files with 377 additions and 131 deletions

View File

@ -21,6 +21,7 @@
#include <cstddef> #include <cstddef>
#include <vector> #include <vector>
#include <boost/core/ignore_unused.hpp>
#include <boost/range/begin.hpp> #include <boost/range/begin.hpp>
#include <boost/range/end.hpp> #include <boost/range/end.hpp>
#include <boost/range/value_type.hpp> #include <boost/range/value_type.hpp>
@ -66,6 +67,8 @@ inline void display(MetaTurn const& meta_turn, const char* reason = "")
//<< " -> " << op_index //<< " -> " << op_index
<< " " << reason << " " << reason
<< std::endl; << std::endl;
#else
boost::ignore_unused(meta_turn, reason);
#endif #endif
} }

View File

@ -189,8 +189,7 @@ private:
public: public:
template <typename T> template <typename T>
static inline return_type apply(this_strategy const& strategy, static inline return_type apply(this_strategy const& , T const& distance)
T const& distance)
{ {
return static_cast<return_type>(distance); return static_cast<return_type>(distance);
} }

View File

@ -1,7 +1,8 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2015-2020, Oracle and/or its affiliates. // Copyright (c) 2015-2025, Oracle and/or its affiliates.
// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
@ -123,7 +124,7 @@ struct assign_loop<1, DimensionCount>
template <typename PointIn, typename PointOut, bool IsEquatorial = true> template <typename PointIn, typename PointOut, bool IsEquatorial = true>
struct normalize_point struct normalize_point
{ {
static inline void apply(PointIn const& point_in, PointOut& point_out) static inline void apply(PointIn const& point_in, PointOut& point_out, bool exact = true)
{ {
using in_coordinate_type = coordinate_type_t<PointIn>; using in_coordinate_type = coordinate_type_t<PointIn>;
@ -135,7 +136,7 @@ struct normalize_point
typename geometry::detail::cs_angular_units<PointIn>::type, typename geometry::detail::cs_angular_units<PointIn>::type,
IsEquatorial, IsEquatorial,
in_coordinate_type in_coordinate_type
>(longitude, latitude); >(longitude, latitude, exact);
assign_loop assign_loop
< <
@ -221,13 +222,13 @@ struct cartesian_box
struct spherical_point struct spherical_point
{ {
template <typename PointIn, typename PointOut> template <typename PointIn, typename PointOut>
static inline void apply(PointIn const& point_in, PointOut& point_out) static inline void apply(PointIn const& point_in, PointOut& point_out, bool exact = true)
{ {
detail::normalize_point detail::normalize_point
< <
PointIn, PointOut, PointIn, PointOut,
(! std::is_same<cs_tag_t<PointIn>, spherical_polar_tag>::value) (! std::is_same<cs_tag_t<PointIn>, spherical_polar_tag>::value)
>::apply(point_in, point_out); >::apply(point_in, point_out, exact);
} }
}; };

View File

@ -5,11 +5,12 @@
// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. // Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
// Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland // Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland
// This file was modified by Oracle on 2013-2020. // This file was modified by Oracle on 2013-2025.
// Modifications copyright (c) 2013-2020, Oracle and/or its affiliates. // Modifications copyright (c) 2013-2025, Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
@ -67,13 +68,14 @@ private:
{ {
static inline bool apply(Point1 const& point1, Point2 const& point2) static inline bool apply(Point1 const& point1, Point2 const& point2)
{ {
typedef typename helper_geometry<Point1>::type helper_point_type1; using helper_point_type1 = typename helper_geometry<Point1>::type;
typedef typename helper_geometry<Point2>::type helper_point_type2; using helper_point_type2 = typename helper_geometry<Point2>::type;
helper_point_type1 point1_normalized; helper_point_type1 point1_normalized;
strategy::normalize::spherical_point::apply(point1, point1_normalized); bool const exact_normalized = false;
strategy::normalize::spherical_point::apply(point1, point1_normalized, exact_normalized);
helper_point_type2 point2_normalized; helper_point_type2 point2_normalized;
strategy::normalize::spherical_point::apply(point2, point2_normalized); strategy::normalize::spherical_point::apply(point2, point2_normalized, exact_normalized);
return point_point_generic return point_point_generic
< <
@ -87,11 +89,11 @@ private:
{ {
static inline bool apply(Point1 const& point1, Point2 const& point2) static inline bool apply(Point1 const& point1, Point2 const& point2)
{ {
typedef typename geometry::select_most_precise using calculation_type = typename geometry::select_most_precise
< <
typename fp_coordinate_type<Point1>::type, typename fp_coordinate_type<Point1>::type,
typename fp_coordinate_type<Point2>::type typename fp_coordinate_type<Point2>::type
>::type calculation_type; >::type;
typename helper_geometry typename helper_geometry
< <
@ -149,7 +151,7 @@ namespace services
template <typename PointLike1, typename PointLike2, typename Tag1, typename Tag2> template <typename PointLike1, typename PointLike2, typename Tag1, typename Tag2>
struct default_strategy<PointLike1, PointLike2, Tag1, Tag2, pointlike_tag, pointlike_tag, spherical_tag, spherical_tag> struct default_strategy<PointLike1, PointLike2, Tag1, Tag2, pointlike_tag, pointlike_tag, spherical_tag, spherical_tag>
{ {
typedef strategy::within::spherical_point_point type; using type = strategy::within::spherical_point_point;
}; };
} // namespace services } // namespace services
@ -166,7 +168,7 @@ namespace strategy { namespace covered_by { namespace services
template <typename PointLike1, typename PointLike2, typename Tag1, typename Tag2> template <typename PointLike1, typename PointLike2, typename Tag1, typename Tag2>
struct default_strategy<PointLike1, PointLike2, Tag1, Tag2, pointlike_tag, pointlike_tag, spherical_tag, spherical_tag> struct default_strategy<PointLike1, PointLike2, Tag1, Tag2, pointlike_tag, pointlike_tag, spherical_tag, spherical_tag>
{ {
typedef strategy::within::spherical_point_point type; using type = strategy::within::spherical_point_point;
}; };
}}} // namespace strategy::covered_by::services }}} // namespace strategy::covered_by::services

View File

@ -33,6 +33,7 @@
#include <boost/geometry/strategies/compare.hpp> #include <boost/geometry/strategies/compare.hpp>
#include <boost/geometry/strategies/side.hpp> #include <boost/geometry/strategies/side.hpp>
#include <boost/geometry/util/promote_integral.hpp>
#include <boost/geometry/util/select_calculation_type.hpp> #include <boost/geometry/util/select_calculation_type.hpp>
#include <boost/geometry/util/select_most_precise.hpp> #include <boost/geometry/util/select_most_precise.hpp>
@ -205,23 +206,29 @@ public :
template <typename P1, typename P2, typename P> template <typename P1, typename P2, typename P>
static inline int apply(P1 const& p1, P2 const& p2, P const& p) static inline int apply(P1 const& p1, P2 const& p2, P const& p)
{ {
using coor_t = typename select_calculation_type_alt<CalculationType, P1, P2, P>::type; constexpr bool are_all_integral_coordinates =
// Promote float->double, small int->int
using promoted_t = typename select_most_precise<coor_t, double>::type;
bool const are_all_integral_coordinates =
std::is_integral<coordinate_type_t<P1>>::value std::is_integral<coordinate_type_t<P1>>::value
&& std::is_integral<coordinate_type_t<P2>>::value && std::is_integral<coordinate_type_t<P2>>::value
&& std::is_integral<coordinate_type_t<P>>::value; && std::is_integral<coordinate_type_t<P>>::value;
// Promote float to double
// For integer: short -> int -> long
// For larger integers: long, long long, std::int64_t all stay as they are (on a Mac)
using coor_t = typename select_calculation_type_alt<CalculationType, P1, P2, P>::type;
using promoted_t = std::conditional_t
<
are_all_integral_coordinates,
typename promote_integral<coor_t>::type,
typename select_most_precise<coor_t, double>::type
>;
eps_policy< math::detail::equals_factor_policy<promoted_t> > epsp; eps_policy< math::detail::equals_factor_policy<promoted_t> > epsp;
promoted_t s = compute_side_value promoted_t const s = compute_side_value
< <
coor_t, promoted_t, are_all_integral_coordinates coor_t, promoted_t, are_all_integral_coordinates
>::apply(p1, p2, p, epsp); >::apply(p1, p2, p, epsp);
promoted_t const zero = promoted_t(); static promoted_t const zero = promoted_t();
return math::detail::equals_by_policy(s, zero, epsp.policy) ? 0 return math::detail::equals_by_policy(s, zero, epsp.policy) ? 0
: s > zero ? 1 : s > zero ? 1
: -1; : -1;

View File

@ -2,8 +2,9 @@
// Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland. // Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland.
// Copyright (c) 2015-2022, Oracle and/or its affiliates. // Copyright (c) 2015-2025, Oracle and/or its affiliates.
// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Contributed and/or modified by Adeel Ahmad, as part of Google Summer of Code 2018 program // Contributed and/or modified by Adeel Ahmad, as part of Google Summer of Code 2018 program
@ -151,11 +152,7 @@ struct constants_on_spheroid<CoordinateType, degree, false>
template <typename Units, typename CoordinateType> template <typename Units, typename CoordinateType>
inline CoordinateType latitude_convert_ep(CoordinateType const& lat) inline CoordinateType latitude_convert_ep(CoordinateType const& lat)
{ {
typedef math::detail::constants_on_spheroid using constants = math::detail::constants_on_spheroid<CoordinateType, Units>;
<
CoordinateType,
Units
> constants;
return constants::quarter_period() - lat; return constants::quarter_period() - lat;
} }
@ -164,31 +161,21 @@ inline CoordinateType latitude_convert_ep(CoordinateType const& lat)
template <typename Units, bool IsEquatorial, typename T> template <typename Units, bool IsEquatorial, typename T>
static bool is_latitude_pole(T const& lat) static bool is_latitude_pole(T const& lat)
{ {
typedef math::detail::constants_on_spheroid using constants = math::detail::constants_on_spheroid<T, Units>;
<
T,
Units
> constants;
return math::equals(math::abs(IsEquatorial return math::equals(math::abs(IsEquatorial
? lat ? lat
: math::latitude_convert_ep<Units>(lat)), : math::latitude_convert_ep<Units>(lat)),
constants::quarter_period()); constants::quarter_period());
} }
template <typename Units, typename T> template <typename Units, typename T>
static bool is_longitude_antimeridian(T const& lon) static bool is_longitude_antimeridian(T const& lon)
{ {
typedef math::detail::constants_on_spheroid using constants = math::detail::constants_on_spheroid<T, Units>;
<
T,
Units
> constants;
return math::equals(math::abs(lon), constants::half_period()); return math::equals(math::abs(lon), constants::half_period());
} }
@ -218,7 +205,7 @@ struct latitude_convert_if_polar<Units, false>
template <typename Units, typename CoordinateType, bool IsEquatorial = true> template <typename Units, typename CoordinateType, bool IsEquatorial = true>
class normalize_spheroidal_coordinates class normalize_spheroidal_coordinates
{ {
typedef constants_on_spheroid<CoordinateType, Units> constants; using constants = constants_on_spheroid<CoordinateType, Units>;
protected: protected:
static inline CoordinateType normalize_up(CoordinateType const& value) static inline CoordinateType normalize_up(CoordinateType const& value)
@ -236,17 +223,22 @@ protected:
} }
public: public:
static inline void apply(CoordinateType& longitude) static inline void apply(CoordinateType& longitude, bool exact = true)
{ {
// normalize longitude // normalize longitude
if (math::equals(math::abs(longitude), constants::half_period())) CoordinateType const epsilon = std::numeric_limits<float>::epsilon();
static constexpr bool is_integer = std::numeric_limits<CoordinateType>::is_integer;
if (exact || is_integer ? math::equals(math::abs(longitude), constants::half_period())
: math::abs(math::abs(longitude) - constants::half_period()) <= epsilon)
{ {
longitude = constants::half_period(); longitude = constants::half_period();
} }
else if (longitude > constants::half_period()) else if (longitude > constants::half_period())
{ {
longitude = normalize_up(longitude); longitude = normalize_up(longitude);
if (math::equals(longitude, -constants::half_period())) if (exact || is_integer ? math::equals(longitude, -constants::half_period())
: math::abs(longitude + constants::half_period()) <= epsilon)
{ {
longitude = constants::half_period(); longitude = constants::half_period();
} }
@ -259,7 +251,8 @@ public:
static inline void apply(CoordinateType& longitude, static inline void apply(CoordinateType& longitude,
CoordinateType& latitude, CoordinateType& latitude,
bool normalize_poles = true) bool normalize_poles = true,
bool exact = true)
{ {
latitude_convert_if_polar<Units, IsEquatorial>::apply(latitude); latitude_convert_if_polar<Units, IsEquatorial>::apply(latitude);
@ -288,7 +281,7 @@ public:
#endif // BOOST_GEOMETRY_NORMALIZE_LATITUDE #endif // BOOST_GEOMETRY_NORMALIZE_LATITUDE
// normalize longitude // normalize longitude
apply(longitude); apply(longitude, exact);
// finally normalize poles // finally normalize poles
if (normalize_poles) if (normalize_poles)
@ -317,7 +310,7 @@ public:
template <typename Units, typename CoordinateType> template <typename Units, typename CoordinateType>
inline void normalize_angle_loop(CoordinateType& angle) inline void normalize_angle_loop(CoordinateType& angle)
{ {
typedef constants_on_spheroid<CoordinateType, Units> constants; using constants = constants_on_spheroid<CoordinateType, Units>;
CoordinateType const pi = constants::half_period(); CoordinateType const pi = constants::half_period();
CoordinateType const two_pi = constants::period(); CoordinateType const two_pi = constants::period();
while (angle > pi) while (angle > pi)
@ -329,7 +322,7 @@ inline void normalize_angle_loop(CoordinateType& angle)
template <typename Units, typename CoordinateType> template <typename Units, typename CoordinateType>
inline void normalize_angle_cond(CoordinateType& angle) inline void normalize_angle_cond(CoordinateType& angle)
{ {
typedef constants_on_spheroid<CoordinateType, Units> constants; using constants = constants_on_spheroid<CoordinateType, Units>;
CoordinateType const pi = constants::half_period(); CoordinateType const pi = constants::half_period();
CoordinateType const two_pi = constants::period(); CoordinateType const two_pi = constants::period();
if (angle > pi) if (angle > pi)
@ -353,22 +346,24 @@ inline void normalize_angle_cond(CoordinateType& angle)
*/ */
template <typename Units, typename CoordinateType> template <typename Units, typename CoordinateType>
inline void normalize_spheroidal_coordinates(CoordinateType& longitude, inline void normalize_spheroidal_coordinates(CoordinateType& longitude,
CoordinateType& latitude) CoordinateType& latitude,
bool exact = true)
{ {
detail::normalize_spheroidal_coordinates detail::normalize_spheroidal_coordinates
< <
Units, CoordinateType Units, CoordinateType
>::apply(longitude, latitude); >::apply(longitude, latitude, true, exact);
} }
template <typename Units, bool IsEquatorial, typename CoordinateType> template <typename Units, bool IsEquatorial, typename CoordinateType>
inline void normalize_spheroidal_coordinates(CoordinateType& longitude, inline void normalize_spheroidal_coordinates(CoordinateType& longitude,
CoordinateType& latitude) CoordinateType& latitude,
bool exact = true)
{ {
detail::normalize_spheroidal_coordinates detail::normalize_spheroidal_coordinates
< <
Units, CoordinateType, IsEquatorial Units, CoordinateType, IsEquatorial
>::apply(longitude, latitude); >::apply(longitude, latitude, true, exact);
} }
/*! /*!
@ -381,12 +376,12 @@ inline void normalize_spheroidal_coordinates(CoordinateType& longitude,
\ingroup utility \ingroup utility
*/ */
template <typename Units, typename CoordinateType> template <typename Units, typename CoordinateType>
inline void normalize_longitude(CoordinateType& longitude) inline void normalize_longitude(CoordinateType& longitude, bool exact = true)
{ {
detail::normalize_spheroidal_coordinates detail::normalize_spheroidal_coordinates
< <
Units, CoordinateType Units, CoordinateType
>::apply(longitude); >::apply(longitude, exact);
} }
/*! /*!
@ -400,7 +395,7 @@ inline void normalize_longitude(CoordinateType& longitude)
template <typename Units, typename CoordinateType> template <typename Units, typename CoordinateType>
inline void normalize_azimuth(CoordinateType& angle) inline void normalize_azimuth(CoordinateType& angle)
{ {
normalize_longitude<Units, CoordinateType>(angle); math::normalize_longitude<Units, CoordinateType>(angle, true);
} }
/*! /*!
@ -435,7 +430,7 @@ inline CoordinateType longitude_distance_signed(CoordinateType const& longitude1
CoordinateType const& longitude2) CoordinateType const& longitude2)
{ {
CoordinateType diff = longitude2 - longitude1; CoordinateType diff = longitude2 - longitude1;
math::normalize_longitude<Units, CoordinateType>(diff); math::normalize_longitude<Units, CoordinateType>(diff, true);
return diff; return diff;
} }
@ -453,10 +448,7 @@ template <typename Units, typename CoordinateType>
inline CoordinateType longitude_distance_unsigned(CoordinateType const& longitude1, inline CoordinateType longitude_distance_unsigned(CoordinateType const& longitude1,
CoordinateType const& longitude2) CoordinateType const& longitude2)
{ {
typedef math::detail::constants_on_spheroid using constants = math::detail::constants_on_spheroid<CoordinateType, Units>;
<
CoordinateType, Units
> constants;
CoordinateType const c0 = 0; CoordinateType const c0 = 0;
CoordinateType diff = longitude_distance_signed<Units>(longitude1, longitude2); CoordinateType diff = longitude_distance_signed<Units>(longitude1, longitude2);

View File

@ -11,11 +11,11 @@
#ifndef BOOST_GEOMETRY_UTIL_PROMOTE_INTEGRAL_HPP #ifndef BOOST_GEOMETRY_UTIL_PROMOTE_INTEGRAL_HPP
#define BOOST_GEOMETRY_UTIL_PROMOTE_INTEGRAL_HPP #define BOOST_GEOMETRY_UTIL_PROMOTE_INTEGRAL_HPP
// For now deactivate the use of multiprecision integers // Uncommenting this macro will use Boost.Multiprecision's cpp_int<> as a last resort
// TODO: activate it later // TODO (#1380): change this to BOOST_GEOMETRY_PROMOTE_INTEGER_TO_BOOST_MULTI_PRECISION
// to be able to let users actively choose to use Boost.Multiprecision, but not enable it by default
#define BOOST_GEOMETRY_NO_MULTIPRECISION_INTEGER #define BOOST_GEOMETRY_NO_MULTIPRECISION_INTEGER
#include <climits> #include <climits>
#include <cstddef> #include <cstddef>
#include <type_traits> #include <type_traits>

View File

@ -101,16 +101,16 @@ struct coordinate_cast<rational<T> >
template <typename T1, typename T2> template <typename T1, typename T2>
struct select_most_precise<boost::rational<T1>, boost::rational<T2> > struct select_most_precise<boost::rational<T1>, boost::rational<T2> >
{ {
typedef typename boost::rational using type = typename boost::rational
< <
typename select_most_precise<T1, T2>::type typename select_most_precise<T1, T2>::type
> type; > ;
}; };
template <typename T> template <typename T>
struct select_most_precise<boost::rational<T>, double> struct select_most_precise<boost::rational<T>, double>
{ {
typedef typename boost::rational<T> type; using type = typename boost::rational<T>;
}; };
namespace util namespace util

View File

@ -14,8 +14,11 @@ foreach(item IN ITEMS
rtree_move_pack rtree_move_pack
rtree_non_cartesian rtree_non_cartesian
rtree_values rtree_values
rtree_with_strategies
#compile-fail rtree_values_invalid #compile-fail rtree_values_invalid
) )
boost_geometry_add_unit_test("index" ${item}) boost_geometry_add_unit_test("index" ${item})
endforeach() endforeach()
add_subdirectory(exceptions)
add_subdirectory(generated)
add_subdirectory(strategies)

View File

@ -9,6 +9,7 @@
build-project exceptions ; build-project exceptions ;
build-project interprocess ; build-project interprocess ;
build-project generated ; build-project generated ;
build-project strategies ;
test-suite boost-geometry-index-rtree test-suite boost-geometry-index-rtree
: :
@ -19,6 +20,5 @@ test-suite boost-geometry-index-rtree
[ run rtree_move_pack.cpp ] [ run rtree_move_pack.cpp ]
[ run rtree_non_cartesian.cpp ] [ run rtree_non_cartesian.cpp ]
[ run rtree_values.cpp ] [ run rtree_values.cpp ]
[ compile rtree_with_strategies.cpp ]
[ compile-fail rtree_values_invalid.cpp ] [ compile-fail rtree_values_invalid.cpp ]
; ;

View File

@ -0,0 +1,15 @@
# Boost.Geometry
# Copyright (c) 2025 Adam Wulkiewicz, Lodz, Poland.
# Copyright (c) 2024, Oracle and/or its affiliates.
# Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
# Use, modification and distribution is subject to the Boost Software License,
# Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
foreach(item IN ITEMS
rtree_exceptions_lin
rtree_exceptions_qua
rtree_exceptions_rst
)
boost_geometry_add_unit_test("index" ${item})
endforeach()

View File

@ -0,0 +1,7 @@
# Boost.Geometry
# Copyright (c) 2025 Adam Wulkiewicz, Lodz, Poland.
# Use, modification and distribution is subject to the Boost Software License,
# Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
add_subdirectory(b2d)

View File

@ -0,0 +1,19 @@
# Boost.Geometry
# Copyright (c) 2025 Adam Wulkiewicz, Lodz, Poland.
# Use, modification and distribution is subject to the Boost Software License,
# Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
foreach(item IN ITEMS
rtree_lin_add_b2d
rtree_lin_mod_b2d
rtree_lin_que_b2d
rtree_qua_add_b2d
rtree_qua_mod_b2d
rtree_qua_que_b2d
rtree_rst_add_b2d
rtree_rst_mod_b2d
rtree_rst_que_b2d
)
boost_geometry_add_unit_test("index" ${item})
endforeach()

View File

@ -0,0 +1,19 @@
# Boost.Geometry
# Copyright (c) 2025 Adam Wulkiewicz, Lodz, Poland.
# Use, modification and distribution is subject to the Boost Software License,
# Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
foreach(item IN ITEMS
rtree_with_strategies_b_l
rtree_with_strategies_b_q
rtree_with_strategies_b_r
rtree_with_strategies_p_l
rtree_with_strategies_p_q
rtree_with_strategies_p_r
rtree_with_strategies_s_l
rtree_with_strategies_s_q
rtree_with_strategies_s_r
)
boost_geometry_add_unit_test("index" ${item})
endforeach()

View File

@ -0,0 +1,20 @@
# Boost.Geometry Index
#
# Copyright (c) 2025 Adam Wulkiewicz, Lodz, Poland.
#
# Use, modification and distribution is subject to the Boost Software License,
# Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
test-suite boost-geometry-index-rtree-strategies
:
[ compile rtree_with_strategies_b_l.cpp ]
[ compile rtree_with_strategies_b_q.cpp ]
[ compile rtree_with_strategies_b_r.cpp ]
[ compile rtree_with_strategies_p_l.cpp ]
[ compile rtree_with_strategies_p_q.cpp ]
[ compile rtree_with_strategies_p_r.cpp ]
[ compile rtree_with_strategies_s_l.cpp ]
[ compile rtree_with_strategies_s_q.cpp ]
[ compile rtree_with_strategies_s_r.cpp ]
;

View File

@ -7,6 +7,9 @@
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt) // http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GEOMETRY_INDEX_TEST_RTREE_STRATEGIES_HPP
#define BOOST_GEOMETRY_INDEX_TEST_RTREE_STRATEGIES_HPP
#include <vector> #include <vector>
#define BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL_PREDICATES #define BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL_PREDICATES
@ -132,7 +135,7 @@ void test_strategies()
} }
template <typename Value, typename Params> template <typename Value, typename Params>
void test_params() void test_rtree()
{ {
test_strategies<Value, Params, bg::strategies::index::cartesian<>>(); test_strategies<Value, Params, bg::strategies::index::cartesian<>>();
test_strategies<Value, Params, bg::strategies::cartesian<>>(); test_strategies<Value, Params, bg::strategies::cartesian<>>();
@ -142,19 +145,4 @@ void test_params()
test_strategies<Value, Params, bg::strategies::geographic<>>(); test_strategies<Value, Params, bg::strategies::geographic<>>();
} }
template <typename Value> #endif // BOOST_GEOMETRY_INDEX_TEST_RTREE_STRATEGIES_HPP
void test_value()
{
test_params<Value, bgi::linear<4>>();
test_params<Value, bgi::quadratic<4>>();
test_params<Value, bgi::rstar<4>>();
}
int test_main(int, char* [])
{
test_value<point>();
test_value<box>();
test_value<segment>();
return 0;
}

View File

@ -0,0 +1,17 @@
// Boost.Geometry Index
// Unit Test
// Copyright (c) 2025 Adam Wulkiewicz, Lodz, Poland.
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include "rtree_with_strategies.hpp"
int test_main(int, char* [])
{
test_rtree<box, bgi::linear<4>>();
return 0;
}

View File

@ -0,0 +1,17 @@
// Boost.Geometry Index
// Unit Test
// Copyright (c) 2025 Adam Wulkiewicz, Lodz, Poland.
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include "rtree_with_strategies.hpp"
int test_main(int, char* [])
{
test_rtree<box, bgi::quadratic<4>>();
return 0;
}

View File

@ -0,0 +1,17 @@
// Boost.Geometry Index
// Unit Test
// Copyright (c) 2025 Adam Wulkiewicz, Lodz, Poland.
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include "rtree_with_strategies.hpp"
int test_main(int, char* [])
{
test_rtree<box, bgi::rstar<4>>();
return 0;
}

View File

@ -0,0 +1,17 @@
// Boost.Geometry Index
// Unit Test
// Copyright (c) 2025 Adam Wulkiewicz, Lodz, Poland.
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include "rtree_with_strategies.hpp"
int test_main(int, char* [])
{
test_rtree<point, bgi::linear<4>>();
return 0;
}

View File

@ -0,0 +1,17 @@
// Boost.Geometry Index
// Unit Test
// Copyright (c) 2025 Adam Wulkiewicz, Lodz, Poland.
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include "rtree_with_strategies.hpp"
int test_main(int, char* [])
{
test_rtree<point, bgi::quadratic<4>>();
return 0;
}

View File

@ -0,0 +1,17 @@
// Boost.Geometry Index
// Unit Test
// Copyright (c) 2025 Adam Wulkiewicz, Lodz, Poland.
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include "rtree_with_strategies.hpp"
int test_main(int, char* [])
{
test_rtree<point, bgi::rstar<4>>();
return 0;
}

View File

@ -0,0 +1,17 @@
// Boost.Geometry Index
// Unit Test
// Copyright (c) 2025 Adam Wulkiewicz, Lodz, Poland.
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include "rtree_with_strategies.hpp"
int test_main(int, char* [])
{
test_rtree<segment, bgi::linear<4>>();
return 0;
}

View File

@ -0,0 +1,17 @@
// Boost.Geometry Index
// Unit Test
// Copyright (c) 2025 Adam Wulkiewicz, Lodz, Poland.
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include "rtree_with_strategies.hpp"
int test_main(int, char* [])
{
test_rtree<segment, bgi::quadratic<4>>();
return 0;
}

View File

@ -0,0 +1,17 @@
// Boost.Geometry Index
// Unit Test
// Copyright (c) 2025 Adam Wulkiewicz, Lodz, Poland.
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include "rtree_with_strategies.hpp"
int test_main(int, char* [])
{
test_rtree<segment, bgi::rstar<4>>();
return 0;
}

View File

@ -1,7 +1,8 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// Unit test // Unit test
// Copyright (c) 2015, Oracle and/or its affiliates. // Copyright (c) 2015-2025, Oracle and/or its affiliates.
// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
// Licensed under the Boost Software License version 1.0. // Licensed under the Boost Software License version 1.0.
// http://www.boost.org/users/license.html // http://www.boost.org/users/license.html
@ -129,7 +130,7 @@ struct test_point_point_with_height
template <typename P> template <typename P>
void test_segment_segment(std::string const& header) void test_segment_segment(std::string const& header)
{ {
typedef bgm::segment<P> seg; using seg = bgm::segment<P>;
std::string const str = header + "-"; std::string const str = header + "-";
@ -158,7 +159,7 @@ void test_segment_segment(std::string const& header)
BOOST_AUTO_TEST_CASE( equals_point_point_se ) BOOST_AUTO_TEST_CASE( equals_point_point_se )
{ {
typedef bg::cs::spherical_equatorial<bg::degree> cs_type; using cs_type = bg::cs::spherical_equatorial<bg::degree>;
test_point_point<bgm::point<int, 2, cs_type> >::apply("se"); test_point_point<bgm::point<int, 2, cs_type> >::apply("se");
test_point_point<bgm::point<double, 2, cs_type> >::apply("se"); test_point_point<bgm::point<double, 2, cs_type> >::apply("se");
@ -176,9 +177,36 @@ BOOST_AUTO_TEST_CASE( equals_point_point_se )
>::apply("se"); >::apply("se");
} }
template <typename T>
std::string to_string_with_precision(const T value, const int precision = 15)
{
std::ostringstream out;
out << std::fixed << std::setprecision(precision) << value;
return out.str();
}
void test_pp_rad(double half_pi)
{
using cs_radian = bg::cs::spherical_equatorial<bg::radian>;
using P = bgm::point<double, 2, cs_radian>;
test_geometry<P, P>("ser_pp_half_pi",
"POINT(" + to_string_with_precision(-half_pi) + " 0)",
"POINT(" + to_string_with_precision(half_pi) + " 0)", true);
}
BOOST_AUTO_TEST_CASE( equals_point_point_radian )
{
test_pp_rad(bg::math::d2r<float>() * 180);
// half pi value with less accuracy
test_pp_rad(-3.14159265358979);
// convert from degrees to radians with constant from epsg 4326 (WGS84)
test_pp_rad(0.017453292519943278 * 180);
}
BOOST_AUTO_TEST_CASE( equals_point_point_with_height_se ) BOOST_AUTO_TEST_CASE( equals_point_point_with_height_se )
{ {
typedef bg::cs::spherical_equatorial<bg::degree> cs_type; using cs_type = bg::cs::spherical_equatorial<bg::degree>;
test_point_point<bgm::point<int, 3, cs_type> >::apply("seh"); test_point_point<bgm::point<int, 3, cs_type> >::apply("seh");
test_point_point<bgm::point<double, 3, cs_type> >::apply("seh"); test_point_point<bgm::point<double, 3, cs_type> >::apply("seh");
@ -198,7 +226,7 @@ BOOST_AUTO_TEST_CASE( equals_point_point_with_height_se )
BOOST_AUTO_TEST_CASE( equals_point_point_geo ) BOOST_AUTO_TEST_CASE( equals_point_point_geo )
{ {
typedef bg::cs::geographic<bg::degree> cs_type; using cs_type = bg::cs::geographic<bg::degree>;
test_point_point<bgm::point<int, 2, cs_type> >::apply("geo"); test_point_point<bgm::point<int, 2, cs_type> >::apply("geo");
test_point_point<bgm::point<double, 2, cs_type> >::apply("geo"); test_point_point<bgm::point<double, 2, cs_type> >::apply("geo");
@ -218,7 +246,7 @@ BOOST_AUTO_TEST_CASE( equals_point_point_geo )
BOOST_AUTO_TEST_CASE( equals_segment_segment_se ) BOOST_AUTO_TEST_CASE( equals_segment_segment_se )
{ {
typedef bg::cs::spherical_equatorial<bg::degree> cs_type; using cs_type = bg::cs::spherical_equatorial<bg::degree>;
test_segment_segment<bgm::point<int, 2, cs_type> >("se"); test_segment_segment<bgm::point<int, 2, cs_type> >("se");
test_segment_segment<bgm::point<double, 2, cs_type> >("se"); test_segment_segment<bgm::point<double, 2, cs_type> >("se");
@ -227,7 +255,7 @@ BOOST_AUTO_TEST_CASE( equals_segment_segment_se )
BOOST_AUTO_TEST_CASE( equals_segment_segment_geo ) BOOST_AUTO_TEST_CASE( equals_segment_segment_geo )
{ {
typedef bg::cs::geographic<bg::degree> cs_type; using cs_type = bg::cs::geographic<bg::degree>;
test_segment_segment<bgm::point<int, 2, cs_type> >("geo"); test_segment_segment<bgm::point<int, 2, cs_type> >("geo");
test_segment_segment<bgm::point<double, 2, cs_type> >("geo"); test_segment_segment<bgm::point<double, 2, cs_type> >("geo");

View File

@ -1,10 +1,11 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2014-2015, Oracle and/or its affiliates. // Copyright (c) 2014-2025, Oracle and/or its affiliates.
// Licensed under the Boost Software License version 1.0. // Licensed under the Boost Software License version 1.0.
// http://www.boost.org/users/license.html // http://www.boost.org/users/license.html
// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
#include <iostream> #include <iostream>
@ -26,11 +27,12 @@
#include <boost/geometry/geometries/multi_linestring.hpp> #include <boost/geometry/geometries/multi_linestring.hpp>
#include <boost/geometry/algorithms/difference.hpp> #include <boost/geometry/algorithms/difference.hpp>
typedef bg::model::point<double,2,bg::cs::cartesian> point_type; using point_type = bg::model::point<double,2,bg::cs::cartesian>;
typedef bg::model::segment<point_type> segment_type; using segment_type = bg::model::segment<point_type>;
typedef bg::model::linestring<point_type> linestring_type; using linestring_type = bg::model::linestring<point_type>;
typedef bg::model::multi_linestring<linestring_type> multi_linestring_type; using multi_linestring_type = bg::model::multi_linestring<linestring_type>;
using L = linestring_type;
using ML = multi_linestring_type;
//=========================================================================== //===========================================================================
@ -46,10 +48,7 @@ BOOST_AUTO_TEST_CASE( test_difference_linestring_linestring )
std::cout << std::endl; std::cout << std::endl;
#endif #endif
typedef linestring_type L; using tester = test_difference_of_geometries<L, L, ML>;
typedef multi_linestring_type ML;
typedef test_difference_of_geometries<L, L, ML> tester;
tester::apply tester::apply
(from_wkt<L>("LINESTRING(0 0,1 1,2 1,3 2)"), (from_wkt<L>("LINESTRING(0 0,1 1,2 1,3 2)"),
@ -565,10 +564,7 @@ BOOST_AUTO_TEST_CASE( test_difference_linestring_multilinestring )
std::cout << std::endl; std::cout << std::endl;
#endif #endif
typedef linestring_type L; using tester = test_difference_of_geometries<L, ML, ML>;
typedef multi_linestring_type ML;
typedef test_difference_of_geometries<L, ML, ML> tester;
// disjoint linestrings // disjoint linestrings
tester::apply tester::apply
@ -789,10 +785,7 @@ BOOST_AUTO_TEST_CASE( test_difference_multilinestring_linestring )
std::cout << std::endl; std::cout << std::endl;
#endif #endif
typedef linestring_type L; using tester = test_difference_of_geometries<ML, L, ML>;
typedef multi_linestring_type ML;
typedef test_difference_of_geometries<ML, L, ML> tester;
// disjoint linestrings // disjoint linestrings
tester::apply tester::apply
@ -874,9 +867,7 @@ BOOST_AUTO_TEST_CASE( test_difference_multilinestring_multilinestring )
std::cout << std::endl; std::cout << std::endl;
#endif #endif
typedef multi_linestring_type ML; using tester = test_difference_of_geometries<ML, ML, ML>;
typedef test_difference_of_geometries<ML, ML, ML> tester;
// disjoint linestrings // disjoint linestrings
tester::apply tester::apply
@ -1166,9 +1157,7 @@ BOOST_AUTO_TEST_CASE( test_difference_ml_ml_degenerate )
std::cout << std::endl; std::cout << std::endl;
#endif #endif
typedef multi_linestring_type ML; using tester = test_difference_of_geometries<ML, ML, ML>;
typedef test_difference_of_geometries<ML, ML, ML> tester;
// the following test cases concern linestrings with duplicate // the following test cases concern linestrings with duplicate
// points and possibly linestrings with zero length. // points and possibly linestrings with zero length.
@ -1253,9 +1242,7 @@ BOOST_AUTO_TEST_CASE( test_difference_ml_ml_spikes )
std::cout << std::endl; std::cout << std::endl;
#endif #endif
typedef multi_linestring_type ML; using tester = test_difference_of_geometries<ML, ML, ML>;
typedef test_difference_of_geometries<ML, ML, ML> tester;
// the following test cases concern linestrings with spikes // the following test cases concern linestrings with spikes
@ -1445,9 +1432,9 @@ BOOST_AUTO_TEST_CASE( test_difference_ml_ml_spikes )
BOOST_AUTO_TEST_CASE( test_difference_ls_mls_geo_rad ) BOOST_AUTO_TEST_CASE( test_difference_ls_mls_geo_rad )
{ {
typedef bg::model::point<double, 2, bg::cs::geographic<bg::radian> > pt; using pt = bg::model::point<double, 2, bg::cs::geographic<bg::radian>>;
typedef bg::model::linestring<pt> ls; using ls = bg::model::linestring<pt>;
typedef bg::model::multi_linestring<ls> mls; using mls = bg::model::multi_linestring<ls>;
bg::srs::spheroid<double> sph_wgs84(6378137.0, 6356752.3142451793); bg::srs::spheroid<double> sph_wgs84(6378137.0, 6356752.3142451793);
boost::geometry::strategy::intersection::geographic_segments<> wgs84(sph_wgs84); boost::geometry::strategy::intersection::geographic_segments<> wgs84(sph_wgs84);

View File

@ -5,6 +5,10 @@
// Copyright (c) 2008-2012 Bruno Lalande, Paris, France. // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
// Copyright (c) 2009-2012 Mateusz Loskot, London, UK. // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
// This file was modified by Oracle on 2025.
// Modifications copyright (c) 2025 Oracle and/or its affiliates.
// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
@ -46,7 +50,6 @@ template <typename T>
void test_bounds() void test_bounds()
{ {
using coordinate_t = boost::rational<T>; using coordinate_t = boost::rational<T>;
using point_t = bg::model::point<coordinate_t, 2, bg::cs::cartesian>;
auto const lowest = bg::util::bounds<coordinate_t>::lowest(); auto const lowest = bg::util::bounds<coordinate_t>::lowest();
auto const highest = bg::util::bounds<coordinate_t>::highest(); auto const highest = bg::util::bounds<coordinate_t>::highest();