@@ -104,8 +104,7 @@ inline void enrich_sort(Operations& operations,
104
104
105
105
// Assign travel-to-vertex/ip index for each turn.
106
106
template <typename Operations, typename Turns>
107
- inline void enrich_assign (Operations& operations, Turns& turns,
108
- bool check_consecutive_turns)
107
+ inline void enrich_assign (Operations& operations, Turns& turns)
109
108
{
110
109
for (auto const & item : util::enumerate (operations))
111
110
{
@@ -131,34 +130,6 @@ inline void enrich_assign(Operations& operations, Turns& turns,
131
130
return next_turn.operations [operations[next_index].operation_index ];
132
131
};
133
132
134
- if (check_consecutive_turns
135
- && indexed.turn_index == operations[next_index].turn_index
136
- && op.seg_id == next_operation ().seg_id )
137
- {
138
- // If the two operations on the same turn are ordered consecutively,
139
- // and they are on the same segment, then the turn where to travel to should
140
- // be considered one further. Therefore next is increased.
141
- //
142
- // It often happens in buffer, in these configurations:
143
- // +---->--+
144
- // | |
145
- // | +->-*---->
146
- // | | |
147
- // ^ +-<-+
148
- // If the next index is not corrected, the small rectangle
149
- // will be kept in the output.
150
-
151
- // This is a normal situation and occurs, for example, in every concave bend.
152
- // In general it should always travel from turn to next turn.
153
- // Only in some circumstances traveling to the same turn is necessary, for example
154
- // if there is only one turn in the outer ring.
155
- //
156
- // (For dissolve this is not done, turn_index is often
157
- // the same for two consecutive operations - but the conditions are changed
158
- // and this should be verified again)
159
- next_index = advance (next_index);
160
- }
161
-
162
133
// Cluster behaviour: next should point after cluster, unless
163
134
// their seg_ids are not the same
164
135
// (For dissolve, this is still to be examined - TODO)
@@ -285,36 +256,50 @@ struct enriched_map_default_include_policy
285
256
// Add all (non discarded) operations on this ring
286
257
// Blocked operations or uu on clusters (for intersection)
287
258
// should be included, to block potential paths in clusters
288
- template <typename Turns, typename MappedVector, typename IncludePolicy>
289
- inline void create_map (Turns const & turns, MappedVector& mapped_vector,
290
- IncludePolicy const & include_policy)
259
+ template <typename Turns, typename IncludePolicy>
260
+ inline auto create_map (Turns const & turns, IncludePolicy const & include_policy)
291
261
{
262
+ using turn_type = typename boost::range_value<Turns>::type;
263
+ using indexed_turn_operation = detail::overlay::indexed_turn_operation
264
+ <
265
+ typename turn_type::turn_operation_type
266
+ >;
267
+
268
+ std::map
269
+ <
270
+ ring_identifier,
271
+ std::vector<indexed_turn_operation>
272
+ > mapped_vector;
273
+
292
274
for (auto const & turn_item : util::enumerate (turns))
293
275
{
294
276
auto const & index = turn_item.index ;
295
277
auto const & turn = turn_item.value ;
296
- if (! turn.discarded )
278
+ if (turn.discarded )
297
279
{
298
- for (auto const & op_item : util::enumerate (turn.operations ))
280
+ continue ;
281
+ }
282
+
283
+ for (auto const & op_item : util::enumerate (turn.operations ))
284
+ {
285
+ auto const & op_index = op_item.index ;
286
+ auto const & op = op_item.value ;
287
+ if (include_policy.include (op.operation ))
299
288
{
300
- auto const & op_index = op_item.index ;
301
- auto const & op = op_item.value ;
302
- if (include_policy.include (op.operation ))
303
- {
304
- ring_identifier const ring_id
305
- (
306
- op.seg_id .source_index ,
307
- op.seg_id .multi_index ,
308
- op.seg_id .ring_index
309
- );
310
- mapped_vector[ring_id].emplace_back
311
- (
312
- index , op_index, op, turn.operations [1 - op_index].seg_id
313
- );
314
- }
289
+ ring_identifier const ring_id
290
+ (
291
+ op.seg_id .source_index ,
292
+ op.seg_id .multi_index ,
293
+ op.seg_id .ring_index
294
+ );
295
+ mapped_vector[ring_id].emplace_back
296
+ (
297
+ index , op_index, op, turn.operations [1 - op_index].seg_id
298
+ );
315
299
}
316
300
}
317
301
}
302
+ return mapped_vector;
318
303
}
319
304
320
305
template <typename Point1, typename Point2>
@@ -356,7 +341,6 @@ inline void calculate_remaining_distance(Turns& turns)
356
341
}
357
342
}
358
343
359
-
360
344
}} // namespace detail::overlay
361
345
#endif // DOXYGEN_NO_DETAIL
362
346
@@ -398,51 +382,14 @@ inline void enrich_intersection_points(Turns& turns,
398
382
? detail::overlay::operation_intersection
399
383
: detail::overlay::operation_union;
400
384
constexpr bool is_dissolve = OverlayType == overlay_dissolve;
401
- constexpr bool is_buffer = OverlayType == overlay_buffer;
402
-
403
- using turn_type = typename boost::range_value<Turns>::type;
404
- using indexed_turn_operation = detail::overlay::indexed_turn_operation
405
- <
406
- typename turn_type::turn_operation_type
407
- > ;
408
-
409
- using mapped_vector_type = std::map
410
- <
411
- ring_identifier,
412
- std::vector<indexed_turn_operation>
413
- >;
414
385
415
386
// Turns are often used by index (in clusters, next_index, etc)
416
387
// and turns may therefore NOT be DELETED - they may only be flagged as discarded
417
388
418
- bool has_cc = false ;
419
- bool has_colocations = false ;
420
-
421
- if BOOST_GEOMETRY_CONSTEXPR (! is_buffer)
422
- {
423
- // Handle colocations, gathering clusters and (below) their properties.
424
- has_colocations = detail::overlay::handle_colocations
425
- <
426
- Reverse1, Reverse2, OverlayType, Geometry1, Geometry2
427
- >(turns, clusters);
428
- // Gather cluster properties (using even clusters with
429
- // discarded turns - for open turns)
430
- detail::overlay::gather_cluster_properties
431
- <
432
- Reverse1,
433
- Reverse2,
434
- OverlayType
435
- >(clusters, turns, target_operation,
436
- geometry1, geometry2, strategy);
437
- }
438
- else
439
- {
440
- // For buffer, this was already done before calling enrich_intersection_points.
441
- has_colocations = ! clusters.empty ();
442
- }
443
-
444
389
discard_duplicate_turns (turns, geometry1, geometry2);
445
390
391
+ bool has_cc = false ;
392
+
446
393
// Discard turns not part of target overlay
447
394
for (auto & turn : turns)
448
395
{
@@ -491,11 +438,15 @@ inline void enrich_intersection_points(Turns& turns,
491
438
strategy);
492
439
}
493
440
441
+ if (! clusters.empty ())
442
+ {
443
+ detail::overlay::cleanup_clusters (turns, clusters);
444
+ detail::overlay::colocate_clusters (clusters, turns);
445
+ }
446
+
494
447
// Create a map of vectors of indexed operation-types to be able
495
448
// to sort intersection points PER RING
496
- mapped_vector_type mapped_vector;
497
-
498
- detail::overlay::create_map (turns, mapped_vector,
449
+ auto mapped_vector = detail::overlay::create_map (turns,
499
450
detail::overlay::enriched_map_default_include_policy ());
500
451
501
452
for (auto & pair : mapped_vector)
@@ -506,14 +457,6 @@ inline void enrich_intersection_points(Turns& turns,
506
457
strategy);
507
458
}
508
459
509
- if (has_colocations)
510
- {
511
- detail::overlay::cleanup_clusters (turns, clusters);
512
- detail::overlay::colocate_clusters (clusters, turns);
513
- }
514
-
515
- // After cleaning up clusters assign the next turns
516
-
517
460
for (auto & pair : mapped_vector)
518
461
{
519
462
#ifdef BOOST_GEOMETRY_DEBUG_ENRICH
@@ -524,7 +467,7 @@ inline void enrich_intersection_points(Turns& turns,
524
467
detail::overlay::enrich_adapt (pair.second , turns);
525
468
}
526
469
527
- detail::overlay::enrich_assign (pair.second , turns, ! is_dissolve );
470
+ detail::overlay::enrich_assign (pair.second , turns);
528
471
}
529
472
530
473
if (has_cc)
0 commit comments