TclCaller
Runs a Tool Command Language (Tcl) command and assigns its return value to an attribute.
TCL命令可以使用TCL语言提供的任何内置TCL功能,以及任何FME提供的TCL设施。
请参阅TCL语言参考手册(www.tcl.tk.) and theFME Tcl Variables and Functionssection below for details of the capabilities.
Common Tcl examples usage include:
- 来自属性的修剪空格:
fme_setattribute tranmedAttribute [string trim [fme_getattribute workinalattribute]]
- Replace all non-numeric characters with spaces in an attribute:
FME_SetAttribute anAttribute [regsub -all {[^0-9]} [FME_GetAttribute anAttribute] {}]
注意,在这种情况下,返回值是实际进行的替换数。
- 匹配对属性的正则表达式:
Regexp {^ [a-za-z] $} [fme_getattribute anattribute]
这个正则表达式测试如果属性的整个值仅由字母字符组成。
请注意,匹配正则表达式时,如果表达式匹配,则返回值将为1,否则为0。
- 记录日志窗口的自定义消息:
fme_logmessage fme_inform {这是我的消息}
制衡功能属性的推荐方法是通过为此目的提供的功能:
fme_getAttribute Attrname.
FME_SetAttribute attrName newVal
FME_CopyAttribute destAttrName srcAttrName
fme_renameattribute destattrname srcattrname.
fme_unsetattributesattrname1 [attrname2attrname3 ...]
Parameters
输出功能参数
将为每个特征评估的TCL表达式。表达式的值将存储在目的地属性。
Note:您可以通过全局访问已发布的参数$ fme_macroverues.数组。如果FME返回错误无法读取“FME_MACROVALUES(Text_Param)”:没有这样的变量,替换$ fme_macroverues.和$::FME\u宏值。
也可以在中提供附加代码源Code编辑。此代码将在翻译开头编译一次,因此提供比提供广泛代码更有效的选项Tcl Expression范围。
A Tcl source file can optionally be provided. The file will be read before the Tcl command is executed. This can be used to reference Tcl functions kept in a common external file.
将存储结果的属性Tcl Expression评估后参数。如果TCL表达式没有返回值,则目的地属性可以留空。
Copy Control
可以使用使用该功能的多个副本Number of Copies Tcl Expression范围。此表达式在输入功能的上下文中进行评估。它返回一个数字,以指示要使用变换器处理要处理的功能的实例。Tcl Expression。
If specified, theCopy Number Attribute将保留每个输出功能的副本编号。例如,如果进行了输入特征的3个副本,则输出副本将分别为0,1和2,分配给它们的副本编号属性。TCL表达式可以检查此属性以确定它正在处理的输出功能编号。
先进的
公开由此创建的任何属性Tcl Expression正在执行,以便其他变换器可以使用它们。
隐藏可能删除的任何属性Tcl Expression被执行。其他变形金刚将无法使用这些属性。
隐藏可能删除的任何清单Tcl Expression被执行。Other transformers will not be able to use these lists.
请注意,如果选择隐藏列表,则选择将包含任何列表属性或嵌套列表。例如,如果您选择隐藏一个名为的列表列表{}then列表{}。attror列表{}。sublist{}也将被隐藏。
FME Tcl Variables and Functions
Four Tcl global variables provide a gateway between an FME feature and the Tcl script: FME_FeatureType, FME_CoordSys, FME_AttrEncoding, and FME_AttrNameEncoding variables. In order to use these in a Tcl procedure, they must be declared as global; otherwise, the variables will be considered to be local and will not affect or interact with the FME feature upon which the function is run. To use them in a function, use a pattern like:
proc doSomething {
global FME_FeatureType
全球fme_coordsys
#剩下的功能进入...
}
此全局变量定义了在使用FME_GetAttribute和FME_SetAttribute函数时指定了TCL所指定的字符编码的名称。随着TCL内部使用UTF-8工作,这意味着在获取FME_GetAttribute函数的属性值时,它将将来自给定编码的属性值转换为UTF-8,并且在设置时将从UTF-8转换为给定编码的值使用FME_SetAttribute函数的属性值。
The value of this variable does not impact the setting or retrieval of attributes when character encoding is known, either on the retrieved attribute or as directed by the arguments to FME_GetAttribute or FME_SetAttribute.
默认属性编码与执行FME的系统的默认字符编码相同,可能被Tcl的内置“encoding system”命令覆盖。通过执行“编码名称”命令可以获得支持的编码的完整列表。
The variable may be set, read, or unset:
设置fme_attrencoding iso8859-2.
puts $FME_AttrEncoding
解开fme_attrencoding.
If FME_AttrEncoding is unset, or is set to be an empty string, it reverts to the default system encoding.
此函数用于确定要素上是否存在属性。
The syntax for FME_AttributeExists is:
fme_attributeexists
If the attribute was present on the feature, the value 1 is returned; otherwise, 0 is returned.
此函数用于确定属性的值是否为null。
FME\u IsAttributeNull的语法是:
FME\u isattributeFull
If the attribute has a null value, the value 1 is returned; otherwise, 0 is returned.
此函数用于检索所有功能属性的名称,并将其作为TCL列表返回。
The syntax for FME_AttributeNames is:
FME_AttributeNames
This global variable defines the name of the character encoding in which Tcl assumes a feature's attributes' names 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 names from UTF-8 to the given encoding system, and use the converted name when referring to the actual feature's attributes.
默认属性编码与执行FME的系统的默认字符编码相同,可能被Tcl的内置“encoding system”命令覆盖。通过执行“编码名称”命令可以获得支持的编码的完整列表。
The variable may be set, read, or unset:
set FME_AttrNameEncoding iso8859-2
puts $FME_AttrNameEncoding
取消设置FME_ATTRNameEncEncoding.
If FME_AttrNameEncoding is unset, or is set to be an empty string, it reverts to the default system encoding.
此全局变量设置为镜像要素的坐标系。与FME_FeatureType变量一样,可以设置,读取和未设置:
set FME_CoordSys UTM10-83
放入$FME\u CoordSys
取消设置FME_COORDSYS
在TclCaller调用的任何Tcl过程中,FME\u Coordinates函数都可以用来读取和写入特征的坐标。它提供了几个选项,如下所示:
维度(2 | 3)
设置特征的维度 - 2或3。
numcoords.
Returns the number of coordinates in the feature.
resetCoords
从功能中删除所有当前坐标。
Note: Calling resetCoords has no effect on the fme_geometry or fme_type attributes. These must be reset or readjusted explicitly by the script so the feature is not left in an inconsistent state.
getcoord(x | y | z)<索引>
在指定的
addcoord
将指定为特征几何末尾的坐标添加。
地质艺术
返回要素的几何类型 - 它将是允许的值之一FME几何模型attributes:
fme\ U点
fme_line
fme_polygon
fme_donut.
fme_aggregate
fme_undefined
geomtype
将功能的几何类型设置为传递的值。没有完成理智检查。重要的是,因为设置不正确的几何型可以稍后阻碍FME来完成。
This function is used to copy a feature attribute. The attribute's original internal data storage type is preserved by using this function. This can be significant when working with high precision floating point values.
FME\u CopyAttribute的语法为:
fme_copyattribute
If the feature did not contain an attribute with the name oldName, then the function does nothing. It will not create a new blank valued attribute.
This function is used to decode character strings which have been encoded as described in the sectionSubstituting Strings in Mapping Files. 函数的结果是输入参数的副本,替换的字符串序列转换回它们所表示的字符。
fme_decodeText的语法是:
fme_decodeText
此函数类似于fme_decodeText,除了它的参数可以被解释为对属性值的引用而不是作为要解码的字符串。
fme_decodetextorattr的语法是:
fme_decodetextorattr [&]
如果参数以Ampersand字符(“&”)开头,则该函数返回通过解码参数的其余部分命名的属性中的值。否则,该函数返回到
This function is used to generate character strings which have are encoded as described in the sectionSubstituting Strings in Mapping Files。该函数的结果是输入参数的副本,具有转换为替换字符串序列的特殊字符,该序列通过FME的文件解析器清洁,并且可以在任何ANSI字符集中表示。
fme_encodeText的语法是:
FME_EncodeText
This function is used to call any FME function from within a Tcl procedure. This allows standard FME functions to be called iteratively on the same feature.
fme_execute的语法是:
fme_execute
任何剩下的参数都传递给函数。例如,@Generalize函数如下调用:
fme_execute概括了道格拉斯10
and this would accomplish the same effect as if @Generalize(Douglas,10) were invoked elsewhere in the mapping file.
如果调用的函数导致功能被删除,则转换将中止。如果特征的总长度小于传入的公差值,@Generalize函数可以这样做。
此全局变量设置为镜像特征的特征类型。与其他变量一样,可以设置、读取和取消设置:
设置fme_featuretype“跑车”
把$ fme_featureType.
此函数可用于从TCL过程中获取特征上的属性值。
fme_getattribute的语法是:
FME_GetAttribute
如果该功能上不存在该属性,则将空字符串返回为值。
FME_LogMessage函数用于将消息写入FME日志文件。它可以通过以下两种方式之一调用:
fme_logmessage
or
fme_logmessage
使用第一个表单时,消息编号必须存在于FME安装文件夹下消息子文件夹中的文件中。其余参数用于填写消息中的任何%0,%1,...%N参数座。例如,如果消息是:
3011,为模式%1打开文件%0
then FME_LogMessage could be called like this:
fme_logmessage fme_inform 3011 /tmp/cacher.txt读取
在第二种形式中,该消息将直接输出到日志文件。
此函数用于重命名功能属性。使用此功能保留属性的原始内部数据存储类型。当使用高精度浮点值时,这可能是显着的。
The syntax for FME_RenameAttribute is:
fme_renameattribute
If the feature did not contain an attribute with the name oldName, then the function does nothing. It will not create a new blank valued attribute.
此函数用于在功能上设置属性的值。
The syntax for FME_SetAttribute is:
FME_SetAttribute [-notranscode]
If the -notranscode option is specified, the bytes of the Tcl variable are copied verbatim to the resulting attribute, in place of a character encoding conversion from Tcl's internal UTF-8 encoding to the target character encoding. This is useful when the Tcl variable is known to contain an array of bytes in a particular character encoding instead of the usual sequence of UTF-8 characters.
生成的属性通常具有附加的字符编码信息。如果未指定
此函数用于将要素上的属性的值设置为null。如果属性不存在,则将创建它。
The syntax for FME_SetAttributeNull is:
FME_SetAttributeNull
如果属性不存在,则将创建它,其类型将是字符串。
此函数在FME临时文件夹中生成临时文件名。
The filename is guaranteed to be a unique, new file.
注意:FME将创建具有给定名称的空文件;您必须在完成后删除它。
fme_tempfilename的语法是:
fme_tempfilename [<前缀>] [<后缀>]
If a prefix and suffix are not provided, the filename will be returned as an arbitrarily uniquely named file in the FME temporary folder. (For information on where this folder is located, see临时文件夹确定。)
如果提供了前缀,则将其用作临时文件夹中的文件名的开始部分,后缀用作结束部分。通常,后缀用于附加扩展,并且在这种情况下,它必须另外包含一个时期“。”。
例如,此调用:
fme_tempfilename栅格.png
会返回一些这样的东西:
c:/Documents and Settings/username/Local Settings/Temp/rastera05921.png
This function is used to remove one or more attributes from a feature.
The syntax for FME_UnsetAttributes is:
fme_unsetattributes 如果该功能不包含列出的任何属性,则不会生成任何错误。fme_unsetattributes只需忽略未在该功能上指定属性的任何参数。
使用说明
% Character
Due to FME parser limitations, a Tcl expression cannot contain a percent (%) character. If a % character is needed, the expression should be coded as a Tcl procedure and put into an external file to be 'source'd in. Note that you can avoid the % character issue by using astringformatter.变形金刚提供了访问TCL“格式”命令的便捷方式。
编辑变换器参数
Using a set of menu options, transformer parameters can be assigned by referencing other elements in the workspace. More advanced functions, such as an advanced editor and an arithmetic editor, are also available in some transformers. To access a menu of these options, clickbeside the applicable parameter. For more information, see变压器参数菜单选项。
变压器类别
搜索FME知识中心
在上搜索有关此变压器的示例和信息FME Knowledge Center。