Skip to content

Commit

Permalink
feat: use tag_cast_t more and extract primary_single_tag
Browse files Browse the repository at this point in the history
  • Loading branch information
barendgehrels committed Oct 7, 2024
1 parent 21fda66 commit bb92f3d
Show file tree
Hide file tree
Showing 48 changed files with 166 additions and 258 deletions.
1 change: 1 addition & 0 deletions include/boost/geometry/algorithms/convert.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@

#include <boost/geometry/core/closure.hpp>
#include <boost/geometry/core/point_order.hpp>
#include <boost/geometry/core/tag_cast.hpp>
#include <boost/geometry/core/tags.hpp>

#include <boost/geometry/geometries/concepts/check.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include <boost/geometry/core/closure.hpp>
#include <boost/geometry/core/exterior_ring.hpp>
#include <boost/geometry/core/interior_rings.hpp>
#include <boost/geometry/core/tag_cast.hpp>

#include <boost/geometry/geometries/linestring.hpp>
#include <boost/geometry/geometries/ring.hpp>
Expand Down Expand Up @@ -177,8 +178,7 @@ struct buffer_range
output_point_type const& p1,
output_point_type const& p2)
{
typedef typename cs_tag<output_point_type>::type cs_tag;
return direction_code<cs_tag>(p0, p1, p2) == 1;
return direction_code<cs_tag_t<output_point_type>>(p0, p1, p2) == 1;
}

