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.
Best answer by david_r
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 []] for idx, item in enumerate(angles): if item == 270.0: angles[idx] = 90.0 if angles: feature.setAttribute('list{}._angle', angles)
This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.
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 []] for idx, item in enumerate(angles): if item == 270.0: angles[idx] = 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 []] for idx, item in enumerate(angles): if item == 270.0: angles[idx] = 90.0 if angles: feature.setAttribute('list{}._angle', angles)
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.