All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
BuildingFootprintService.h
1 // Copyright eeGeo Ltd (2012-2014), All Rights Reserved
2 
3 #pragma once
4 
5 #include "Types.h"
6 #include "BuildingFootprints.h"
7 #include "ICallback.h"
8 
9 #include "MortonKey.h"
10 #include "BuildingFootprint.h"
11 #include "MortonKeyLRUCache.h"
12 #include "Space.h"
13 
14 #include <vector>
15 #include <queue>
16 #include <functional>
17 
18 
19 namespace Eegeo
20 {
21  namespace BuildingFootprints
22  {
24  {
26  BuildingFootprintServiceRequestId requestId,
27  bool success,
28  const std::vector<BuildingFootprint>& footprints)
29  : m_requestId(requestId)
30  , m_isSuccess(success)
31  , m_footprints(footprints)
32  {}
33 
34  BuildingFootprintServiceRequestId GetRequestId() const { return m_requestId; }
35 
36  bool Succeeded() const { return m_isSuccess; }
37 
38  const std::vector<BuildingFootprint>& Footprints() const { return m_footprints; }
39  private:
40  BuildingFootprintServiceRequestId m_requestId;
41  bool m_isSuccess;
42  std::vector<BuildingFootprint> m_footprints;
43  };
44 
45 
46 
47 
48 
50  {
51  public:
53 
54  static const float MaxQueryRadius;
55 
57  BuildingFootprintRepository& footprintRepository,
58  int cacheSize);
59 
60  BuildingFootprintServiceRequestId GetFootprintsInRadius(const Eegeo::Space::LatLong& pointLatLong, float radiusMetres, int maxResults, IQueryCallback& callback);
61 
62  BuildingFootprintServiceRequestId GetClosestFootprint(const Eegeo::Space::LatLong& pointLatLong, float searchRadiusMetres, bool allFootprintsInGroup, IQueryCallback& callback);
63 
64  BuildingFootprintServiceRequestId GetClosestFootprintOverlappingAltitude(const Eegeo::Space::LatLongAltitude& pointLatLongAlt, float searchRadiusMetres, bool allFootprintsInGroup, IQueryCallback& userCallback);
65 
66  void CancelRequest(BuildingFootprintServiceRequestId requestId);
67 
68  void ClearCache();
69 
70  void Update();
71 
72  private:
73  std::vector<Streaming::MortonKey> GetKeysInUse() const;
74 
75  void UpdateCache();
76 
77  void PruneCache(int desiredCacheSize);
78 
79  BuildingFootprintServiceRequestId CreateQuery(const QueryParams& queryParams);
80 
81  void OnQueryComplete(const BuildingFootprintServiceQuery& query);
82 
83  BuildingFootprintServiceRequestId NextRequestId();
84 
85  bool CanMakeWebRequests() const;
86 
87  BuildingFootprintResourceService& m_footprintResourceService;
88  BuildingFootprintRepository& m_footprintRepository;
89  const int m_cacheSize;
90 
92  TQueryCompleteHandler m_queryCompleteHandler;
93 
94  std::deque<BuildingFootprintServiceQuery*> m_pendingExecution;
95  std::vector<BuildingFootprintServiceQuery*> m_pendingCompletion;
96  MortonKeyLRUCache m_keysMRU;
97  int m_nextRequestId;
98  };
99 
100 
101  }
102 }