35 : m_locations(), m_id_to_index(), m_population(population), m_finalized(false), m_tree()
42 throw std::runtime_error(
"Calling addLocation while GeoGrid is finalized not supported!");
48 template <
typename Policy,
typename F>
54 template <
typename Policy>
63 throw std::runtime_error(
"Calling \"" + functionName +
"\" with GeoGrid not finalized not supported!");
69 vector<geogrid_detail::KdTree2DPoint> points;
81 set<const Location*> result;
83 auto agg = BuildAggregator<BoxPolicy>(
85 make_tuple(min(long1, long2), min(lat1, lat2), max(long1, long2), max(lat1, lat2)));
93 using boost::geometry::get;
103 vector<const Location*> result;
105 auto agg = BuildAggregator<RadiusPolicy>(
MakeCollector(back_inserter(result)), make_tuple(startPt, radius));
113 double currentRadius = startRadius;
114 vector<ContactPool*> pools;
116 while (pools.empty()) {
118 const auto& locPool = nearLoc->CRefPools(
id);
119 pools.insert(pools.end(), locPool.begin(), locPool.end());
122 if (currentRadius == numeric_limits<double>::infinity()) {
133 priority_queue<Location*, vector<Location*>, decltype(cmp)> queue(cmp);
135 queue.push(loc.get());
136 if (queue.size() > k) {
141 vector<Location*> topLocations;
142 while (!queue.empty()) {
143 auto loc = queue.top();
144 topLocations.push_back(loc);
std::vector< const Location * > LocationsInRadius(const Location &start, double radius) const
Search for locations in radius (in km) around start.
Id
Enumerates the ContactPool types.
A GeoAggregator that has to be called with a functor.
A group of Persons that potentially have contacts with one another.
Collector< InsertIter, T > MakeCollector(const InsertIter &ins)
Build a Collector, useful for type inference.
Header for the core ContactPool class.
bool m_finalized
Internal KdTree for quick spatial lookup.
void AddLocation(std::shared_ptr< Location > location)
Adds a location to this GeoGrid.
GeoGrid(stride::Population *population)
GeoGrid and associated Population.
std::vector< std::shared_ptr< Location > > m_locations
< Container for Locations in GeoGrid.
std::set< const Location * > LocationsInBox(double long1, double lat1, double long2, double lat2) const
Gets the locations in a rectangle determined by the two coordinates (long1, lat1) and (long2...
void Finalize()
Disables the addLocation method and builds the kdtree.
std::vector< Location * > TopK(size_t k) const
Gets the K biggest (in population count) locations of this GeoGrid.
std::unordered_map< unsigned int, unsigned int > m_id_to_index
Stores pointer to Popluation, but does not take ownership.
Key Data structure: container for (a) all individuals in the population (b) the ContactPoolSys wchich...
Namespace for the geographic and demograhic classes.
const Coordinate GetCoordinate() const
Gets the Coordinate of this Location.
GeoAggregator< Policy, F > BuildAggregator(F functor, typename Policy::Args &&args) const
Build a GeoAggregator with a predefined functor and given args for the Policy.
KdTree for some more information on methods.
A GeoAggregator constructed with a functor.
unsigned int GetPopCount() const
Gets the absolute population.
std::vector< stride::ContactPool * > GetNearbyPools(stride::ContactType::Id id, const Location &start, double startRadius=10.0) const
Find contactpools in startRadius (in km) around start and, if none are found, double the radius and s...
Header file for the core Population class.
static KdTree Build(const std::vector< geogrid_detail::KdTree2DPoint > &points)
Build a balanced tree from the given set of points efficiently.
void CheckFinalized(const std::string &functionName) const
< Checks whether the GeoGrid is finalized i.e. certain operations can(not) be used.
Location for use within the GeoGrid, contains Coordinate and index to ContactPools.