| 249 | |
| 250 | #if defined(OMIM_OS_MAC) || defined(OMIM_OS_IPHONE) |
| 251 | ParsedMapApi::UrlType ParsedMapApi::ParseGeoNav(std::string const & raw) |
| 252 | { |
| 253 | Reset(); |
| 254 | SCOPE_GUARD(guard, [this] |
| 255 | { |
| 256 | if (m_requestType == UrlType::Incorrect) |
| 257 | Reset(); |
| 258 | }); |
| 259 | |
| 260 | url::Url const url(raw); |
| 261 | |
| 262 | if (url.GetHost() == "place") |
| 263 | { |
| 264 | auto const latLon = url.GetParamValue("coordinate"); |
| 265 | auto const addr = url.GetParamValue("address"); |
| 266 | |
| 267 | if (latLon) |
| 268 | { |
| 269 | auto const tokens = strings::Tokenize(*latLon, ","); |
| 270 | double lat; |
| 271 | double lon; |
| 272 | |
| 273 | if (tokens.size() != 2 || !strings::to_double(tokens[0], lat) || !strings::to_double(tokens[1], lon) || |
| 274 | !mercator::ValidLat(lat) || !mercator::ValidLon(lon)) |
| 275 | { |
| 276 | LOG(LWARNING, ("Invalid lat,lon in", raw)); |
| 277 | return m_requestType = UrlType::Incorrect; |
| 278 | } |
| 279 | |
| 280 | m_searchRequest = SearchRequest(); |
| 281 | m_searchRequest.m_query = *latLon; |
| 282 | m_searchRequest.m_selectFirstResult = true; |
| 283 | m_centerLatLon = {lat, lon}; |
| 284 | return m_requestType = UrlType::Search; |
| 285 | } |
| 286 | |
| 287 | else if (addr) |
| 288 | { |
| 289 | m_searchRequest = SearchRequest(); |
| 290 | m_searchRequest.m_query = *addr; |
| 291 | m_searchRequest.m_selectFirstResult = true; |
| 292 | return m_requestType = UrlType::Search; |
| 293 | } |
| 294 | } |
| 295 | |
| 296 | else if (url.GetHost() == "directions") |
| 297 | { |
| 298 | auto const source = url.GetParamValue("source"); |
| 299 | auto const destination = url.GetParamValue("destination"); |
| 300 | |
| 301 | if (source) |
| 302 | SetRouteMark(*source, RouteMarkType::Start); |
| 303 | |
| 304 | if (url.GetParamValue("waypoint")) |
| 305 | for (auto const & param : url.GetParams()) |
| 306 | if (param.first == "waypoint") |
| 307 | SetRouteMark(param.second, RouteMarkType::Intermediate); |
| 308 |
nothing calls this directly
no test coverage detected