Skip to content

Commit

Permalink
Move calculate_coordinate to algorithms/
Browse files Browse the repository at this point in the history
Fixes #1367
  • Loading branch information
TheMarex authored and chaupow committed Sep 1, 2015
1 parent 2c10ef9 commit 14e63eb
Show file tree
Hide file tree
Showing 14 changed files with 53 additions and 48 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ add_executable(osrm-prepare ${PrepareSources} $<TARGET_OBJECTS:ANGLE> $<TARGET_O
file(GLOB ServerGlob server/*.cpp)
file(GLOB DescriptorGlob descriptors/*.cpp)
file(GLOB DatastructureGlob data_structures/search_engine_data.cpp data_structures/route_parameters.cpp util/bearing.cpp)
file(GLOB CoordinateGlob data_structures/coordinate*.cpp)
file(GLOB CoordinateGlob data_structures/coordinate.cpp algorithms/coordinate_calculation.cpp)
file(GLOB AlgorithmGlob algorithms/polyline_compressor.cpp algorithms/polyline_formatter.cpp algorithms/douglas_peucker.cpp)
file(GLOB HttpGlob server/http/*.cpp)
file(GLOB LibOSRMGlob library/*.cpp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ constexpr static const float RAD = 0.017453292519943295769236907684886f;
constexpr static const float earth_radius = 6372797.560856f;
}

double coordinate_calculation::great_circle_distance(const int lat1,
namespace coordinate_calculation
{

double great_circle_distance(const int lat1,
const int lon1,
const int lat2,
const int lon2)
Expand Down Expand Up @@ -74,21 +77,21 @@ double coordinate_calculation::great_circle_distance(const int lat1,
return earth_radius * cHarv;
}

double coordinate_calculation::great_circle_distance(const FixedPointCoordinate &coordinate_1,
double great_circle_distance(const FixedPointCoordinate &coordinate_1,
const FixedPointCoordinate &coordinate_2)
{
return great_circle_distance(coordinate_1.lat, coordinate_1.lon, coordinate_2.lat,
coordinate_2.lon);
}

float coordinate_calculation::euclidean_distance(const FixedPointCoordinate &coordinate_1,
float euclidean_distance(const FixedPointCoordinate &coordinate_1,
const FixedPointCoordinate &coordinate_2)
{
return euclidean_distance(coordinate_1.lat, coordinate_1.lon, coordinate_2.lat,
coordinate_2.lon);
}

float coordinate_calculation::euclidean_distance(const int lat1,
float euclidean_distance(const int lat1,
const int lon1,
const int lat2,
const int lon2)
Expand All @@ -108,7 +111,7 @@ float coordinate_calculation::euclidean_distance(const int lat1,
return std::hypot(x_value, y_value) * earth_radius;
}

float coordinate_calculation::perpendicular_distance(const FixedPointCoordinate &source_coordinate,
float perpendicular_distance(const FixedPointCoordinate &source_coordinate,
const FixedPointCoordinate &target_coordinate,
const FixedPointCoordinate &query_location)
{
Expand All @@ -119,7 +122,7 @@ float coordinate_calculation::perpendicular_distance(const FixedPointCoordinate
nearest_location, ratio);
}

float coordinate_calculation::perpendicular_distance(const FixedPointCoordinate &segment_source,
float perpendicular_distance(const FixedPointCoordinate &segment_source,
const FixedPointCoordinate &segment_target,
const FixedPointCoordinate &query_location,
FixedPointCoordinate &nearest_location,
Expand All @@ -132,7 +135,7 @@ float coordinate_calculation::perpendicular_distance(const FixedPointCoordinate
nearest_location, ratio);
}

float coordinate_calculation::perpendicular_distance_from_projected_coordinate(
float perpendicular_distance_from_projected_coordinate(
const FixedPointCoordinate &source_coordinate,
const FixedPointCoordinate &target_coordinate,
const FixedPointCoordinate &query_location,
Expand All @@ -146,7 +149,7 @@ float coordinate_calculation::perpendicular_distance_from_projected_coordinate(
nearest_location, ratio);
}

float coordinate_calculation::perpendicular_distance_from_projected_coordinate(
float perpendicular_distance_from_projected_coordinate(
const FixedPointCoordinate &segment_source,
const FixedPointCoordinate &segment_target,
const FixedPointCoordinate &query_location,
Expand Down Expand Up @@ -221,29 +224,29 @@ float coordinate_calculation::perpendicular_distance_from_projected_coordinate(
BOOST_ASSERT(nearest_location.is_valid());

const float approximate_distance =
coordinate_calculation::euclidean_distance(query_location, nearest_location);
euclidean_distance(query_location, nearest_location);
BOOST_ASSERT(0.f <= approximate_distance);
return approximate_distance;
}

void coordinate_calculation::lat_or_lon_to_string(const int value, std::string &output)
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);
}

float coordinate_calculation::deg_to_rad(const float degree)
float deg_to_rad(const float degree)
{
return degree * (static_cast<float>(M_PI) / 180.f);
}

float coordinate_calculation::rad_to_deg(const float radian)
float rad_to_deg(const float radian)
{
return radian * (180.f * static_cast<float>(M_1_PI));
}

float coordinate_calculation::bearing(const FixedPointCoordinate &first_coordinate,
float bearing(const FixedPointCoordinate &first_coordinate,
const FixedPointCoordinate &second_coordinate)
{
const float lon_diff =
Expand All @@ -266,3 +269,5 @@ float coordinate_calculation::bearing(const FixedPointCoordinate &first_coordina
}
return result;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -33,50 +33,50 @@ struct FixedPointCoordinate;
#include <string>
#include <utility>

struct coordinate_calculation
namespace coordinate_calculation
{
static double
double
great_circle_distance(const int lat1, const int lon1, const int lat2, const int lon2);

static double great_circle_distance(const FixedPointCoordinate &first_coordinate,
const FixedPointCoordinate &second_coordinate);
double great_circle_distance(const FixedPointCoordinate &first_coordinate,
const FixedPointCoordinate &second_coordinate);

static float euclidean_distance(const FixedPointCoordinate &first_coordinate,
const FixedPointCoordinate &second_coordinate);
float euclidean_distance(const FixedPointCoordinate &first_coordinate,
const FixedPointCoordinate &second_coordinate);

static float euclidean_distance(const int lat1, const int lon1, const int lat2, const int lon2);
float euclidean_distance(const int lat1, const int lon1, const int lat2, const int lon2);

static void lat_or_lon_to_string(const int value, std::string &output);
void lat_or_lon_to_string(const int value, std::string &output);

static float perpendicular_distance(const FixedPointCoordinate &segment_source,
const FixedPointCoordinate &segment_target,
const FixedPointCoordinate &query_location);
float perpendicular_distance(const FixedPointCoordinate &segment_source,
const FixedPointCoordinate &segment_target,
const FixedPointCoordinate &query_location);

static float perpendicular_distance(const FixedPointCoordinate &segment_source,
const FixedPointCoordinate &segment_target,
const FixedPointCoordinate &query_location,
FixedPointCoordinate &nearest_location,
float &ratio);
float perpendicular_distance(const FixedPointCoordinate &segment_source,
const FixedPointCoordinate &segment_target,
const FixedPointCoordinate &query_location,
FixedPointCoordinate &nearest_location,
float &ratio);

static float perpendicular_distance_from_projected_coordinate(
float perpendicular_distance_from_projected_coordinate(
const FixedPointCoordinate &segment_source,
const FixedPointCoordinate &segment_target,
const FixedPointCoordinate &query_location,
const std::pair<double, double> &projected_coordinate);

static float perpendicular_distance_from_projected_coordinate(
float 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,
float &ratio);

static float deg_to_rad(const float degree);
static float rad_to_deg(const float radian);
float deg_to_rad(const float degree);
float rad_to_deg(const float radian);

static float bearing(const FixedPointCoordinate &first_coordinate,
const FixedPointCoordinate &second_coordinate);
};
float bearing(const FixedPointCoordinate &first_coordinate,
const FixedPointCoordinate &second_coordinate);
}

#endif // COORDINATE_CALCULATION
2 changes: 1 addition & 1 deletion data_structures/coordinate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#include "coordinate_calculation.hpp"
#include "../algorithms/coordinate_calculation.hpp"

#ifndef NDEBUG
#include "../util/simple_logger.hpp"
Expand Down
2 changes: 1 addition & 1 deletion data_structures/rectangle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef RECTANGLE_HPP
#define RECTANGLE_HPP

#include "coordinate_calculation.hpp"
#include "../algorithms/coordinate_calculation.hpp"

#include <boost/assert.hpp>

Expand Down
2 changes: 1 addition & 1 deletion descriptors/description_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "description_factory.hpp"

#include "../algorithms/polyline_formatter.hpp"
#include "../data_structures/coordinate_calculation.hpp"
#include "../algorithms/coordinate_calculation.hpp"
#include "../data_structures/internal_route_result.hpp"
#include "../data_structures/turn_instructions.hpp"
#include "../util/container.hpp"
Expand Down
2 changes: 1 addition & 1 deletion descriptors/descriptor_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef DESCRIPTOR_BASE_HPP
#define DESCRIPTOR_BASE_HPP

#include "../data_structures/coordinate_calculation.hpp"
#include "../algorithms/coordinate_calculation.hpp"
#include "../data_structures/internal_route_result.hpp"
#include "../data_structures/phantom_node.hpp"
#include "../typedefs.h"
Expand Down
2 changes: 1 addition & 1 deletion extractor/extraction_containers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "extraction_containers.hpp"
#include "extraction_way.hpp"

#include "../data_structures/coordinate_calculation.hpp"
#include "../algorithms/coordinate_calculation.hpp"
#include "../data_structures/node_id.hpp"
#include "../data_structures/range_table.hpp"

Expand Down
2 changes: 1 addition & 1 deletion routing_algorithms/map_matching.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include "routing_base.hpp"

#include "../data_structures/coordinate_calculation.hpp"
#include "../algorithms/coordinate_calculation.hpp"
#include "../data_structures/hidden_markov_model.hpp"
#include "../util/json_logger.hpp"
#include "../util/matching_debug_info.hpp"
Expand Down
2 changes: 1 addition & 1 deletion routing_algorithms/routing_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef ROUTING_BASE_HPP
#define ROUTING_BASE_HPP

#include "../data_structures/coordinate_calculation.hpp"
#include "../algorithms/coordinate_calculation.hpp"
#include "../data_structures/internal_route_result.hpp"
#include "../data_structures/search_engine_data.hpp"
#include "../data_structures/turn_instructions.hpp"
Expand Down
2 changes: 1 addition & 1 deletion tools/components.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include "../typedefs.h"
#include "../algorithms/tiny_components.hpp"
#include "../data_structures/coordinate_calculation.hpp"
#include "../algorithms/coordinate_calculation.hpp"
#include "../data_structures/dynamic_graph.hpp"
#include "../data_structures/static_graph.hpp"
#include "../util/fingerprint.hpp"
Expand Down
2 changes: 1 addition & 1 deletion unit_tests/algorithms/geometry_string.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <boost/test/unit_test.hpp>

#include "../../algorithms/polyline_compressor.hpp"
#include "../../data_structures/coordinate_calculation.hpp"
#include "../../algorithms/coordinate_calculation.hpp"

#include <osrm/coordinate.hpp>

Expand Down
2 changes: 1 addition & 1 deletion unit_tests/data_structures/coordinate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include <boost/test/unit_test.hpp>

#include "../../data_structures/coordinate_calculation.hpp"
#include "../../algorithms/coordinate_calculation.hpp"

#include <osrm/coordinate.hpp>

Expand Down
2 changes: 1 addition & 1 deletion unit_tests/data_structures/static_rtree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#include "../../data_structures/coordinate_calculation.hpp"
#include "../../algorithms/coordinate_calculation.hpp"
#include "../../data_structures/static_rtree.hpp"
#include "../../data_structures/query_node.hpp"
#include "../../data_structures/edge_based_node.hpp"
Expand Down

0 comments on commit 14e63eb

Please sign in to comment.