Fixing rounding errors by a hack.
This commit is contained in:
		
							parent
							
								
									8a47c87a8a
								
							
						
					
					
						commit
						f1332c7c6a
					
				| @ -172,7 +172,7 @@ public: | |||||||
|                 resultNode.nodeBasedEdgeNameID = candidate.nameID; |                 resultNode.nodeBasedEdgeNameID = candidate.nameID; | ||||||
|                 resultNode.weight1 = candidate.weight; |                 resultNode.weight1 = candidate.weight; | ||||||
|                 dist = tmpDist; |                 dist = tmpDist; | ||||||
|                 resultNode.location.lat = round(100000*(y2lat(static_cast<double>(tmp.lat)/100000.))); |                 resultNode.location.lat = round(100000.*(y2lat(static_cast<double>(tmp.lat)/100000.))); | ||||||
|                 resultNode.location.lon = tmp.lon; |                 resultNode.location.lon = tmp.lon; | ||||||
|                 foundNode = true; |                 foundNode = true; | ||||||
|                 smallestEdge = candidate; |                 smallestEdge = candidate; | ||||||
| @ -195,7 +195,13 @@ public: | |||||||
| 
 | 
 | ||||||
|         double ratio = std::min(1., LengthOfVector(smallestEdge.startCoord, newEndpoint)/LengthOfVector(smallestEdge.startCoord, smallestEdge.targetCoord) ); |         double ratio = std::min(1., LengthOfVector(smallestEdge.startCoord, newEndpoint)/LengthOfVector(smallestEdge.startCoord, smallestEdge.targetCoord) ); | ||||||
|         assert(ratio >= 0 && ratio <=1); |         assert(ratio >= 0 && ratio <=1); | ||||||
|         //        INFO("node: " << resultNode.edgeBasedNode << ", orig weight1: " << resultNode.weight1 << ", orig weight2: " << resultNode.weight2);
 | 
 | ||||||
|  |         //Hack to fix rounding errors and wandering via nodes.
 | ||||||
|  |         if(std::abs(location.lon - resultNode.location.lon) == 1) | ||||||
|  |             resultNode.location.lon = location.lon; | ||||||
|  |         if(std::abs(location.lat - resultNode.location.lat) == 1) | ||||||
|  |              resultNode.location.lat = location.lat; | ||||||
|  | 
 | ||||||
|         resultNode.weight1 *= ratio; |         resultNode.weight1 *= ratio; | ||||||
|         if(INT_MAX != resultNode.weight2) { |         if(INT_MAX != resultNode.weight2) { | ||||||
|             resultNode.weight2 -= resultNode.weight1; |             resultNode.weight2 -= resultNode.weight1; | ||||||
| @ -425,7 +431,7 @@ private: | |||||||
|         if(c != a){ |         if(c != a){ | ||||||
|             const double m = (d-b)/(c-a); // slope
 |             const double m = (d-b)/(c-a); // slope
 | ||||||
|             // Projection of (x,y) on line joining (a,b) and (c,d)
 |             // Projection of (x,y) on line joining (a,b) and (c,d)
 | ||||||
|             p = ((x + (m*y)) + (m*m*a - m*b))/(1 + m*m); |             p = ((x + (m*y)) + (m*m*a - m*b))/(1. + m*m); | ||||||
|             q = b + m*(p - a); |             q = b + m*(p - a); | ||||||
|         } |         } | ||||||
|         else{ |         else{ | ||||||
|  | |||||||
| @ -159,6 +159,7 @@ public: | |||||||
| 					convertInternalReversedCoordinateToString(rawRoute.segmentEndCoordinates[segmentIdx].startPhantom.location, tmp); | 					convertInternalReversedCoordinateToString(rawRoute.segmentEndCoordinates[segmentIdx].startPhantom.location, tmp); | ||||||
| 				else | 				else | ||||||
| 					convertInternalReversedCoordinateToString(rawRoute.rawViaNodeCoordinates[segmentIdx], tmp); | 					convertInternalReversedCoordinateToString(rawRoute.rawViaNodeCoordinates[segmentIdx], tmp); | ||||||
|  | 
 | ||||||
| 				reply.content += tmp; | 				reply.content += tmp; | ||||||
| 				reply.content += "]"; | 				reply.content += "]"; | ||||||
| 			} | 			} | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user