[][src]Crate popdat

popdat ("population data") generates Scenarios given a map and some external census data. Some of this functionality should maybe be reorganized or incorporated into the importer crate, but for now, it's convenient to organize it here.

All of the types and methods here are tied to a single Map. Even if a city is chopped up into multiple pieces, for now, let's assume we're just dealing with one map at a time. That lets us use the map's coordinate system, building IDs, etc.

These types form a pipeline:

  1. For a given map, find some census data that describes how many people live in different areas of the city. (CensusArea)
  2. Take the CensusAreas and turn them into individual CensusPersons, by randomly choosing a specific building on the map as their home, and assigning specific attributes based on the census data's distribution.
  3. For each CensusPerson, classify them into a PersonType, then generate a Schedule of different Activities throughout the day.
  4. Pick specific buildings to visit to satisfy the Schedule.

Modules

activities
distribute_people
import_census
make_person

Structs

CensusArea

Represents aggregate demographic data for some part of a city. These could be census tracts or blocks, depending what data we find. All of the areas should roughly partition the map -- we probably don't need to guarantee we cover every single building, but we definitely shouldn't have two overlapping areas.

CensusPerson

Demographic information for a single person

Config

Any arbitrarily chosen parameters needed should be put here, so they can be controlled from the UI or tuned for different cities.

Schedule

A single person's daily schedule. It's assumed that someone always starts at home. And for most people, the last entry should probably be Activity::Home.

Enums

Activity

Different things people might do in the day. Maybe it's more clear to call this a DestinationType or similar.

PersonType

It might be useful to classify a CensusPerson into different categories to figure out their Schedule.

Functions

generate_scenario

Wires together all the pieces, so you can just hand this any map, and it'll automatically find appropriate census data, and use it to produce a Scenario.