\brief This benchmark is written to estimate how LinearExtrapolation() extrapolates real users tracks. The idea behind the test is to measure the distance between extrapolated location and real track.
| 175 | /// tracks. The idea behind the test is to measure the distance between extrapolated location and |
| 176 | /// real track. |
| 177 | int main(int argc, char * argv[]) |
| 178 | { |
| 179 | gflags::SetUsageMessage( |
| 180 | "Location extrapolation benchmark. Cumulative moving average, variance and standard " |
| 181 | "deviation for all extrapolation deviations from tracks passed in comma separated csv with " |
| 182 | "csv_path."); |
| 183 | gflags::ParseCommandLineFlags(&argc, &argv, true); |
| 184 | |
| 185 | if (FLAGS_csv_path.empty()) |
| 186 | { |
| 187 | LOG(LERROR, ("Path to csv file with user tracks should be set.")); |
| 188 | return -1; |
| 189 | } |
| 190 | |
| 191 | Tracks tracks; |
| 192 | if (!Parse(FLAGS_csv_path, tracks)) |
| 193 | { |
| 194 | LOG(LERROR, ("An error while parsing", FLAGS_csv_path, "file. Please check if it has a correct format.")); |
| 195 | return -1; |
| 196 | } |
| 197 | |
| 198 | // Printing some statistics about tracks. |
| 199 | size_t trackPointNum = 0; |
| 200 | for (auto const & t : tracks) |
| 201 | trackPointNum += t.size(); |
| 202 | |
| 203 | double trackLengths = 0; |
| 204 | for (auto const & t : tracks) |
| 205 | { |
| 206 | double trackLenM = 0; |
| 207 | for (size_t j = 1; j < t.size(); ++j) |
| 208 | trackLenM += ms::DistanceOnEarth(ms::LatLon(t[j - 1].m_lat, t[j - 1].m_lon), ms::LatLon(t[j].m_lat, t[j].m_lon)); |
| 209 | trackLengths += trackLenM; |
| 210 | } |
| 211 | |
| 212 | LOG(LINFO, ("General tracks statistics." |
| 213 | "\n Number of tracks:", |
| 214 | tracks.size(), "\n Number of track points:", trackPointNum, "\n Average points per track:", |
| 215 | trackPointNum / tracks.size(), "\n Average track length:", trackLengths / tracks.size(), "meters")); |
| 216 | |
| 217 | // For all points of each track in |tracks| some extrapolations will be calculated. |
| 218 | // The number of extrapolations depends on |Extrapolator::kExtrapolationPeriodMs| |
| 219 | // and |Extrapolator::kMaxExtrapolationTimeMs| and equal for all points. |
| 220 | // Then cumulative moving average and variance of each extrapolation will be printed. |
| 221 | auto const extrapolationNumber = |
| 222 | static_cast<size_t>(Extrapolator::kMaxExtrapolationTimeMs / Extrapolator::kExtrapolationPeriodMs); |
| 223 | MovingAverageVec mes(extrapolationNumber); |
| 224 | MovingAverageVec squareMes(extrapolationNumber); |
| 225 | // Number of extrapolations for which projections are calculated successfully. |
| 226 | size_t projectionCounter = 0; |
| 227 | for (auto const & t : tracks) |
| 228 | { |
| 229 | if (t.size() <= 1) |
| 230 | continue; |
| 231 | |
| 232 | m2::PolylineD poly; |
| 233 | for (auto const & p : t) |
| 234 | poly.Add(mercator::FromLatLon(p.m_lat, p.m_lon)); |
nothing calls this directly
no test coverage detected