Skip to main content

Hello,

the objective of the workbench is to cut objects in order of priority according to the values of the attributes. The priority has to be fixed automatically.

I first generate a table that looks like this:

Capture1The objective is to autmacitally generate the order of clipping in a table :

 Capture2I don't know how to solve this problem, can anybody help me?Thank you

Ronan

@ronan​ This can be achieved with a few transformers. In the solution I've assumed that the "Order" is the number of elements in "ID clipped" largest to smallest. These instructions will take you from your first table to the second exactly.

 

Firstly use an Aggregator (Group by "ID") to reduce the number of features to one per "ID". In the Aggregator's parameters, concatenate "ID referred" using ", " (<comma><space>) as the separator, and create a list of "ID referred"

Then count the elements of your list using a ListElementCounter

Then sort the features on _element_count (numeric descending) in a Sorter

Finally drop any temporary attributes/lists not required and create "Order" as @Count() (indexed at 1)

Have attached workspace built in FME 2020.2.2 to demonstrate this.

 


thantks a lot.

The problem is that there is not always a link between the number of element of ID and the priority. This method is working on the example I provided, but it won't work on another exemple.

I the method should take into account ID 1 has priority over ID 2 AND ID 1 has priority over ID 2...


thantks a lot.

The problem is that there is not always a link between the number of element of ID and the priority. This method is working on the example I provided, but it won't work on another exemple.

I the method should take into account ID 1 has priority over ID 2 AND ID 1 has priority over ID 2...

Hi @ronan​,

I think I see what you are getting at. If an ID has priority over another it comes first, so an ID must come before all values in it's list. So ID = 1 must come before IDs 2, 3, and 4. ID = 2 only comes before 4 and ID 3 must come before Ids 2 and 4. Therefore the order must be 1, 3, 2, 4.

Let me know if that's right.

It's the end of the day here, so I'll get back to you later but I feel a solution is possible


Hi @ronan​,

I think I see what you are getting at. If an ID has priority over another it comes first, so an ID must come before all values in it's list. So ID = 1 must come before IDs 2, 3, and 4. ID = 2 only comes before 4 and ID 3 must come before Ids 2 and 4. Therefore the order must be 1, 3, 2, 4.

Let me know if that's right.

It's the end of the day here, so I'll get back to you later but I feel a solution is possible

Yes exactly


OK - found a bit of time before finishing.

Similar to before , at least to start with.

  1. Having aggregated the features, grouped by ID, as earlier we then sort the list (just so ensure elements are in lowest to highest order )
  2. Next concatentate the list with no seperator (e.g. [a, b, c, d] -> abcd) as IDs
  3. At the same time calculate the maximum length of all the lists.
  4. Unconditionally join the max length back onto all features
  5. Then create a sort attribute from the IDs zero-padded to the right to the max list length
  6. Sort the features by the sort attribute (numeric ascending)
  7. Finally tidy up the lists and temporary attributes and create Order as before.

I hope this is more of a solution than before!


Eureka!

Thank a lot, the solution that you suggest is working well. What's more, I'm learning new FME notions using your solution.

I'm adapting now the solution to my project. I think it gonna work. In case not, I let you know.

Have a good day


Reply