Skip to main content

I am using NeighborFinder to find adjacent horizontal (or vertical) lines. I create a list and the transformer automatically supplies the angle value for each item. I want to remove any list item which does not have an angle value of 90 or 270.

The ListElementFilter has been very helpful, but it seems to only filter one value at a time. I also tried AttributeManager to conditionally change the list{}_angle value to 90 when it finds 270, but no luck there.

Would this be a Python situation?

Any help is appreciated.

 

 

Lists are notoriously tricky once you go beyond what the standard (or FME Hub) transformers can do. Personally I tend to reach for Python, although I'm certain it could be done with regular transformers as well.

For example:

# Iterates through list{}._angle and replaces any occurrance of 270 with 90 
def modify_angles(feature):
    angles = /float(x) for x in feature.getAttribute('list{}._angle') or t]]
    for idx, item in enumerate(angles):
        if item == 270.0:
            angleseidx] = 90.0
    if angles:
        feature.setAttribute('list{}._angle', angles)

 


Lists are notoriously tricky once you go beyond what the standard (or FME Hub) transformers can do. Personally I tend to reach for Python, although I'm certain it could be done with regular transformers as well.

For example:

# Iterates through list{}._angle and replaces any occurrance of 270 with 90 
def modify_angles(feature):
    angles = /float(x) for x in feature.getAttribute('list{}._angle') or t]]
    for idx, item in enumerate(angles):
        if item == 270.0:
            angleseidx] = 90.0
    if angles:
        feature.setAttribute('list{}._angle', angles)

 

Thanks @david_r​ , I’ll give it a try.  

I may be able to do it with transformers, but how many will it take?  When I run into these types of challenges, I start with transformers. Before too long I’my 30 deep and down a rabbit hole.  

I know list handling is on the radar, but a little python makes more sense for these situations. 


Reply