Tclcaller.
运行工具命令语言(TCL)命令,并将其返回值分配给属性。
The Tcl command can operate on the feature’s geometry and/or attributes, using any of the built-in Tcl functions provided by the Tcl language, as well as any of the FME-provided Tcl facilities.
See the Tcl language reference manual (www.tcl.tk.)和FME TCL变量和功能下面的部分有关功能的详细信息。
常见的TCL示例用法包括:
- 来自属性的修剪空格:
fme_setattribute tranmedAttribute [string trim [fme_getattribute workinalattribute]]
- 将所有非数字字符替换为属性中的空格:
fme_setattribute anattribute [regsub -all {[^ 0-9]} [fme_getattribute anattribute] {}]
请注意,在这种情况下,返回值是实际所做的替换的数量。
- Match a regular expression against an attribute:
regexp {^[A-Za-z]$} [FME_GetAttribute anAttribute]
This regular expression tests if the entire value of the attribute consists only of alphabetic characters.
Note that when matching regular expressions, the return value will be 1 if the expression matched, and 0 otherwise.
- Log a custom message to the log window:
FME_LogMessage fme_inform {This is my message}
The recommended way to manipulate feature attributes is through the functions that are provided for this purpose:
fme_getAttribute Attrname.
fme_settribute attrname nemval.
fme_copyattribute destattrname srcattrname.
FME_RenameAttribute destAttrName srcAttrName
FME_UnsetAttributes attrName1 [attrName2 attrName3 ...]
参数
输出功能参数
将为每个特征评估的TCL表达式。表达式的值将存储在Destination Attribute。
笔记:您可以通过全局访问已发布的参数$FME_MacroValues大批。如果FME返回错误Can't read "FME_MacroValues(text_param)": no such variable, 代替$FME_MacroValues和$ :: fme_macraverues.。
还可以提供附加的代码源代码编辑。此代码将在翻译开头编译一次,因此提供比提供广泛代码更有效的选项TCL表达范围。
可以可选地提供TCL源文件。在执行TCL命令之前将读取该文件。这可以用于引用保存在公共外部文件中的TCL函数。
The attribute which will store the result of theTCL表达parameter after it is evaluated. If the Tcl Expression does not return a value, the destination attribute can be left blank.
复制控件
It is possible to create multiple copies of a feature using the复制TCL表达的数量范围。This expression is evaluated in the context of the input feature. It returns a number to indicate how many instances of the feature are to be processed using the transformer'sTCL表达。
如果指定,则复制号码属性将保留每个输出功能的副本编号。例如,如果进行了输入特征的3个副本,则输出副本将分别为0,1和2,分配给它们的副本编号属性。TCL表达式可以检查此属性以确定它正在处理的输出功能编号。
Advanced
Exposes any attributes that are created by theTCL表达正在执行,以便其他变换器可以使用它们。
隐藏可能删除的任何属性TCL表达被执行。Other transformers will not be able to use these attributes.
隐藏可能删除的任何清单TCL表达被执行。其他变形金刚将无法使用这些列表。
请注意,如果选择隐藏列表,则选择将包含任何列表属性或嵌套列表。例如,如果您选择隐藏一个名为的列表列表{}然后列表{}。attr或者list {}。sublist {}也将被隐藏。
FME TCL变量和功能
四个TCL全局变量提供FME功能和TCL脚本之间的网关:FME_FEATURETYPE,FME_COORDSYS,FME_ATTRENCODING和FME_ATTRNAMENMEncoding变量。为了在TCL程序中使用这些过程,他们必须被宣布为全局;否则,变量将被认为是本地的,不会影响或与运行功能的FME功能相互作用。要在函数中使用它们,请使用像:
proc dosomething {
全球fme_featuretype.
global FME_CoordSys
#剩下的功能进入...
}
This global variable defines the name of the character encoding in which Tcl assumes a feature's attributes are specified when working with FME_GetAttribute and FME_SetAttribute functions. As Tcl works internally with UTF-8, this means that it will convert attribute values from the given encoding to UTF-8 when getting the value of attribute with FME_GetAttribute function, and will convert values from UTF-8 to the given encoding when setting the attribute value using FME_SetAttribute function.
当已知字符编码时,此变量的值不会影响属性的设置或检索属性,或者在检索到的属性上或按照fme_getattribute或fme_setattribute的参数指示。
默认属性编码与FME正在执行的系统的默认字符编码相同,并且可能被TCL内置的“编码系统”命令覆盖。通过执行命令“编码名称”,可以获得支持编码的完整列表。
可以设置,读取或未设置变量:
set FME_AttrEncoding iso8859-2
把$ fme_attrencoding.
unset FME_AttrEncoding
如果fme_attrencoding未知,或被设置为空字符串,则它将恢复为默认系统编码。
此函数用于确定特征上是否存在属性。
fme_attributeexists的语法是:
FME_AttributeExists
如果特征上存在该属性,则返回值1;否则,返回0。
此函数用于确定属性的值是否为null。
fme_isattributenull的语法是:
fme_isattributenull
如果属性具有空值,则返回值1;否则,返回0。
此函数用于检索所有功能属性的名称,并将其作为TCL列表返回。
fme_attributenames的语法是:
fme_attributenames.
此全局变量定义了在使用FME_GetAttribute和FME_SetAttribute函数时指定了TCL假设要素的属性的字符编码的名称。由于TCL内部使用UTF-8工作,这意味着它将将属性名称转换为UTF-8到给定的编码系统,并在参考实际功能的属性时使用转换的名称。
默认属性编码与FME正在执行的系统的默认字符编码相同,并且可能被TCL内置的“编码系统”命令覆盖。通过执行命令“编码名称”,可以获得支持编码的完整列表。
可以设置,读取或未设置变量:
设置fme_attrnameEncoding ISO8859-2.
将$ fme_attrnameEncoding.
unset FME_AttrNameEncoding
如果fme_attrnameEncoding未命令,或被设置为空字符串,则它将恢复为默认系统编码。
此全局变量设置为镜像要素的坐标系。与FME_FeatureType变量一样,可以设置,读取和未设置:
设置fme_coordsys utm10-83.
把$ fme_coordsys
取消设置FME_COORDSYS
在TCLCaller调用的任何TCL过程中,FME_CoordInate函数可用于读取和写入该功能的坐标。它提供了几个选项,如下所示:
dimension (2|3)
设置特征的维度 - 2或3。
numcoords.
返回该功能中的坐标数。
resetcoords.
从功能中删除所有当前坐标。
注意:调用ResetCoords对FME_GEOMERY或FME_TYPE属性没有影响。这些必须由脚本明确重置或重新调整,因此该功能不会处于不一致状态。
getCoord (x|y|z)
在指定的
addCoord
将指定为特征几何末尾的坐标添加。
地质艺术
返回要素的几何类型 - 它将是允许的值之一FME几何模型属性:
FME_POINT.
fme_line.
fme_polygon.
fme_donut.
fme_aggregate.
fme_undefined.
geomtype
将功能的几何类型设置为传递的值。没有完成理智检查。重要的是,因为设置不正确的几何型可以稍后阻碍FME来完成。
此函数用于复制功能属性。使用此功能保留属性的原始内部数据存储类型。当使用高精度浮点值时,这可能是显着的。
fme_copyattribute的语法是:
FME_CopyAttribute
如果该功能没有包含名称odgName的属性,则该函数没有任何内容。它不会创建一个新的空白值属性。
此函数用于解码已被编码的字符串,如部分中所述将字符串替换为映射文件。函数的结果是输入参数的副本,具有转换回的替换字符串序列。
fme_decodeText的语法是:
fme_decodeText
此函数类似于fme_decodeText,除了它的参数可以被解释为对属性值的引用而不是作为要解码的字符串。
The syntax for FME_DecodeTextOrAttr is:
FME_DecodeTextOrAttr [&]
If the argument begins with an ampersand character ("&"), the function returns the value in the attribute named by decoding the remainder of the argument. Otherwise, the function returns the decoded equivalent of
此函数用于生成字符串,该字符串已被编码如本节中所述将字符串替换为映射文件。该函数的结果是输入参数的副本,具有转换为替换字符串序列的特殊字符,该序列通过FME的文件解析器清洁,并且可以在任何ANSI字符集中表示。
The syntax for FME_EncodeText is:
fme_encodeText
此函数用于从TCL过程中调用任何FME函数。这允许在同一功能上迭代调用标准FME函数。
The syntax for FME_Execute is:
fme_execute
任何剩下的参数都传递给函数。例如,@Generalize函数如下调用:
FME_Execute Generalize Douglas 10
这将完成与映射文件中其他地方的@Generalize(道格拉斯,10)在映射文件中的其他地方调用相同的效果。
如果调用的函数导致要删除的功能,则将中止转换。如果特征的总长度小于传入的公差值,则@Generalize函数可以执行此操作。
此全局变量设置为镜像要素的特征类型。与其他变量一样,可以设置,读取和未设置:
设置fme_featuretype“跑车”
把$ fme_featureType.
此函数可用于从TCL过程中获取特征上的属性值。
fme_getattribute的语法是:
fme_getattribute
如果该功能上不存在该属性,则将空字符串返回为值。
FME_LogMessage函数用于将消息写入FME日志文件。它可以通过以下两种方式之一调用:
FME_LogMessage
或者
FME_LogMessage
When the first form is used, the message number must be present in a file in the messages subfolder under the FME installation folder. The remaining parameters are used to fill in any %0, %1, ... %n parameter holders in the message. For example, if the message was:
3011,为模式%1打开文件%0
然后可以像这样调用fme_logmessage:
fme_logmessage fme_inform 3011 /tmp/cacher.txt读取
在第二种形式中,消息直接输出to the log file.
此函数用于重命名功能属性。使用此功能保留属性的原始内部数据存储类型。当使用高精度浮点值时,这可能是显着的。
fme_renomeattribute的语法是:
FME_RenameAttribute
如果该功能没有包含名称odgName的属性,则该函数没有任何内容。它不会创建一个新的空白值属性。
This function is used to set the value of an attribute on a feature.
fme_setattribute的语法是:
fme_setattribute [-notranscode]
如果指定了-NotRanscode选项,则TCL变量的字节将逐字复制到生成的属性,代替从TCL的内部UTF-8编码到目标字符编码的字符编码转换。当已知TCL变量包含特定字符编码中的字节数组而不是UTF-8字符的通常序列时,这是有用的。
生成的属性通常具有附加的字符编码信息。如果未指定
此函数用于将要素上的属性的值设置为null。如果属性不存在,则将创建它。
fme_setattributenull的语法是:
fme_setattributenull
If the attribute does not exist, it will be created and its type will be string.
此函数在FME临时文件夹中生成临时文件名。
FileName保证是一个唯一的新文件。
笔记:FME will create an empty file with the given name; you must delete it when you are done.
fme_tempfilename的语法是:
FME_TempFilename [
如果未提供前缀和后缀,则文件名将在FME临时文件夹中作为任意唯一命名的文件返回。(有关此文件夹所在的信息,请参阅临时文件夹确定。)
If a prefix is provided, then that is used as the beginning portion of the filename within the temporary folder, and the suffix is used as the ending portion. Typically the suffix is used to append an extension, and in this case, it would have to additionally include a period "."
例如,此调用:
FME_TempFilename raster .png
would return something like:
C:/文档和设置/用户名/本地设置/ temp / rastera05921.png
此函数用于从功能中删除一个或多个属性。
fme_unsetattributes的语法是:
fme_unsetattributes 如果该功能不包含列出的任何属性,则不会生成任何错误。fme_unsetattributes只需忽略未在该功能上指定属性的任何参数。
Usage Notes
% 特点
由于FME解析器限制,TCL表达式不能包含百分比(%)字符。如果需要%字符,则应将表达式编码为TCL过程,并将外部文件放入“源”中。请注意,您可以使用A避免%字符问题stringformatter.transformer, which provides a convenient way to access the Tcl 'format' command.
编辑变压器参数
使用一组菜单选项,可以通过引用工作区中的其他元素来分配变压器参数。一些变压器也可提供更高级的功能,例如高级编辑器和算术编辑器。要访问这些选项的菜单,请单击除适用的参数旁边。有关更多信息,请参阅Transformer Parameter Menu Options。
变压器类别
FME社亚搏国际在线官网区
The FME Community is the place for demos, how-tos, articles, FAQs, and more. Get answers to your questions, learn from other users, and suggest, vote, and comment on new features.
搜索有关此变压器的样本和信息FME社亚搏国际在线官网区。