template <typename Strategies>
Expand Down Expand Up @@ -929,11 +929,7 @@ inline void buffer_inserter(GeometryInput const& geometry_input, OutputIterator

dispatch::buffer_inserter
<
typename tag_cast
<
typename tag<GeometryInput>::type,
multi_tag
>::type,
tag_cast_t<tag_t<GeometryInput>, multi_tag>,
GeometryInput,
GeometryOutput
>::apply(geometry_input, collection,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,12 @@ namespace detail { namespace centroid
// cartesian. But if it was needed then one should translate using
// CS-specific technique, e.g. in spherical/geographic a translation
// vector should contain coordinates being multiplies of 2PI or 360 deg.
template <typename Geometry,
typename CastedTag = typename tag_cast
<
typename tag<Geometry>::type,
areal_tag
>::type,
typename CSTag = typename cs_tag<Geometry>::type>
template
<
typename Geometry,
typename CastedTag = tag_cast_t<tag_t<Geometry>, areal_tag>,
typename CSTag = cs_tag_t<Geometry>
>
struct translating_transformer
{
typedef typename geometry::point_type<Geometry>::type point_type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ namespace detail { namespace disjoint
{

template <typename Geometry1, typename Geometry2,
typename Tag1 = typename tag<Geometry1>::type,
typename Tag1OrMulti = typename tag_cast<Tag1, multi_tag>::type>
typename Tag1 = tag_t<Geometry1>,
typename Tag1OrMulti = tag_cast_t<Tag1, multi_tag>>
struct disjoint_no_intersections_policy
{
/*!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ struct envelope_range_of_boxes

static const bool is_equatorial = ! std::is_same
<
typename cs_tag<box_type>::type,
cs_tag_t<box_type>,
spherical_polar_tag
>::value;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ struct range_collect_vectors


// Default version (cartesian)
template <typename Box, typename Collection, typename CSTag = typename cs_tag<Box>::type>
template <typename Box, typename Collection, typename CSTag = cs_tag_t<Box>>
struct box_collect_vectors
{
// Calculate on coordinate type, but if it is integer,
Expand Down
8 changes: 4 additions & 4 deletions include/boost/geometry/algorithms/detail/equals/interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ template
<
typename Geometry1,
typename Geometry2,
typename Tag1 = typename tag<Geometry1>::type,
typename Tag2 = typename tag<Geometry2>::type,
typename CastedTag1 = typename tag_cast<Tag1, pointlike_tag, linear_tag, areal_tag>::type,
typename CastedTag2 = typename tag_cast<Tag2, pointlike_tag, linear_tag, areal_tag>::type,
typename Tag1 = tag_t<Geometry1>,
typename Tag2 = tag_t<Geometry2>,
typename CastedTag1 = tag_cast_t<Tag1, pointlike_tag, linear_tag, areal_tag>,
typename CastedTag2 = tag_cast_t<Tag2, pointlike_tag, linear_tag, areal_tag>,
std::size_t DimensionCount = dimension<Geometry1>::type::value,
bool Reverse = reverse_dispatch<Geometry1, Geometry2>::type::value
>
Expand Down
6 changes: 3 additions & 3 deletions include/boost/geometry/algorithms/detail/extreme_points.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -546,10 +546,10 @@ inline bool extreme_points(Geometry const& geometry,
Extremes& extremes,
Intruders& intruders)
{
typedef typename strategy::side::services::default_strategy
using strategy_type = typename strategy::side::services::default_strategy
<
typename cs_tag<Geometry>::type
>::type strategy_type;
cs_tag_t<Geometry>
>::type;

return geometry::extreme_points<Edge>(geometry,extremes, intruders, strategy_type());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

#include <boost/geometry/core/static_assert.hpp>
#include <boost/geometry/core/tag.hpp>
#include <boost/geometry/core/tag_cast.hpp>
#include <boost/geometry/core/tags.hpp>

#include <boost/geometry/util/type_traits.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include <boost/geometry/core/interior_rings.hpp>
#include <boost/geometry/core/reverse_dispatch.hpp>
#include <boost/geometry/core/ring_type.hpp>
#include <boost/geometry/core/tag_cast.hpp>
#include <boost/geometry/core/tags.hpp>

#include <boost/geometry/geometries/box.hpp>
Expand Down Expand Up @@ -811,7 +812,7 @@ struct get_turns_multi_polygon_cs
template <typename Geometry>
struct topological_tag_base
{
typedef typename tag_cast<typename tag<Geometry>::type, pointlike_tag, linear_tag, areal_tag>::type type;
using type = tag_cast_t<tag_t<Geometry>, pointlike_tag, linear_tag, areal_tag>;
};

template <typename Geometry1, typename Geometry2, typename AssignPolicy,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include <boost/geometry/core/point_order.hpp>
#include <boost/geometry/core/reverse_dispatch.hpp>
#include <boost/geometry/core/static_assert.hpp>
#include <boost/geometry/core/tag_cast.hpp>

#include <boost/geometry/geometries/concepts/check.hpp>

Expand Down Expand Up @@ -504,13 +505,13 @@ template
bool Reverse1 = detail::overlay::do_reverse<geometry::point_order<Geometry1>::value>::value,
bool Reverse2 = detail::overlay::do_reverse<geometry::point_order<Geometry2>::value>::value,
// tag dispatching:
typename TagIn1 = typename geometry::tag<Geometry1>::type,
typename TagIn2 = typename geometry::tag<Geometry2>::type,
typename TagIn1 = tag_t<Geometry1>,
typename TagIn2 = tag_t<Geometry2>,
typename TagOut = typename detail::setop_insert_output_tag<GeometryOut>::type,
// metafunction finetuning helpers:
typename CastedTagIn1 = typename geometry::tag_cast<TagIn1, areal_tag, linear_tag, pointlike_tag>::type,
typename CastedTagIn2 = typename geometry::tag_cast<TagIn2, areal_tag, linear_tag, pointlike_tag>::type,
typename CastedTagOut = typename geometry::tag_cast<TagOut, areal_tag, linear_tag, pointlike_tag>::type
typename CastedTagIn1 = tag_cast_t<TagIn1, areal_tag, linear_tag, pointlike_tag>,
typename CastedTagIn2 = tag_cast_t<TagIn2, areal_tag, linear_tag, pointlike_tag>,
typename CastedTagOut = tag_cast_t<TagOut, areal_tag, linear_tag, pointlike_tag>
>
struct intersection_insert
{
Expand Down Expand Up @@ -1064,7 +1065,7 @@ struct intersection_insert
> : detail_dispatch::overlay::pointlike_linear_point
<
Point, Linear, PointOut, OverlayType,
point_tag, typename tag_cast<Tag, segment_tag, linear_tag>::type
point_tag, tag_cast_t<Tag, segment_tag, linear_tag>
>
{};

Expand All @@ -1086,7 +1087,7 @@ struct intersection_insert
<
MultiPoint, Linear, PointOut, OverlayType,
multi_point_tag,
typename tag_cast<Tag, segment_tag, linear_tag>::type
tag_cast_t<Tag, segment_tag, linear_tag>
>
{};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include <boost/geometry/core/access.hpp>
#include <boost/geometry/core/coordinate_type.hpp>
#include <boost/geometry/core/tag_cast.hpp>

// For spherical/geographic longitudes covered_by point/box
#include <boost/geometry/strategies/cartesian/point_in_box.hpp>
Expand All @@ -36,11 +37,7 @@ template
<
std::size_t Dimension,
typename Geometry,
typename CastedCSTag = typename tag_cast
<
typename cs_tag<Geometry>::type,
spherical_tag
>::type
typename CastedCSTag = tag_cast_t<cs_tag_t<Geometry>, spherical_tag>
>
struct preceding_check
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#include <boost/geometry/core/exterior_ring.hpp>
#include <boost/geometry/core/point_order.hpp>
#include <boost/geometry/core/static_assert.hpp>
#include <boost/geometry/core/tag_cast.hpp>
#include <boost/geometry/core/tags.hpp>

#include <boost/geometry/geometries/concepts/check.hpp>
Expand Down Expand Up @@ -148,11 +149,7 @@ template
typename DimensionVector,
std::size_t Index,
std::size_t Count,
typename CastedCSTag = typename tag_cast
<
typename cs_tag<Point>::type,
spherical_tag
>::type
typename CastedCSTag = tag_cast_t<cs_tag_t<Point>, spherical_tag>
>
struct get_direction_loop
{
Expand Down Expand Up @@ -497,14 +494,14 @@ struct sectionalize_part

// In cartesian this is envelope of previous point expanded with current point
// in non-cartesian this is envelope of a segment
box_first_in_section<typename cs_tag<point_type>::type>
box_first_in_section<cs_tag_t<point_type>>
::apply(section.bounding_box, previous_point, current_point, strategy);
}
else
{
// In cartesian this is expand with current point
// in non-cartesian this is expand with a segment
box_next_in_section<typename cs_tag<point_type>::type>
box_next_in_section<cs_tag_t<point_type>>
::apply(section.bounding_box, previous_point, current_point, strategy);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ template
<
typename Geometry1,
typename Geometry2,
typename Tag1 = typename tag<Geometry1>::type,
typename Tag2 = typename tag<Geometry2>::type,
typename CastedTag1 = typename tag_cast<Tag1, pointlike_tag, linear_tag, areal_tag>::type,
typename CastedTag2 = typename tag_cast<Tag2, pointlike_tag, linear_tag, areal_tag>::type,
typename Tag1 = tag_t<Geometry1>,
typename Tag2 = tag_t<Geometry2>,
typename CastedTag1 = tag_cast_t<Tag1, pointlike_tag, linear_tag, areal_tag>,
typename CastedTag2 = tag_cast_t<Tag2, pointlike_tag, linear_tag, areal_tag>,
bool Reverse = reverse_dispatch<Geometry1, Geometry2>::type::value
>
struct touches
Expand Down
27 changes: 2 additions & 25 deletions include/boost/geometry/algorithms/detail/tupled_output.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -520,10 +520,10 @@ struct expect_output_assert
TupledOut,
is_tag_same_as_pred<Tag>::template pred
>::value,
typename geometry::tag_cast
tag_cast_t
<
Tag, pointlike_tag, linear_tag, areal_tag
>::type
>
>
{};

Expand All @@ -540,29 +540,6 @@ struct expect_output
: expect_output_assert<Geometry1, Geometry2, TupledOut, Tags>...
{};


template <typename CastedTag>
struct single_tag_from_base_tag;

template <>
struct single_tag_from_base_tag<pointlike_tag>
{
typedef point_tag type;
};

template <>
struct single_tag_from_base_tag<linear_tag>
{
typedef linestring_tag type;
};

template <>
struct single_tag_from_base_tag<areal_tag>
{
typedef polygon_tag type;
};


template
<
typename Geometry,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include <boost/geometry/algorithms/envelope.hpp>
#include <boost/geometry/algorithms/detail/partition.hpp>
#include <boost/geometry/core/tag.hpp>
#include <boost/geometry/core/tag_cast.hpp>
#include <boost/geometry/core/tags.hpp>

#include <boost/geometry/geometries/box.hpp>
Expand Down
18 changes: 6 additions & 12 deletions include/boost/geometry/algorithms/difference.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#include <boost/geometry/algorithms/detail/overlay/intersection_insert.hpp>
#include <boost/geometry/algorithms/detail/visit.hpp>
#include <boost/geometry/core/geometry_types.hpp>
#include <boost/geometry/core/primary_single_tag.hpp>
#include <boost/geometry/core/tag_cast.hpp>
#include <boost/geometry/geometries/adapted/boost_variant.hpp> // For backward compatibility
#include <boost/geometry/strategies/default_strategy.hpp>
#include <boost/geometry/strategies/detail.hpp>
Expand Down Expand Up @@ -106,14 +108,10 @@ template
>
struct call_intersection_insert_tupled_base
{
typedef typename geometry::detail::single_tag_from_base_tag
using single_tag = primary_single_tag_t
<
typename geometry::tag_cast
<
typename geometry::tag<Geometry1>::type,
pointlike_tag, linear_tag, areal_tag
>::type
>::type single_tag;
tag_cast_t<tag_t<Geometry1>, pointlike_tag, linear_tag, areal_tag>
>;

typedef detail::expect_output
<
Expand Down Expand Up @@ -283,11 +281,7 @@ inline OutputIterator difference_insert(Geometry1 const& geometry1,
template
<
typename Geometry, typename Collection,
typename CastedTag = typename geometry::tag_cast
<
typename geometry::tag<Geometry>::type,
pointlike_tag, linear_tag, areal_tag
>::type
typename CastedTag = tag_cast_t<tag_t<Geometry>, pointlike_tag, linear_tag, areal_tag>
>
struct multi_output_type
{
Expand Down
12 changes: 6 additions & 6 deletions include/boost/geometry/algorithms/dispatch/closest_points.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,22 @@ namespace dispatch
template
<
typename Geometry1, typename Geometry2,
typename Tag1 = typename tag_cast
typename Tag1 = tag_cast_t
<
typename tag<Geometry1>::type,
tag_t<Geometry1>,
segment_tag,
box_tag,
linear_tag,
areal_tag
>::type,
typename Tag2 = typename tag_cast
>,
typename Tag2 = tag_cast_t
<
typename tag<Geometry2>::type,
tag_t<Geometry2>,
segment_tag,
box_tag,
linear_tag,
areal_tag
>::type,
>,
bool Reverse = reverse_dispatch<Geometry1, Geometry2>::type::value
>
struct closest_points : not_implemented<Tag1, Tag2>
Expand Down
Loading

0 comments on commit bb92f3d

Please sign in to comment.