Skip to content

Commit

Permalink
feat: Update building usage attribute validator description
Browse files Browse the repository at this point in the history
The building usage attribute validator description has been updated to
provide more detailed information about its functionality and the output
it produces.
  • Loading branch information
miseyu committed Jul 23, 2024
1 parent df91a5e commit f18b751
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 19 deletions.
2 changes: 1 addition & 1 deletion schema/actions.json
Original file line number Diff line number Diff line change
Expand Up @@ -1388,7 +1388,7 @@
{
"name": "PLATEAU.BuildingUsageAttributeValidator",
"type": "processor",
"description": "Validates Building Usage attributes",
"description": "This processor validates building usage attributes by checking for the presence of required attributes and ensuring the correctness of city codes. It outputs errors through the lBldgError and codeError ports if any issues are found.",
"parameter": null,
"builtin": true,
"inputPorts": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl ProcessorFactory for BuildingUsageAttributeValidatorFactory {
}

fn description(&self) -> &str {
"Validates Building Usage attributes"
"This processor validates building usage attributes by checking for the presence of required attributes and ensuring the correctness of city codes. It outputs errors through the lBldgError and codeError ports if any issues are found."
}

fn parameter_schema(&self) -> Option<schemars::schema::RootSchema> {
Expand Down Expand Up @@ -214,25 +214,27 @@ impl Processor for BuildingUsageAttributeValidator {
)
.into());
};
let survey_year = if let Some(AttributeValue::Array(detail_attributes)) =
gml_attributes.get("uro:buildingDetailAttribute")
{
detail_attributes.first().map(|detail_attribute| {
if let AttributeValue::Map(details_attribute) = detail_attribute {
if let Some(AttributeValue::String(survey_year)) =
details_attribute.get("uro:surveyYear")
{
survey_year.clone()
} else {
"".to_string()
}
let survey_year = gml_attributes
.get("uro:buildingDetailAttribute")
.and_then(|attr| {
if let AttributeValue::Array(detail_attributes) = attr {
detail_attributes.first().and_then(|detail_attribute| {
if let AttributeValue::Map(details_attribute) = detail_attribute {
details_attribute.get("uro:surveyYear").and_then(|year| {
if let AttributeValue::String(survey_year) = year {
Some(survey_year.clone())
} else {
None
}
})
} else {
None
}
})
} else {
"".to_string()
None
}
})
} else {
None
};
});
let mut error_messages = Vec::<String>::new();
let all_keys = feature.all_attribute_keys();
for (key, value) in USAGE_ATTRIBUTES.iter() {
Expand Down
21 changes: 21 additions & 0 deletions worker/crates/types/src/attribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -462,4 +462,25 @@ mod tests {
let number2 = Number::from(42);
assert_eq!(compare_numbers(&number1, &number2), Some(Ordering::Greater));
}

#[test]
fn test_all_attribute_keys() {
let mut map = HashMap::new();
map.insert(
"key1".to_string(),
AttributeValue::String("value1".to_string()),
);
let mut nested_map = HashMap::new();
nested_map.insert(
"key2".to_string(),
AttributeValue::String("value2".to_string()),
);
map.insert("nested".to_string(), AttributeValue::Map(nested_map));

let keys = all_attribute_keys(&map);
assert_eq!(
keys,
vec!["key1".to_string(), "nested".to_string(), "key2".to_string()]
);
}
}

0 comments on commit f18b751

Please sign in to comment.