Document GeoDB; remove unused code; minor fixes

This commit is contained in:
2021-07-16 10:13:58 -05:00
parent 658d5ddbdc
commit 0c9465411f
6 changed files with 71 additions and 35 deletions

View File

@@ -182,6 +182,38 @@ The keys in the `capacities (tonne)` dictionary should be the amounts (in tonnes
}
```
### Geographic database
Instead of specifying locations using latitudes and longitudes, it is also possible to specify them using unique identifiers, such as the name of a US state, or the county FIPS code. This works anywhere `latitude (deg)` and `longitude (deg)` are expected. For example, instead of:
```json
{
"initial amounts": {
"C1": {
"latitude (deg)": 37.27182,
"longitude (deg)": -119.2704,
"amount (tonne)": [934.56, 934.56]
},
}
}
```
is is possible to write:
```json
{
"initial amounts": {
"C1": {
"location": "us-state:CA",
"amount (tonne)": [934.56, 934.56]
},
}
}
```
Location names follow the format `db:id`, where `db` is the name of the database and `id` is the identifier for a specific location. RELOG currently includes the following databases:
Database | Description | Examples
---------|-------------|----------
`us-state`| List of states of the United States. | `us-state:IL` (State of Illinois)
`2018-us-county` | List of United States counties, as of 2018. IDs are 5-digit FIPS codes. | `2018-us-county:17043` (DuPage county in Illinois)
### Current limitations
* Each plant can only be opened exactly once. After open, the plant remains open until the end of the simulation.
@@ -192,4 +224,3 @@ The keys in the `capacities (tonne)` dictionary should be the amounts (in tonnes
## Output Data Format (JSON)
To be documented.

View File

@@ -168,25 +168,6 @@ function _geodb_load_2018_us_county()::Dict{String,GeoRegion}
)
end
# # 2018 US ZIP codes
# # -----------------------------------------------------------------------------
# function _extract_cols_2018_us_zcta(table::Shapefile.Table, i::Int)::OrderedDict{String,Any}
# return OrderedDict("id" => table.ZCTA5CE10[i])
# end
# function _geodb_load_2018_us_zcta()::Dict{String,GeoRegion}
# return _geodb_load_gov_census(
# db_name = "2018-us-zcta",
# extract_cols = _extract_cols_2018_us_zcta,
# shp_crc32 = 0x6391f5fc,
# shp_filename = "cb_2018_us_zcta510_500k.shp",
# shp_url = "https://www2.census.gov/geo/tiger/GENZ2018/shp/cb_2018_us_zcta510_500k.zip",
# population_url = "http://www2.census.gov/programs-surveys/popest/datasets/2010-2019/national/totals/nst-est2019-alldata.csv",
# population_crc32 = 0x191cc64c,
# population_col = "POPESTIMATE2019",
# )
# end
# US States
# -----------------------------------------------------------------------------
function _extract_cols_us_state(table::Shapefile.Table, i::Int)::OrderedDict{String,Any}
@@ -218,7 +199,6 @@ end
function geodb_load(db_name::AbstractString)::Dict{String,GeoRegion}
db_name == "2018-us-county" && return _geodb_load_2018_us_county()
db_name == "2018-us-zcta" && return _geodb_load_2018_us_zcta()
db_name == "us-state" && return _geodb_load_us_state()
error("Unknown database: $db_name")
end

View File

@@ -100,6 +100,13 @@ function parse(json)::Instance
disposal_limit = Dict(p => [0.0 for t = 1:T] for p in keys(output))
disposal_cost = Dict(p => [0.0 for t = 1:T] for p in keys(output))
# GeoDB
if "location" in keys(location_dict)
region = geodb_query(location_dict["location"])
location_dict["latitude (deg)"] = region.centroid.lat
location_dict["longitude (deg)"] = region.centroid.lon
end
# Disposal
if "disposal" in keys(location_dict)
for (product_name, disposal_dict) in location_dict["disposal"]