Fix naming in coordinate_calculation

This commit is contained in:
Patrick Niklaus
2016-01-04 13:30:03 +01:00
parent e8bc69aa01
commit 4312013552
15 changed files with 137 additions and 135 deletions
+13 -2
View File
@@ -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);
+1 -1
View File
@@ -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);
+2 -2
View File
@@ -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 &current_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;
+28 -30
View File
@@ -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);
+16 -16
View File
@@ -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;
}
+1 -1
View File
@@ -415,7 +415,7 @@ class StaticRTree
{
auto &current_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