| 101 | } |
| 102 | |
| 103 | Status MatchPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms, |
| 104 | const api::MatchParameters ¶meters, |
| 105 | osrm::engine::api::ResultT &result) const |
| 106 | { |
| 107 | if (!algorithms.HasMapMatching()) |
| 108 | { |
| 109 | return Error("NotImplemented", |
| 110 | "Map matching is not implemented for the chosen search algorithm.", |
| 111 | result); |
| 112 | } |
| 113 | |
| 114 | if (!CheckAlgorithms(parameters, algorithms, result)) |
| 115 | return Status::Error; |
| 116 | |
| 117 | const auto &facade = algorithms.GetFacade(); |
| 118 | |
| 119 | BOOST_ASSERT(parameters.IsValid()); |
| 120 | |
| 121 | // enforce maximum number of locations for performance reasons |
| 122 | if (max_locations_map_matching > 0 && |
| 123 | static_cast<int>(parameters.coordinates.size()) > max_locations_map_matching) |
| 124 | { |
| 125 | return Error("TooBig", "Too many trace coordinates", result); |
| 126 | } |
| 127 | |
| 128 | if (!CheckAllCoordinates(parameters.coordinates)) |
| 129 | { |
| 130 | return Error("InvalidValue", "Invalid coordinate value.", result); |
| 131 | } |
| 132 | |
| 133 | if (max_radius_map_matching > 0 && std::any_of(parameters.radiuses.begin(), |
| 134 | parameters.radiuses.end(), |
| 135 | [&](const auto &radius) |
| 136 | { |
| 137 | if (!radius) |
| 138 | return false; |
| 139 | return *radius > max_radius_map_matching; |
| 140 | })) |
| 141 | { |
| 142 | return Error("TooBig", "Radius search size is too large for map matching.", result); |
| 143 | } |
| 144 | |
| 145 | // Check for same or increasing timestamps. Impl. note: Incontrast to `sort(first, |
| 146 | // last, less_equal)` checking `greater` in reverse meets irreflexive requirements. |
| 147 | const auto time_increases_monotonically = std::is_sorted( |
| 148 | parameters.timestamps.rbegin(), parameters.timestamps.rend(), std::greater<>{}); |
| 149 | |
| 150 | if (!time_increases_monotonically) |
| 151 | { |
| 152 | return Error("InvalidValue", "Timestamps need to be monotonically increasing.", result); |
| 153 | } |
| 154 | |
| 155 | SubMatchingList sub_matchings; |
| 156 | api::tidy::Result tidied; |
| 157 | if (parameters.tidy) |
| 158 | { |
| 159 | // Transparently tidy match parameters, do map matching on tidied parameters. |
| 160 | // Then use the mapping to restore the original <-> tidied relationship. |
nothing calls this directly
no test coverage detected