Stride Reference Manual
- generated for commit 9643b11
|
A Geographic grid of simulation region contains Locations that in turn contain an index to the ContactPools situated at that Location. More...
#include <GeoGrid.h>
Public Types | |
using | iterator = std::vector< std::shared_ptr< Location >>::iterator |
using | const_iterator = std::vector< std::shared_ptr< Location >>::const_iterator |
Public Member Functions | |
GeoGrid (stride::Population *population) | |
GeoGrid and associated Population. More... | |
GeoGrid (const GeoGrid &)=delete | |
No copy constructor. More... | |
GeoGrid | operator= (const GeoGrid &)=delete |
No copy assignment. More... | |
void | AddLocation (std::shared_ptr< Location > location) |
Adds a location to this GeoGrid. More... | |
void | Finalize () |
Disables the addLocation method and builds the kdtree. More... | |
std::shared_ptr< Location > | GetById (unsigned int id) const |
Gets a Location by Id and check if the Id exists. More... | |
stride::Population * | GetPopulation () const |
Get the Population associated with this GeoGrid. More... | |
std::vector< const Location * > | LocationsInRadius (const Location &start, double radius) const |
Search for locations in radius (in km) around start . More... | |
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 search again until the radius gets infinite. More... | |
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, lat2). More... | |
std::set< const Location * > | LocationsInBox (Location *loc1, Location *loc2) const |
Gets the location in a rectangle defined by the two Locations. More... | |
std::vector< Location * > | TopK (size_t k) const |
Gets the K biggest (in population count) locations of this GeoGrid. More... | |
template<typename Policy , typename F > | |
GeoAggregator< Policy, F > | BuildAggregator (F functor, typename Policy::Args &&args) const |
Build a GeoAggregator with a predefined functor and given args for the Policy. More... | |
template<typename Policy > | |
GeoAggregator< Policy > | BuildAggregator (typename Policy::Args &&args) const |
Build a GeoAggregator that gets its functor when calling, with given args for the Policy. More... | |
iterator | begin () |
Iterator to first Location. More... | |
iterator | end () |
Iterator to the end of the Location storage. More... | |
const_iterator | cbegin () const |
Const Iterator to first Location. More... | |
const_iterator | cend () const |
Const iterator to the end of the Location storage. More... | |
std::shared_ptr< Location > & | operator[] (size_t index) |
Gets a Location by index, doesn't performs a range check. More... | |
const std::shared_ptr< Location > & | operator[] (size_t index) const |
Gets a Location by index, doesn't performs a range check. More... | |
size_t | size () const |
Gets current size of Location storage. More... | |
Private Member Functions | |
void | CheckFinalized (const std::string &functionName) const |
< Checks whether the GeoGrid is finalized i.e. certain operations can(not) be used. More... | |
Private Attributes | |
std::vector< std::shared_ptr< Location > > | m_locations |
< Container for Locations in GeoGrid. More... | |
std::unordered_map< unsigned int, unsigned int > | m_id_to_index |
Stores pointer to Popluation, but does not take ownership. More... | |
stride::Population * | m_population |
Is the GeoGrid finalized (ready for use) yet? More... | |
bool | m_finalized |
Internal KdTree for quick spatial lookup. More... | |
GeoGridKdTree | m_tree |
A Geographic grid of simulation region contains Locations that in turn contain an index to the ContactPools situated at that Location.
using geopop::GeoGrid::iterator = std::vector<std::shared_ptr<Location>>::iterator |
using geopop::GeoGrid::const_iterator = std::vector<std::shared_ptr<Location>>::const_iterator |
|
explicit |
GeoGrid and associated Population.
Definition at line 34 of file GeoGrid.cpp.
|
delete |
No copy constructor.
void geopop::GeoGrid::AddLocation | ( | std::shared_ptr< Location > | location | ) |
Adds a location to this GeoGrid.
Definition at line 39 of file GeoGrid.cpp.
References m_finalized, m_id_to_index, and m_locations.
Referenced by geopop::LocationsCSVReader::FillGeoGrid().
void geopop::GeoGrid::Finalize | ( | ) |
Disables the addLocation method and builds the kdtree.
Definition at line 67 of file GeoGrid.cpp.
References geopop::KdTree< geogrid_detail::KdTree2DPoint >::Build(), m_finalized, m_locations, and m_tree.
|
inline |
Gets a Location by Id and check if the Id exists.
Definition at line 60 of file GeoGrid.h.
References m_id_to_index, and m_locations.
Referenced by geopop::GeoGridReader::AddCommutes(), and geopop::CommutesCSVReader::FillGeoGrid().
|
inline |
Get the Population associated with this GeoGrid.
Definition at line 63 of file GeoGrid.h.
References BuildAggregator(), GetNearbyPools(), LocationsInBox(), LocationsInRadius(), m_population, and TopK().
Referenced by geopop::Generator< ID >::Apply(), and geopop::Populator< ID >::Apply().
vector< const Location * > geopop::GeoGrid::LocationsInRadius | ( | const Location & | start, |
double | radius | ||
) | const |
Search for locations in radius
(in km) around start
.
Definition at line 98 of file GeoGrid.cpp.
References CheckFinalized(), and geopop::MakeCollector().
Referenced by GetNearbyPools(), and GetPopulation().
vector< ContactPool * > geopop::GeoGrid::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 search again until the radius gets infinite.
May return an empty vector when there are really no pools to be found (empty grid).
Definition at line 111 of file GeoGrid.cpp.
References LocationsInRadius().
Referenced by GetPopulation().
set< const Location * > geopop::GeoGrid::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, lat2).
The coordinates must be positioned on the diagonal, i.e:
p1 --—+ +----—p1 | | | | | | or | | | | | | +----—p2 p2---—+
Definition at line 77 of file GeoGrid.cpp.
References CheckFinalized(), and geopop::MakeCollector().
Referenced by GetPopulation(), and LocationsInBox().
Gets the location in a rectangle defined by the two Locations.
Definition at line 91 of file GeoGrid.cpp.
References geopop::Location::GetCoordinate(), and LocationsInBox().
vector< Location * > geopop::GeoGrid::TopK | ( | size_t | k | ) | const |
Gets the K biggest (in population count) locations of this GeoGrid.
Definition at line 129 of file GeoGrid.cpp.
References geopop::Location::GetPopCount(), and m_locations.
Referenced by geopop::Generator< ID >::Apply(), and GetPopulation().
GeoAggregator< Policy, F > geopop::GeoGrid::BuildAggregator | ( | F | functor, |
typename Policy::Args && | args | ||
) | const |
Build a GeoAggregator with a predefined functor and given args for the Policy.
Definition at line 49 of file GeoGrid.cpp.
References m_tree.
Referenced by GetPopulation().
GeoAggregator< Policy > geopop::GeoGrid::BuildAggregator | ( | typename Policy::Args && | args | ) | const |
Build a GeoAggregator that gets its functor when calling, with given args for the Policy.
Definition at line 55 of file GeoGrid.cpp.
References m_tree.
|
inline |
|
inline |
Iterator to the end of the Location storage.
Definition at line 109 of file GeoGrid.h.
References m_locations.
|
inline |
|
inline |
Const iterator to the end of the Location storage.
Definition at line 115 of file GeoGrid.h.
References m_locations.
Gets a Location by index, doesn't performs a range check.
Definition at line 118 of file GeoGrid.h.
References m_locations.
Gets a Location by index, doesn't performs a range check.
Definition at line 121 of file GeoGrid.h.
References m_locations.
|
inline |
Gets current size of Location storage.
Definition at line 124 of file GeoGrid.h.
References CheckFinalized(), and m_locations.
|
private |
< Checks whether the GeoGrid is finalized i.e. certain operations can(not) be used.
Definition at line 60 of file GeoGrid.cpp.
References m_finalized.
Referenced by LocationsInBox(), LocationsInRadius(), and size().
|
private |
< Container for Locations in GeoGrid.
Associative container maps Location Id to index in m_locations.
Definition at line 132 of file GeoGrid.h.
Referenced by AddLocation(), begin(), cbegin(), cend(), end(), Finalize(), GetById(), operator[](), size(), and TopK().
|
private |
Stores pointer to Popluation, but does not take ownership.
Definition at line 135 of file GeoGrid.h.
Referenced by AddLocation(), and GetById().
|
private |
Is the GeoGrid finalized (ready for use) yet?
Definition at line 138 of file GeoGrid.h.
Referenced by GetPopulation().
|
private |
Internal KdTree for quick spatial lookup.
Definition at line 141 of file GeoGrid.h.
Referenced by AddLocation(), CheckFinalized(), and Finalize().
|
private |
Definition at line 144 of file GeoGrid.h.
Referenced by BuildAggregator(), and Finalize().