19 #include "geopop/ContactCenter.h" 23 #include <boost/property_tree/json_parser.hpp> 42 for (
const auto& location : geoGrid) {
43 pair<string, ptree> child;
45 locations.push_back(move(child));
47 root.add_child(
"locations", locations);
50 pair<string, ptree> child;
52 persons.push_back(move(child));
54 root.add_child(
"persons", persons);
56 m_persons_found.clear();
57 write_json(stream, root);
62 ptree contactCenter_root;
63 contactCenter_root.put(
"id", contactCenter->GetId());
64 contactCenter_root.put(
"type",
ToString(contactCenter->GetContactPoolType()));
67 for (
const auto& pool : *contactCenter) {
68 pair<string, ptree> child;
70 pools.push_back(move(child));
73 contactCenter_root.add_child(
"pools", pools);
74 return contactCenter_root;
79 ptree contactPool_root;
80 contactPool_root.put(
"id", contactPool->
GetId());
82 for (
auto person : *contactPool) {
85 person_root.put(
"", person->GetId());
86 people.push_back(make_pair(
"", person_root));
88 contactPool_root.add_child(
"people", people);
89 return contactPool_root;
94 ptree coordinate_root;
95 coordinate_root.put(
"longitude", boost::geometry::get<0>(coordinate));
96 coordinate_root.put(
"latitude", boost::geometry::get<1>(coordinate));
97 return coordinate_root;
103 location_root.put(
"id", location.
GetID());
104 location_root.put(
"name", location.
GetName());
105 location_root.put(
"province", location.
GetProvince());
106 location_root.put(
"population", location.
GetPopCount());
110 if (!commutes.empty()) {
112 for (
auto commute_pair : commutes) {
113 commutes_root.put(to_string(commute_pair.first->GetID()), commute_pair.second);
115 location_root.add_child(
"commutes", commutes_root);
118 ptree contactCenters;
120 for (
const auto& c : location.CRefCenters(typ)) {
121 pair<string, ptree> child;
123 contactCenters.push_back(move(child));
126 location_root.add_child(
"contactCenters", contactCenters);
128 return location_root;
134 person_root.put(
"id", person->
GetId());
135 person_root.put(
"age", person->
GetAge());
136 person_root.put(
"K12School", person->
GetPoolId(Id::K12School));
137 person_root.put(
"College", person->
GetPoolId(Id::College));
138 person_root.put(
"Household", person->
GetPoolId(Id::Household));
139 person_root.put(
"Workplace", person->
GetPoolId(Id::Workplace));
140 person_root.put(
"PrimaryCommunity", person->
GetPoolId(Id::PrimaryCommunity));
141 person_root.put(
"SecondaryCommunity", person->
GetPoolId(Id::SecondaryCommunity));
unsigned int GetID() const
Gets ID of this Location.
boost::property_tree::ptree WriteLocation(const Location &location)
Create a Boost Property Tree containing all info needed to reconstruct a Location.
std::string GetName() const
Gets the name.
Header file for the Person class.
A group of Persons that potentially have contacts with one another.
Header for the core ContactPool class.
constexpr std::initializer_list< Id > IdList
To allow iteration over the type ids.
std::set< stride::Person * > m_persons_found
The persons found when looping over the ContactPools.
unsigned int GetPoolId(const ContactType::Id &poolType) const
Get ID of contactpool_type.
string ToString(Id l)
Converts a LogMode value to corresponding name.
unsigned int GetProvince() const
Gets the province.
unsigned int GetId() const
Get the id.
boost::property_tree::ptree WritePerson(stride::Person *person)
Create a Boost Property Tree containing all info needed to reconstruct a Person.
unsigned int GetId() const
Get the pool id.
float GetAge() const
Get the age.
boost::property_tree::ptree WriteContactCenter(std::shared_ptr< ContactCenter > contactCenter)
Create a Boost Property Tree containing all info needed to reconstruct a ContactCenter.
A Geographic grid of simulation region contains Locations that in turn contain an index to the Contac...
boost::property_tree::ptree WriteCoordinate(const Coordinate &coordinate)
Create a Boost Property Tree containing all info needed to reconstruct a Coordinate.
Namespace for the geographic and demograhic classes.
const Coordinate GetCoordinate() const
Gets the Coordinate of this Location.
void Write(GeoGrid &geoGrid, std::ostream &stream) override
Write the provided GeoGrid to the proved ostream in JSON format.
boost::geometry::model::point< double, 2, boost::geometry::cs::geographic< boost::geometry::degree >> Coordinate
unsigned int GetPopCount() const
Gets the absolute population.
boost::property_tree::ptree WriteContactPool(stride::ContactPool *contactPool)
Create a Boost Property Tree containing all info needed to reconstruct a ContactPool.
GeoGridJSONWriter()
Construct the GeoGridJSONWriter.
Location for use within the GeoGrid, contains Coordinate and index to ContactPools.
Store and handle person data.
Namespace for the simulator and related classes.
Namespace to manage types of ContactPool.
const std::vector< std::pair< Location *, double > > & CRefOutgoingCommutes() const
References outgoing commute Locations + fraction of commutes to that Location.