MCPcopy Create free account
hub / github.com/comaps/comaps / GetSmPoint

Function GetSmPoint

libs/geometry/mercator.cpp:31–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29}
30
31m2::PointD GetSmPoint(m2::PointD const & pt, double lonMetersR, double latMetersR)
32{
33 using std::max, std::min;
34
35 double const lat = YToLat(pt.y);
36 double const lon = XToLon(pt.x);
37
38 double const latDegreeOffset = latMetersR * Bounds::kDegreesInMeter;
39 double const newLat = min(90.0, max(-90.0, lat + latDegreeOffset));
40
41 double const cosL = max(cos(math::DegToRad(newLat)), 0.00001);
42 ASSERT_GREATER(cosL, 0.0, ());
43
44 double const lonDegreeOffset = lonMetersR * Bounds::kDegreesInMeter / cosL;
45 double const newLon = min(180.0, max(-180.0, lon + lonDegreeOffset));
46
47 return FromLatLon(newLat, newLon);
48}
49
50double DistanceOnEarth(m2::PointD const & p1, m2::PointD const & p2)
51{

Callers 4

GenerateNearbyPositionFunction · 0.85
PredictLocationMethod · 0.85
UNIT_TESTFunction · 0.85
UpdateMethod · 0.85

Calls 4

YToLatFunction · 0.85
XToLonFunction · 0.85
DegToRadFunction · 0.85
FromLatLonFunction · 0.70

Tested by 1

UNIT_TESTFunction · 0.68