Skip to content

Commit

Permalink
chore: modernize ring and related types to ring_t and related
Browse files Browse the repository at this point in the history
  • Loading branch information
barendgehrels committed Nov 4, 2024
1 parent 74b7900 commit b98ea78
Show file tree
Hide file tree
Showing 35 changed files with 128 additions and 152 deletions.
11 changes: 3 additions & 8 deletions include/boost/geometry/algorithms/convert.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,11 +381,9 @@ struct convert<Box, Polygon, box_tag, polygon_tag, 2, false>
{
static inline void apply(Box const& box, Polygon& polygon)
{
typedef typename ring_type<Polygon>::type ring_type;

convert
<
Box, ring_type,
Box, ring_type_t<Polygon>,
box_tag, ring_tag,
2, false
>::apply(box, exterior_ring(polygon));
Expand Down Expand Up @@ -415,10 +413,9 @@ struct convert<Ring, Polygon, ring_tag, polygon_tag, DimensionCount, false>
{
static inline void apply(Ring const& ring, Polygon& polygon)
{
typedef typename ring_type<Polygon>::type ring_type;
convert
<
Ring, ring_type,
Ring, ring_type_t<Polygon>,
ring_tag, ring_tag,
DimensionCount, false
>::apply(ring, exterior_ring(polygon));
Expand All @@ -431,11 +428,9 @@ struct convert<Polygon, Ring, polygon_tag, ring_tag, DimensionCount, false>
{
static inline void apply(Polygon const& polygon, Ring& ring)
{
typedef typename ring_type<Polygon>::type ring_type;

convert
<
ring_type, Ring,
ring_type_t<Polygon>, Ring,
ring_tag, ring_tag,
DimensionCount, false
>::apply(exterior_ring(polygon), ring);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -747,11 +747,10 @@ template
struct buffer_inserter<polygon_tag, PolygonInput, PolygonOutput>
{
private:
typedef typename ring_type<PolygonInput>::type input_ring_type;
typedef typename ring_type<PolygonOutput>::type output_ring_type;

typedef buffer_inserter_ring<input_ring_type, output_ring_type> policy;
using input_ring_type = ring_type_t<PolygonInput>;
using output_ring_type = ring_type_t<PolygonOutput>;

using policy = buffer_inserter_ring<input_ring_type, output_ring_type>;

template
<
Expand Down Expand Up @@ -875,7 +874,7 @@ struct buffer_inserter<multi_tag, Multi, PolygonOutput>
<
typename single_tag_of<tag_t<Multi>>::type,
typename boost::range_value<Multi const>::type,
typename geometry::ring_type<PolygonOutput>::type
geometry::ring_type_t<PolygonOutput>
>
>
{};
Expand Down Expand Up @@ -915,7 +914,7 @@ inline void buffer_inserter(GeometryInput const& geometry_input, OutputIterator

using collection_type = detail::buffer::buffered_piece_collection
<
typename geometry::ring_type<GeometryOutput>::type,
geometry::ring_type_t<GeometryOutput>,
Strategies,
DistanceStrategy
>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ template<>
struct get_ring<detail::buffer::buffered_ring_collection_tag>
{
template<typename MultiGeometry>
static inline typename ring_type<MultiGeometry>::type const& apply(
static inline ring_type_t<MultiGeometry> const& apply(
ring_identifier const& id,
MultiGeometry const& multi_ring)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class disjoint_segment_areal<Segment, Polygon, polygon_tag>
{
if (! disjoint_range_segment_or_box
<
typename geometry::ring_type<Polygon>::type,
geometry::ring_type_t<Polygon>,
Segment
>::apply(geometry::exterior_ring(polygon), segment, strategy))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ class point_to_polygon
private:
typedef point_to_range
<
Point, typename ring_type<Polygon>::type, Closure, Strategies
Point, ring_type_t<Polygon>, Closure, Strategies
> per_ring;

struct distance_to_interior_rings
Expand Down
3 changes: 1 addition & 2 deletions include/boost/geometry/algorithms/detail/envelope/areal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ struct envelope_polygon
template <typename Polygon, typename Box, typename Strategy>
static inline void apply(Polygon const& polygon, Box& mbr, Strategy const& strategy)
{
typename ring_return_type<Polygon const>::type ext_ring
= exterior_ring(polygon);
ring_return_type_t<Polygon const> ext_ring = exterior_ring(polygon);

if (geometry::is_empty(ext_ring))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,9 +395,7 @@ struct polygon_collect_vectors
{
static inline void apply(Collection& collection, Polygon const& polygon)
{
typedef typename geometry::ring_type<Polygon>::type ring_type;

typedef range_collect_vectors<ring_type, Collection> per_range;
using per_range = range_collect_vectors<geometry::ring_type_t<Polygon>, Collection>;
per_range::apply(collection, exterior_ring(polygon));

auto const& rings = interior_rings(polygon);
Expand Down
7 changes: 3 additions & 4 deletions include/boost/geometry/algorithms/detail/extreme_points.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,11 +412,10 @@ struct extreme_points<Polygon, Dimension, polygon_tag>
static inline bool apply(Polygon const& polygon, Extremes& extremes, Intruders& intruders,
SideStrategy const& strategy)
{
typedef typename geometry::ring_type<Polygon>::type ring_type;
typedef detail::extreme_points::extreme_points_on_ring
using ring_implementation = detail::extreme_points::extreme_points_on_ring
<
ring_type, Dimension
> ring_implementation;
geometry::ring_type_t<Polygon>, Dimension
>;

if (! ring_implementation::apply(geometry::exterior_ring(polygon),
extremes, intruders, strategy))
Expand Down
5 changes: 2 additions & 3 deletions include/boost/geometry/algorithms/detail/is_valid/polygon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,14 @@ class is_valid_polygon
VisitPolicy& visitor,
Strategy const& strategy)
{
typedef debug_validity_phase<Polygon> debug_phase;
typedef typename ring_type<Polygon>::type ring_type;
using debug_phase = debug_validity_phase<Polygon>;

// check validity of exterior ring
debug_phase::apply(1);

if (! detail::is_valid::is_valid_ring
<
ring_type,
ring_type_t<Polygon>,
false // do not check self intersections
>::apply(exterior_ring(polygon), visitor, strategy))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ struct copy_segment_point_polygon
// Call ring-version with the right ring
return copy_segment_point_range
<
typename geometry::ring_type<Polygon>::type,
geometry::ring_type_t<Polygon>,
Reverse,
SegmentIdentifier,
PointOut
Expand Down
4 changes: 2 additions & 2 deletions include/boost/geometry/algorithms/detail/overlay/get_ring.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ template<>
struct get_ring<polygon_tag>
{
template<typename Polygon>
static inline typename ring_return_type<Polygon const>::type const apply(
static inline ring_return_type_t<Polygon const> const apply(
ring_identifier const& id,
Polygon const& polygon)
{
Expand All @@ -103,7 +103,7 @@ template<>
struct get_ring<multi_polygon_tag>
{
template<typename MultiPolygon>
static inline typename ring_type<MultiPolygon>::type const& apply(
static inline ring_type_t<MultiPolygon> const& apply(
ring_identifier const& id,
MultiPolygon const& multi_polygon)
{
Expand Down
12 changes: 5 additions & 7 deletions include/boost/geometry/algorithms/detail/overlay/get_turns.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,13 @@ class get_turns_in_sections
{
using range1_view = detail::closed_clockwise_view
<
typename ring_type<Geometry1>::type const,
ring_type_t<Geometry1> const,
geometry::closure<Geometry1>::value,
Reverse1 ? counterclockwise : clockwise
>;
using range2_view = detail::closed_clockwise_view
<
typename ring_type<Geometry2>::type const,
ring_type_t<Geometry2> const,
geometry::closure<Geometry2>::value,
Reverse2 ? counterclockwise : clockwise
>;
Expand Down Expand Up @@ -740,14 +740,12 @@ struct get_turns_polygon_cs
InterruptPolicy& interrupt_policy,
signed_size_type multi_index = -1)
{
typedef typename geometry::ring_type<Polygon>::type ring_type;

typedef detail::get_turns::get_turns_cs
using intersector_type = detail::get_turns::get_turns_cs
<
ring_type, Box,
geometry::ring_type_t<Polygon>, Box,
Reverse, ReverseBox,
TurnPolicy
> intersector_type;
>;

intersector_type::apply(
source_id1, geometry::exterior_ring(polygon),
Expand Down
10 changes: 5 additions & 5 deletions include/boost/geometry/algorithms/detail/overlay/overlay.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,14 @@ inline OutputIterator return_if_one_input_is_empty(Geometry1 const& geometry1,
Geometry2 const& geometry2,
OutputIterator out, Strategy const& strategy)
{
typedef typename geometry::ring_type<GeometryOut>::type ring_type;
typedef std::deque<ring_type> ring_container_type;
using ring_type = geometry::ring_type_t<GeometryOut>;
using ring_container_type = std::deque<ring_type>;

typedef ring_properties
using properties = ring_properties
<
geometry::point_type_t<ring_type>,
typename geometry::area_result<ring_type, Strategy>::type
> properties;
>;

// Silence warning C4127: conditional expression is constant
#if defined(_MSC_VER)
Expand Down Expand Up @@ -256,7 +256,7 @@ struct overlay
>;
using turn_container_type = std::deque<turn_info>;

using ring_type = typename geometry::ring_type<GeometryOut>::type;
using ring_type = geometry::ring_type_t<GeometryOut>;
using ring_container_type = std::deque<ring_type>;

// Define the clusters, mapping cluster_id -> turns
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@ namespace dispatch
ring_identifier id, RingPropertyMap& ring_properties,
Strategy const& strategy)
{
typedef typename geometry::ring_type<Polygon>::type ring_type;
typedef select_rings<ring_tag, ring_type> per_ring;
using per_ring = select_rings<ring_tag, geometry::ring_type_t<Polygon>>;

per_ring::apply(exterior_ring(polygon), geometry, id, ring_properties, strategy);

Expand All @@ -131,8 +130,7 @@ namespace dispatch
ring_identifier id, RingPropertyMap& ring_properties,
Strategy const& strategy)
{
typedef typename geometry::ring_type<Polygon>::type ring_type;
typedef select_rings<ring_tag, ring_type> per_ring;
using per_ring = select_rings<ring_tag, geometry::ring_type_t<Polygon>>;

per_ring::apply(exterior_ring(polygon), id, ring_properties, strategy);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ inline bool calculate_from_inside(Geometry1 const& geometry1,

auto const& range1 = sub_range(geometry1, turn.operations[op_id].seg_id);

using range2_view = detail::closed_clockwise_view<typename ring_type<Geometry2>::type const>;
using range2_view = detail::closed_clockwise_view<ring_type_t<Geometry2> const>;
range2_view const range2(sub_range(geometry2, turn.operations[other_op_id].seg_id));

BOOST_GEOMETRY_ASSERT(boost::size(range1));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ struct full_section_range
template <typename Polygon, typename Section>
struct full_section_polygon
{
static inline typename ring_return_type<Polygon const>::type apply(Polygon const& polygon, Section const& section)
static inline ring_return_type_t<Polygon const> apply(Polygon const& polygon, Section const& section)
{
return section.ring_id.ring_index < 0
? geometry::exterior_ring(polygon)
Expand All @@ -71,10 +71,10 @@ template
>
struct full_section_multi
{
static inline typename ring_return_type<MultiGeometry const>::type apply(
static inline ring_return_type_t<MultiGeometry const> apply(
MultiGeometry const& multi, Section const& section)
{
typedef typename boost::range_size<MultiGeometry>::type size_type;
using size_type = typename boost::range_size<MultiGeometry>::type;

BOOST_GEOMETRY_ASSERT
(
Expand Down Expand Up @@ -171,7 +171,7 @@ struct range_by_section<multi_linestring_tag, MultiLinestring, Section>
\param section structure with section
*/
template <typename Geometry, typename Section>
inline typename ring_return_type<Geometry const>::type
inline ring_return_type_t<Geometry const>
range_by_section(Geometry const& geometry, Section const& section)
{
concepts::check<Geometry const>();
Expand Down
6 changes: 3 additions & 3 deletions include/boost/geometry/algorithms/detail/sub_range.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ struct sub_range<Geometry, Tag, false>
template <typename Geometry>
struct sub_range<Geometry, polygon_tag, false>
{
typedef typename geometry::ring_return_type<Geometry>::type return_type;
using return_type = geometry::ring_return_type_t<Geometry>;

template <typename Id> static inline
return_type apply(Geometry & geometry, Id const& id)
Expand All @@ -69,10 +69,10 @@ struct sub_range<Geometry, polygon_tag, false>
}
else
{
typedef typename boost::range_size
using size_type = typename boost::range_size
<
typename geometry::interior_type<Geometry>::type
>::type size_type;
>::type;
size_type const ri = static_cast<size_type>(id.ring_index);
return range::at(geometry::interior_rings(geometry), ri);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ struct point_in_geometry<Polygon, polygon_tag>
{
int const code = point_in_geometry
<
typename ring_type<Polygon>::type
ring_type_t<Polygon>
>::apply(point, exterior_ring(polygon), strategy);

if (code == 1)
Expand All @@ -204,7 +204,7 @@ struct point_in_geometry<Polygon, polygon_tag>
{
int const interior_code = point_in_geometry
<
typename ring_type<Polygon>::type
ring_type_t<Polygon>
>::apply(point, *it, strategy);

if (interior_code != -1)
Expand Down
8 changes: 4 additions & 4 deletions include/boost/geometry/algorithms/perimeter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ struct perimeter<Geometry, ring_tag>
template <typename Polygon>
struct perimeter<Polygon, polygon_tag> : detail::calculate_polygon_sum
{
typedef typename default_length_result<Polygon>::type return_type;
typedef detail::length::range_length
using return_type = typename default_length_result<Polygon>::type;
using policy = detail::length::range_length
<
typename ring_type<Polygon>::type,
ring_type_t<Polygon>,
closure<Polygon>::value
> policy;
>;

template <typename Strategy>
static inline return_type apply(Polygon const& polygon, Strategy const& strategy)
Expand Down
14 changes: 4 additions & 10 deletions include/boost/geometry/core/exterior_ring.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,9 @@ struct exterior_ring
template <typename Polygon>
struct exterior_ring<polygon_tag, Polygon>
{
static
typename geometry::ring_return_type<Polygon>::type
apply(Polygon& polygon)
static geometry::ring_return_type_t<Polygon> apply(Polygon& polygon)
{
return traits::exterior_ring
<
typename std::remove_const<Polygon>::type
>::get(polygon);
return traits::exterior_ring<std::remove_const_t<Polygon>>::get(polygon);
}
};

Expand All @@ -100,7 +95,7 @@ struct exterior_ring<polygon_tag, Polygon>
\return a reference to the exterior ring
*/
template <typename Polygon>
inline typename ring_return_type<Polygon>::type exterior_ring(Polygon& polygon)
inline ring_return_type_t<Polygon> exterior_ring(Polygon& polygon)
{
return core_dispatch::exterior_ring
<
Expand All @@ -121,8 +116,7 @@ inline typename ring_return_type<Polygon>::type exterior_ring(Polygon& polygon)
\qbk{distinguish,const version}
*/
template <typename Polygon>
inline typename ring_return_type<Polygon const>::type exterior_ring(
Polygon const& polygon)
inline ring_return_type_t<Polygon const> exterior_ring(Polygon const& polygon)
{
return core_dispatch::exterior_ring
<
Expand Down
Loading

0 comments on commit b98ea78

Please sign in to comment.