span8
span4
Introduction to Conditional Attribute Mapping
Conditional mapping makes use of theSchemaMapper’s “Filter Features” action. It is a way to define a simple conditional clause to perform attribute mappings based on specific conditions.
在本教程中,我们将操纵包含水主数据温哥华市的单层。该层可以被分成Abandoned
andActive
基于属性的管道,我们将利用这个值的,有条件的条款一起,以重新映射层的架构有两种方式:1)使用属性值作为过滤器和2)使用FME特征类型的过滤器。
源数据都是一层,看起来像这样的:
工作区模板:conditionalattributemapping.fmwt
第1步 -The water mains schema contains attributes namedOBJECTID
andLifecycleStatus
, both of which will play a part in our conditional filter. Open the dataset in the Data Inspector and take a look at theLifecycleStatus
属性的一些功能。你会发现,它的值或者是Abandoned
或价值Active
:
对于我们的教程,这取决于价值LifecycleStatus
中,fme_feature_type
属性将被映射到Abandoned
orActive
andOBJECTID
will be renamed to eitherAbandonedID
orActiveID
。
如果我们的条件属性映射查找表遵循结构简单用在矿井属性映射文章where the left column holds the attributes and values we’re starting with, and the right column dictates what we want as output, the table would look something like this:
1 SourceAttribute,DestinationAttribute 2 OBJECTID,AbandonedID 3 OBJECTID,ActiveID
The problem with this lookup table is thatOBJECTID
is defined as a source twice under SourceAttribute (because we want to map it in two different ways). This is clearly problematic; we need to give more explicit instructions. To correct this, a clause is added stating when to use which definition.
1 FilterAttribute,FilterAttributeValue,SourceAttribute,DestinationAttribute 2 LifecycleStatus,Abandoned,OBJECTID,AbandonedID 3 LifecycleStatus,Active,OBJECTID,ActiveID
The logic working here is as follows:
IF LifecycleStatus =中止,则OBJECTID➜AbandonedID IF LifecycleStatus =活动的,那么OBJECTID➜ActiveID
第2步 -In our demo workspace, open the SchemaMapper transformer’s parameters. A lookup table is provided for you - feel free to inspect the lookup table reader parameters Preview panel to get a sense of the table structure.
第3步 -点击进入创建操作参数窗口。请注意,我们有两个动作 - 一个用于过滤的功能,一个用于映射属性。
过滤器功能的行动定义where子句中LifecycleStatus Attribute = LifecycleStatus Value
:
地图属性动作定义属性地图,SourceAttribute
becomesDestinationAttribute
:
Also worth noting is the Source Attribute: Keep / Remove option. Remove is selected with the aim of tidying the data and focusing on the remapped attribute values rather than the originals. Using the Keep option would retain the originalOBJECTID
现场,并与新的沿的值。
第4步 -接受参数和返回到工作区。我们的单水管层现在已经在逻辑上分成两个基础上,LifecycleStatus
attribute: we have features marked with anAbandonedID
and features marked with anActiveID
。Using anAttributeFilter我们现在可以在这两个群体的功能映射到两个驶出的特征类型和写入我们的AutoCAD文件。
下面是完成工作区的图像:
Since Workbench does not know that the correct mappings exist in the SchemaMapper, the destination attributes are flagged as unconnected (the red triangles that appear in our writer attribute dropdown). However, when the workspace is run, the output will be correct because the attributes exist, they just aren’t exposed.
另外,该AttributeExposer变压器可用于露出这些新属性并引起写入器属性被可视地连接。
工作区模板:conditionalattributemappingusingfeaturetypes.fmwt
因为它也可以通过过滤器格式属性滤波不限于用户定义的属性。一个有用的格式属性的一个例子是fme_feature_type
,其中包含的要素类的名称。要执行这项任务的关键是提供查找表中的FME格式属性。在下面的例子中,两个功能在工作空间中存在的类型:Water_Distribution / wControlValve
andWater_Distribution / wMain
。我们愿在此基础上的功能型被读取生成的架构进行重命名的属性。
To create this workflow we need a lookup table that uses the>fme_feature_type
attribute. A lookup table is provided within the workspace template, but you may wish to create your own which looks like the one below:
1 FilterAttribute,FilterAttributeValue,SourceAttribute,DestinationAttribute 2 fme_feature_type,Water_Distribution / wControlValve,OBJECTID,ValveID 3 fme_feature_type,Water_Distribution / wControlValve,直径,ValveDiameter 4 fme_feature_type,Water_Distribution / wMain,OBJECTID,PIPEID 5 fme_feature_type,Water_Distribution / wMain,直径,PipeDiameter
至于有条件的属性映射,在我们的查找表的每一行定义一个模式映射规则。在此查找表州的第一条规则:
IF Feature Type Name = Water_Distribution/wControlValve THEN OBJECTID becomes ValveID
该变压器的SchemaMapper创建操作对话的镜子上面的例子表中给出。例如,在预先设定的过滤器功能操作窗口,其中口述的我们的规则的属性过滤器部分的两列被突出显示:
运行工作空间,并注意AttributeFilter分开我们两个特征类型,以及我们已经重新映射我们OBJECTID
attribute along the way.
这是填好的工作区:
下载包含以下内容:
The data used here originates from open data made available by theCity of Vancouver, 不列颠哥伦比亚省。它包含了开放政府许可协议进行许可信息 - 温哥华。
其他资源
©2019安全亚搏在线软件公司|法律