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

Function MetersToXY

libs/geometry/mercator.cpp:13–29  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11namespace mercator
12{
13m2::RectD MetersToXY(double lon, double lat, double lonMetersR, double latMetersR)
14{
15 using std::cos, std::fabs, std::max, std::min;
16
17 double const latDegreeOffset = latMetersR * Bounds::kDegreesInMeter;
18 double const minLat = max(-90.0, lat - latDegreeOffset);
19 double const maxLat = min(90.0, lat + latDegreeOffset);
20
21 double const cosL = max(cos(math::DegToRad(max(fabs(minLat), fabs(maxLat)))), 0.00001);
22 ASSERT_GREATER(cosL, 0.0, ());
23
24 double const lonDegreeOffset = lonMetersR * Bounds::kDegreesInMeter / cosL;
25 double const minLon = max(-180.0, lon - lonDegreeOffset);
26 double const maxLon = min(180.0, lon + lonDegreeOffset);
27
28 return {FromLatLon(minLat, minLon), FromLatLon(maxLat, maxLon)};
29}
30
31m2::PointD GetSmPoint(m2::PointD const & pt, double lonMetersR, double latMetersR)
32{

Callers 11

UNIT_TESTFunction · 0.85
SetViewportMethod · 0.85
PredictLocationMethod · 0.85
mainFunction · 0.85
OnLocationUpdateMethod · 0.85
MoveIteratorMethod · 0.85
UNIT_TESTFunction · 0.85

Calls 2

DegToRadFunction · 0.85
FromLatLonFunction · 0.70

Tested by 3

UNIT_TESTFunction · 0.68
UNIT_TESTFunction · 0.68