Skip to content

Commit

Permalink
Merge pull request #1350 from Project-OSRM/feature/prune_incremental_…
Browse files Browse the repository at this point in the history
…search

speed up nearest neighbor query by pruning
  • Loading branch information
DennisOSRM committed Jan 20, 2015
2 parents 8f813fb + 01f3237 commit bf7b146
Show file tree
Hide file tree
Showing 14 changed files with 733 additions and 416 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ 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)
list(REMOVE_ITEM DatastructureGlob data_structures/Coordinate.cpp)
file(GLOB CoordinateGlob data_structures/coordinate.cpp)
file(GLOB CoordinateGlob data_structures/coordinate*.cpp)
file(GLOB AlgorithmGlob algorithms/*.cpp)
file(GLOB HttpGlob Server/Http/*.cpp)
file(GLOB LibOSRMGlob Library/*.cpp)
Expand Down
47 changes: 2 additions & 45 deletions Include/osrm/coordinate.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Copyright (c) 2013, Project OSRM, Dennis Luxen, others
Copyright (c) 2015, Project OSRM, Dennis Luxen, others
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
Expand Down Expand Up @@ -36,6 +36,7 @@ namespace
{
constexpr static const float COORDINATE_PRECISION = 1000000.f;
}

struct FixedPointCoordinate
{
int lat;
Expand All @@ -56,52 +57,8 @@ struct FixedPointCoordinate
bool is_valid() const;
bool operator==(const FixedPointCoordinate &other) const;

static double
ApproximateDistance(const int lat1, const int lon1, const int lat2, const int lon2);

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

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

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

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

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

static void convertInternalCoordinateToString(const FixedPointCoordinate &coordinate,
std::string &output);

static void convertInternalReversedCoordinateToString(const FixedPointCoordinate &coordinate,
std::string &output);

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

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

static int
OrderedPerpendicularDistanceApproximation(const FixedPointCoordinate &segment_source,
const FixedPointCoordinate &segment_target,
const FixedPointCoordinate &query_location);

static float GetBearing(const FixedPointCoordinate &A, const FixedPointCoordinate &B);

float GetBearing(const FixedPointCoordinate &other) const;

void Output(std::ostream &out) const;

static float DegreeToRadian(const float degree);
static float RadianToDegree(const float radian);
};

inline std::ostream &operator<<(std::ostream &out_stream, FixedPointCoordinate const &coordinate)
Expand Down
Loading

0 comments on commit bf7b146

Please sign in to comment.