Stride Reference Manual  - generated for commit 9643b11
GeoGridReader.cpp
Go to the documentation of this file.
1 /*
2  * This is free software: you can redistribute it and/or modify it
3  * under the terms of the GNU General Public License as published by
4  * the Free Software Foundation, either version 3 of the License, or
5  * any later version.
6  * The software is distributed in the hope that it will be useful,
7  * but WITHOUT ANY WARRANTY; without even the implied warranty of
8  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9  * GNU General Public License for more details.
10  * You should have received a copy of the GNU General Public License
11  * along with the software. If not, see <http://www.gnu.org/licenses/>.
12  *
13  * Copyright 2018, Jan Broeckhove and Bistromatics group.
14  */
15 
16 #include "GeoGridReader.h"
17 
18 #include "geopop/GeoGrid.h"
19 #include "geopop/Location.h"
20 
21 namespace geopop {
22 
23 GeoGridReader::GeoGridReader(std::unique_ptr<std::istream> inputStream, stride::Population* pop)
24  : m_people(), m_commutes(), m_inputStream(std::move(inputStream)), m_population(pop)
25 {
26 }
28 {
29  for (const auto& commute_tuple : m_commutes) {
30  const auto a = geoGrid.GetById(std::get<0>(commute_tuple));
31  const auto b = geoGrid.GetById(std::get<1>(commute_tuple));
32  const auto amount = std::get<2>(commute_tuple);
33  a->AddOutgoingCommute(b, amount);
34  b->AddIncomingCommute(a, amount);
35  }
36 }
37 
38 } // namespace geopop
void AddCommutes(GeoGrid &geoGrid)
Add the commutes that were found to their respective Locations symmetrically.
GeoGridReader(std::unique_ptr< std::istream > inputStream, stride::Population *pop)
Parametrized constructor.
STL namespace.
A Geographic grid of simulation region contains Locations that in turn contain an index to the Contac...
Definition: GeoGrid.h:41
Key Data structure: container for (a) all individuals in the population (b) the ContactPoolSys wchich...
Definition: Population.h:47
Namespace for the geographic and demograhic classes.
Definition: Coordinate.h:21
std::vector< std::tuple< unsigned int, unsigned int, double > > m_commutes
Definition: GeoGridReader.h:64
std::shared_ptr< Location > GetById(unsigned int id) const
Gets a Location by Id and check if the Id exists.
Definition: GeoGrid.h:60