When using the Reprojector transformer FME logs the transformation in the log file. Below is an example from a log file: Reprojector: Using transformation `NAD27_to_NAD83_Canada_FME,Forward(Grid File Interpolation,EPSG:1313)' when reprojecting from LL-27 to EPSG:4326 Is there any way to ``capture`` the transformation used in an attribute or anything that can be written out? Thanks, CA
Page 1 / 1
Hi,
This may not be an ideal solution, but it's possible to collect only the messages which match with a specific condition using Python.
A PythonCaller with this script, for example, provides a functionality to collect every message which starts with "Reprojector:".
----- import fmeobjects g_messageList = s] # Callback function to collect every message # which starts with "Reprojector:". def collectMessages(severity, message): if message.startswith('Reprojector:'): g_messageList.append(message) class LogCallbackSetter(object): def __init__(self): # Set the callback function to log file object. logger = fmeobjects.FMELogFile() logger.setCallBack(collectMessages) def input(self, feature): self.pyoutput(feature) def close(self): pass
-----
Insert the PythonCaller before the Reprojector, then you can refer to the messages stored in "g_messageList" using Shutdown Python Script or another PythonCaller.
Example 1: This shutdown script writes the messages into a text file.
----- f = open('C:/tmp/messages.log', 'w') for msg in g_messageList: f.write('%s\\n' % msg) f.close()
-----
Example 2: A PythonCaller with this script adds the messages to each feature as a list attribute. In this case, a FeatureHolder should be inserted between the Reprojector and this PythonCaller in order to complete collecting messages.
-----
import fmeobjects class MessageExtractor(object): def __init__(self): pass def input(self, feature): feature.setAttribute('messages{}', g_messageList) self.pyoutput(feature) def close(self): pass
-----
Takashi
Correction: There is no need to use a FeatureMerger in Example 2.
Example 3: This script can be used instead of Example 2.
-----
import fmeobjects def setMessages(feature): feature.setAttribute('messages{}', g_messageList) -----
Takashi
... Correction to the Correction (:-( Replace "FeatureMerger" with "FeatureHolder".
You could also just read the log file and extract the info, that is if you dont need it for the same translation.
Thanks Takashi.
That looks like it will do exactly what I need.
CA