Skip to content

Commit

Permalink
feat(engine): enhance CityGML reader and update example workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
miseyu committed Nov 21, 2024
1 parent 262719f commit 0e86f50
Show file tree
Hide file tree
Showing 4 changed files with 156 additions and 5 deletions.
9 changes: 6 additions & 3 deletions engine/runtime/action-processor/src/feature/reader/citygml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,10 @@ pub(crate) fn read_citygml(
.map_err(|e| super::errors::FeatureProcessorError::FileCityGmlReader(format!("{:?}", e)))?;
parse_tree_reader(
&mut st,
&feature.attributes,
citygml_params.flatten.unwrap_or(false),
base_url,
ctx,
&ctx,
fw,
)
.map_err(|e| super::errors::FeatureProcessorError::FileCityGmlReader(format!("{:?}", e)))?;
Expand All @@ -77,9 +78,10 @@ pub(crate) fn read_citygml(

fn parse_tree_reader<R: BufRead>(
st: &mut SubTreeReader<'_, '_, R>,
base_attributes: &HashMap<Attribute, AttributeValue>,
flatten: bool,
base_url: Url,
ctx: ExecutorContext,
ctx: &ExecutorContext,
fw: &mut dyn ProcessorChannelForwarder,
) -> Result<(), super::errors::FeatureProcessorError> {
let mut entities = Vec::new();
Expand Down Expand Up @@ -153,7 +155,7 @@ fn parse_tree_reader<R: BufRead>(
let attributes = entity.root.to_attribute_json();
let gml_id = entity.root.id();
let name = entity.root.typename();
let attributes = HashMap::<Attribute, AttributeValue>::from([
let mut attributes = HashMap::<Attribute, AttributeValue>::from([
(Attribute::new("cityGmlAttributes"), attributes.into()),
(
Attribute::new("gmlName"),
Expand All @@ -171,6 +173,7 @@ fn parse_tree_reader<R: BufRead>(
AttributeValue::String(format!("root_{}", to_hash(base_url.as_str()))),
),
]);
attributes.extend(base_attributes.clone());
let lod = LodMask::find_lods_by_citygml_value(&entity.root);
let metadata = Metadata {
feature_id: gml_id.map(|id| id.to_string()),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
mod helper;

fn main() {
helper::execute("data-convert/02-tran-rwy-trk-squr-wwy/workflow.yml");
helper::execute("data-convert/03-frn-veg/workflow.yml");
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/reearth/reearth-flow/main/engine/schema/workflow.json
id: a10c0286-e413-4695-8a39-17037d30973b
name: "DataConvert-03-frn-veg-workflow"
entryGraphId: 167c38dc-97f1-494c-a16b-6e09cdee179b
with:
cityGmlPath:
cityCode:
codelistsPath:
schemasPath:
schemaJson: !include ../../../config/schema.txt
targetPackages:
- frn
- veg
addNsprefixToFeatureTypes: true
extractDmGeometryAsXmlFragment: false
outputPath:
graphs:
- !include ../../../graphs/attribute_reader.yml
- !include ../../../graphs/folder_and_file_path_reader.yml
- id: 167c38dc-97f1-494c-a16b-6e09cdee179b
name: entry_point
nodes:
- id: d5fa7732-ef20-45ec-a331-e6d57571354b
name: AttributeReader
type: subGraph
subGraphId: 64931277-3a82-4a1c-88bc-9b54fe172518

- id: e1a0388f-78a3-4aec-b3e1-d6ffc9065dc9
name: AttributeMapperFilePath
type: action
action: AttributeMapper
with:
mappers:
- attribute: code
valueAttribute: meshCode
- attribute: type
valueAttribute: package
- attribute: maxLod
valueAttribute: maxLod
- attribute: length
expr: |
env.get("__value")["package"].len()
- attribute: file
expr: |
file::extract_filename(env.get("__value").cityGmlPath)
- id: c8d0f9dd-8f3d-46e0-8608-dfa22801a3d2
name: FileWriterTsvFilePath
type: action
action: FileWriter
with:
format: tsv
output: |
file::join_path(env.get("outputPath"), "maxLod.tsv")
- id: 254d6287-7649-4647-9ab5-0c1c423f356a
name: FeatureReaderByCityGml
type: action
action: FeatureReader
with:
format: citygml
dataset: |
env.get("__value").cityGmlPath
- id: 8510992d-2546-4e89-a09b-f31ff435bbb7
name: FeatureFilterByPackage
type: action
action: FeatureFilter
with:
conditions:
- expr: |
env.get("__value")["package"] == "frn"
outputPort: frn
- expr: |
env.get("__value")["package"] == "veg"
outputPort: veg
- id: 6e5ed9fc-006e-4dbe-8699-4663dba795cb
name: AttributeMapperFrn
type: action
action: AttributeMapper
with:
mappers:
- attribute: meshcode
valueAttribute: meshCode
- attribute: city_code
valueAttribute: cityCode
- attribute: city_name
valueAttribute: cityName
- attribute: feature_type
valueAttribute: gmlName
- attribute: gml_id
valueAttribute: gmlId

- id: 928e21d9-fc30-4876-ba03-41338cfa47ed
name: VerticalReprojectorFrn
type: action
action: VerticalReprojector
with:
reprojectorType: jgd2011ToWgs84

- id: b4862d31-4bb2-49b1-8f0d-6d58dd4cb385
name: Cesium3DTilesWriterByFrn
type: action
action: Cesium3DTilesWriter
with:
minZoom: 15
maxZoom: 18
attachTexture: true
output: |
file::join_path(env.get("outputPath"), "frn_lod0-3")
edges:
- id: 7b81f501-3f07-4cec-bf9b-9cefcebdf47d
from: d5fa7732-ef20-45ec-a331-e6d57571354b
to: e1a0388f-78a3-4aec-b3e1-d6ffc9065dc9
fromPort: filePath
toPort: default
- id: 284b02d9-8051-4614-a03c-583274c700f8
from: e1a0388f-78a3-4aec-b3e1-d6ffc9065dc9
to: c8d0f9dd-8f3d-46e0-8608-dfa22801a3d2
fromPort: default
toPort: default
- id: a4751655-5956-4e27-a976-e35f8914ad31
from: d5fa7732-ef20-45ec-a331-e6d57571354b
to: 254d6287-7649-4647-9ab5-0c1c423f356a
fromPort: filePath
toPort: default
- id: fb48e9e0-fa1b-4f27-8a89-84b6d2e1c6d7
from: 254d6287-7649-4647-9ab5-0c1c423f356a
to: 8510992d-2546-4e89-a09b-f31ff435bbb7
fromPort: default
toPort: default
- id: 1e29f24a-620b-472c-805f-8295bf5920c2
from: 8510992d-2546-4e89-a09b-f31ff435bbb7
to: 6e5ed9fc-006e-4dbe-8699-4663dba795cb
fromPort: frn
toPort: default
- id: 703fbdd0-516f-4201-b2ad-5575ab684fbc
from: 6e5ed9fc-006e-4dbe-8699-4663dba795cb
to: 928e21d9-fc30-4876-ba03-41338cfa47ed
fromPort: default
toPort: default
- id: e862f11a-88a6-4c1b-a743-ba80253039df
from: 928e21d9-fc30-4876-ba03-41338cfa47ed
to: b4862d31-4bb2-49b1-8f0d-6d58dd4cb385
fromPort: default
toPort: default
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/reearth/reearth-flow/main/engine/schema/workflow.json
id: 3e39d990-0a80-47df-9be9-3bf7c0068b5a
name: "DataConvert-05-luse-lsld-workflow"
name: "DataConvert-04-luse-lsld-workflow"
entryGraphId: 0e500d5a-7882-4835-9285-9763ba8b5b65
with:
cityGmlPath:
Expand Down

0 comments on commit 0e86f50

Please sign in to comment.