Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
16 changes: 8 additions & 8 deletions .github/workflows/minimal-clang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,28 @@ jobs:

include:
- b2_toolset: clang-3.9
b2_cxxstd: 03,11
b2_cxxstd: 14
version: "3.9"
- b2_toolset: clang-4.0
b2_cxxstd: 03,11
b2_cxxstd: 14
version: "4.0"
- b2_toolset: clang-5.0
b2_cxxstd: 03,11,14
b2_cxxstd: 14
version: "5.0"
- b2_toolset: clang-6.0
b2_cxxstd: 03,11,14
b2_cxxstd: 14
version: "6.0"
- b2_toolset: clang-7
b2_cxxstd: 03,11,14,17
b2_cxxstd: 14,17
version: "7"
- b2_toolset: clang-8
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: 14,17,2a
version: "9"
- b2_toolset: clang-10
b2_cxxstd: 03,11,14,17,2a
b2_cxxstd: 14,17,2a
version: "10"

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

include:
- b2_toolset: gcc-4.8
b2_cxxstd: 03,11
version: "4.8"
- b2_toolset: gcc-4.9
b2_cxxstd: 03,11
b2_cxxstd: 14
version: "4.9"
- b2_toolset: gcc-5
b2_cxxstd: 03,11,14
b2_cxxstd: 14
version: "5"
- b2_toolset: gcc-6
b2_cxxstd: 03,11,14
b2_cxxstd: 14
version: "6"
- b2_toolset: gcc-7
b2_cxxstd: 03,11,14,17
b2_cxxstd: 14,17
version: "7"
- b2_toolset: gcc-8
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: 14,17,2a
version: "9"

steps:
Expand Down
56 changes: 40 additions & 16 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 @@ -43,10 +43,12 @@
// #include <boost/geometry/algorithms/detail/throw_on_empty_input.hpp>
#include <boost/geometry/algorithms/detail/multi_sum.hpp>

#include <boost/geometry/strategies/area.hpp>
#include <boost/geometry/strategies/area_result.hpp>
#include <boost/geometry/strategies/default_area_result.hpp>
#include <boost/geometry/algorithms/area_result.hpp>
#include <boost/geometry/algorithms/default_area_result.hpp>

#include <boost/geometry/strategies/area/services.hpp>
#include <boost/geometry/strategies/default_strategy.hpp>
#include <boost/geometry/strategy/area.hpp>

#include <boost/geometry/strategies/concepts/area_concept.hpp>

Expand Down Expand Up @@ -86,23 +88,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 +118,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 +222,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 +237,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
152 changes: 152 additions & 0 deletions include/boost/geometry/algorithms/area_result.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
// Boost.Geometry

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

// This file was modified by Oracle on 2020.
// Modifications copyright (c) 2020 Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, 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)

#ifndef BOOST_GEOMETRY_STRATEGY_AREA_RESULT_HPP
#define BOOST_GEOMETRY_STRATEGY_AREA_RESULT_HPP


#include <boost/geometry/core/coordinate_type.hpp>
#include <boost/geometry/core/cs.hpp>

#include <boost/geometry/strategies/area/services.hpp>
#include <boost/geometry/strategies/default_strategy.hpp>
#include <boost/geometry/strategies/detail.hpp>
#include <boost/geometry/strategy/area.hpp>

#include <boost/geometry/util/select_most_precise.hpp>
#include <boost/geometry/util/select_sequence_element.hpp>


#include <boost/mpl/if.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/variant/variant_fwd.hpp>


namespace boost { namespace geometry
{


#ifndef DOXYGEN_NO_DETAIL
namespace detail { namespace area
{


template
<
typename Geometry,
typename Strategy,
bool IsUmbrella = strategies::detail::is_umbrella_strategy<Strategy>::value
>
struct area_result
: decltype(std::declval<Strategy>().area(std::declval<Geometry>()))
::template result_type<Geometry>
{};

template
<
typename Geometry,
typename Strategy
>
struct area_result<Geometry, Strategy, false>
: Strategy::template result_type<Geometry>
{};


}} // namespace detail::area
#endif //DOXYGEN_NO_DETAIL


/*!
\brief Meta-function defining return type of area function
\ingroup area
\note The return-type is defined by Geometry and Strategy
*/
template
<
typename Geometry,
typename Strategy = default_strategy
>
struct area_result
: detail::area::area_result<Geometry, Strategy>
{};

template <BOOST_VARIANT_ENUM_PARAMS(typename T), typename Strategy>
struct area_result<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>, Strategy>
: geometry::area_result
<
typename geometry::util::select_sequence_element
<
typename boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>::types
>::type,
Strategy
>
{};

template <typename Geometry>
struct area_result<Geometry, default_strategy>
: geometry::area_result
<
Geometry,
typename geometry::strategies::area::services::default_strategy
<
Geometry
>::type
>
{};

#ifndef DOXYGEN_NO_DETAIL
namespace detail { namespace area
{

template <typename Curr, typename Next>
struct pred_more_precise_default_area_result
{
typedef typename geometry::area_result<Curr, default_strategy>::type curr_result_t;
typedef typename geometry::area_result<Next, default_strategy>::type next_result_t;

typedef typename boost::mpl::if_c
<
boost::is_same
<
curr_result_t,
typename geometry::select_most_precise
<
curr_result_t,
next_result_t
>::type
>::value,
Curr,
Next
>::type type;
};

}} // namespace detail::area
#endif //DOXYGEN_NO_DETAIL

template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
struct area_result<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>, default_strategy>
: geometry::area_result
<
typename geometry::util::select_sequence_element
<
typename boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>::types,
geometry::detail::area::pred_more_precise_default_area_result
>::type,
default_strategy
>
{};


}} // namespace boost::geometry


#endif // BOOST_GEOMETRY_STRATEGY_AREA_RESULT_HPP
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
Loading