40 throw runtime_error(
"Failed to parse Proto file");
44 for (
int idx = 0; idx < protoGrid.
persons_size(); idx++) {
53 geoGrid.AddLocation(move(loc));
64 const auto protoType = protoContactPools.
type();
66 static const map<proto::GeoGrid_Location_ContactPools_Type, Id> types = {
74 const auto typeId = types.at(protoType);
76 for (
int idx = 0; idx < protoContactPools.
pools_size(); idx++) {
93 loc->RefPools(type).emplace_back(result);
95 for (
int idx = 0; idx < protoContactPool.
people_size(); idx++) {
96 const auto person_id =
static_cast<unsigned int>(protoContactPool.
people(idx));
97 const auto person =
m_people.at(person_id);
98 result->AddMember(person);
100 person->SetPoolId(type, static_cast<unsigned int>(result->GetId()));
106 const auto id = protoLocation.
id();
107 const auto& name = protoLocation.
name();
108 const auto province = protoLocation.
province();
109 const auto population = protoLocation.
population();
112 auto loc = make_shared<Location>(id, province, coordinate, name, population);
119 for (
int idx = 0; idx < protoLocation.
commutes_size(); idx++) {
129 const auto id =
static_cast<unsigned int>(protoPerson.
id());
double proportion() const
Header file for the Person class.
void AddCommutes(GeoGrid &geoGrid)
Add the commutes that were found to their respective Locations symmetrically.
void ParseContactPools(std::shared_ptr< Location > loc, const proto::GeoGrid_Location_ContactPools &protoContactPools)
Create ContactPools based on protobuf ContactPools info.
::google::protobuf::int64 population() const
::proto::GeoGrid_Location_ContactPools_Type type() const
int contactpools_size() const
stride::Population * m_population
Population to use in the GeoGrid may be nullptr.
void Read() override
Actually perform the read and return the GeoGrid.
int locations_size() const
std::shared_ptr< Location > ParseLocation(const proto::GeoGrid_Location &protoLocation)
Create a Location based on protobuf Location info.
const ::proto::GeoGrid_Location & locations(int index) const
::google::protobuf::int64 province() const
stride::Person * ParsePerson(const proto::GeoGrid_Person &person)
Create a Person based on protobuf Person info.
::google::protobuf::int64 id() const
geopop::GeoGrid & RefGeoGrid()
Reference the GeoGrid associated with this population (may be a nullptr).
GeoGridProtoReader(std::unique_ptr< std::istream > inputStream, stride::Population *pop)
Construct the GeoGridJSONReader with the istream which contains the Protobuf info.
::google::protobuf::int64 age() const
ContactPoolSys & RefPoolSys()
Reference the ContactPoolSys of the Population.
const ::proto::GeoGrid_Person & persons(int index) const
void ParseContactPool(std::shared_ptr< Location > loc, const proto::GeoGrid_Location_ContactPools_ContactPool &protoContactPool, stride::ContactType::Id typeId)
Create a ContactPool based on the provided protobuf ContactPool.
Key Data structure: container for (a) all individuals in the population (b) the ContactPoolSys wchich...
Namespace for the geographic and demograhic classes.
std::vector< std::tuple< unsigned int, unsigned int, double > > m_commutes
Person * CreatePerson(unsigned int id, double age, unsigned int householdId, unsigned int k12SchoolId, unsigned int collegeId, unsigned int workId, unsigned int primaryCommunityId, unsigned int secondaryCommunityId)
Create Person in the population.
std::unique_ptr< std::istream > m_inputStream
File to read.
::google::protobuf::int64 people(int index) const
An abstract base class for creating a GeoGrid that was read from a file, can be implemented using mul...
Coordinate ParseCoordinate(const proto::GeoGrid_Location_Coordinate &protoCoordinate)
Create a Coordinate based on the provided protobuf Coordinate.
int commutes_size() const
const ::proto::GeoGrid_Location_ContactPools_ContactPool & pools(int index) const
boost::geometry::model::point< double, 2, boost::geometry::cs::geographic< boost::geometry::degree >> Coordinate
Header file for the core Population class.
std::map< unsigned int, stride::Person * > m_people
< Store the persons (id->person) that were found while loping over the ContactPools.
::google::protobuf::int64 id() const
const ::proto::GeoGrid_Location_Coordinate & coordinate() const
ContactPool * CreateContactPool(ContactType::Id typeId)
Create a new contact pool of a given type.
Store and handle person data.
const ::proto::GeoGrid_Location_Commute & commutes(int index) const
const ::proto::GeoGrid_Location_ContactPools & contactpools(int index) const
const ::std::string & name() const
::google::protobuf::int64 to() const
Namespace to manage types of ContactPool.