fix mangled offsets and edge weights on compressed edges (all tests passing)
This commit is contained in:
		
							parent
							
								
									8ec3d549a6
								
							
						
					
					
						commit
						5b8d8a83dd
					
				| @ -352,25 +352,37 @@ void EdgeBasedGraphFactory::InsertEdgeBasedNode( | |||||||
| 
 | 
 | ||||||
|         // reconstruct bidirectional edge with individual weights and put each into the NN index
 |         // reconstruct bidirectional edge with individual weights and put each into the NN index
 | ||||||
| 
 | 
 | ||||||
|         std::vector<int> forward_dist_prefix_sum( forward_geometry.size() ); |         std::vector<int> forward_dist_prefix_sum(forward_geometry.size(), 0); | ||||||
|         std::vector<int> reverse_dist_prefix_sum( reverse_geometry.size() ); |         std::vector<int> reverse_dist_prefix_sum(reverse_geometry.size(), 0); | ||||||
| 
 | 
 | ||||||
|         // quick'n'dirty prefix sum as std::partial_sum needs addtional casts
 |         // quick'n'dirty prefix sum as std::partial_sum needs addtional casts
 | ||||||
|         // SimpleLogger().Write(logDEBUG) << "Prefix sums of edge " << e1 << ", w: " << reverse_data.distance;
 |         // SimpleLogger().Write(logDEBUG) << "Prefix sums of edge " << e1 << ", w: " << reverse_data.distance;
 | ||||||
|         int temp_sum = 0; |         int temp_sum = 0; | ||||||
|         for( unsigned i = 0; i < forward_geometry.size(); ++i ) { | 
 | ||||||
|  |         std::cout << "\nfwd geom: "; | ||||||
|  |         for (unsigned i = 0; i < forward_geometry.size(); ++i) | ||||||
|  |         { | ||||||
|  |             forward_dist_prefix_sum[i] = temp_sum; | ||||||
|             temp_sum += forward_geometry[i].second; |             temp_sum += forward_geometry[i].second; | ||||||
|  | 
 | ||||||
|             BOOST_ASSERT( forward_data.distance >= temp_sum ); |             BOOST_ASSERT( forward_data.distance >= temp_sum ); | ||||||
|             forward_dist_prefix_sum[i] = forward_data.distance - temp_sum; |             std::cout << forward_dist_prefix_sum[i] << " "; | ||||||
|         } |         } | ||||||
|  |         std::cout << std::endl; | ||||||
|  | 
 | ||||||
|         // BOOST_ASSERT( forward_data.distance == temp_sum );
 |         // BOOST_ASSERT( forward_data.distance == temp_sum );
 | ||||||
|         temp_sum = 0; |         temp_sum = 0; | ||||||
|  |         std::cout << "rev geom: "; | ||||||
|         for( unsigned i = 0; i < reverse_geometry.size(); ++i ) { |         for( unsigned i = 0; i < reverse_geometry.size(); ++i ) { | ||||||
|             temp_sum += reverse_geometry[i].second; |             temp_sum += reverse_geometry[reverse_geometry.size()-1-i].second; | ||||||
|             BOOST_ASSERT( reverse_data.distance >= temp_sum ); |  | ||||||
|             reverse_dist_prefix_sum[i] = reverse_data.distance - temp_sum; |             reverse_dist_prefix_sum[i] = reverse_data.distance - temp_sum; | ||||||
|  |             BOOST_ASSERT( reverse_data.distance >= temp_sum ); | ||||||
|  | 
 | ||||||
|  |             std::cout << reverse_dist_prefix_sum[i] << " "; | ||||||
|         } |         } | ||||||
|         // BOOST_ASSERT( reverse_data.distance == temp_sum );
 |         std::cout << std::endl; | ||||||
|  | 
 | ||||||
|  |         // BOOST_ASSERT(false);
 | ||||||
| 
 | 
 | ||||||
|         BOOST_ASSERT( forward_geometry.size() == reverse_geometry.size() ); |         BOOST_ASSERT( forward_geometry.size() == reverse_geometry.size() ); | ||||||
| 
 | 
 | ||||||
| @ -386,12 +398,18 @@ void EdgeBasedGraphFactory::InsertEdgeBasedNode( | |||||||
|         { |         { | ||||||
|             max_id = std::max(reverse_data.edgeBasedNodeID, max_id); |             max_id = std::max(reverse_data.edgeBasedNodeID, max_id); | ||||||
|         } |         } | ||||||
|  | 
 | ||||||
|  |         SimpleLogger().Write(logDEBUG) << "-> serializing packed edge " << forward_data.edgeBasedNodeID << "|" << reverse_data.edgeBasedNodeID; | ||||||
|  | 
 | ||||||
|         // traverse arrays from start and end respectively
 |         // traverse arrays from start and end respectively
 | ||||||
|         for( unsigned i = 0; i < geometry_size; ++i ) { |         for( unsigned i = 0; i < geometry_size; ++i ) { | ||||||
|             BOOST_ASSERT( current_edge_start_coordinate_id == reverse_geometry[geometry_size-1-i].first ); |             BOOST_ASSERT( current_edge_start_coordinate_id == reverse_geometry[geometry_size-1-i].first ); | ||||||
|             const NodeID current_edge_target_coordinate_id = forward_geometry[i].first; |             const NodeID current_edge_target_coordinate_id = forward_geometry[i].first; | ||||||
|             BOOST_ASSERT( current_edge_target_coordinate_id != current_edge_start_coordinate_id); |             BOOST_ASSERT( current_edge_target_coordinate_id != current_edge_start_coordinate_id); | ||||||
| 
 | 
 | ||||||
|  |             SimpleLogger().Write(logDEBUG) << "  runs from coordinate " << current_edge_start_coordinate_id << " to " << current_edge_target_coordinate_id; | ||||||
|  |             SimpleLogger().Write(logDEBUG) << "  fwd edge: " << forward_geometry[i].second << ", rev edge: " << reverse_geometry[geometry_size-1-i].second; | ||||||
|  |             SimpleLogger().Write(logDEBUG) << "  fwd offset: " << forward_dist_prefix_sum[i] << ", rev offset: " << reverse_dist_prefix_sum[geometry_size-1-i]; | ||||||
|             // build edges
 |             // build edges
 | ||||||
|             m_edge_based_node_list.push_back( |             m_edge_based_node_list.push_back( | ||||||
|                 EdgeBasedNode( |                 EdgeBasedNode( | ||||||
| @ -401,9 +419,9 @@ void EdgeBasedGraphFactory::InsertEdgeBasedNode( | |||||||
|                     current_edge_target_coordinate_id, |                     current_edge_target_coordinate_id, | ||||||
|                     forward_data.nameID, |                     forward_data.nameID, | ||||||
|                     forward_geometry[i].second, |                     forward_geometry[i].second, | ||||||
|                     reverse_geometry[geometry_size-1-i].second, |                     reverse_geometry[i].second, | ||||||
|                     forward_dist_prefix_sum[i], |                     forward_dist_prefix_sum[i], | ||||||
|                     reverse_dist_prefix_sum[geometry_size-1-i], |                     reverse_dist_prefix_sum[i], | ||||||
|                     m_geometry_compressor.GetPositionForID(e1), |                     m_geometry_compressor.GetPositionForID(e1), | ||||||
|                     i, |                     i, | ||||||
|                     belongs_to_tiny_cc |                     belongs_to_tiny_cc | ||||||
| @ -640,6 +658,12 @@ void EdgeBasedGraphFactory::Run( | |||||||
|             if( !edge_data.forward ) { |             if( !edge_data.forward ) { | ||||||
|                 continue; |                 continue; | ||||||
|             } |             } | ||||||
|  |             const NodeID target = m_node_based_graph->GetTarget(current_edge); | ||||||
|  | 
 | ||||||
|  |             SimpleLogger().Write(logDEBUG) << "expanded node " << numbered_edges_count << " runs from " << | ||||||
|  |                 m_node_info_list.at(current_node).lat << "," << m_node_info_list.at(current_node).lon << " to " << | ||||||
|  |                 m_node_info_list.at(target).lat << "," << m_node_info_list.at(target).lon; | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
|             BOOST_ASSERT( numbered_edges_count < m_node_based_graph->GetNumberOfEdges() ); |             BOOST_ASSERT( numbered_edges_count < m_node_based_graph->GetNumberOfEdges() ); | ||||||
|             edge_data.edgeBasedNodeID = numbered_edges_count; |             edge_data.edgeBasedNodeID = numbered_edges_count; | ||||||
| @ -839,7 +863,7 @@ void EdgeBasedGraphFactory::Run( | |||||||
|                 original_edge_data_vector.push_back( |                 original_edge_data_vector.push_back( | ||||||
|                     OriginalEdgeData( |                     OriginalEdgeData( | ||||||
|                         (edge_is_compressed ? m_geometry_compressor.GetPositionForID(e1) : v), |                         (edge_is_compressed ? m_geometry_compressor.GetPositionForID(e1) : v), | ||||||
|                         (edge_is_compressed ? edge_data1.nameID : edge_data1.nameID), |                         edge_data1.nameID, | ||||||
|                         turn_instruction, |                         turn_instruction, | ||||||
|                         edge_is_compressed |                         edge_is_compressed | ||||||
|                     ) |                     ) | ||||||
| @ -857,6 +881,8 @@ void EdgeBasedGraphFactory::Run( | |||||||
|                 BOOST_ASSERT( SPECIAL_NODEID != edge_data1.edgeBasedNodeID ); |                 BOOST_ASSERT( SPECIAL_NODEID != edge_data1.edgeBasedNodeID ); | ||||||
|                 BOOST_ASSERT( SPECIAL_NODEID != edge_data2.edgeBasedNodeID ); |                 BOOST_ASSERT( SPECIAL_NODEID != edge_data2.edgeBasedNodeID ); | ||||||
| 
 | 
 | ||||||
|  |                 SimpleLogger().Write(logDEBUG) << "Generating expanded edge (" << edge_data1.edgeBasedNodeID << "," << edge_data2.edgeBasedNodeID << "), w: " << distance; | ||||||
|  | 
 | ||||||
|                 m_edge_based_edge_list.push_back( |                 m_edge_based_edge_list.push_back( | ||||||
|                     EdgeBasedEdge( |                     EdgeBasedEdge( | ||||||
|                         edge_data1.edgeBasedNodeID, |                         edge_data1.edgeBasedNodeID, | ||||||
|  | |||||||
| @ -32,6 +32,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||||||
| #include <boost/foreach.hpp> | #include <boost/foreach.hpp> | ||||||
| 
 | 
 | ||||||
| #include <fstream> | #include <fstream> | ||||||
|  | #include <limits> | ||||||
| 
 | 
 | ||||||
| int current_free_list_maximum = 0; | int current_free_list_maximum = 0; | ||||||
| int UniqueNumber () { return ++current_free_list_maximum; } | int UniqueNumber () { return ++current_free_list_maximum; } | ||||||
|  | |||||||
| @ -30,7 +30,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||||||
| #include <boost/unordered_map.hpp> | #include <boost/unordered_map.hpp> | ||||||
| #include <boost/filesystem.hpp> | #include <boost/filesystem.hpp> | ||||||
| 
 | 
 | ||||||
| #include <limits> |  | ||||||
| #include <vector> | #include <vector> | ||||||
| 
 | 
 | ||||||
| #ifndef GEOMETRY_COMPRESSOR_H | #ifndef GEOMETRY_COMPRESSOR_H | ||||||
| @ -50,11 +49,6 @@ public: | |||||||
|         const EdgeWeight weight2 |         const EdgeWeight weight2 | ||||||
|     ); |     ); | ||||||
| 
 | 
 | ||||||
|     // void AddLastViaNodeIDToCompressedEdge(
 |  | ||||||
|     //     const EdgeID edge_id,
 |  | ||||||
|     //     const NodeID node_id,
 |  | ||||||
|     //     const EdgeWeight weight
 |  | ||||||
|     // );
 |  | ||||||
|     bool HasEntryForID(const EdgeID edge_id) const; |     bool HasEntryForID(const EdgeID edge_id) const; | ||||||
|     void PrintStatistics() const; |     void PrintStatistics() const; | ||||||
|     void SerializeInternalVector(const std::string & path) const; |     void SerializeInternalVector(const std::string & path) const; | ||||||
|  | |||||||
| @ -672,7 +672,7 @@ public: | |||||||
|                         } |                         } | ||||||
| 
 | 
 | ||||||
|                         double current_ratio = 0.; |                         double current_ratio = 0.; | ||||||
|                         double current_perpendicular_distance = current_edge.ComputePerpendicularDistance( |                         const double current_perpendicular_distance = current_edge.ComputePerpendicularDistance( | ||||||
|                             m_coordinate_list->at(current_edge.u), |                             m_coordinate_list->at(current_edge.u), | ||||||
|                             m_coordinate_list->at(current_edge.v), |                             m_coordinate_list->at(current_edge.v), | ||||||
|                             input_coordinate, |                             input_coordinate, | ||||||
| @ -691,13 +691,13 @@ public: | |||||||
|                         ) { //found a new minimum
 |                         ) { //found a new minimum
 | ||||||
|                             min_dist = current_perpendicular_distance; |                             min_dist = current_perpendicular_distance; | ||||||
|                             //TODO: use assignment c'tor in PhantomNode
 |                             //TODO: use assignment c'tor in PhantomNode
 | ||||||
|                             result_phantom_node.forward_node_id = current_edge.reverse_edge_based_node_id; |                             result_phantom_node.forward_node_id = current_edge.forward_edge_based_node_id; | ||||||
|                             result_phantom_node.reverse_node_id = current_edge.forward_edge_based_node_id; |                             result_phantom_node.reverse_node_id = current_edge.reverse_edge_based_node_id; | ||||||
|                             result_phantom_node.name_id = current_edge.name_id; |                             result_phantom_node.name_id = current_edge.name_id; | ||||||
|                             result_phantom_node.forward_weight = current_edge.reverse_weight; |                             result_phantom_node.forward_weight = current_edge.forward_weight; | ||||||
|                             result_phantom_node.reverse_weight = current_edge.forward_weight; |                             result_phantom_node.reverse_weight = current_edge.reverse_weight; | ||||||
|                             result_phantom_node.forward_offset = current_edge.reverse_offset; |                             result_phantom_node.forward_offset = current_edge.forward_offset; | ||||||
|                             result_phantom_node.reverse_offset = current_edge.forward_offset; |                             result_phantom_node.reverse_offset = current_edge.reverse_offset; | ||||||
|                             result_phantom_node.packed_geometry_id = current_edge.packed_geometry_id; |                             result_phantom_node.packed_geometry_id = current_edge.packed_geometry_id; | ||||||
|                             result_phantom_node.fwd_segment_position = current_edge.fwd_segment_position; |                             result_phantom_node.fwd_segment_position = current_edge.fwd_segment_position; | ||||||
| 
 | 
 | ||||||
| @ -758,10 +758,10 @@ public: | |||||||
|             ratio = std::min(1., ratio); |             ratio = std::min(1., ratio); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         SimpleLogger().Write(logDEBUG) << "result_phantom_node.forward_offset: " << result_phantom_node.forward_offset; |         SimpleLogger().Write(logDEBUG) << "[rtree] result_phantom_node.forward_offset: " << result_phantom_node.forward_offset; | ||||||
|         SimpleLogger().Write(logDEBUG) << "result_phantom_node.reverse_offset: " << result_phantom_node.reverse_offset; |         SimpleLogger().Write(logDEBUG) << "[rtree] result_phantom_node.reverse_offset: " << result_phantom_node.reverse_offset; | ||||||
|         SimpleLogger().Write(logDEBUG) << "result_phantom_node.forward_weight: " << result_phantom_node.forward_weight; |         SimpleLogger().Write(logDEBUG) << "[rtree] result_phantom_node.forward_weight: " << result_phantom_node.forward_weight; | ||||||
|         SimpleLogger().Write(logDEBUG) << "result_phantom_node.reverse_weight: " << result_phantom_node.reverse_weight; |         SimpleLogger().Write(logDEBUG) << "[rtree] result_phantom_node.reverse_weight: " << result_phantom_node.reverse_weight; | ||||||
| 
 | 
 | ||||||
|         if (SPECIAL_NODEID != result_phantom_node.forward_node_id) |         if (SPECIAL_NODEID != result_phantom_node.forward_node_id) | ||||||
|         { |         { | ||||||
| @ -772,14 +772,14 @@ public: | |||||||
|             result_phantom_node.reverse_weight *= (1.-ratio); |             result_phantom_node.reverse_weight *= (1.-ratio); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         SimpleLogger().Write(logDEBUG) << "result location: " << result_phantom_node.location << ", start: " << current_start_coordinate << ", end: " << current_end_coordinate; |         SimpleLogger().Write(logDEBUG) << "[rtree] result location: " << result_phantom_node.location << ", start: " << current_start_coordinate << ", end: " << current_end_coordinate; | ||||||
|         SimpleLogger().Write(logDEBUG) << "fwd node: " << result_phantom_node.forward_node_id << ", rev node: " << result_phantom_node.reverse_node_id; |         SimpleLogger().Write(logDEBUG) << "[rtree] fwd node: " << result_phantom_node.forward_node_id << ", rev node: " << result_phantom_node.reverse_node_id; | ||||||
|         SimpleLogger().Write(logDEBUG) << "fwd weight: " << result_phantom_node.forward_weight << ", rev weight: " << result_phantom_node.reverse_weight; |         SimpleLogger().Write(logDEBUG) << "[rtree] fwd weight: " << result_phantom_node.forward_weight << ", rev weight: " << result_phantom_node.reverse_weight; | ||||||
|         SimpleLogger().Write(logDEBUG) << "fwd offset: " << result_phantom_node.forward_offset << ", rev offset: " << result_phantom_node.reverse_offset; |         SimpleLogger().Write(logDEBUG) << "[rtree] fwd offset: " << result_phantom_node.forward_offset << ", rev offset: " << result_phantom_node.reverse_offset; | ||||||
|         SimpleLogger().Write(logDEBUG) << "bidirected: " << (result_phantom_node.isBidirected() ? "y" : "n"); |         SimpleLogger().Write(logDEBUG) << "[rtree] bidirected: " << (result_phantom_node.isBidirected() ? "y" : "n"); | ||||||
|         SimpleLogger().Write(logDEBUG) << "name id: " << result_phantom_node.name_id; |         SimpleLogger().Write(logDEBUG) << "[rtree] name id: " << result_phantom_node.name_id; | ||||||
|         SimpleLogger().Write(logDEBUG) << "geom id: " << result_phantom_node.packed_geometry_id; |         SimpleLogger().Write(logDEBUG) << "[rtree] geom id: " << result_phantom_node.packed_geometry_id; | ||||||
|         SimpleLogger().Write(logDEBUG) << "ratio: " << ratio; |         SimpleLogger().Write(logDEBUG) << "[rtree] ratio: " << ratio; | ||||||
| 
 | 
 | ||||||
|         return found_a_nearest_edge; |         return found_a_nearest_edge; | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -57,6 +57,8 @@ public: | |||||||
|         RawRouteData & raw_route_data |         RawRouteData & raw_route_data | ||||||
|     ) const |     ) const | ||||||
|     { |     { | ||||||
|  |         SimpleLogger().Write(logDEBUG) << "shrt path routing"; | ||||||
|  | 
 | ||||||
|         BOOST_FOREACH( |         BOOST_FOREACH( | ||||||
|             const PhantomNodes & phantom_node_pair, |             const PhantomNodes & phantom_node_pair, | ||||||
|             phantom_nodes_vector |             phantom_nodes_vector | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user