Skip to content

Commit e1571b3

Browse files
authored
Merge pull request #850 from awulkiew/feature/gc
Add DynamicGeometry and GeometryCollection.
2 parents 8e3785e + c9edabe commit e1571b3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+3160
-1171
lines changed

include/boost/geometry/algorithms/append.hpp

+117-209
Large diffs are not rendered by default.

include/boost/geometry/algorithms/area.hpp

+34-32
Original file line numberDiff line numberDiff line change
@@ -19,35 +19,34 @@
1919
#ifndef BOOST_GEOMETRY_ALGORITHMS_AREA_HPP
2020
#define BOOST_GEOMETRY_ALGORITHMS_AREA_HPP
2121

22-
#include <boost/concept_check.hpp>
2322
#include <boost/core/ignore_unused.hpp>
2423
#include <boost/range/begin.hpp>
2524
#include <boost/range/end.hpp>
2625
#include <boost/range/size.hpp>
2726
#include <boost/range/value_type.hpp>
2827

29-
#include <boost/variant/apply_visitor.hpp>
30-
#include <boost/variant/static_visitor.hpp>
31-
#include <boost/variant/variant_fwd.hpp>
32-
3328
#include <boost/geometry/core/closure.hpp>
3429
#include <boost/geometry/core/exterior_ring.hpp>
3530
#include <boost/geometry/core/interior_rings.hpp>
3631
#include <boost/geometry/core/point_order.hpp>
3732
#include <boost/geometry/core/point_type.hpp>
3833
#include <boost/geometry/core/ring_type.hpp>
3934
#include <boost/geometry/core/tags.hpp>
40-
41-
#include <boost/geometry/geometries/concepts/check.hpp>
35+
#include <boost/geometry/core/visit.hpp>
4236

4337
#include <boost/geometry/algorithms/detail/calculate_null.hpp>
4438
#include <boost/geometry/algorithms/detail/calculate_sum.hpp>
4539
// #include <boost/geometry/algorithms/detail/throw_on_empty_input.hpp>
4640
#include <boost/geometry/algorithms/detail/multi_sum.hpp>
41+
#include <boost/geometry/algorithms/detail/visit.hpp>
4742

4843
#include <boost/geometry/algorithms/area_result.hpp>
4944
#include <boost/geometry/algorithms/default_area_result.hpp>
5045

46+
#include <boost/geometry/geometries/adapted/boost_variant.hpp> // For backward compatibility
47+
#include <boost/geometry/geometries/concepts/check.hpp>
48+
49+
#include <boost/geometry/strategies/area/services.hpp>
5150
#include <boost/geometry/strategies/area/cartesian.hpp>
5251
#include <boost/geometry/strategies/area/geographic.hpp>
5352
#include <boost/geometry/strategies/area/spherical.hpp>
@@ -273,10 +272,10 @@ struct area<default_strategy, false>
273272
} // namespace resolve_strategy
274273

275274

276-
namespace resolve_variant
275+
namespace resolve_dynamic
277276
{
278277

279-
template <typename Geometry>
278+
template <typename Geometry, typename Tag = typename geometry::tag<Geometry>::type>
280279
struct area
281280
{
282281
template <typename Strategy>
@@ -287,37 +286,40 @@ struct area
287286
}
288287
};
289288

290-
template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
291-
struct area<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
289+
template <typename Geometry>
290+
struct area<Geometry, dynamic_geometry_tag>
292291
{
293-
typedef boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> variant_type;
294-
295292
template <typename Strategy>
296-
struct visitor
297-
: boost::static_visitor<typename area_result<variant_type, Strategy>::type>
293+
static inline typename area_result<Geometry, Strategy>::type
294+
apply(Geometry const& geometry, Strategy const& strategy)
298295
{
299-
Strategy const& m_strategy;
300-
301-
visitor(Strategy const& strategy): m_strategy(strategy) {}
302-
303-
template <typename Geometry>
304-
typename area_result<variant_type, Strategy>::type
305-
operator()(Geometry const& geometry) const
296+
typename area_result<Geometry, Strategy>::type result = 0;
297+
traits::visit<Geometry>::apply([&](auto const& g)
306298
{
307-
return area<Geometry>::apply(geometry, m_strategy);
308-
}
309-
};
299+
result = area<util::remove_cref_t<decltype(g)>>::apply(g, strategy);
300+
}, geometry);
301+
return result;
302+
}
303+
};
310304

305+
template <typename Geometry>
306+
struct area<Geometry, geometry_collection_tag>
307+
{
311308
template <typename Strategy>
312-
static inline typename area_result<variant_type, Strategy>::type
313-
apply(variant_type const& geometry,
314-
Strategy const& strategy)
309+
static inline typename area_result<Geometry, Strategy>::type
310+
apply(Geometry const& geometry, Strategy const& strategy)
315311
{
316-
return boost::apply_visitor(visitor<Strategy>(strategy), geometry);
312+
typename area_result<Geometry, Strategy>::type result = 0;
313+
detail::visit_breadth_first([&](auto const& g)
314+
{
315+
result += area<util::remove_cref_t<decltype(g)>>::apply(g, strategy);
316+
return true;
317+
}, geometry);
318+
return result;
317319
}
318320
};
319321

