Skip to main content
Question

coordinate system transformation

  • August 8, 2013
  • 5 replies
  • 65 views

ca
Contributor
Forum|alt.badge.img+3
  • Contributor
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
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.

5 replies

takashi
Celebrity
  • August 9, 2013
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 = []   # 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

takashi
Celebrity
  • August 9, 2013
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

takashi
Celebrity
  • August 9, 2013
... Correction to the Correction (:-( Replace "FeatureMerger" with "FeatureHolder".

fmelizard
Safer
Forum|alt.badge.img+22
  • Safer
  • August 9, 2013
You could also just read the log file and extract the info, that is if you dont need it for the same translation.

ca
Contributor
Forum|alt.badge.img+3
  • Author
  • Contributor
  • August 9, 2013
Thanks Takashi.

 

 

That looks like it will do exactly what I need.

 

 

CA