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

apply_feature_functors.hpp « drape_frontend - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a88792e0e436fad41989a3ae4b513a7a157a99e0 (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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#pragma once

#include "drape_frontend/stylist.hpp"
#include "drape_frontend/tile_key.hpp"
#include "drape_frontend/shape_view_params.hpp"

#include "drape/pointers.hpp"

#include "indexer/point_to_int64.hpp"

#include "geometry/point2d.hpp"
#include "geometry/spline.hpp"

#include "std/unordered_map.hpp"

class CaptionDefProto;
class CircleRuleProto;
class ShieldRuleProto;
class SymbolRuleProto;

//#define CALC_FILTERED_POINTS

namespace df
{

struct TextViewParams;
class MapShape;
struct BuildingOutline;

using TInsertShapeFn = function<void(drape_ptr<MapShape> && shape)>;

class BaseApplyFeature
{
public:
  BaseApplyFeature(m2::PointD const & tileCenter,
                   TInsertShapeFn const & insertShape, FeatureID const & id,
                   int minVisibleScale, uint8_t rank, CaptionDescription const & captions);

  virtual ~BaseApplyFeature() {}

  struct HotelData
  {
    bool m_isHotel = false;
    string m_rating;
    int m_stars = 0;
    int m_priceCategory = 0;
  };

  void SetHotelData(HotelData && hotelData);

protected:
  void ExtractCaptionParams(CaptionDefProto const * primaryProto,
                            CaptionDefProto const * secondaryProto,
                            double depth, TextViewParams & params) const;
  string ExtractHotelInfo() const;

  TInsertShapeFn m_insertShape;
  FeatureID m_id;
  CaptionDescription const & m_captions;
  int m_minVisibleScale;
  uint8_t m_rank;
  HotelData m_hotelData;

  m2::PointD m_tileCenter;
};

class ApplyPointFeature : public BaseApplyFeature
{
  using TBase = BaseApplyFeature;

public:
  ApplyPointFeature(m2::PointD const & tileCenter,
                    TInsertShapeFn const & insertShape, FeatureID const & id,
                    int minVisibleScale, uint8_t rank, CaptionDescription const & captions,
                    float posZ);

  void operator()(m2::PointD const & point, bool hasArea);
  void ProcessRule(Stylist::TRuleWrapper const & rule);
  void Finish();

protected:
  float const m_posZ;

private:
  bool m_hasPoint;
  bool m_hasArea;
  bool m_createdByEditor;
  bool m_obsoleteInEditor;
  double m_symbolDepth;
  double m_circleDepth;
  SymbolRuleProto const * m_symbolRule;
  CircleRuleProto const * m_circleRule;
  m2::PointF m_centerPoint;
};

class ApplyAreaFeature : public ApplyPointFeature
{
  using TBase = ApplyPointFeature;

public:
  ApplyAreaFeature(m2::PointD const & tileCenter,
                   TInsertShapeFn const & insertShape, FeatureID const & id,
                   m2::RectD const & clipRect, bool isBuilding, float minPosZ,
                   float posZ, int minVisibleScale, uint8_t rank,
                   CaptionDescription const & captions);

  using TBase::operator ();

  void operator()(m2::PointD const & p1, m2::PointD const & p2, m2::PointD const & p3);
  void ProcessRule(Stylist::TRuleWrapper const & rule);

private:
  using TEdge = pair<int, int>;

  void ProcessBuildingPolygon(m2::PointD const & p1, m2::PointD const & p2, m2::PointD const & p3);
  void CalculateBuildingOutline(bool calculateNormals, BuildingOutline & outline);
  int GetIndex(m2::PointD const & pt);
  void BuildEdges(int vertexIndex1, int vertexIndex2, int vertexIndex3);
  bool EqualEdges(TEdge const & edge1, TEdge const & edge2) const;
  bool FindEdge(TEdge const & edge);
  m2::PointD CalculateNormal(m2::PointD const & p1, m2::PointD const & p2, m2::PointD const & p3) const;

  vector<m2::PointD> m_triangles;

  buffer_vector<m2::PointD, kBuildingOutlineSize> m_points;
  buffer_vector<pair<TEdge, int>, kBuildingOutlineSize> m_edges;
  float const m_minPosZ;
  bool const m_isBuilding;
  m2::RectD m_clipRect;
};

class ApplyLineFeature : public BaseApplyFeature
{
  using TBase = BaseApplyFeature;

public:
  ApplyLineFeature(m2::PointD const & tileCenter, double currentScaleGtoP,
                   TInsertShapeFn const & insertShape, FeatureID const & id,
                   m2::RectD const & clipRect, int minVisibleScale, uint8_t rank,
                   CaptionDescription const & captions, int zoomLevel, size_t pointsCount);

  void operator() (m2::PointD const & point);
  bool HasGeometry() const;
  void ProcessRule(Stylist::TRuleWrapper const & rule);
  void Finish();

private:
  m2::SharedSpline m_spline;
  vector<m2::SharedSpline> m_clippedSplines;
  double m_currentScaleGtoP;
  double m_sqrScale;
  m2::PointD m_lastAddedPoint;
  bool m_simplify;
  int m_zoomLevel;
  size_t m_initialPointsCount;
  double m_shieldDepth;
  ShieldRuleProto const * m_shieldRule;
  m2::RectD m_clipRect;

#ifdef CALC_FILTERED_POINTS
  int m_readedCount;
#endif
};

} // namespace df