refactor FirstAndLastSegmentOfWay
This commit is contained in:
		
							parent
							
								
									ea1a89290a
								
							
						
					
					
						commit
						0d9b70552e
					
				| @ -119,39 +119,39 @@ void ExtractionContainers::PrepareData(const std::string &output_file_name, | ||||
|         while (way_start_and_end_iterator != way_start_end_id_list.end() && | ||||
|                restrictions_iterator != restrictions_list.end()) | ||||
|         { | ||||
|             if (way_start_and_end_iterator->wayID < restrictions_iterator->restriction.from.way) | ||||
|             if (way_start_and_end_iterator->way_id < restrictions_iterator->restriction.from.way) | ||||
|             { | ||||
|                 ++way_start_and_end_iterator; | ||||
|                 continue; | ||||
|             } | ||||
| 
 | ||||
|             if (way_start_and_end_iterator->wayID > restrictions_iterator->restriction.from.way) | ||||
|             if (way_start_and_end_iterator->way_id > restrictions_iterator->restriction.from.way) | ||||
|             { | ||||
|                 ++restrictions_iterator; | ||||
|                 continue; | ||||
|             } | ||||
| 
 | ||||
|             BOOST_ASSERT(way_start_and_end_iterator->wayID == restrictions_iterator->restriction.from.way); | ||||
|             BOOST_ASSERT(way_start_and_end_iterator->way_id == restrictions_iterator->restriction.from.way); | ||||
|             const NodeID via_node_id = restrictions_iterator->restriction.via.node; | ||||
| 
 | ||||
|             if (way_start_and_end_iterator->firstStart == via_node_id) | ||||
|             if (way_start_and_end_iterator->first_segment_source_id == via_node_id) | ||||
|             { | ||||
|                 restrictions_iterator->restriction.from.node = | ||||
|                     way_start_and_end_iterator->firstTarget; | ||||
|                     way_start_and_end_iterator->first_segment_source_id; | ||||
|             } | ||||
|             else if (way_start_and_end_iterator->firstTarget == via_node_id) | ||||
|             else if (way_start_and_end_iterator->first_segment_source_id == via_node_id) | ||||
|             { | ||||
|                 restrictions_iterator->restriction.from.node = | ||||
|                     way_start_and_end_iterator->firstStart; | ||||
|                     way_start_and_end_iterator->first_segment_source_id; | ||||
|             } | ||||
|             else if (way_start_and_end_iterator->lastStart == via_node_id) | ||||
|             else if (way_start_and_end_iterator->last_segment_source_id == via_node_id) | ||||
|             { | ||||
|                 restrictions_iterator->restriction.from.node = | ||||
|                     way_start_and_end_iterator->lastTarget; | ||||
|                     way_start_and_end_iterator->last_segment_target_id; | ||||
|             } | ||||
|             else if (way_start_and_end_iterator->lastTarget == via_node_id) | ||||
|             else if (way_start_and_end_iterator->last_segment_target_id == via_node_id) | ||||
|             { | ||||
|                 restrictions_iterator->restriction.from.node = way_start_and_end_iterator->lastStart; | ||||
|                 restrictions_iterator->restriction.from.node = way_start_and_end_iterator->last_segment_source_id; | ||||
|             } | ||||
|             ++restrictions_iterator; | ||||
|         } | ||||
| @ -176,32 +176,32 @@ void ExtractionContainers::PrepareData(const std::string &output_file_name, | ||||
|         while (way_start_and_end_iterator != way_start_end_id_list.end() && | ||||
|                restrictions_iterator != restrictions_list.end()) | ||||
|         { | ||||
|             if (way_start_and_end_iterator->wayID < restrictions_iterator->restriction.to.way) | ||||
|             if (way_start_and_end_iterator->way_id < restrictions_iterator->restriction.to.way) | ||||
|             { | ||||
|                 ++way_start_and_end_iterator; | ||||
|                 continue; | ||||
|             } | ||||
|             if (way_start_and_end_iterator->wayID > restrictions_iterator->restriction.to.way) | ||||
|             if (way_start_and_end_iterator->way_id > restrictions_iterator->restriction.to.way) | ||||
|             { | ||||
|                 ++restrictions_iterator; | ||||
|                 continue; | ||||
|             } | ||||
|             NodeID via_node_id = restrictions_iterator->restriction.via.node; | ||||
|             if (way_start_and_end_iterator->lastStart == via_node_id) | ||||
|             if (way_start_and_end_iterator->last_segment_source_id == via_node_id) | ||||
|             { | ||||
|                 restrictions_iterator->restriction.to.node = way_start_and_end_iterator->lastTarget; | ||||
|                 restrictions_iterator->restriction.to.node = way_start_and_end_iterator->last_segment_target_id; | ||||
|             } | ||||
|             else if (way_start_and_end_iterator->lastTarget == via_node_id) | ||||
|             else if (way_start_and_end_iterator->last_segment_target_id == via_node_id) | ||||
|             { | ||||
|                 restrictions_iterator->restriction.to.node = way_start_and_end_iterator->lastStart; | ||||
|                 restrictions_iterator->restriction.to.node = way_start_and_end_iterator->last_segment_source_id; | ||||
|             } | ||||
|             else if (way_start_and_end_iterator->firstStart == via_node_id) | ||||
|             else if (way_start_and_end_iterator->first_segment_source_id == via_node_id) | ||||
|             { | ||||
|                 restrictions_iterator->restriction.to.node = way_start_and_end_iterator->firstTarget; | ||||
|                 restrictions_iterator->restriction.to.node = way_start_and_end_iterator->first_segment_source_id; | ||||
|             } | ||||
|             else if (way_start_and_end_iterator->firstTarget == via_node_id) | ||||
|             else if (way_start_and_end_iterator->first_segment_source_id == via_node_id) | ||||
|             { | ||||
|                 restrictions_iterator->restriction.to.node = way_start_and_end_iterator->firstStart; | ||||
|                 restrictions_iterator->restriction.to.node = way_start_and_end_iterator->first_segment_source_id; | ||||
|             } | ||||
| 
 | ||||
|             if (std::numeric_limits<unsigned>::max() != restrictions_iterator->restriction.from.node && | ||||
|  | ||||
| @ -36,37 +36,41 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||
| 
 | ||||
| struct FirstAndLastSegmentOfWay | ||||
| { | ||||
|     EdgeID wayID; | ||||
|     NodeID firstStart; | ||||
|     NodeID firstTarget; | ||||
|     NodeID lastStart; | ||||
|     NodeID lastTarget; | ||||
|     EdgeID way_id; | ||||
|     NodeID first_segment_source_id; | ||||
|     NodeID first_segment_target_id; | ||||
|     NodeID last_segment_source_id; | ||||
|     NodeID last_segment_target_id; | ||||
|     FirstAndLastSegmentOfWay() | ||||
|         : wayID(std::numeric_limits<unsigned>::max()), firstStart(std::numeric_limits<unsigned>::max()), firstTarget(std::numeric_limits<unsigned>::max()), lastStart(std::numeric_limits<unsigned>::max()), | ||||
|           lastTarget(std::numeric_limits<unsigned>::max()) | ||||
|         : way_id(std::numeric_limits<EdgeID>::max()), | ||||
|           first_segment_source_id(std::numeric_limits<NodeID>::max()), | ||||
|           first_segment_target_id(std::numeric_limits<NodeID>::max()), | ||||
|           last_segment_source_id(std::numeric_limits<NodeID>::max()), | ||||
|           last_segment_target_id(std::numeric_limits<NodeID>::max()) | ||||
|     { | ||||
|     } | ||||
| 
 | ||||
|     FirstAndLastSegmentOfWay(unsigned w, NodeID fs, NodeID ft, NodeID ls, NodeID lt) | ||||
|         : wayID(w), firstStart(fs), firstTarget(ft), lastStart(ls), lastTarget(lt) | ||||
|     FirstAndLastSegmentOfWay(EdgeID w, NodeID fs, NodeID ft, NodeID ls, NodeID lt) | ||||
|         : way_id(w), first_segment_source_id(fs), first_segment_target_id(ft), | ||||
|           last_segment_source_id(ls), last_segment_target_id(lt) | ||||
|     { | ||||
|     } | ||||
| 
 | ||||
|     static FirstAndLastSegmentOfWay min_value() | ||||
|     { | ||||
|         return FirstAndLastSegmentOfWay((std::numeric_limits<unsigned>::min)(), | ||||
|                                     (std::numeric_limits<unsigned>::min)(), | ||||
|                                     (std::numeric_limits<unsigned>::min)(), | ||||
|                                     (std::numeric_limits<unsigned>::min)(), | ||||
|                                     (std::numeric_limits<unsigned>::min)()); | ||||
|         return {std::numeric_limits<EdgeID>::min(), | ||||
|                 std::numeric_limits<NodeID>::min(), | ||||
|                 std::numeric_limits<NodeID>::min(), | ||||
|                 std::numeric_limits<NodeID>::min(), | ||||
|                 std::numeric_limits<NodeID>::min()}; | ||||
|     } | ||||
|     static FirstAndLastSegmentOfWay max_value() | ||||
|     { | ||||
|         return FirstAndLastSegmentOfWay((std::numeric_limits<unsigned>::max)(), | ||||
|                                     (std::numeric_limits<unsigned>::max)(), | ||||
|                                     (std::numeric_limits<unsigned>::max)(), | ||||
|                                     (std::numeric_limits<unsigned>::max)(), | ||||
|                                     (std::numeric_limits<unsigned>::max)()); | ||||
|         return {std::numeric_limits<EdgeID>::max(), | ||||
|                 std::numeric_limits<NodeID>::max(), | ||||
|                 std::numeric_limits<NodeID>::max(), | ||||
|                 std::numeric_limits<NodeID>::max(), | ||||
|                 std::numeric_limits<NodeID>::max()}; | ||||
|     } | ||||
| }; | ||||
| 
 | ||||
| @ -75,7 +79,7 @@ struct FirstAndLastSegmentOfWayStxxlCompare | ||||
|     using value_type = FirstAndLastSegmentOfWay; | ||||
|     bool operator()(const FirstAndLastSegmentOfWay &a, const FirstAndLastSegmentOfWay &b) const | ||||
|     { | ||||
|         return a.wayID < b.wayID; | ||||
|         return a.way_id < b.way_id; | ||||
|     } | ||||
|     value_type max_value() { return FirstAndLastSegmentOfWay::max_value(); } | ||||
|     value_type min_value() { return FirstAndLastSegmentOfWay::min_value(); } | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user