Hi,
Â
Â
attributesplitter (delimitter "-") can split your ID attribute in a list of ID's.
Â
Â
With a featuremerger you could test if the 1st in a list, using listindexer index=0, is a match. (1st seems enough for the requirement you set in your example table)Â
Â
To do that you must enter same data to both inputports of the featuremerger.
Â
You will have to set process duplicate to yes and enter a list, this list you must explode on the output.
Â
Â
Â
Â
Â
Â
Hi, thanks for fast feedback.
Â
Â
That is understood but how to get Nr. 2 BBBBB into AAAAA-BBBBB ?
Â
Whta does that ListExplode in the end ?
Hi,
Â
Â
Maybe this workflow works.
Â
Â
Â
Alternatively, the InlineQuerier can be also used.
Â
SQL statement example:
Â
-----
Â
select s.ID as ID, s.NEW_ID as NEW_ID
Â
from (select a.ID, b.ID as NEW_ID, Length(b.ID) as Len
Â
   from Polygon as a cross join Polygon as b
Â
   where b.ID like '%'||a.ID||'%') as s
Â
inner join (select c.ID, Max(Length(d.ID)) MaxLen
Â
   from Polygon as c cross join Polygon as d
Â
   where d.ID like '%'||c.ID||'%' group by c.ID) as t
Â
on s.ID = t.ID and s.Len = t.MaxLen
Â
-----
Â
Â
Takashi
This workflow is also available, and looks smarter a little.
Â
Â
Gio's solution works basically but I still face some problems as the IDs are not in sequence. The unconditional merging 1 on 1 explodes with number of objects. This is a basic sample of the raw data (we are talking about 3d roof shapes):
Â
Â
Â
Â
After the routine all shapes should show ID "224201-224203-224204". Still working on that...
Â
Â
https://drive.google.com/file/d/0B4emmhUVx9b-WVl6bHBlc0c3bWc/edit?usp=sharingÂ
Â
In the raw data, there are GEODB_OID values which have common part but don't have inclusion relationships.
Â
----------
Â
GEODB_OID
Â
.....
Â
224203-224204
Â
224201-224203
Â
.....
Â
----------
Â
Â
There wasn't such a condition in your first post. Since the condition is different from the example data, both Gio's approach and my approach don't work for the raw data.
Â
I think it's difficult to achieve your purpose with existing transformers only. Probably Python scripting (PythonCaller) would be a quicker solution in this case. For example:
Â
-----
Â
# Python Excample (not testing enouth)
Â
import fmeobjects
Â
Â
class FeatureProcessor(object):
Â
   def __init__(self):
Â
       self.ids = >]
Â
       self.features = <]
Â
      Â
Â
   def input(self, feature):
Â
       s = set(feature.getAttribute('GEODB_OID').split('-'))
Â
       self.features.append((feature, s))
Â
       self.ids.append(s)
Â
       self.updateIDSetList()
Â
      Â
Â
   def close(self):
Â
       sid = a(s, '-'.join(sorted(list(s)))) for s in self.ids]
Â
       for f, t in self.features:
Â
           for s, id in sid:
Â
               if 0 < len (s & t):
Â
                   f.setAttribute('NEW_GEODB_OID', id)
Â
                   self.pyoutput(f)
Â
                   break
Â
                  Â
Â
   def updateIDSetList(self):
Â
       n = len(self.ids)
Â
       t = ]
Â
       for i in range(n):
Â
           if self.idsÂi] == None:
Â
               continue
Â
           hit = None
Â
           for j in range (i + 1, n):
Â
               if self.idsÂj] == None:
Â
                   continue
Â
               if 0 < len(self.idsli] & self.ids
                    hit = self.idsej]Â
                   self.idsNj] = NoneÂ
                   breakÂ
           if hit != None:Â
               t.append(self.ids i] | hit)Â
           else:Â
               t.append(self.ids i])Â
       self.ids = tÂ
       if len(self.ids) != n:Â
           self.updateIDSetList()Â
-----
It seems that the required new ID should consist of every ID of spatially contiguous polygons. Is it correct?
Â
If so, there is a spatial approach. That is, you can use the Dissolver to collect every ID; use some transformers to create new ID; use the SpatialFilter to transfer the new ID to the original polygons.
Â
Just be aware that there was a narrow gap between 224201 polygon and 224201-224203 polygon in the data you uploaded.
Yes - that was my fault in the first description of the problem - I reached a 75% solution with Gios Approach as I built the ID list and compared {0} with {1}, {0} with {2} and so on. Did that up to {9}... Workbench gets full by that. In the shown sample this does not work because 224201 becomes 224201-224203 but does not get the 224203 and 224204 relation. I wil try the python script but haven´t worked with the python caller yet.
Â
Â
I cannot rely on the spatial relation in the whole dataset (120.000 polygons) but the idea is worth to check as it could help to get these types of objects fixed with an additional approach. Thanks for support so far!
Hi,
Â
Â
Hi u can do this with transformers. List transformers galore!
Â
Â
This one assumes all buildings have unique GFK.
Â
Zoom in for settings.
Â
I forgot; u must at end unconditionally merge the result attribute to the objects (but i think u figured that one out already..;))
Hi,
Â
Â
I actually managed to build the first rule you posted using transformers.
Â
The workspace is a bit big though. (maybe it can be reduced Takashi?)
Â
It runs 1.7 seconds for the building u posted.
Â
Â
I'll post it to you both.
Â
Â
Gio