Fix naming in coordinate_calculation
This commit is contained in:
		
							parent
							
								
									e8bc69aa01
								
							
						
					
					
						commit
						4312013552
					
				| @ -3,17 +3,28 @@ | ||||
| 
 | ||||
| #include "engine/descriptors/descriptor_base.hpp" | ||||
| #include "util/xml_renderer.hpp" | ||||
| #include "util/string_util.hpp" | ||||
| 
 | ||||
| #include "osrm/json_container.hpp" | ||||
| 
 | ||||
| #include <iostream> | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| template <class DataFacadeT> class GPXDescriptor final : public BaseDescriptor<DataFacadeT> | ||||
| { | ||||
|   private: | ||||
|     DescriptorConfig config; | ||||
|     DataFacadeT *facade; | ||||
| 
 | ||||
|     template<std::size_t digits> | ||||
|     void fixedIntToString(const int value, std::string &output) | ||||
|     { | ||||
|         char buffer[digits]; | ||||
|         buffer[digits-1] = 0; // zero termination
 | ||||
|         output = printInt<11, 6>(buffer, value); | ||||
|     } | ||||
| 
 | ||||
|     void AddRoutePoint(const FixedPointCoordinate &coordinate, osrm::json::Array &json_route) | ||||
|     { | ||||
|         osrm::json::Object json_lat; | ||||
| @ -22,10 +33,10 @@ template <class DataFacadeT> class GPXDescriptor final : public BaseDescriptor<D | ||||
| 
 | ||||
|         std::string tmp; | ||||
| 
 | ||||
|         coordinate_calculation::lat_or_lon_to_string(coordinate.lat, tmp); | ||||
|         fixedIntToString<12>(coordinate.lat, tmp); | ||||
|         json_lat.values["_lat"] = tmp; | ||||
| 
 | ||||
|         coordinate_calculation::lat_or_lon_to_string(coordinate.lon, tmp); | ||||
|         fixedIntToString<12>(coordinate.lon, tmp); | ||||
|         json_lon.values["_lon"] = tmp; | ||||
| 
 | ||||
|         json_row.values.push_back(json_lat); | ||||
|  | ||||
| @ -133,7 +133,7 @@ template <typename RTreeT> class GeospatialQuery | ||||
|     { | ||||
|         FixedPointCoordinate point_on_segment; | ||||
|         double ratio; | ||||
|         const auto current_perpendicular_distance = coordinate_calculation::perpendicular_distance( | ||||
|         const auto current_perpendicular_distance = coordinate_calculation::perpendicularDistance( | ||||
|             coordinates->at(data.u), coordinates->at(data.v), input_coordinate, point_on_segment, | ||||
|             ratio); | ||||
| 
 | ||||
|  | ||||
| @ -76,7 +76,7 @@ template <class DataFacadeT> class MapMatchingPlugin : public BasePlugin | ||||
| 
 | ||||
|         double query_radius = 10 * gps_precision; | ||||
|         double last_distance = | ||||
|             coordinate_calculation::haversine_distance(input_coords[0], input_coords[1]); | ||||
|             coordinate_calculation::haversineDistance(input_coords[0], input_coords[1]); | ||||
| 
 | ||||
|         sub_trace_lengths.resize(input_coords.size()); | ||||
|         sub_trace_lengths[0] = 0; | ||||
| @ -85,7 +85,7 @@ template <class DataFacadeT> class MapMatchingPlugin : public BasePlugin | ||||
|             bool allow_uturn = false; | ||||
|             if (0 < current_coordinate) | ||||
|             { | ||||
|                 last_distance = coordinate_calculation::haversine_distance( | ||||
|                 last_distance = coordinate_calculation::haversineDistance( | ||||
|                     input_coords[current_coordinate - 1], input_coords[current_coordinate]); | ||||
| 
 | ||||
|                 sub_trace_lengths[current_coordinate] += | ||||
|  | ||||
| @ -196,7 +196,7 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching< | ||||
|             const auto ¤t_coordinate = trace_coordinates[t]; | ||||
| 
 | ||||
|             const auto haversine_distance = | ||||
|                 coordinate_calculation::haversine_distance(prev_coordinate, current_coordinate); | ||||
|                 coordinate_calculation::haversineDistance(prev_coordinate, current_coordinate); | ||||
| 
 | ||||
|             // compute d_t for this timestamp and the next one
 | ||||
|             for (const auto s : osrm::irange<std::size_t>(0u, prev_viterbi.size())) | ||||
|  | ||||
| @ -648,11 +648,11 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface | ||||
|             for (const auto &p : unpacked_path) | ||||
|             { | ||||
|                 current_coordinate = facade->GetCoordinateOfNode(p.node); | ||||
|                 distance += coordinate_calculation::haversine_distance(previous_coordinate, | ||||
|                 distance += coordinate_calculation::haversineDistance(previous_coordinate, | ||||
|                                                                        current_coordinate); | ||||
|                 previous_coordinate = current_coordinate; | ||||
|             } | ||||
|             distance += coordinate_calculation::haversine_distance(previous_coordinate, | ||||
|             distance += coordinate_calculation::haversineDistance(previous_coordinate, | ||||
|                                                                    target_phantom.location); | ||||
|         } | ||||
|         return distance; | ||||
|  | ||||
| @ -8,44 +8,42 @@ struct FixedPointCoordinate; | ||||
| 
 | ||||
| namespace coordinate_calculation | ||||
| { | ||||
| double haversine_distance(const int lat1, const int lon1, const int lat2, const int lon2); | ||||
| double haversineDistance(const int lat1, const int lon1, const int lat2, const int lon2); | ||||
| 
 | ||||
| double haversine_distance(const FixedPointCoordinate &first_coordinate, | ||||
|                           const FixedPointCoordinate &second_coordinate); | ||||
| double haversineDistance(const FixedPointCoordinate &first_coordinate, | ||||
|                          const FixedPointCoordinate &second_coordinate); | ||||
| 
 | ||||
| double great_circle_distance(const FixedPointCoordinate &first_coordinate, | ||||
|                              const FixedPointCoordinate &second_coordinate); | ||||
| double greatCircleDistance(const FixedPointCoordinate &first_coordinate, | ||||
|                            const FixedPointCoordinate &second_coordinate); | ||||
| 
 | ||||
| double great_circle_distance(const int lat1, const int lon1, const int lat2, const int lon2); | ||||
| double greatCircleDistance(const int lat1, const int lon1, const int lat2, const int lon2); | ||||
| 
 | ||||
| void lat_or_lon_to_string(const int value, std::string &output); | ||||
| double perpendicularDistance(const FixedPointCoordinate &segment_source, | ||||
|                              const FixedPointCoordinate &segment_target, | ||||
|                              const FixedPointCoordinate &query_location); | ||||
| 
 | ||||
| double perpendicular_distance(const FixedPointCoordinate &segment_source, | ||||
|                               const FixedPointCoordinate &segment_target, | ||||
|                               const FixedPointCoordinate &query_location); | ||||
| double perpendicularDistance(const FixedPointCoordinate &segment_source, | ||||
|                              const FixedPointCoordinate &segment_target, | ||||
|                              const FixedPointCoordinate &query_location, | ||||
|                              FixedPointCoordinate &nearest_location, | ||||
|                              double &ratio); | ||||
| 
 | ||||
| double perpendicular_distance(const FixedPointCoordinate &segment_source, | ||||
|                               const FixedPointCoordinate &segment_target, | ||||
|                               const FixedPointCoordinate &query_location, | ||||
|                               FixedPointCoordinate &nearest_location, | ||||
|                               double &ratio); | ||||
| double | ||||
| perpendicularDistanceFromProjectedCoordinate(const FixedPointCoordinate &segment_source, | ||||
|                                              const FixedPointCoordinate &segment_target, | ||||
|                                              const FixedPointCoordinate &query_location, | ||||
|                                              const std::pair<double, double> &projected_coordinate); | ||||
| 
 | ||||
| double perpendicular_distance_from_projected_coordinate( | ||||
|     const FixedPointCoordinate &segment_source, | ||||
|     const FixedPointCoordinate &segment_target, | ||||
|     const FixedPointCoordinate &query_location, | ||||
|     const std::pair<double, double> &projected_coordinate); | ||||
| double | ||||
| perpendicularDistanceFromProjectedCoordinate(const FixedPointCoordinate &segment_source, | ||||
|                                              const FixedPointCoordinate &segment_target, | ||||
|                                              const FixedPointCoordinate &query_location, | ||||
|                                              const std::pair<double, double> &projected_coordinate, | ||||
|                                              FixedPointCoordinate &nearest_location, | ||||
|                                              double &ratio); | ||||
| 
 | ||||
| double perpendicular_distance_from_projected_coordinate( | ||||
|     const FixedPointCoordinate &segment_source, | ||||
|     const FixedPointCoordinate &segment_target, | ||||
|     const FixedPointCoordinate &query_location, | ||||
|     const std::pair<double, double> &projected_coordinate, | ||||
|     FixedPointCoordinate &nearest_location, | ||||
|     double &ratio); | ||||
| 
 | ||||
| double deg_to_rad(const double degree); | ||||
| double rad_to_deg(const double radian); | ||||
| double degToRad(const double degree); | ||||
| double radToDeg(const double radian); | ||||
| 
 | ||||
| double bearing(const FixedPointCoordinate &first_coordinate, | ||||
|                const FixedPointCoordinate &second_coordinate); | ||||
|  | ||||
| @ -94,35 +94,35 @@ struct RectangleInt2D | ||||
|         switch (d) | ||||
|         { | ||||
|         case NORTH: | ||||
|             min_dist = coordinate_calculation::great_circle_distance( | ||||
|             min_dist = coordinate_calculation::greatCircleDistance( | ||||
|                 location, FixedPointCoordinate(max_lat, location.lon)); | ||||
|             break; | ||||
|         case SOUTH: | ||||
|             min_dist = coordinate_calculation::great_circle_distance( | ||||
|             min_dist = coordinate_calculation::greatCircleDistance( | ||||
|                 location, FixedPointCoordinate(min_lat, location.lon)); | ||||
|             break; | ||||
|         case WEST: | ||||
|             min_dist = coordinate_calculation::great_circle_distance( | ||||
|             min_dist = coordinate_calculation::greatCircleDistance( | ||||
|                 location, FixedPointCoordinate(location.lat, min_lon)); | ||||
|             break; | ||||
|         case EAST: | ||||
|             min_dist = coordinate_calculation::great_circle_distance( | ||||
|             min_dist = coordinate_calculation::greatCircleDistance( | ||||
|                 location, FixedPointCoordinate(location.lat, max_lon)); | ||||
|             break; | ||||
|         case NORTH_EAST: | ||||
|             min_dist = coordinate_calculation::great_circle_distance( | ||||
|             min_dist = coordinate_calculation::greatCircleDistance( | ||||
|                 location, FixedPointCoordinate(max_lat, max_lon)); | ||||
|             break; | ||||
|         case NORTH_WEST: | ||||
|             min_dist = coordinate_calculation::great_circle_distance( | ||||
|             min_dist = coordinate_calculation::greatCircleDistance( | ||||
|                 location, FixedPointCoordinate(max_lat, min_lon)); | ||||
|             break; | ||||
|         case SOUTH_EAST: | ||||
|             min_dist = coordinate_calculation::great_circle_distance( | ||||
|             min_dist = coordinate_calculation::greatCircleDistance( | ||||
|                 location, FixedPointCoordinate(min_lat, max_lon)); | ||||
|             break; | ||||
|         case SOUTH_WEST: | ||||
|             min_dist = coordinate_calculation::great_circle_distance( | ||||
|             min_dist = coordinate_calculation::greatCircleDistance( | ||||
|                 location, FixedPointCoordinate(min_lat, min_lon)); | ||||
|             break; | ||||
|         default: | ||||
| @ -145,23 +145,23 @@ struct RectangleInt2D | ||||
| 
 | ||||
|         min_max_dist = std::min( | ||||
|             min_max_dist, | ||||
|             std::max(coordinate_calculation::great_circle_distance(location, upper_left), | ||||
|                      coordinate_calculation::great_circle_distance(location, upper_right))); | ||||
|             std::max(coordinate_calculation::greatCircleDistance(location, upper_left), | ||||
|                      coordinate_calculation::greatCircleDistance(location, upper_right))); | ||||
| 
 | ||||
|         min_max_dist = std::min( | ||||
|             min_max_dist, | ||||
|             std::max(coordinate_calculation::great_circle_distance(location, upper_right), | ||||
|                      coordinate_calculation::great_circle_distance(location, lower_right))); | ||||
|             std::max(coordinate_calculation::greatCircleDistance(location, upper_right), | ||||
|                      coordinate_calculation::greatCircleDistance(location, lower_right))); | ||||
| 
 | ||||
|         min_max_dist = | ||||
|             std::min(min_max_dist, | ||||
|                      std::max(coordinate_calculation::great_circle_distance(location, lower_right), | ||||
|                               coordinate_calculation::great_circle_distance(location, lower_left))); | ||||
|                      std::max(coordinate_calculation::greatCircleDistance(location, lower_right), | ||||
|                               coordinate_calculation::greatCircleDistance(location, lower_left))); | ||||
| 
 | ||||
|         min_max_dist = | ||||
|             std::min(min_max_dist, | ||||
|                      std::max(coordinate_calculation::great_circle_distance(location, lower_left), | ||||
|                               coordinate_calculation::great_circle_distance(location, upper_left))); | ||||
|                      std::max(coordinate_calculation::greatCircleDistance(location, lower_left), | ||||
|                               coordinate_calculation::greatCircleDistance(location, upper_left))); | ||||
|         return min_max_dist; | ||||
|     } | ||||
| 
 | ||||
|  | ||||
| @ -415,7 +415,7 @@ class StaticRTree | ||||
|         { | ||||
|             auto ¤t_edge = current_leaf_node.objects[i]; | ||||
|             const float current_perpendicular_distance = | ||||
|                 coordinate_calculation::perpendicular_distance_from_projected_coordinate( | ||||
|                 coordinate_calculation::perpendicularDistanceFromProjectedCoordinate( | ||||
|                     m_coordinate_list->at(current_edge.u), m_coordinate_list->at(current_edge.v), | ||||
|                     input_coordinate, projected_coordinate); | ||||
|             // distance must be non-negative
 | ||||
|  | ||||
| @ -100,7 +100,7 @@ void DescriptionFactory::Run(const unsigned zoom_level) | ||||
|     { | ||||
|         // move down names by one, q&d hack
 | ||||
|         path_description[i - 1].name_id = path_description[i].name_id; | ||||
|         path_description[i].length = coordinate_calculation::great_circle_distance( | ||||
|         path_description[i].length = coordinate_calculation::greatCircleDistance( | ||||
|             path_description[i - 1].location, path_description[i].location); | ||||
|     } | ||||
| 
 | ||||
|  | ||||
| @ -541,7 +541,7 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges( | ||||
|                             const QueryNode &from = m_node_info_list[previous]; | ||||
|                             const QueryNode &to = m_node_info_list[target_node.first]; | ||||
|                             const double segment_length = | ||||
|                                 coordinate_calculation::great_circle_distance(from.lat, from.lon, | ||||
|                                 coordinate_calculation::greatCircleDistance(from.lat, from.lon, | ||||
|                                                                               to.lat, to.lon); | ||||
| 
 | ||||
|                             edge_segment_file.write(reinterpret_cast<const char *>(&to.node_id), | ||||
| @ -559,7 +559,7 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges( | ||||
|                         static const unsigned node_count = 2; | ||||
|                         const QueryNode from = m_node_info_list[node_u]; | ||||
|                         const QueryNode to = m_node_info_list[node_v]; | ||||
|                         const double segment_length = coordinate_calculation::great_circle_distance( | ||||
|                         const double segment_length = coordinate_calculation::greatCircleDistance( | ||||
|                             from.lat, from.lon, to.lat, to.lon); | ||||
|                         edge_segment_file.write(reinterpret_cast<const char *>(&node_count), | ||||
|                                                 sizeof(node_count)); | ||||
|  | ||||
| @ -302,7 +302,7 @@ void ExtractionContainers::PrepareEdges(lua_State *segment_state) | ||||
|         BOOST_ASSERT(edge_iterator->source_coordinate.lat != std::numeric_limits<int>::min()); | ||||
|         BOOST_ASSERT(edge_iterator->source_coordinate.lon != std::numeric_limits<int>::min()); | ||||
| 
 | ||||
|         const double distance = coordinate_calculation::great_circle_distance( | ||||
|         const double distance = coordinate_calculation::greatCircleDistance( | ||||
|             edge_iterator->source_coordinate.lat, edge_iterator->source_coordinate.lon, | ||||
|             node_iterator->lat, node_iterator->lon); | ||||
| 
 | ||||
|  | ||||
| @ -177,7 +177,7 @@ int main(int argc, char *argv[]) | ||||
|                 if (source < target || SPECIAL_EDGEID == graph->FindEdge(target, source)) | ||||
|                 { | ||||
|                     total_network_length += | ||||
|                         100 * coordinate_calculation::great_circle_distance( | ||||
|                         100 * coordinate_calculation::greatCircleDistance( | ||||
|                                   coordinate_list[source].lat, coordinate_list[source].lon, | ||||
|                                   coordinate_list[target].lat, coordinate_list[target].lon); | ||||
| 
 | ||||
|  | ||||
| @ -22,7 +22,7 @@ constexpr static const double earth_radius = 6372797.560856; | ||||
| namespace coordinate_calculation | ||||
| { | ||||
| 
 | ||||
| double haversine_distance(const int lat1, const int lon1, const int lat2, const int lon2) | ||||
| double haversineDistance(const int lat1, const int lon1, const int lat2, const int lon2) | ||||
| { | ||||
|     BOOST_ASSERT(lat1 != std::numeric_limits<int>::min()); | ||||
|     BOOST_ASSERT(lon1 != std::numeric_limits<int>::min()); | ||||
| @ -38,30 +38,30 @@ double haversine_distance(const int lat1, const int lon1, const int lat2, const | ||||
|     const double dlat2 = lt2 * (RAD); | ||||
|     const double dlong2 = ln2 * (RAD); | ||||
| 
 | ||||
|     const double dLong = dlong1 - dlong2; | ||||
|     const double dLat = dlat1 - dlat2; | ||||
|     const double dlong = dlong1 - dlong2; | ||||
|     const double dlat = dlat1 - dlat2; | ||||
| 
 | ||||
|     const double aHarv = std::pow(std::sin(dLat / 2.0), 2.0) + | ||||
|                          std::cos(dlat1) * std::cos(dlat2) * std::pow(std::sin(dLong / 2.), 2); | ||||
|     const double cHarv = 2. * std::atan2(std::sqrt(aHarv), std::sqrt(1.0 - aHarv)); | ||||
|     return earth_radius * cHarv; | ||||
|     const double aharv = std::pow(std::sin(dlat / 2.0), 2.0) + | ||||
|                          std::cos(dlat1) * std::cos(dlat2) * std::pow(std::sin(dlong / 2.), 2); | ||||
|     const double charv = 2. * std::atan2(std::sqrt(aharv), std::sqrt(1.0 - aharv)); | ||||
|     return earth_radius * charv; | ||||
| } | ||||
| 
 | ||||
| double haversine_distance(const FixedPointCoordinate &coordinate_1, | ||||
|                           const FixedPointCoordinate &coordinate_2) | ||||
| double haversineDistance(const FixedPointCoordinate &coordinate_1, | ||||
|                          const FixedPointCoordinate &coordinate_2) | ||||
| { | ||||
|     return haversine_distance(coordinate_1.lat, coordinate_1.lon, coordinate_2.lat, | ||||
|                               coordinate_2.lon); | ||||
|     return haversineDistance(coordinate_1.lat, coordinate_1.lon, coordinate_2.lat, | ||||
|                              coordinate_2.lon); | ||||
| } | ||||
| 
 | ||||
| double great_circle_distance(const FixedPointCoordinate &coordinate_1, | ||||
|                              const FixedPointCoordinate &coordinate_2) | ||||
| double greatCircleDistance(const FixedPointCoordinate &coordinate_1, | ||||
|                            const FixedPointCoordinate &coordinate_2) | ||||
| { | ||||
|     return great_circle_distance(coordinate_1.lat, coordinate_1.lon, coordinate_2.lat, | ||||
|                                  coordinate_2.lon); | ||||
|     return greatCircleDistance(coordinate_1.lat, coordinate_1.lon, coordinate_2.lat, | ||||
|                                coordinate_2.lon); | ||||
| } | ||||
| 
 | ||||
| double great_circle_distance(const int lat1, const int lon1, const int lat2, const int lon2) | ||||
| double greatCircleDistance(const int lat1, const int lon1, const int lat2, const int lon2) | ||||
| { | ||||
|     BOOST_ASSERT(lat1 != std::numeric_limits<int>::min()); | ||||
|     BOOST_ASSERT(lon1 != std::numeric_limits<int>::min()); | ||||
| @ -78,51 +78,51 @@ double great_circle_distance(const int lat1, const int lon1, const int lat2, con | ||||
|     return std::hypot(x_value, y_value) * earth_radius; | ||||
| } | ||||
| 
 | ||||
| double perpendicular_distance(const FixedPointCoordinate &source_coordinate, | ||||
|                               const FixedPointCoordinate &target_coordinate, | ||||
|                               const FixedPointCoordinate &query_location) | ||||
| double perpendicularDistance(const FixedPointCoordinate &source_coordinate, | ||||
|                              const FixedPointCoordinate &target_coordinate, | ||||
|                              const FixedPointCoordinate &query_location) | ||||
| { | ||||
|     double ratio; | ||||
|     FixedPointCoordinate nearest_location; | ||||
| 
 | ||||
|     return perpendicular_distance(source_coordinate, target_coordinate, query_location, | ||||
|                                   nearest_location, ratio); | ||||
|     return perpendicularDistance(source_coordinate, target_coordinate, query_location, | ||||
|                                  nearest_location, ratio); | ||||
| } | ||||
| 
 | ||||
| double perpendicular_distance(const FixedPointCoordinate &segment_source, | ||||
|                               const FixedPointCoordinate &segment_target, | ||||
|                               const FixedPointCoordinate &query_location, | ||||
|                               FixedPointCoordinate &nearest_location, | ||||
|                               double &ratio) | ||||
| double perpendicularDistance(const FixedPointCoordinate &segment_source, | ||||
|                              const FixedPointCoordinate &segment_target, | ||||
|                              const FixedPointCoordinate &query_location, | ||||
|                              FixedPointCoordinate &nearest_location, | ||||
|                              double &ratio) | ||||
| { | ||||
|     return perpendicular_distance_from_projected_coordinate( | ||||
|     return perpendicularDistanceFromProjectedCoordinate( | ||||
|         segment_source, segment_target, query_location, | ||||
|         {mercator::lat2y(query_location.lat / COORDINATE_PRECISION), | ||||
|          query_location.lon / COORDINATE_PRECISION}, | ||||
|         nearest_location, ratio); | ||||
| } | ||||
| 
 | ||||
| double perpendicular_distance_from_projected_coordinate( | ||||
|     const FixedPointCoordinate &source_coordinate, | ||||
|     const FixedPointCoordinate &target_coordinate, | ||||
|     const FixedPointCoordinate &query_location, | ||||
|     const std::pair<double, double> &projected_coordinate) | ||||
| double | ||||
| perpendicularDistanceFromProjectedCoordinate(const FixedPointCoordinate &source_coordinate, | ||||
|                                              const FixedPointCoordinate &target_coordinate, | ||||
|                                              const FixedPointCoordinate &query_location, | ||||
|                                              const std::pair<double, double> &projected_coordinate) | ||||
| { | ||||
|     double ratio; | ||||
|     FixedPointCoordinate nearest_location; | ||||
| 
 | ||||
|     return perpendicular_distance_from_projected_coordinate(source_coordinate, target_coordinate, | ||||
|                                                             query_location, projected_coordinate, | ||||
|                                                             nearest_location, ratio); | ||||
|     return perpendicularDistanceFromProjectedCoordinate(source_coordinate, target_coordinate, | ||||
|                                                         query_location, projected_coordinate, | ||||
|                                                         nearest_location, ratio); | ||||
| } | ||||
| 
 | ||||
| double perpendicular_distance_from_projected_coordinate( | ||||
|     const FixedPointCoordinate &segment_source, | ||||
|     const FixedPointCoordinate &segment_target, | ||||
|     const FixedPointCoordinate &query_location, | ||||
|     const std::pair<double, double> &projected_coordinate, | ||||
|     FixedPointCoordinate &nearest_location, | ||||
|     double &ratio) | ||||
| double | ||||
| perpendicularDistanceFromProjectedCoordinate(const FixedPointCoordinate &segment_source, | ||||
|                                              const FixedPointCoordinate &segment_target, | ||||
|                                              const FixedPointCoordinate &query_location, | ||||
|                                              const std::pair<double, double> &projected_coordinate, | ||||
|                                              FixedPointCoordinate &nearest_location, | ||||
|                                              double &ratio) | ||||
| { | ||||
|     BOOST_ASSERT(query_location.is_valid()); | ||||
| 
 | ||||
| @ -133,7 +133,7 @@ double perpendicular_distance_from_projected_coordinate( | ||||
|     const double b = segment_source.lon / COORDINATE_PRECISION; | ||||
|     const double c = mercator::lat2y(segment_target.lat / COORDINATE_PRECISION); | ||||
|     const double d = segment_target.lon / COORDINATE_PRECISION; | ||||
|     double p, q /*,mX*/, nY; | ||||
|     double p, q /*,mX*/, new_y; | ||||
|     if (std::abs(a - c) > std::numeric_limits<double>::epsilon()) | ||||
|     { | ||||
|         const double m = (d - b) / (c - a); // slope
 | ||||
| @ -146,16 +146,16 @@ double perpendicular_distance_from_projected_coordinate( | ||||
|         p = c; | ||||
|         q = y; | ||||
|     } | ||||
|     nY = (d * p - c * q) / (a * d - b * c); | ||||
|     new_y = (d * p - c * q) / (a * d - b * c); | ||||
| 
 | ||||
|     // discretize the result to coordinate precision. it's a hack!
 | ||||
|     if (std::abs(nY) < (1.0 / COORDINATE_PRECISION)) | ||||
|     if (std::abs(new_y) < (1.0 / COORDINATE_PRECISION)) | ||||
|     { | ||||
|         nY = 0.0; | ||||
|         new_y = 0.0; | ||||
|     } | ||||
| 
 | ||||
|     // compute ratio
 | ||||
|     ratio = static_cast<double>((p - nY * a) / | ||||
|     ratio = static_cast<double>((p - new_y * a) / | ||||
|                                 c); // These values are actually n/m+n and m/m+n , we need
 | ||||
|     // not calculate the explicit values of m an n as we
 | ||||
|     // are just interested in the ratio
 | ||||
| @ -190,34 +190,27 @@ double perpendicular_distance_from_projected_coordinate( | ||||
|     } | ||||
|     BOOST_ASSERT(nearest_location.is_valid()); | ||||
| 
 | ||||
|     const double approximate_distance = great_circle_distance(query_location, nearest_location); | ||||
|     const double approximate_distance = greatCircleDistance(query_location, nearest_location); | ||||
|     BOOST_ASSERT(0.0 <= approximate_distance); | ||||
|     return approximate_distance; | ||||
| } | ||||
| 
 | ||||
| void lat_or_lon_to_string(const int value, std::string &output) | ||||
| { | ||||
|     char buffer[12]; | ||||
|     buffer[11] = 0; // zero termination
 | ||||
|     output = printInt<11, 6>(buffer, value); | ||||
| } | ||||
| double degToRad(const double degree) { return degree * (static_cast<double>(M_PI) / 180.0); } | ||||
| 
 | ||||
| double deg_to_rad(const double degree) { return degree * (static_cast<double>(M_PI) / 180.0); } | ||||
| 
 | ||||
| double rad_to_deg(const double radian) { return radian * (180.0 * static_cast<double>(M_1_PI)); } | ||||
| double radToDeg(const double radian) { return radian * (180.0 * static_cast<double>(M_1_PI)); } | ||||
| 
 | ||||
| double bearing(const FixedPointCoordinate &first_coordinate, | ||||
|                const FixedPointCoordinate &second_coordinate) | ||||
| { | ||||
|     const double lon_diff = | ||||
|         second_coordinate.lon / COORDINATE_PRECISION - first_coordinate.lon / COORDINATE_PRECISION; | ||||
|     const double lon_delta = deg_to_rad(lon_diff); | ||||
|     const double lat1 = deg_to_rad(first_coordinate.lat / COORDINATE_PRECISION); | ||||
|     const double lat2 = deg_to_rad(second_coordinate.lat / COORDINATE_PRECISION); | ||||
|     const double lon_delta = degToRad(lon_diff); | ||||
|     const double lat1 = degToRad(first_coordinate.lat / COORDINATE_PRECISION); | ||||
|     const double lat2 = degToRad(second_coordinate.lat / COORDINATE_PRECISION); | ||||
|     const double y = std::sin(lon_delta) * std::cos(lat2); | ||||
|     const double x = | ||||
|         std::cos(lat1) * std::sin(lat2) - std::sin(lat1) * std::cos(lat2) * std::cos(lon_delta); | ||||
|     double result = rad_to_deg(std::atan2(y, x)); | ||||
|     double result = radToDeg(std::atan2(y, x)); | ||||
|     while (result < 0.0) | ||||
|     { | ||||
|         result += 360.0; | ||||
|  | ||||
| @ -13,11 +13,11 @@ BOOST_AUTO_TEST_CASE(regression_test_1347) | ||||
|     FixedPointCoordinate v(10.001 * COORDINATE_PRECISION, -100.002 * COORDINATE_PRECISION); | ||||
|     FixedPointCoordinate q(10.002 * COORDINATE_PRECISION, -100.001 * COORDINATE_PRECISION); | ||||
| 
 | ||||
|     double d1 = coordinate_calculation::perpendicular_distance(u, v, q); | ||||
|     double d1 = coordinate_calculation::perpendicularDistance(u, v, q); | ||||
| 
 | ||||
|     double ratio; | ||||
|     FixedPointCoordinate nearest_location; | ||||
|     double d2 = coordinate_calculation::perpendicular_distance(u, v, q, nearest_location, ratio); | ||||
|     double d2 = coordinate_calculation::perpendicularDistance(u, v, q, nearest_location, ratio); | ||||
| 
 | ||||
|     BOOST_CHECK_LE(std::abs(d1 - d2), 0.01); | ||||
| } | ||||
|  | ||||
| @ -63,9 +63,9 @@ template <typename DataT> class LinearSearchNN | ||||
|             { | ||||
|                 double current_ratio = 0.; | ||||
|                 FixedPointCoordinate nearest; | ||||
|                 const double lhs_dist = coordinate_calculation::perpendicular_distance( | ||||
|                 const double lhs_dist = coordinate_calculation::perpendicularDistance( | ||||
|                     coords->at(lhs.u), coords->at(lhs.v), input_coordinate, nearest, current_ratio); | ||||
|                 const double rhs_dist = coordinate_calculation::perpendicular_distance( | ||||
|                 const double rhs_dist = coordinate_calculation::perpendicularDistance( | ||||
|                     coords->at(rhs.u), coords->at(rhs.v), input_coordinate, nearest, current_ratio); | ||||
|                 return lhs_dist < rhs_dist; | ||||
|             }); | ||||
| @ -231,9 +231,9 @@ void sampling_verify_rtree(RTreeT &rtree, | ||||
| 
 | ||||
|         double current_ratio = 0.; | ||||
|         FixedPointCoordinate nearest; | ||||
|         const double rtree_dist = coordinate_calculation::perpendicular_distance( | ||||
|         const double rtree_dist = coordinate_calculation::perpendicularDistance( | ||||
|             coords[rtree_u], coords[rtree_v], q, nearest, current_ratio); | ||||
|         const double lsnn_dist = coordinate_calculation::perpendicular_distance( | ||||
|         const double lsnn_dist = coordinate_calculation::perpendicularDistance( | ||||
|             coords[lsnn_u], coords[lsnn_v], q, nearest, current_ratio); | ||||
|         BOOST_CHECK_LE(std::abs(rtree_dist - lsnn_dist), std::numeric_limits<double>::epsilon()); | ||||
|     } | ||||
| @ -358,30 +358,30 @@ void TestRectangle(double width, double height, double center_lat, double center | ||||
| 
 | ||||
|     /* Distance to line segments of rectangle */ | ||||
|     BOOST_CHECK_EQUAL(rect.GetMinDist(north), | ||||
|                       coordinate_calculation::great_circle_distance( | ||||
|                       coordinate_calculation::greatCircleDistance( | ||||
|                           north, FixedPointCoordinate(rect.max_lat, north.lon))); | ||||
|     BOOST_CHECK_EQUAL(rect.GetMinDist(south), | ||||
|                       coordinate_calculation::great_circle_distance( | ||||
|                       coordinate_calculation::greatCircleDistance( | ||||
|                           south, FixedPointCoordinate(rect.min_lat, south.lon))); | ||||
|     BOOST_CHECK_EQUAL(rect.GetMinDist(west), | ||||
|                       coordinate_calculation::great_circle_distance( | ||||
|                       coordinate_calculation::greatCircleDistance( | ||||
|                           west, FixedPointCoordinate(west.lat, rect.min_lon))); | ||||
|     BOOST_CHECK_EQUAL(rect.GetMinDist(east), | ||||
|                       coordinate_calculation::great_circle_distance( | ||||
|                       coordinate_calculation::greatCircleDistance( | ||||
|                           east, FixedPointCoordinate(east.lat, rect.max_lon))); | ||||
| 
 | ||||
|     /* Distance to corner points */ | ||||
|     BOOST_CHECK_EQUAL(rect.GetMinDist(north_east), | ||||
|                       coordinate_calculation::great_circle_distance( | ||||
|                       coordinate_calculation::greatCircleDistance( | ||||
|                           north_east, FixedPointCoordinate(rect.max_lat, rect.max_lon))); | ||||
|     BOOST_CHECK_EQUAL(rect.GetMinDist(north_west), | ||||
|                       coordinate_calculation::great_circle_distance( | ||||
|                       coordinate_calculation::greatCircleDistance( | ||||
|                           north_west, FixedPointCoordinate(rect.max_lat, rect.min_lon))); | ||||
|     BOOST_CHECK_EQUAL(rect.GetMinDist(south_east), | ||||
|                       coordinate_calculation::great_circle_distance( | ||||
|                       coordinate_calculation::greatCircleDistance( | ||||
|                           south_east, FixedPointCoordinate(rect.min_lat, rect.max_lon))); | ||||
|     BOOST_CHECK_EQUAL(rect.GetMinDist(south_west), | ||||
|                       coordinate_calculation::great_circle_distance( | ||||
|                       coordinate_calculation::greatCircleDistance( | ||||
|                           south_west, FixedPointCoordinate(rect.min_lat, rect.min_lon))); | ||||
| } | ||||
| 
 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user