Move Centroid to coordinate_calculation
This commit is contained in:
		
							parent
							
								
									ebd8bf7c7c
								
							
						
					
					
						commit
						c9e2a8d24a
					
				@ -53,15 +53,6 @@ struct EdgeBasedNode
 | 
				
			|||||||
                     (reverse_edge_based_node_id != SPECIAL_NODEID));
 | 
					                     (reverse_edge_based_node_id != SPECIAL_NODEID));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    static inline util::Coordinate Centroid(const util::Coordinate a, const util::Coordinate b)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        util::Coordinate centroid;
 | 
					 | 
				
			||||||
        // The coordinates of the midpoint are given by:
 | 
					 | 
				
			||||||
        centroid.lon = (a.lon + b.lon) / util::FixedLongitude(2);
 | 
					 | 
				
			||||||
        centroid.lat = (a.lat + b.lat) / util::FixedLatitude(2);
 | 
					 | 
				
			||||||
        return centroid;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    NodeID forward_edge_based_node_id; // needed for edge-expanded graph
 | 
					    NodeID forward_edge_based_node_id; // needed for edge-expanded graph
 | 
				
			||||||
    NodeID reverse_edge_based_node_id; // needed for edge-expanded graph
 | 
					    NodeID reverse_edge_based_node_id; // needed for edge-expanded graph
 | 
				
			||||||
    NodeID u;                          // indices into the coordinates array
 | 
					    NodeID u;                          // indices into the coordinates array
 | 
				
			||||||
 | 
				
			|||||||
@ -64,6 +64,8 @@ double perpendicularDistanceFromProjectedCoordinate(
 | 
				
			|||||||
    Coordinate &nearest_location,
 | 
					    Coordinate &nearest_location,
 | 
				
			||||||
    double &ratio);
 | 
					    double &ratio);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Coordinate centroid(const Coordinate lhs, const Coordinate rhs);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
double bearing(const Coordinate first_coordinate, const Coordinate second_coordinate);
 | 
					double bearing(const Coordinate first_coordinate, const Coordinate second_coordinate);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Get angle of line segment (A,C)->(C,B)
 | 
					// Get angle of line segment (A,C)->(C,B)
 | 
				
			||||||
 | 
				
			|||||||
@ -137,11 +137,8 @@ class StaticRTree
 | 
				
			|||||||
                    BOOST_ASSERT(current_element.u < coordinate_list.size());
 | 
					                    BOOST_ASSERT(current_element.u < coordinate_list.size());
 | 
				
			||||||
                    BOOST_ASSERT(current_element.v < coordinate_list.size());
 | 
					                    BOOST_ASSERT(current_element.v < coordinate_list.size());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    Coordinate current_centroid =
 | 
					                    Coordinate current_centroid = coordinate_calculation::centroid(
 | 
				
			||||||
                        EdgeDataT::Centroid(Coordinate(coordinate_list[current_element.u].lon,
 | 
					                        coordinate_list[current_element.u], coordinate_list[current_element.v]);
 | 
				
			||||||
                                                       coordinate_list[current_element.u].lat),
 | 
					 | 
				
			||||||
                                            Coordinate(coordinate_list[current_element.v].lon,
 | 
					 | 
				
			||||||
                                                       coordinate_list[current_element.v].lat));
 | 
					 | 
				
			||||||
                    current_centroid.lat = FixedLatitude(
 | 
					                    current_centroid.lat = FixedLatitude(
 | 
				
			||||||
                        COORDINATE_PRECISION *
 | 
					                        COORDINATE_PRECISION *
 | 
				
			||||||
                        coordinate_calculation::mercator::latToY(toFloating(current_centroid.lat)));
 | 
					                        coordinate_calculation::mercator::latToY(toFloating(current_centroid.lat)));
 | 
				
			||||||
 | 
				
			|||||||
@ -200,6 +200,16 @@ double perpendicularDistanceFromProjectedCoordinate(
 | 
				
			|||||||
    return approximate_distance;
 | 
					    return approximate_distance;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Coordinate centroid(const Coordinate lhs, const Coordinate rhs)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    Coordinate centroid;
 | 
				
			||||||
 | 
					    // The coordinates of the midpoints are given by:
 | 
				
			||||||
 | 
					    // x = (x1 + x2) /2 and y = (y1 + y2) /2.
 | 
				
			||||||
 | 
					    centroid.lon = (lhs.lon + rhs.lon) / FixedLongitude(2);
 | 
				
			||||||
 | 
					    centroid.lat = (lhs.lat + rhs.lat) / FixedLatitude(2);
 | 
				
			||||||
 | 
					    return centroid;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
double degToRad(const double degree)
 | 
					double degToRad(const double degree)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    using namespace boost::math::constants;
 | 
					    using namespace boost::math::constants;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user