blob: 7543af4efe12968deffe66db3f8a2bdcae9b01e5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
#pragma once
#include "platform/http_client.hpp"
#include "geometry/point2d.hpp"
#include "geometry/latlon.hpp"
#include "base/thread.hpp"
#include "std/string.hpp"
#include "std/vector.hpp"
namespace routing
{
/// URL string generator for MAPS.ME OSRM server request.
/// \param serverURL http server url with protocol, name and port if needed. For example:
/// http://mail.ru:12345
/// \param startPoint Coordinates of a start point.
/// \param finalPoint Coordinates of a finish point.
/// \return URL for OSRM MAPS.ME server request.
/// \see MapsMePlugin.hpp for REST protocol.
string GenerateOnlineRequest(string const & serverURL, ms::LatLon const & startPoint,
ms::LatLon const & finalPoint);
/// \brief ParseResponse MAPS.ME OSRM server response parser.
/// \param serverResponse Server response data.
/// \param outPoints Mwm map points.
/// \return true if there are some maps in a server's response.
bool ParseResponse(string const & serverResponse, vector<m2::PointD> & outPoints);
class OnlineCrossFetcher : public threads::IRoutine
{
public:
/// \brief OnlineCrossFetcher helper class to make request to online OSRM server
/// and get mwm names list
/// \param serverURL Server URL
/// \param startPoint Start point coordinates
/// \param finalPoint Finish point coordinates
OnlineCrossFetcher(string const & serverURL, ms::LatLon const & startPoint,
ms::LatLon const & finalPoint);
/// Overrides threads::IRoutine processing procedure. Calls online OSRM server and parses response.
void Do() override;
/// \brief GetMwmPoints returns mwm representation points list.
/// \return Mwm points to build route from startPt to finishPt. Empty list if there were errors.
vector<m2::PointD> const & GetMwmPoints() { return m_mwmPoints; }
private:
platform::HttpClient m_request;
vector<m2::PointD> m_mwmPoints;
};
}
|