Skip to content

Commit a45dd5c

Browse files
awulkiewtinko92
authored andcommitted
[intersection] Modify tupled-output utils and move them out from intersection code.
1 parent aca6253 commit a45dd5c

File tree

4 files changed

+348
-152
lines changed

4 files changed

+348
-152
lines changed

include/boost/geometry/algorithms/detail/intersection/areal_areal.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ namespace detail { namespace intersection
2626
template
2727
<
2828
typename GeometryOut,
29-
typename OutTag = typename detail::intersection::tag
29+
typename OutTag = typename geometry::detail::setop_insert_output_tag
3030
<
3131
typename geometry::detail::output_geometry_value
3232
<
@@ -85,9 +85,10 @@ struct intersection_areal_areal_<TupledOut, tupled_output_tag>
8585

8686
boost::ignore_unused
8787
<
88-
detail::intersection::expect_output_pla
88+
geometry::detail::expect_output
8989
<
90-
Areal1, Areal2, single_out
90+
Areal1, Areal2, single_out,
91+
point_tag, linestring_tag, polygon_tag
9192
>
9293
>();
9394

include/boost/geometry/algorithms/detail/intersection/multi.hpp

Lines changed: 63 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -432,16 +432,28 @@ struct intersection_insert
432432
TupledOut,
433433
OverlayType,
434434
ReverseMultiLinestring, ReverseRing,
435-
multi_linestring_tag, ring_tag, detail::intersection::tupled_output_tag,
436-
linear_tag, areal_tag, detail::intersection::tupled_output_tag
435+
multi_linestring_tag, ring_tag, detail::tupled_output_tag,
436+
linear_tag, areal_tag, detail::tupled_output_tag
437437
> : detail::intersection::intersection_of_multi_linestring_with_areal
438438
<
439439
ReverseRing,
440440
TupledOut,
441441
OverlayType,
442442
true
443443
>
444-
, detail::intersection::expect_output_pl<MultiLinestring, Ring, TupledOut>
444+
, detail::expect_output
445+
<
446+
MultiLinestring, Ring, TupledOut,
447+
// NOTE: points can be the result only in case of intersection.
448+
// TODO: union should require L and A
449+
typename boost::mpl::if_c
450+
<
451+
(OverlayType == overlay_intersection),
452+
point_tag,
453+
void
454+
>::type,
455+
linestring_tag
456+
>
445457
{};
446458

447459

@@ -458,16 +470,28 @@ struct intersection_insert
458470
TupledOut,
459471
OverlayType,
460472
ReverseMultiLinestring, ReversePolygon,
461-
multi_linestring_tag, polygon_tag, detail::intersection::tupled_output_tag,
462-
linear_tag, areal_tag, detail::intersection::tupled_output_tag
473+
multi_linestring_tag, polygon_tag, detail::tupled_output_tag,
474+
linear_tag, areal_tag, detail::tupled_output_tag
463475
> : detail::intersection::intersection_of_multi_linestring_with_areal
464476
<
465477
ReversePolygon,
466478
TupledOut,
467479
OverlayType,
468480
true
469481
>
470-
, detail::intersection::expect_output_pl<MultiLinestring, Polygon, TupledOut>
482+
, detail::expect_output
483+
<
484+
MultiLinestring, Polygon, TupledOut,
485+
// NOTE: points can be the result only in case of intersection.
486+
// TODO: union should require L and A
487+
typename boost::mpl::if_c
488+
<
489+
(OverlayType == overlay_intersection),
490+
point_tag,
491+
void
492+
>::type,
493+
linestring_tag
494+
>
471495
{};
472496

473497
template
@@ -483,16 +507,31 @@ struct intersection_insert
483507
TupledOut,
484508
OverlayType,
485509
ReversePolygon, ReverseMultiLinestring,
486-
polygon_tag, multi_linestring_tag, detail::intersection::tupled_output_tag,
487-
areal_tag, linear_tag, detail::intersection::tupled_output_tag
510+
polygon_tag, multi_linestring_tag, detail::tupled_output_tag,
511+
areal_tag, linear_tag, detail::tupled_output_tag
488512
> : detail::intersection::intersection_of_areal_with_multi_linestring
489513
<
490514
ReversePolygon,
491515
TupledOut,
492516
OverlayType,
493517
true
494518
>
495-
, detail::intersection::expect_output_pl<Polygon, MultiLinestring, TupledOut>
519+
, detail::expect_output
520+
<
521+
Polygon, MultiLinestring, TupledOut,
522+
// NOTE: points can be the result only in case of intersection.
523+
// TODO: union should require L and A
524+
// TODO: in general the result of difference should depend on the first argument
525+
// but this specialization calls L/A in reality so the first argument is linear.
526+
// So expect only L for difference?
527+
typename boost::mpl::if_c
528+
<
529+
(OverlayType == overlay_intersection),
530+
point_tag,
531+
void
532+
>::type,
533+
linestring_tag
534+
>
496535
{};
497536

498537
template
@@ -508,16 +547,28 @@ struct intersection_insert
508547
TupledOut,
509548
OverlayType,
510549
ReverseMultiLinestring, ReverseMultiPolygon,
511-
multi_linestring_tag, multi_polygon_tag, detail::intersection::tupled_output_tag,
512-
linear_tag, areal_tag, detail::intersection::tupled_output_tag
550+
multi_linestring_tag, multi_polygon_tag, detail::tupled_output_tag,
551+
linear_tag, areal_tag, detail::tupled_output_tag
513552
> : detail::intersection::intersection_of_multi_linestring_with_areal
514553
<
515554
ReverseMultiPolygon,
516555
TupledOut,
517556
OverlayType,
518557
true
519558
>
520-
, detail::intersection::expect_output_pl<MultiLinestring, MultiPolygon, TupledOut>
559+
, detail::expect_output
560+
<
561+
MultiLinestring, MultiPolygon, TupledOut,
562+
// NOTE: points can be the result only in case of intersection.
563+
// TODO: union should require L and A
564+
typename boost::mpl::if_c
565+
<
566+
(OverlayType == overlay_intersection),
567+
point_tag,
568+
void
569+
>::type,
570+
linestring_tag
571+
>
521572
{};
522573

523574

include/boost/geometry/algorithms/detail/overlay/intersection_insert.hpp

Lines changed: 34 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -525,73 +525,6 @@ struct intersection_areal_linear_point
525525
};
526526

