Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chrk/schema updates #69

Merged
merged 5 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 33 additions & 51 deletions lcax.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,53 +146,31 @@
}
},
"BuildingModelScope": {
"type": "object",
"required": [
"building_services",
"external_works",
"type": "string",
"enum": [
"facilitating_works",
"ff_e",
"finishes",
"substructure",
"superstructure_envelope",
"superstructure_frame",
"superstructure_internal_elements"
],
"properties": {
"building_services": {
"type": "boolean"
},
"external_works": {
"type": "boolean"
},
"facilitating_works": {
"type": "boolean"
},
"ff_e": {
"type": "boolean"
},
"finishes": {
"type": "boolean"
},
"substructure": {
"type": "boolean"
},
"superstructure_envelope": {
"type": "boolean"
},
"superstructure_frame": {
"type": "boolean"
},
"superstructure_internal_elements": {
"type": "boolean"
}
}
"superstructure_envelope",
"superstructure_internal_elements",
"finishes",
"building_services",
"external_works",
"ff_e"
]
},
"BuildingType": {
"type": "string",
"enum": [
"renovation",
"new"
"new_construction_works",
"demolition",
"deconstruction_and_new_construction_works",
"retrofit_works",
"extension_works",
"retrofit_and_extension_works",
"fit_out_works",
"operations",
"other"
]
},
"BuildingTypology": {
Expand Down Expand Up @@ -673,6 +651,7 @@
"LifeCycleStage": {
"type": "string",
"enum": [
"a0",
"a1a3",
"a4",
"a5",
Expand All @@ -683,6 +662,7 @@
"b5",
"b6",
"b7",
"b8",
"c1",
"c2",
"c3",
Expand Down Expand Up @@ -765,14 +745,13 @@
]
},
"buildingModelScope": {
"anyOf": [
{
"$ref": "#/definitions/BuildingModelScope"
},
{
"type": "null"
}
]
"type": [
"array",
"null"
],
"items": {
"$ref": "#/definitions/BuildingModelScope"
}
},
"buildingPermitYear": {
"type": [
Expand Down Expand Up @@ -918,9 +897,12 @@
"ProjectPhase": {
"type": "string",
"enum": [
"design",
"ongoing",
"built",
"strategic_design",
"concept_design",
"technical_design",
"construction",
"post_completion",
"in_use",
"other"
]
},
Expand Down
4 changes: 2 additions & 2 deletions modules/calculation/tests/datafixtures/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@
"results": null,
"projectInfo": {
"type": "buildingInfo",
"buildingType": "new",
"buildingTypology": "office",
"buildingType": "new_construction_works",
"buildingTypology": ["office"],
"certifications": null,
"buildingMass": null,
"buildingHeight": null,
Expand Down
4 changes: 2 additions & 2 deletions modules/convert/src/lcabyg/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ fn add_building_data(project: &mut LCAxProject, node: &nodes::Building) {
project.reference_study_period = Some(node.calculation_timespan as u8);
project.project_info = Some(ProjectInfo::BuildingInfo {
0: BuildingInfo {
building_type: BuildingType::NEW,
building_typology: BuildingTypology::from(&node.building_type),
building_type: BuildingType::NEW_CONSTRUCTION_WORKS,
building_typology: vec![BuildingTypology::from(&node.building_type)],
certifications: None,
building_mass: None,
building_height: None,
Expand Down
6 changes: 6 additions & 0 deletions modules/models/src/life_cycle_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use tsify::Tsify;
#[serde(rename_all = "lowercase")]
#[cfg_attr(feature = "jsbindings", derive(Tsify))]
pub enum LifeCycleStage {
A0,
A1A3,
A4,
A5,
Expand All @@ -20,6 +21,7 @@ pub enum LifeCycleStage {
B5,
B6,
B7,
B8,
C1,
C2,
C3,
Expand All @@ -30,6 +32,7 @@ pub enum LifeCycleStage {
impl fmt::Display for LifeCycleStage {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
LifeCycleStage::A0 => write!(f, "A0"),
LifeCycleStage::A1A3 => write!(f, "A1A3"),
LifeCycleStage::A4 => write!(f, "A4"),
LifeCycleStage::A5 => write!(f, "A5"),
Expand All @@ -40,6 +43,7 @@ impl fmt::Display for LifeCycleStage {
LifeCycleStage::B5 => write!(f, "B5"),
LifeCycleStage::B6 => write!(f, "B6"),
LifeCycleStage::B7 => write!(f, "B7"),
LifeCycleStage::B8 => write!(f, "B8"),
LifeCycleStage::C1 => write!(f, "C1"),
LifeCycleStage::C2 => write!(f, "C2"),
LifeCycleStage::C3 => write!(f, "C3"),
Expand All @@ -54,6 +58,7 @@ impl TryFrom<&str> for LifeCycleStage {

fn try_from(value: &str) -> Result<Self, Self::Error> {
match value.to_lowercase().as_str() {
"a0" => Ok(LifeCycleStage::A0),
"a1to3" => Ok(LifeCycleStage::A1A3),
"a1a3" => Ok(LifeCycleStage::A1A3),
"a1-3" => Ok(LifeCycleStage::A1A3),
Expand All @@ -66,6 +71,7 @@ impl TryFrom<&str> for LifeCycleStage {
"b5" => Ok(LifeCycleStage::B5),
"b6" => Ok(LifeCycleStage::B6),
"b7" => Ok(LifeCycleStage::B7),
"b8" => Ok(LifeCycleStage::B8),
"c1" => Ok(LifeCycleStage::C1),
"c2" => Ok(LifeCycleStage::C2),
"c3" => Ok(LifeCycleStage::C3),
Expand Down
66 changes: 46 additions & 20 deletions modules/models/src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl Project {
assemblies: HashMap::new(),
results: None,
project_info: None,
project_phase: ProjectPhase::DESIGN,
project_phase: ProjectPhase::STRATEGIC_DESIGN,
software_info: SoftwareInfo {
goal_and_scope_definition: None,
lca_software: "lcax".to_string(),
Expand All @@ -84,9 +84,17 @@ pub struct SoftwareInfo {
#[serde(rename_all = "lowercase")]
#[cfg_attr(feature = "jsbindings", derive(Tsify))]
pub enum ProjectPhase {
DESIGN,
ONGOING,
BUILT,
#[allow(non_camel_case_types)]
STRATEGIC_DESIGN,
#[allow(non_camel_case_types)]
CONCEPT_DESIGN,
#[allow(non_camel_case_types)]
TECHNICAL_DESIGN,
CONSTRUCTION,
#[allow(non_camel_case_types)]
POST_COMPLETION,
#[allow(non_camel_case_types)]
IN_USE,
#[default]
OTHER,
}
Expand Down Expand Up @@ -114,7 +122,7 @@ pub enum ProjectInfo {
#[cfg_attr(feature = "jsbindings", derive(Tsify))]
pub struct BuildingInfo {
pub building_type: BuildingType,
pub building_typology: BuildingTypology,
pub building_typology: Vec<BuildingTypology>,
pub certifications: Option<Vec<String>>,
pub building_mass: Option<ValueUnit>,
pub building_height: Option<ValueUnit>,
Expand All @@ -135,7 +143,7 @@ pub struct BuildingInfo {
pub general_energy_class: GeneralEnergyClass,
pub local_energy_class: Option<String>,
pub building_users: Option<u64>,
pub building_model_scope: Option<BuildingModelScope>,
pub building_model_scope: Option<Vec<BuildingModelScope>>,
}

#[derive(Deserialize, Serialize, JsonSchema, Clone)]
Expand Down Expand Up @@ -188,24 +196,44 @@ impl From<&String> for GeneralEnergyClass {
#[derive(Deserialize, Serialize, JsonSchema, Clone)]
#[serde(rename_all = "lowercase")]
#[cfg_attr(feature = "jsbindings", derive(Tsify))]
pub struct BuildingModelScope {
pub facilitating_works: bool,
pub substructure: bool,
pub superstructure_frame: bool,
pub superstructure_envelope: bool,
pub superstructure_internal_elements: bool,
pub finishes: bool,
pub building_services: bool,
pub external_works: bool,
pub ff_e: bool,
pub enum BuildingModelScope {
#[allow(non_camel_case_types)]
FACILITATING_WORKS,
SUBSTRUCTURE,
#[allow(non_camel_case_types)]
SUPERSTRUCTURE_FRAME,
#[allow(non_camel_case_types)]
SUPERSTRUCTURE_ENVELOPE,
#[allow(non_camel_case_types)]
SUPERSTRUCTURE_INTERNAL_ELEMENTS,
FINISHES,
#[allow(non_camel_case_types)]
BUILDING_SERVICES,
#[allow(non_camel_case_types)]
EXTERNAL_WORKS,
#[allow(non_camel_case_types)]
FF_E,
}

#[derive(Deserialize, Serialize, JsonSchema, Clone)]
#[serde(rename_all = "lowercase")]
#[cfg_attr(feature = "jsbindings", derive(Tsify))]
pub enum BuildingType {
RENOVATION,
NEW,
#[allow(non_camel_case_types)]
NEW_CONSTRUCTION_WORKS,
DEMOLITION,
#[allow(non_camel_case_types)]
DECONSTRUCTION_AND_NEW_CONSTRUCTION_WORKS,
#[allow(non_camel_case_types)]
RETROFIT_WORKS,
#[allow(non_camel_case_types)]
EXTENSION_WORKS,
#[allow(non_camel_case_types)]
RETROFIT_AND_EXTENSION_WORKS,
#[allow(non_camel_case_types)]
FIT_OUT_WORKS,
OPERATIONS,
OTHER,
}

#[derive(Deserialize, Serialize, JsonSchema, Clone)]
Expand All @@ -219,7 +247,6 @@ pub enum BuildingTypology {
INDUSTRIAL,
INFRASTRUCTURE,
AGRICULTURAL,
MIXEDUSE,
OTHER,
}

Expand All @@ -233,7 +260,6 @@ impl From<&String> for BuildingTypology {
"industrial" => BuildingTypology::INDUSTRIAL,
"infrastructure" => BuildingTypology::INFRASTRUCTURE,
"agricultural" => BuildingTypology::AGRICULTURAL,
"mixeduse" => BuildingTypology::MIXEDUSE,
_ => BuildingTypology::OTHER,
}
}
Expand Down
Binary file modified packages/python/src/lcax/lcax.abi3.so
Binary file not shown.
Loading