Skip to main content

Hi,

I am working with CityGML data and using FME to process and transform buildings from a 3DCityDB into CityGML output. I know I can use the 3DCityDBImporter/Exporter for this but I would like to create a custom FME script for more control.

I am trying to transform attributes from the 3DCityDB into a format suitable for CityGML output, specifically list attributes like citygml_function{}, citygml_function{}.codeSpace and citygml_usage{}, citygml_usage{}.codeSpace. These attributes are stored as strings with values separated by --/\--, and the corresponding URLs (codeSpace) are also in a similar delimited format.

I attatch one building with these attributes in csv format as an example.

The end result should be like this feature (building):

Have anyone done something similar as this? Im not very used to working with lists. Would appreciate the help, thanks in advance!

I solved it with a PythonCaller. Way easier to handle the data there.

Here is the Python code if anyone is facing the same problem:
 

import fme
import fmeobjects

class FeatureProcessor(object):

def __init__(self):
pass

def input(self, feature):

function = feature.getAttribute('function')
function_codespace = feature.getAttribute('function_codespace')
usage = feature.getAttribute('usage')
usage_codespace = feature.getAttribute('usage_codespace')

function_list = function.split('--/\\--')
function_codespace_list = function_codespace.split('--/\\--')
usage_list = usage.split('--/\\--')
usage_codespace_list = usage_codespace.split('--/\\--')

for i, value in enumerate(function_list):
if value:
feature.setAttribute(f'citygml_function{{{i}}}', value)

for i, value in enumerate(function_codespace_list):
if value:
feature.setAttribute(f'citygml_function{{{i}}}.codeSpace', value)

for i, value in enumerate(usage_list):
if value:
feature.setAttribute(f'citygml_usage{{{i}}}', value)

for i, value in enumerate(usage_codespace_list):
if value:
feature.setAttribute(f'citygml_usage{{{i}}}.codeSpace', value)

self.pyoutput(feature)

def close(self):
pass

def process_group(self):
pass

def has_support_for(self, support_type):
if support_type == fmeobjects.FME_SUPPORT_FEATURE_TABLE_SHIM:
return False
return False

 


Reply