Skip to main content

Hello,

I have a Feature and I am using a FeatureWriter to output a final GeoJson, until there everything is working fine when it's about direct attribute.

How about automatically looping a nested list, to get a list of one specific attribute and attach it to my FeatureWriter as a json property (an array) and keeping in the mean time the already well defined relation between the main object and it's list 

Basically I want this attribute "classification" (see the screenshot attached), to be output at the end as a json property of a type array using a FeatureWriter Geojson.

Bellow the final output expected, of course without building the GeoJson by myself but letting the FeatureWriter (GeoJson) to do the job:

{
"type" : "FeatureCollection",
"name" : "SomeName",
"features" : Â
{
"type" : "Feature",
"geometry" : {
"type" : "GeometryCollection",
"geometries" : null
},
"properties" : {
"someProperty" : "someValue",
"classification": r"value1", "value2"]
}
},
{
"type" : "Feature",
"geometry" : {
"type" : "GeometryCollection",
"geometries" : null
},
"properties" : {
"someProperty" : "someValue",
"classification": C"value1", "value2"]
}
}
]
}

Hi @jacquint, if you have created already the list "class{}.AirspaceLayerClass.classification" that stores the values, you can convert it to a JSON array with the JSONTemplater and write it to the destination GeoJSON dataset as a 'json' type attribute.

Template Expression in JSONTemplater TUpdated]:

 
    fme:get-list-attribute("class{}.AirspaceLayerClass.classification")
]

0684Q00000ArJnfQAF.png


Thank you very much @takashi it works perfectly !


Hi !

Actually I talk too fast probably :)

It's working but now I have duplicated feature in the output. Any idea?

Thank you.


Hi !

Actually I talk too fast probably :)

It's working but now I have duplicated feature in the output. Any idea?

Thank you.

duplicate sets in the input probably.

 

Like features with multi classifications can lead to this.

 

 


Hi !

Actually I talk too fast probably :)

It's working but now I have duplicated feature in the output. Any idea?

Thank you.

The JSONTemplater won't duplicate features. To find where the features would duplicate, consider run the workspace with Full Inspection mode (Workbench menu Run > Run with Full Inspection).

 


Yes a feature can have multiple classifications that's why I want in the same level of the feature in the GeoJson output to have a classification array.

The way I am doing it is probably not the right one, see the screenshot attached: screen-shot-2018-04-03-at-71447-pm.png

The JSONTemplater is here only to handle the templating of the classification's array see screenshot:

screen-shot-2018-04-03-at-72144-pm.png

then each array must be merged back in to the feature where it belongs by the FeatureWriter right? see screenshot: screen-shot-2018-04-03-at-72425-pm.png

Thank you very much in advance !


Yes a feature can have multiple classifications that's why I want in the same level of the feature in the GeoJson output to have a classification array.

The way I am doing it is probably not the right one, see the screenshot attached: screen-shot-2018-04-03-at-71447-pm.png

The JSONTemplater is here only to handle the templating of the classification's array see screenshot:

screen-shot-2018-04-03-at-72144-pm.png

then each array must be merged back in to the feature where it belongs by the FeatureWriter right? see screenshot: screen-shot-2018-04-03-at-72425-pm.png

Thank you very much in advance !

In your workflow, the two data flows from the AttributeManager and the JSONTemplter will join into a singel flow, but features won't be merged. It's the reason why the features have been duplicated. If you need to merge the features, consider using the FeatureMerger.

 

However, the JSONTempleter preserves all attributes of the input feature, so it's not essential to merge back the resulting feature to the original feature. I think you can just remove the connection between the AttributeManager and the AttributeRenamer.

 

 

 


Yes a feature can have multiple classifications that's why I want in the same level of the feature in the GeoJson output to have a classification array.

The way I am doing it is probably not the right one, see the screenshot attached: screen-shot-2018-04-03-at-71447-pm.png

The JSONTemplater is here only to handle the templating of the classification's array see screenshot:

screen-shot-2018-04-03-at-72144-pm.png

then each array must be merged back in to the feature where it belongs by the FeatureWriter right? see screenshot: screen-shot-2018-04-03-at-72425-pm.png

Thank you very much in advance !

Thank you very much @takashi

 

 

It's workign as expected. I didn't know that the JSONTemplater preserved the other non

 


Reply