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)使用FME特征类型使用属性值和2)使用FME功能类型作为过滤器。
源数据都在一层上,看起来如下所示:
工作区模板:conditionalattributemapping.fmwt.
第1步 -The water mains schema contains attributes named对象
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
and对象
will be renamed to eitherAbandonedID
orActiveID
。
如果我们的条件属性映射查找表遵循inthe的简单结构属性映射文章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 that对象
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:
如果Lifecyclestatus =被遗弃的那么ObjectID➜如果Lifecyclestatus = Active那么ObjectID➜AsiveId
第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步 -单击“创建操作参数”窗口。请注意,我们有两个动作 - 一个用于过滤功能,一个用于映射属性。
过滤器功能操作定义其中的子句LifecycleStatus Attribute = LifecycleStatus Value
:
地图属性操作定义属性映射在其中SourceAttribute
becomesdestinistrtribute.
:
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 original对象
字段和值以及新的。
步骤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.变压器可用于公开这些新属性并导致Writer属性可明显连接。
工作区模板:conditionalattributemappingusingfeaturetypes.fmwt
过滤不限于用户定义的属性,因为它也可以通过格式属性进行过滤。有用格式属性的示例是fme_feature_type.
,其中包含要素类型名称。执行此任务的关键是在查找表中提供FME格式属性。在以下示例中,Workspace中存在两个功能类型:water_distribution / wontrolvalve.
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
与条件属性映射一样,我们查找表中的每一行都定义了架构映射规则。此查找表中的第一个规则状态:
如果功能类型Name = Water_Distribution/wControlValve THEN OBJECTID becomes ValveID
SchemoMapper Transformer创建动作对话框镜像上面给出的示例表。例如,在“预设筛选器功能”窗口中,突出显示了指示我们规则的属性过滤部分的两列:
运行工作区并注意该属性将我们的两个特征类型分开,并将我们重新映射对象
attribute along the way.
这是已完成的工作区:
下载包含以下内容:
The data used here originates from open data made available by theCity of Vancouver, 不列颠哥伦比亚省。它包含根据开放政府许可证的信息 - 温哥华。
额外资源
©2019 S亚搏在线afe Software Inc |法律