Folds mercator projections into coordinate_calculation
This commit is contained in:
parent
d1c4a26791
commit
5de8f1803c
@ -62,8 +62,14 @@ double bearing(const FixedPointCoordinate first_coordinate,
|
||||
double computeAngle(const FixedPointCoordinate first,
|
||||
const FixedPointCoordinate second,
|
||||
const FixedPointCoordinate third);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace mercator
|
||||
{
|
||||
double yToLat(const double value);
|
||||
double latToY(const double latitude);
|
||||
} // ns mercator
|
||||
} // ns coordinate_calculation
|
||||
} // ns util
|
||||
} // ns osrm
|
||||
|
||||
#endif // COORDINATE_CALCULATION
|
||||
|
@ -1,26 +0,0 @@
|
||||
#ifndef MERCATOR_HPP
|
||||
#define MERCATOR_HPP
|
||||
|
||||
#include <cmath>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
namespace mercator
|
||||
{
|
||||
|
||||
inline double yToLat(const double value) noexcept
|
||||
{
|
||||
return 180. * M_1_PI * (2. * std::atan(std::exp(value * M_PI / 180.)) - M_PI_2);
|
||||
}
|
||||
|
||||
inline double latToY(const double latitude) noexcept
|
||||
{
|
||||
return 180. * M_1_PI * std::log(std::tan(M_PI_4 + latitude * (M_PI / 180.) / 2.));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // MERCATOR_HPP
|
@ -8,7 +8,6 @@
|
||||
|
||||
#include "util/bearing.hpp"
|
||||
#include "util/integer_range.hpp"
|
||||
#include "util/mercator.hpp"
|
||||
#include "util/osrm_exception.hpp"
|
||||
#include "util/typedefs.hpp"
|
||||
|
||||
@ -140,8 +139,8 @@ class StaticRTree
|
||||
FixedPointCoordinate(coordinate_list.at(current_element.v).lat,
|
||||
coordinate_list.at(current_element.v).lon));
|
||||
current_centroid.lat =
|
||||
COORDINATE_PRECISION *
|
||||
mercator::latToY(current_centroid.lat / COORDINATE_PRECISION);
|
||||
COORDINATE_PRECISION * coordinate_calculation::mercator::latToY(
|
||||
current_centroid.lat / COORDINATE_PRECISION);
|
||||
|
||||
current_wrapper.m_hilbert_value = hilbertCode(current_centroid);
|
||||
}
|
||||
@ -342,7 +341,7 @@ class StaticRTree
|
||||
{
|
||||
std::vector<EdgeDataT> results;
|
||||
std::pair<double, double> projected_coordinate = {
|
||||
mercator::latToY(input_coordinate.lat / COORDINATE_PRECISION),
|
||||
coordinate_calculation::mercator::latToY(input_coordinate.lat / COORDINATE_PRECISION),
|
||||
input_coordinate.lon / COORDINATE_PRECISION};
|
||||
|
||||
// initialize queue with root element
|
||||
|
@ -1,6 +1,5 @@
|
||||
#include "util/coordinate_calculation.hpp"
|
||||
|
||||
#include "util/mercator.hpp"
|
||||
#include "util/string_util.hpp"
|
||||
#include "util/trigonometry_table.hpp"
|
||||
|
||||
@ -90,6 +89,8 @@ double perpendicularDistance(const FixedPointCoordinate segment_source,
|
||||
FixedPointCoordinate &nearest_location,
|
||||
double &ratio)
|
||||
{
|
||||
using namespace coordinate_calculation;
|
||||
|
||||
return perpendicularDistanceFromProjectedCoordinate(
|
||||
segment_source, segment_target, query_location,
|
||||
{mercator::latToY(query_location.lat / COORDINATE_PRECISION),
|
||||
@ -119,6 +120,8 @@ perpendicularDistanceFromProjectedCoordinate(const FixedPointCoordinate segment_
|
||||
FixedPointCoordinate &nearest_location,
|
||||
double &ratio)
|
||||
{
|
||||
using namespace coordinate_calculation;
|
||||
|
||||
BOOST_ASSERT(query_location.IsValid());
|
||||
|
||||
// initialize values
|
||||
@ -222,6 +225,8 @@ double computeAngle(const FixedPointCoordinate first,
|
||||
const FixedPointCoordinate second,
|
||||
const FixedPointCoordinate third)
|
||||
{
|
||||
using namespace coordinate_calculation;
|
||||
|
||||
const double v1x = (first.lon - second.lon) / COORDINATE_PRECISION;
|
||||
const double v1y = mercator::latToY(first.lat / COORDINATE_PRECISION) -
|
||||
mercator::latToY(second.lat / COORDINATE_PRECISION);
|
||||
@ -238,6 +243,19 @@ double computeAngle(const FixedPointCoordinate first,
|
||||
|
||||
return angle;
|
||||
}
|
||||
|
||||
namespace mercator
|
||||
{
|
||||
double yToLat(const double value)
|
||||
{
|
||||
return 180. * M_1_PI * (2. * std::atan(std::exp(value * M_PI / 180.)) - M_PI_2);
|
||||
}
|
||||
|
||||
double latToY(const double latitude)
|
||||
{
|
||||
return 180. * M_1_PI * std::log(std::tan(M_PI_4 + latitude * (M_PI / 180.) / 2.));
|
||||
}
|
||||
}
|
||||
} // ns mercato // ns mercatorr
|
||||
} // ns coordinate_calculation
|
||||
} // ns util
|
||||
} // ns osrm
|
||||
|
@ -1,10 +0,0 @@
|
||||
#include "util/mercator.hpp"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user