Welcome to mirror list, hosted at ThFree Co, Russian Federation.

mwm_url.hpp « map - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e1a636553062b3ce7611f0fcfc361583c8b8f1fe (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#pragma once

#include "geometry/rect2d.hpp"

#include "std/string.hpp"

class ApiMarkPoint;
class BookmarkManager;

namespace url_scheme
{

struct ApiPoint
{
  double m_lat;
  double m_lon;
  string m_name;
  string m_id;
  string m_style;
};

struct RoutePoint
{
  RoutePoint() = default;
  RoutePoint(m2::PointD const & org, string const & name) : m_org(org), m_name(name) {}
  m2::PointD m_org = m2::PointD::Zero();
  string m_name;
};

class Uri;

/// Handles [mapswithme|mwm]://map?params - everything related to displaying info on a map
class ParsedMapApi
{
public:
  enum class ParsingResult
  {
    Incorrect,
    Map,
    Route
  };

  ParsedMapApi() = default;

  void SetBookmarkManager(BookmarkManager * manager);

  ParsingResult SetUriAndParse(string const & url);
  bool IsValid() const { return m_isValid; }
  string const & GetGlobalBackUrl() const { return m_globalBackUrl; }
  string const & GetAppTitle() const { return m_appTitle; }
  int GetApiVersion() const { return m_version; }
  void Reset();
  bool GoBackOnBalloonClick() const { return m_goBackOnBalloonClick; }

  /// @name Used in settings map viewport after invoking API.
  bool GetViewportRect(m2::RectD & rect) const;
  ApiMarkPoint const * GetSinglePoint() const;
  vector<RoutePoint> const & GetRoutePoints() const { return m_routePoints; }
  string const & GetRoutingType() const { return m_routingType; }
private:
  ParsingResult Parse(Uri const & uri);
  bool AddKeyValue(string key, string const & value, vector<ApiPoint> & points);
  bool RouteKeyValue(string key, string const & value, vector<string> & pattern);

  BookmarkManager * m_bmManager = nullptr;
  vector<RoutePoint> m_routePoints;
  string m_globalBackUrl;
  string m_appTitle;
  string m_routingType;
  int m_version = 0;
  /// Zoom level in OSM format (e.g. from 1.0 to 20.0)
  /// Taken into an account when calculating viewport rect, but only if points count is == 1
  double m_zoomLevel = 0.0;
  bool m_goBackOnBalloonClick = false;
  bool m_isValid = false;
};

}