Skip to main content
Question

Change detector on attributes only

  • February 12, 2018
  • 7 replies
  • 94 views

Forum|alt.badge.img

Hi everyone,

I'm trying to compare 2 PostGIS spatial table (points representing airports) to detect changes. When there's a change in geometry, the change detector works great. But when there's a change only on an attribute in a raw, I can't find it!

In fact I can find it if I select the right field name in the parameters (because I know wich field has been changed in my test). But it doesn't work when I select all attributes, which is the real situation. I need to detect changes on tables with unknown atrributes updates. Match geometry is always set to "none" in this case beacuse I want to check changes only on attributes.

I've also tried to combine CRCcalculator, feature merger, update detector, tester, etc. but even for a very simple test - only one non-geometric attribute in a raw changed between the 2 tables - I can't find a way to make this change appear in a transformer output...

Any help would be very appreciated

Thanks!

7 replies

Forum|alt.badge.img

By attribute I mean a value in a field, not the field name itself... Sorry for this translation issue


david_r
Evangelist
  • February 13, 2018

Could it be that the transformer has an issue with binary attribute values? Try inserting a PythonCaller with the following code just before the ChangeDetector:

from fmeobjects import *
 
def ConvertBinaryToHex(feature):
    for attr in feature.getAllAttributeNames():
        attr_value = feature.getAttribute(attr)
        if isinstance(attr_value, bytearray):
            # Convert bytearray to string with hexadecimal values
            hex_value = ''.join('{:02x}'.format(x) for x in attr_value)
            feature.setAttribute(attr, hex_value)

This will convert all the binary attribute values to hexadecimal strings. 


Forum|alt.badge.img

Hi David, thanks a lot for your help. The script seems to work but the value of my new "hex_value" field is <missing>... I think I set properly the parameters of the python caller since I can add and see other extra field with a simple string value (as a test since I'm not a python specialist).

I have entirely empty and <null> fields in my table. Could it be an issue ?


david_r
Evangelist
  • February 13, 2018
jeremielemarcha wrote:

Hi David, thanks a lot for your help. The script seems to work but the value of my new "hex_value" field is <missing>... I think I set properly the parameters of the python caller since I can add and see other extra field with a simple string value (as a test since I'm not a python specialist).

I have entirely empty and <null> fields in my table. Could it be an issue ?

I'm not sure I understand. Could you post some screenshots?

Forum|alt.badge.img
david_r wrote:
I'm not sure I understand. Could you post some screenshots?
Yes sure. Here you can see the hex_value field stays <missing>

 


Forum|alt.badge.img
jeremielemarcha wrote:
Yes sure. Here you can see the hex_value field stays <missing>

 

I tried the change detector alone in a blank workspace and now it detects the only value that has change between my two PostGIS tables. I don't know why it works now...

 

 

If you have any information about the <missing> hex_value field, I'm still interested to understand

 

 

Anyway, thanks a lot for your help !

 

 


david_r
Evangelist
  • February 13, 2018
jeremielemarcha wrote:
Yes sure. Here you can see the hex_value field stays <missing>

 

Unless there's an attribute called "hex_value" on your feature before the PythonCaller, there won't be one after the PythonCaller either. The PythconCaller "re-codes" all the binary values in place, i.e. on the same attribute name.

Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings