consolidate duplicated distance calculations
This commit is contained in:
+29
-32
@@ -28,57 +28,54 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#ifndef FIXED_POINT_COORDINATE_H_
|
||||
#define FIXED_POINT_COORDINATE_H_
|
||||
|
||||
#include <iosfwd> //for std::ostream
|
||||
#include <iosfwd> //for std::ostream
|
||||
|
||||
static const double COORDINATE_PRECISION = 1000000.;
|
||||
|
||||
struct FixedPointCoordinate {
|
||||
struct FixedPointCoordinate
|
||||
{
|
||||
int lat;
|
||||
int lon;
|
||||
|
||||
FixedPointCoordinate();
|
||||
explicit FixedPointCoordinate( int lat, int lon);
|
||||
explicit FixedPointCoordinate(int lat, int lon);
|
||||
void Reset();
|
||||
bool isSet() const;
|
||||
bool isValid() const;
|
||||
bool operator==(const FixedPointCoordinate & other) 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 int lat1, const int lon1, const int lat2, const int lon2);
|
||||
|
||||
static double ApproximateDistance(
|
||||
const FixedPointCoordinate & c1,
|
||||
const FixedPointCoordinate & c2
|
||||
);
|
||||
static double ApproximateDistance(const FixedPointCoordinate &c1,
|
||||
const FixedPointCoordinate &c2);
|
||||
|
||||
static double ApproximateEuclideanDistance(
|
||||
const FixedPointCoordinate & c1,
|
||||
const FixedPointCoordinate & c2
|
||||
);
|
||||
static double ApproximateEuclideanDistance(const FixedPointCoordinate &c1,
|
||||
const FixedPointCoordinate &c2);
|
||||
|
||||
static void convertInternalLatLonToString(
|
||||
const int value,
|
||||
std::string & output
|
||||
);
|
||||
static void convertInternalLatLonToString(const int value, std::string &output);
|
||||
|
||||
static void convertInternalCoordinateToString(
|
||||
const FixedPointCoordinate & coord,
|
||||
std::string & output
|
||||
);
|
||||
static void convertInternalCoordinateToString(const FixedPointCoordinate &coord,
|
||||
std::string &output);
|
||||
|
||||
static void convertInternalReversedCoordinateToString(
|
||||
const FixedPointCoordinate & coord,
|
||||
std::string & output
|
||||
);
|
||||
static void convertInternalReversedCoordinateToString(const FixedPointCoordinate &coord,
|
||||
std::string &output);
|
||||
|
||||
void Output(std::ostream & out) const;
|
||||
static double ComputePerpendicularDistance(const FixedPointCoordinate &point,
|
||||
const FixedPointCoordinate &segA,
|
||||
const FixedPointCoordinate &segB);
|
||||
|
||||
static double ComputePerpendicularDistance(const FixedPointCoordinate &coord_a,
|
||||
const FixedPointCoordinate &coord_b,
|
||||
const FixedPointCoordinate &query_location,
|
||||
FixedPointCoordinate &nearest_location,
|
||||
double &r);
|
||||
|
||||
void Output(std::ostream &out) const;
|
||||
};
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& o, FixedPointCoordinate const & c){
|
||||
inline std::ostream &operator<<(std::ostream &o, FixedPointCoordinate const &c)
|
||||
{
|
||||
c.Output(o);
|
||||
return o;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user