Skip to main content

I want to export some data to gml, and I see that I have some complex geometries, which results in different sets of coordinates for each polygon (after geometry extractor). I made a list and each element within the list contains the set of coordinates for each segment of the geometry, but not all the polygons have the extra dimensions.

Therefore, I want to make an if-statement where only the extra xml-statement is shown when there is data in the list. I tried using this, but it does not work.

Can anybody point out an error in the statement.

Not only the line with the statement posList..., but also the other statements around them, I want to delete when the list element is not existing.

 

 

If there is another way of doing this (e.g. with a loop), I am open to suggestions.

 

</gml:exterior>

 

If {(fme:has-attribute("interior_xy_l{0}.part")) then (

 

<gml:exterior>

 

<gml:LinearRing>

 

<gml:posList>{fme:get-attribute("interior_xy_l{0}.part")}</gml:posList>

 

</gml:LinearRing>

 

</gml:exterior>)

 

else ()}

 

 

Hi @evagadeyne, this is just a partial and syntactic correction on the if statement. I don't know if it's correct in the context of the entire expression.

{
    if (fme:has-attribute("interior_xy_l{0}.part"))
    then
    <gml:exterior>
        <gml:LinearRing>
            <gml:posList>{fme:get-attribute("interior_xy_l{0}.part")}</gml:posList>
        </gml:LinearRing>
    </gml:exterior>
    else ()
}

Thank you @takashi

this works! Can I make a loop over all the list members from 0 to 5 above the if statement, so I do not need to copy-paste this 6 times?


Thank you @takashi

this works! Can I make a loop over all the list members from 0 to 5 above the if statement, so I do not need to copy-paste this 6 times?

Yes, you can do that with a for statement. This expression iterates to create <exterior> element for every element in the list.

{
    for $p in fme:get-list-attribute("interior_xy_l{}.part")
    return
    <gml:exterior>
        <gml:LinearRing>
            <gml:posList>{$p}</gml:posList>
        </gml:LinearRing>
    </gml:exterior>
}

 

If you need to limit the maximum number of iteration to 6, for example, this expression is available. Note: $i will store a number starting with 1.

{
    for $p at $i in fme:get-list-attribute("interior_xy_l{}.part")
    where $i < 7
    return
    <gml:exterior>
        <gml:LinearRing>
            <gml:posList>{$p}</gml:posList>
        </gml:LinearRing>
    </gml:exterior>
}

 


Reply