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

Function CalcFerryDurationHours

libs/routing/geometry.cpp:31–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29using namespace std;
30
31double CalcFerryDurationHours(string_view durationHours, double roadLenKm)
32{
33 // Look for more info: https://confluence.mail.ru/display/MAPSME/Ferries
34 // Shortly: the coefs were received from statistic about ferries with durations in OSM.
35 double constexpr kIntercept = 0.2490726747447476;
36 /// @todo This constant means that average ferry speed is 1/0.02 = 50km/h OMG!
37 double constexpr kSlope = 0.02078913;
38
39 if (durationHours.empty())
40 return kIntercept + kSlope * roadLenKm;
41
42 double durationH = 0.0;
43 CHECK(strings::to_double(durationHours, durationH), (durationHours));
44
45 // See: https://confluence.mail.ru/download/attachments/249123157/image2019-8-22_16-15-53.png
46 // Shortly: we drop some points: (x: lengthKm, y: durationH), that are upper or lower these two lines.
47 double constexpr kUpperBoundIntercept = 4.0;
48 double constexpr kUpperBoundSlope = 0.037;
49 if (kUpperBoundIntercept + kUpperBoundSlope * roadLenKm - durationH < 0)
50 return kIntercept + kSlope * roadLenKm;
51
52 double constexpr kLowerBoundIntercept = -2.0;
53 double constexpr kLowerBoundSlope = 0.015;
54 if (kLowerBoundIntercept + kLowerBoundSlope * roadLenKm - durationH > 0)
55 return kIntercept + kSlope * roadLenKm;
56
57 return durationH;
58}
59
60class RoadAttrsGetter
61{

Callers 1

LoadMethod · 0.85

Calls 2

to_doubleFunction · 0.50
emptyMethod · 0.45

Tested by

no test coverage detected