Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
[algorithms][strategies] Add umbrella strategies for area, envelope a…
…nd expand.
  • Loading branch information
awulkiew committed Jul 10, 2020
commit a5b46d0f8bcccbf0ef6043dc94910673fba09c98
24 changes: 16 additions & 8 deletions .github/workflows/minimal-clang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,36 @@ jobs:

include:
- b2_toolset: clang-3.9
b2_cxxstd: 03,11
# b2_cxxstd: 03,11
b2_cxxstd: 14
version: "3.9"
- b2_toolset: clang-4.0
b2_cxxstd: 03,11
# b2_cxxstd: 03,11
b2_cxxstd: 14
version: "4.0"
- b2_toolset: clang-5.0
b2_cxxstd: 03,11,14
# b2_cxxstd: 03,11,14
b2_cxxstd: 14
version: "5.0"
- b2_toolset: clang-6.0
b2_cxxstd: 03,11,14
# b2_cxxstd: 03,11,14
b2_cxxstd: 14
version: "6.0"
- b2_toolset: clang-7
b2_cxxstd: 03,11,14,17
# b2_cxxstd: 03,11,14,17
b2_cxxstd: 14,17
version: "7"
- b2_toolset: clang-8
b2_cxxstd: 03,11,14,17
# b2_cxxstd: 03,11,14,17
b2_cxxstd: 14,17
version: "8"
- b2_toolset: clang-9
b2_cxxstd: 03,11,14,17,2a
# b2_cxxstd: 03,11,14,17,2a
b2_cxxstd: 14,17,2a
version: "9"
- b2_toolset: clang-10
b2_cxxstd: 03,11,14,17,2a
# b2_cxxstd: 03,11,14,17,2a
b2_cxxstd: 14,17,2a
version: "10"

steps:
Expand Down
27 changes: 17 additions & 10 deletions .github/workflows/minimal-gcc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
fail-fast: false
matrix:
b2_toolset: [
gcc-4.8,
# gcc-4.8,
gcc-4.9,
gcc-5,
gcc-6,
Expand All @@ -30,26 +30,33 @@ jobs:
]

include:
- b2_toolset: gcc-4.8
b2_cxxstd: 03,11
version: "4.8"
# - b2_toolset: gcc-4.8
# b2_cxxstd: 03,11
# b2_cxxstd: 14
# version: "4.8"
- b2_toolset: gcc-4.9
b2_cxxstd: 03,11
# b2_cxxstd: 03,11
b2_cxxstd: 14
version: "4.9"
- b2_toolset: gcc-5
b2_cxxstd: 03,11,14
# b2_cxxstd: 03,11,14
b2_cxxstd: 14
version: "5"
- b2_toolset: gcc-6
b2_cxxstd: 03,11,14
# b2_cxxstd: 03,11,14
b2_cxxstd: 14
version: "6"
- b2_toolset: gcc-7
b2_cxxstd: 03,11,14,17
# b2_cxxstd: 03,11,14,17
b2_cxxstd: 14,17
version: "7"
- b2_toolset: gcc-8
b2_cxxstd: 03,11,14,17
# b2_cxxstd: 03,11,14,17
b2_cxxstd: 14,17
version: "8"
- b2_toolset: gcc-9
b2_cxxstd: 03,11,14,17,2a
# b2_cxxstd: 03,11,14,17,2a
b2_cxxstd: 14,17,2a
version: "9"

steps:
Expand Down
48 changes: 35 additions & 13 deletions include/boost/geometry/algorithms/area.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
// Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland.

// This file was modified by Oracle on 2017, 2018.
// Modifications copyright (c) 2017-2018 Oracle and/or its affiliates.
// This file was modified by Oracle on 2017-2020.
// Modifications copyright (c) 2017-2020 Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle

// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
Expand Down Expand Up @@ -86,23 +86,25 @@ template
>
struct ring_area
{
template <typename Ring, typename Strategy>
static inline typename area_result<Ring, Strategy>::type
apply(Ring const& ring, Strategy const& strategy)
template <typename Ring, typename Strategies>
static inline typename area_result<Ring, Strategies>::type
apply(Ring const& ring, Strategies const& strategies)
{
BOOST_CONCEPT_ASSERT( (geometry::concepts::AreaStrategy<Ring, Strategy>) );
using strategy_type = decltype(strategies.area(ring));

BOOST_CONCEPT_ASSERT( (geometry::concepts::AreaStrategy<Ring, strategy_type>) );
assert_dimension<Ring, 2>();

// Ignore warning (because using static method sometimes) on strategy
boost::ignore_unused(strategy);
boost::ignore_unused(strategies);

// An open ring has at least three points,
// A closed ring has at least four points,
// if not, there is no (zero) area
if (boost::size(ring)
< core_detail::closure::minimum_ring_size<Closure>::value)
{
return typename area_result<Ring, Strategy>::type();
return typename area_result<Ring, Strategies>::type();
}

typedef typename reversible_view<Ring const, Direction>::type rview_type;
Expand All @@ -114,10 +116,12 @@ struct ring_area

rview_type rview(ring);
view_type view(rview);
typename Strategy::template state<Ring> state;
iterator_type it = boost::begin(view);
iterator_type end = boost::end(view);

strategy_type strategy = strategies.area(ring);
typename strategy_type::template state<Ring> state;

for (iterator_type previous = it++;
it != end;
++previous, ++it)
Expand Down Expand Up @@ -216,7 +220,11 @@ struct area<MultiGeometry, multi_polygon_tag> : detail::multi_sum
namespace resolve_strategy
{

template <typename Strategy>
template
<
typename Strategy,
bool IsUmbrella = strategies::detail::is_umbrella_strategy<Strategy>::value
>
struct area
{
template <typename Geometry>
Expand All @@ -227,16 +235,30 @@ struct area
}
};

template <typename Strategy>
struct area<Strategy, false>
{
template <typename Geometry>
static auto apply(Geometry const& geometry, Strategy const& strategy)
{
using strategies::area::services::strategy_converter;
return dispatch::area
<
Geometry
>::apply(geometry, strategy_converter<Strategy>::get(strategy));
}
};

template <>
struct area<default_strategy>
struct area<default_strategy, false>
{
template <typename Geometry>
static inline typename area_result<Geometry>::type
apply(Geometry const& geometry, default_strategy)
{
typedef typename strategy::area::services::default_strategy
typedef typename strategies::area::services::default_strategy
<
typename cs_tag<Geometry>::type
Geometry
>::type strategy_type;

return dispatch::area<Geometry>::apply(geometry, strategy_type());
Expand Down
12 changes: 9 additions & 3 deletions include/boost/geometry/algorithms/correct.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
// Copyright (c) 2014-2017 Adam Wulkiewicz, Lodz, Poland.

// This file was modified by Oracle on 2017.
// Modifications copyright (c) 2017 Oracle and/or its affiliates.
// This file was modified by Oracle on 2017-2020.
// Modifications copyright (c) 2017-2020 Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle

// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
Expand Down Expand Up @@ -147,7 +147,13 @@ struct correct_ring
typedef typename area_result<Ring, Strategy>::type area_result_type;
Predicate<area_result_type> predicate;
area_result_type const zero = 0;
if (predicate(ring_area_type::apply(r, strategy), zero))
if (predicate(ring_area_type::apply(r,
// TEMP - in the future (umbrella) strategy will be passed
geometry::strategies::area::services::strategy_converter
<
Strategy
>::get(strategy)),
zero))
{
std::reverse(boost::begin(r), boost::end(r));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Boost.Geometry

// Copyright (c) 2019, Oracle and/or its affiliates.
// Copyright (c) 2019-2020, Oracle and/or its affiliates.

// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle

Expand Down Expand Up @@ -297,7 +297,12 @@ struct calculate_point_order_by_area
Ring, Strategy
>::type result_type;

result_type const result = ring_area_type::apply(ring, strategy);
result_type const result = ring_area_type::apply(ring,
// TEMP - in the future (umbrella) strategy will be passed
geometry::strategies::area::services::strategy_converter
<
decltype(strategy.get_area_strategy())
>::get(strategy.get_area_strategy()));

result_type const zero = 0;
return result == zero ? geometry::order_undetermined
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland.

// Copyright (c) 2014-2019, Oracle and/or its affiliates.
// Copyright (c) 2014-2020, Oracle and/or its affiliates.
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle

Expand Down Expand Up @@ -42,6 +42,10 @@
#include <boost/geometry/policies/compare.hpp>


// TEMP
#include <boost/geometry/strategies2/envelope.hpp>


namespace boost { namespace geometry
{

Expand Down Expand Up @@ -139,7 +143,12 @@ class multipoint_linear
{
geometry::expand(total,
geometry::return_envelope<Box>(segment, m_strategy),
typename EnvelopeStrategy::box_expand_strategy_type());
// TEMP - envelope umbrella strategy also contains
// expand strategies
strategies::envelope::services::strategy_converter
<
EnvelopeStrategy
>::get(m_strategy));
}

EnvelopeStrategy const& m_strategy;
Expand Down Expand Up @@ -423,7 +432,14 @@ class multi_point_multi_geometry
> overlaps_box_point_type;
typedef expand_box_box_pair
<
typename Strategy::envelope_strategy_type::box_expand_strategy_type
// TEMP - envelope umbrella strategy also contains
// expand strategies
decltype(strategies::envelope::services::strategy_converter
<
typename Strategy::envelope_strategy_type
>::get(strategy.get_envelope_strategy())
.expand(std::declval<box1_type>(),
std::declval<box2_type>()))
> expand_box_box_pair_type;
typedef overlaps_box_box_pair
<
Expand Down
9 changes: 5 additions & 4 deletions include/boost/geometry/algorithms/detail/envelope/box.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
// Copyright (c) 2008-2015 Bruno Lalande, Paris, France.
// Copyright (c) 2009-2015 Mateusz Loskot, London, UK.

// This file was modified by Oracle on 2015-2018.
// Modifications copyright (c) 2015-2018, Oracle and/or its affiliates.
// This file was modified by Oracle on 2015-2020.
// Modifications copyright (c) 2015-2020, 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
Expand Down Expand Up @@ -39,9 +39,10 @@ template <typename Box>
struct envelope<Box, box_tag>
{
template<typename BoxIn, typename BoxOut, typename Strategy>
static inline void apply(BoxIn const& box_in, BoxOut& mbr, Strategy const& )
static inline void apply(BoxIn const& box_in, BoxOut& mbr, Strategy const& strategy)
{
Strategy::apply(box_in, mbr);
using strategy_t = decltype(strategy.envelope(box_in, mbr));
strategy_t::apply(box_in, mbr);
}
};

Expand Down
Loading