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

features_road_graph.hpp « routing - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 776cc5aae0aaaebb33991d279c08943801704019 (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
#pragma once
#include "routing/road_graph.hpp"
#include "routing/vehicle_model.hpp"

#include "indexer/feature_data.hpp"
#include "indexer/mwm_set.hpp"

#include "geometry/point2d.hpp"

#include "base/cache.hpp"

#include "std/unique_ptr.hpp"
#include "std/vector.hpp"

class Index;
class FeatureType;

namespace routing
{

class FeaturesRoadGraph : public IRoadGraph
{
public:
  FeaturesRoadGraph(IVehicleModel const & vehicleModel, Index const & index, MwmSet::MwmId const & mwmID);

  static uint32_t GetStreetReadScale();

  inline MwmSet::MwmId GetMwmID() const { return m_mwmID; }

  double GetCacheMiss() const
  {
    if (m_cacheAccess == 0)
      return 0.0;
    return (double)m_cacheMiss / (double)m_cacheAccess;
  }

protected:
  // IRoadGraph overrides:
  RoadInfo GetRoadInfo(uint32_t featureId) const override;
  double GetSpeedKMPH(uint32_t featureId) const override;
  double GetMaxSpeedKMPH() const override;
  void ForEachFeatureClosestToCross(m2::PointD const & cross,
                                    CrossEdgesLoader & edgesLoader) const override;

private:
  friend class CrossFeaturesLoader;

  bool IsOneWay(FeatureType const & ft) const;
  double GetSpeedKMPHFromFt(FeatureType const & ft) const;
  void LoadFeature(uint32_t featureId, FeatureType & ft) const;

  // ft must be set if fullLoad set to false (optimization)
  RoadInfo const & GetCachedRoadInfo(uint32_t featureId, FeatureType & ft, bool fullLoad) const;

  Index const & m_index;
  MwmSet::MwmId const m_mwmID;
  IVehicleModel const & m_vehicleModel;
  
  mutable my::Cache<uint32_t, RoadInfo> m_cache;
  mutable uint32_t m_cacheMiss;
  mutable uint32_t m_cacheAccess;
};

}  // namespace routing