527527

528-
struct tupled_output_tag {};
529-
530-
531-
template
532-
<
533-
typename GeometryOut,
534-
bool IsTupled = geometry::detail::is_tupled_range_values<GeometryOut>::value
535-
>
536-
struct tag
537-
: geometry::tag<GeometryOut>
538-
{};
539-
540-
template <typename GeometryOut>
541-
struct tag<GeometryOut, true>
542-
{
543-
typedef tupled_output_tag type;
544-
};
545-
546-
547-
template <typename Geometry1, typename Geometry2, typename TupledOut>
548-
struct expect_output_p
549-
{
550-
static const bool is_point_found = geometry::tuples::exists_if
551-
<
552-
TupledOut, geometry::detail::is_tag_same_as_pred<point_tag>::template pred
553-
>::value;
554-
555-
BOOST_MPL_ASSERT_MSG
556-
(
557-
is_point_found, POINTLIKE_GEOMETRY_EXPECTED_IN_TUPLED_OUTPUT,
558-
(types<Geometry1, Geometry2, TupledOut>)
559-
);
560-
};
561-
562-
template <typename Geometry1, typename Geometry2, typename TupledOut>
563-
struct expect_output_pl
564-
: expect_output_p<Geometry1, Geometry2, TupledOut>
565-
{
566-
static const bool is_linestring_found = geometry::tuples::exists_if
567-
<
568-
TupledOut, geometry::detail::is_tag_same_as_pred<linestring_tag>::template pred
569-
>::value;
570-
571-
BOOST_MPL_ASSERT_MSG
572-
(
573-
is_linestring_found, LINEAR_GEOMETRY_EXPECTED_IN_TUPLED_OUTPUT,
574-
(types<Geometry1, Geometry2, TupledOut>)
575-
);
576-
};
577-
578-
template <typename Geometry1, typename Geometry2, typename TupledOut>
579-
struct expect_output_pla
580-
: expect_output_pl<Geometry1, Geometry2, TupledOut>
581-
{
582-
static const bool is_polygon_found = geometry::tuples::exists_if
583-
<
584-
TupledOut, geometry::detail::is_tag_same_as_pred<polygon_tag>::template pred
585-
>::value;
586-
587-
BOOST_MPL_ASSERT_MSG
588-
(
589-
is_polygon_found, AREAL_GEOMETRY_EXPECTED_IN_TUPLED_OUTPUT,
590-
(types<Geometry1, Geometry2, TupledOut>)
591-
);
592-
};
593-
594-
595528
}} // namespace detail::intersection
596529
#endif // DOXYGEN_NO_DETAIL
597530