320-
} // namespace resolve_variant
322+
} // namespace resolve_dynamic
321323

322324

323325
/*!
@@ -349,7 +351,7 @@ area(Geometry const& geometry)
349351

350352
// detail::throw_on_empty_input(geometry);
351353

352-
return resolve_variant::area<Geometry>::apply(geometry, default_strategy());
354+
return resolve_dynamic::area<Geometry>::apply(geometry, default_strategy());
353355
}
354356

355357
/*!
@@ -385,7 +387,7 @@ area(Geometry const& geometry, Strategy const& strategy)
385387

386388
// detail::throw_on_empty_input(geometry);
387389

388-
return resolve_variant::area<Geometry>::apply(geometry, strategy);
390+
return resolve_dynamic::area<Geometry>::apply(geometry, strategy);
389391
}
390392

391393

include/boost/geometry/algorithms/area_result.hpp

+16-49
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,13 @@
1616

1717
#include <type_traits>
1818

19+
#include <boost/geometry/algorithms/detail/select_geometry_type.hpp>
20+
1921
#include <boost/geometry/core/coordinate_type.hpp>
2022
#include <boost/geometry/core/cs.hpp>
23+
#include <boost/geometry/core/geometry_types.hpp>
24+
#include <boost/geometry/core/tag.hpp>
25+
#include <boost/geometry/core/tags.hpp>
2126

2227
#include <boost/geometry/strategies/area/services.hpp>
2328
#include <boost/geometry/strategies/default_strategy.hpp>
@@ -27,9 +32,6 @@
2732
#include <boost/geometry/util/sequence.hpp>
2833
#include <boost/geometry/util/type_traits.hpp>
2934

30-
#include <boost/variant/variant_fwd.hpp>
31-
32-
3335
namespace boost { namespace geometry
3436
{
3537

@@ -58,11 +60,7 @@ struct area_result<Geometry, Strategy, false>
5860
};
5961

6062

61-
template
62-
<
63-
typename Geometry,
64-
bool IsGeometry = util::is_geometry<Geometry>::value
65-
>
63+
template <typename Geometry>
6664
struct default_area_result
6765
: area_result
6866
<
@@ -74,37 +72,16 @@ struct default_area_result
7472
>
7573
{};
7674

77-
// Workaround for VS2015
78-
#if defined(_MSC_VER) && (_MSC_VER < 1910)
79-
template
80-
<
81-
typename Geometry,
82-
bool IsGeometry = util::is_geometry<Geometry>::value
83-
>
84-
struct coordinate_type
85-
: geometry::coordinate_type<Geometry>
86-
{};
87-
template <typename Geometry>
88-
struct coordinate_type<Geometry, false>
89-
{
90-
typedef int type;
91-
};
92-
template <typename Geometry>
93-
struct default_area_result<Geometry, false>
94-
{
95-
typedef int type;
96-
};
97-
#endif
9875

9976
template <typename Curr, typename Next>
10077
struct more_precise_coordinate_type
10178
: std::is_same
10279
<
103-
typename coordinate_type<Curr>::type,
80+
typename geometry::coordinate_type<Curr>::type,
10481
typename geometry::select_most_precise
10582
<
106-
typename coordinate_type<Curr>::type,
107-
typename coordinate_type<Next>::type
83+
typename geometry::coordinate_type<Curr>::type,
84+
typename geometry::coordinate_type<Next>::type
10885
>::type
10986
>
11087
{};
@@ -139,35 +116,25 @@ template
139116
typename Strategy = default_strategy
140117
>
141118
struct area_result
142-
: detail::area::area_result<Geometry, Strategy>
143-
{};
144-
145-
template <BOOST_VARIANT_ENUM_PARAMS(typename T), typename Strategy>
146-
struct area_result<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>, Strategy>
147-
: geometry::area_result
119+
: detail::area::area_result
148120
<
149-
typename util::select_pack_element
121+
typename detail::select_geometry_type
150122
<
151-
detail::area::more_precise_coordinate_type,
152-
BOOST_VARIANT_ENUM_PARAMS(T)
123+
Geometry,
124+
detail::area::more_precise_coordinate_type
153125
>::type,
154126
Strategy
155127
>
156128
{};
157129

158130
template <typename Geometry>
159131
struct area_result<Geometry, default_strategy>
160-
: detail::area::default_area_result<Geometry>
161-
{};
162-
163-
template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
164-
struct area_result<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>, default_strategy>
165132
: detail::area::default_area_result
166133
<
167-
typename util::select_pack_element
134+
typename detail::select_geometry_type
168135
<
169-
detail::area::more_precise_default_area_result,
170-
BOOST_VARIANT_ENUM_PARAMS(T)
136+
Geometry,
137+
detail::area::more_precise_default_area_result
171138
>::type
172139
>
173140
{};

include/boost/geometry/algorithms/clear.hpp

+19-30
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
55
// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
66

7-
// This file was modified by Oracle on 2020.
8-
// Modifications copyright (c) 2020, Oracle and/or its affiliates.
7+
// This file was modified by Oracle on 2020-2021.
8+
// Modifications copyright (c) 2020-2021, Oracle and/or its affiliates.
99
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
1010

1111
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
@@ -21,17 +21,15 @@
2121

2222
#include <type_traits>
2323

24-
#include <boost/variant/apply_visitor.hpp>
25-
#include <boost/variant/static_visitor.hpp>
26-
#include <boost/variant/variant_fwd.hpp>
27-
2824
#include <boost/geometry/algorithms/not_implemented.hpp>
2925
#include <boost/geometry/core/access.hpp>
3026
#include <boost/geometry/core/exterior_ring.hpp>
3127
#include <boost/geometry/core/interior_rings.hpp>
3228
#include <boost/geometry/core/mutable_range.hpp>
3329
#include <boost/geometry/core/tag_cast.hpp>
3430
#include <boost/geometry/core/tags.hpp>
31+
#include <boost/geometry/core/visit.hpp>
32+
#include <boost/geometry/geometries/adapted/boost_variant.hpp> // for backward compatibility
3533
#include <boost/geometry/geometries/concepts/check.hpp>
3634

3735

@@ -137,40 +135,31 @@ struct clear<Geometry, multi_tag>
137135
{};
138136

139137

140-
} // namespace dispatch
141-
#endif // DOXYGEN_NO_DISPATCH
142-
143-
144-
namespace resolve_variant {
145-
146138
template <typename Geometry>
147-
struct clear
139+
struct clear<Geometry, dynamic_geometry_tag>
148140
{
149-
static inline void apply(Geometry& geometry)
141+
static void apply(Geometry& geometry)
150142
{
151-
dispatch::clear<Geometry>::apply(geometry);
143+
traits::visit<Geometry>::apply([](auto & g)
144+
{
145+
clear<std::remove_reference_t<decltype(g)>>::apply(g);
146+
}, geometry);
152147
}
153148
};
154149

155-
template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
156-
struct clear<variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
157-
{
158-
struct visitor: static_visitor<void>
159-
{
160-
template <typename Geometry>
161-
inline void operator()(Geometry& geometry) const
162-
{
163-
clear<Geometry>::apply(geometry);
164-
}
165-
};
166150

167-
static inline void apply(variant<BOOST_VARIANT_ENUM_PARAMS(T)>& geometry)
151+
template <typename Geometry>
152+
struct clear<Geometry, geometry_collection_tag>
153+
{
154+
static void apply(Geometry& geometry)
168155
{
169-
boost::apply_visitor(visitor(), geometry);
156+
traits::clear<Geometry>::apply(geometry);
170157
}
171158
};
172159

173-
} // namespace resolve_variant
160+
161+
} // namespace dispatch
162+
#endif // DOXYGEN_NO_DISPATCH
174163

175164

176165
/*!
@@ -191,7 +180,7 @@ inline void clear(Geometry& geometry)
191180
{
192181
concepts::check<Geometry>();
193182

194-
resolve_variant::clear<Geometry>::apply(geometry);
183+
dispatch::clear<Geometry>::apply(geometry);
195184
}
196185

197186

include/boost/geometry/algorithms/detail/buffer/buffered_ring.hpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,14 @@ struct buffered_ring_collection : public std::vector<Ring>
8383

8484

8585
// Turn off concept checking (for now)
86-
namespace dispatch
86+
namespace concepts
8787
{
88-
template <typename Geometry, bool IsConst>
89-
struct check<Geometry, detail::buffer::buffered_ring_collection_tag, IsConst>
88+
89+
template <typename Geometry>
90+
struct concept_type<Geometry, geometry::detail::buffer::buffered_ring_collection_tag>
9091
{
92+
struct dummy {};
93+
using type = dummy;
9194
};
9295

9396
}

include/boost/geometry/algorithms/detail/comparable_distance/interface.hpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_COMPARABLE_DISTANCE_INTERFACE_HPP
2121
#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_COMPARABLE_DISTANCE_INTERFACE_HPP
2222

23+
24+
#include <boost/geometry/algorithms/detail/distance/interface.hpp>
25+
26+
#include <boost/geometry/geometries/adapted/boost_variant.hpp> // For backward compatibility
2327
#include <boost/geometry/geometries/concepts/check.hpp>
2428

2529
#include <boost/geometry/strategies/comparable_distance_result.hpp>
@@ -29,8 +33,6 @@
2933
#include <boost/geometry/strategies/distance/comparable.hpp>
3034
#include <boost/geometry/strategies/distance/services.hpp>
3135

32-
#include <boost/geometry/algorithms/detail/distance/interface.hpp>
33-
3436

3537
namespace boost { namespace geometry
3638
{

0 commit comments

Comments
 (0)