@@ -614,7 +547,7 @@ template
614547
// tag dispatching:
615548
typename TagIn1 = typename geometry::tag<Geometry1>::type,
616549
typename TagIn2 = typename geometry::tag<Geometry2>::type,
617-
typename TagOut = typename detail::intersection::tag<GeometryOut>::type,
550+
typename TagOut = typename detail::setop_insert_output_tag<GeometryOut>::type,
618551
// metafunction finetuning helpers:
619552
typename CastedTagIn1 = typename geometry::tag_cast<TagIn1, areal_tag, linear_tag, pointlike_tag>::type,
620553
typename CastedTagIn2 = typename geometry::tag_cast<TagIn2, areal_tag, linear_tag, pointlike_tag>::type,
@@ -996,13 +929,21 @@ struct intersection_insert
996929
<
997930
Linear1, Linear2, TupledOut, OverlayType,
998931
Reverse1, Reverse2,
999-
TagIn1, TagIn2, detail::intersection::tupled_output_tag,
1000-
linear_tag, linear_tag, detail::intersection::tupled_output_tag
932+
TagIn1, TagIn2, detail::tupled_output_tag,
933+
linear_tag, linear_tag, detail::tupled_output_tag
1001934
>
1002-
// NOTE: This is not fully correct because points can be the result only in
1003-
// case of intersection but intersection_insert is called also by difference.
1004-
// So this requirement could be relaxed in the future.
1005-
: detail::intersection::expect_output_pl<Linear1, Linear2, TupledOut>
935+
: detail::expect_output
936+
<
937+
Linear1, Linear2, TupledOut,
938+
// NOTE: points can be the result only in case of intersection.
939+
typename boost::mpl::if_c
940+
<
941+
(OverlayType == overlay_intersection),
942+
point_tag,
943+
void
944+
>::type,
945+
linestring_tag
946+
>
1006947
{
1007948
// NOTE: The order of geometries in TupledOut tuple/pair must correspond to the order
1008949
// iterators in OutputIterators tuple/pair.
@@ -1113,10 +1054,10 @@ struct intersection_insert
11131054
<
11141055
PointLike1, PointLike2, TupledOut, OverlayType,
11151056
Reverse1, Reverse2,
1116-
TagIn1, TagIn2, detail::intersection::tupled_output_tag,
1117-
pointlike_tag, pointlike_tag, detail::intersection::tupled_output_tag
1057+
TagIn1, TagIn2, detail::tupled_output_tag,
1058+
pointlike_tag, pointlike_tag, detail::tupled_output_tag
11181059
>
1119-
: detail::intersection::expect_output_p<PointLike1, PointLike2, TupledOut>
1060+
: detail::expect_output<PointLike1, PointLike2, TupledOut, point_tag>
11201061
{
11211062
// NOTE: The order of geometries in TupledOut tuple/pair must correspond to the order
11221063
// of iterators in OutputIterators tuple/pair.
@@ -1240,16 +1181,16 @@ struct intersection_insert
12401181
<
12411182
PointLike, Linear, TupledOut, OverlayType,
12421183
Reverse1, Reverse2,
1243-
TagIn1, TagIn2, detail::intersection::tupled_output_tag,
1244-
pointlike_tag, linear_tag, detail::intersection::tupled_output_tag
1184+
TagIn1, TagIn2, detail::tupled_output_tag,
1185+
pointlike_tag, linear_tag, detail::tupled_output_tag
12451186
>
12461187
// Reuse the implementation for PointLike/PointLike.
12471188
: intersection_insert
12481189
<
12491190
PointLike, Linear, TupledOut, OverlayType,
12501191
Reverse1, Reverse2,
1251-
TagIn1, TagIn2, detail::intersection::tupled_output_tag,
1252-
pointlike_tag, pointlike_tag, detail::intersection::tupled_output_tag
1192+
TagIn1, TagIn2, detail::tupled_output_tag,
1193+
pointlike_tag, pointlike_tag, detail::tupled_output_tag
12531194
>
12541195
{};
12551196

@@ -1265,8 +1206,8 @@ struct intersection_insert
12651206
<
12661207
Linestring, MultiPoint, TupledOut, overlay_intersection,
12671208
Reverse1, Reverse2,
1268-
linestring_tag, multi_point_tag, detail::intersection::tupled_output_tag,
1269-
linear_tag, pointlike_tag, detail::intersection::tupled_output_tag
1209+
linestring_tag, multi_point_tag, detail::tupled_output_tag,
1210+
linear_tag, pointlike_tag, detail::tupled_output_tag
12701211
>
12711212
{
12721213
template <typename RobustPolicy, typename OutputIterators, typename Strategy>
@@ -1368,16 +1309,16 @@ struct intersection_insert
13681309
<
13691310
PointLike, Areal, TupledOut, OverlayType,
13701311
Reverse1, Reverse2,
1371-
TagIn1, TagIn2, detail::intersection::tupled_output_tag,
1372-
pointlike_tag, areal_tag, detail::intersection::tupled_output_tag
1312+
TagIn1, TagIn2, detail::tupled_output_tag,
1313+
pointlike_tag, areal_tag, detail::tupled_output_tag
13731314
>
13741315
// Reuse the implementation for PointLike/PointLike.
13751316
: intersection_insert
13761317
<
13771318
PointLike, Areal, TupledOut, OverlayType,
13781319
Reverse1, Reverse2,
1379-
TagIn1, TagIn2, detail::intersection::tupled_output_tag,
1380-
pointlike_tag, pointlike_tag, detail::intersection::tupled_output_tag
1320+
TagIn1, TagIn2, detail::tupled_output_tag,
1321+
pointlike_tag, pointlike_tag, detail::tupled_output_tag
13811322
>
13821323
{};
13831324

@@ -1394,8 +1335,8 @@ struct intersection_insert
13941335
<
13951336
Areal, MultiPoint, TupledOut, overlay_intersection,
13961337
Reverse1, Reverse2,
1397-
TagIn1, multi_point_tag, detail::intersection::tupled_output_tag,
1398-
areal_tag, pointlike_tag, detail::intersection::tupled_output_tag
1338+
TagIn1, multi_point_tag, detail::tupled_output_tag,
1339+
areal_tag, pointlike_tag, detail::tupled_output_tag
13991340
>
14001341
{
14011342
template <typename RobustPolicy, typename OutputIterators, typename Strategy>
@@ -1426,8 +1367,8 @@ struct intersection_insert
14261367
TupledOut,
14271368
OverlayType,
14281369
ReverseLinestring, ReversePolygon,
1429-
linestring_tag, polygon_tag, detail::intersection::tupled_output_tag,
1430-
linear_tag, areal_tag, detail::intersection::tupled_output_tag
1370+
linestring_tag, polygon_tag, detail::tupled_output_tag,
1371+
linear_tag, areal_tag, detail::tupled_output_tag
14311372
> : detail::intersection::intersection_of_linestring_with_areal
14321373
<
14331374
ReversePolygon,
@@ -1450,8 +1391,8 @@ struct intersection_insert
14501391
TupledOut,
14511392
OverlayType,
14521393
ReverseLinestring, ReverseRing,
1453-
linestring_tag, ring_tag, detail::intersection::tupled_output_tag,
1454-
linear_tag, areal_tag, detail::intersection::tupled_output_tag
1394+
linestring_tag, ring_tag, detail::tupled_output_tag,
1395+
linear_tag, areal_tag, detail::tupled_output_tag
14551396
> : detail::intersection::intersection_of_linestring_with_areal
14561397
<
14571398
ReverseRing,

0 commit comments

Comments
 (0)