练习1 Address Open Data Project
Data Geodatabase地址(文件)
总体目标 将文件Geodatabase转换为GML并映射模式
演示了 模式映射的属性管理
开始工作 没有一个
结束工作 C: \ \ DesktopBasic \ Transformers-Ex1-Complete.fmw FMEData2016 \工作区

作为推动开放政府的一部分,the city's corporate address database is to be made available online.然而,它目前以Esri文件Geodatabase格式保存,因此不适合以原始形式交付。Instead the data will be translated to a GML/XML format and transformed into a new schema.

作为所有与数据翻译有关的事情的管理者,you have been handed this task to carry out.


1) Inspect Data
像往常一样,第一个任务是熟悉数据。为此,在FME数据检查器中打开以下数据集:

读者的格式 Esri地理数据库(文件Geodb API)
读者数据集 C: \ \ Addresses.gdb FMEData2016 \ Data \地址

The table that is to be translated is called "PostalAddress." The important thing here is not how the data looks in the graphic display,但更多的是表视图窗口中存在哪些属性。

Optionally you may wish to locate the file C:\FMEData2016\Resources\AddressSchema.xsd and open it in a text editor (or other XML file viewer).xsd文件描述XML/GML数据集的模式,创建这个文件是为了定义我们希望在地址GML数据集中具有哪些属性。

2) Create Workspace
Now that you are familiar with both the source data and the required output schema,启动FME工作台,并从一个空工作区开始。Select Readers > Add Reader from the menubar.

添加与数据检查器中值相同的读取器。

读者的格式 Esri地理数据库(文件Geodb API)
读者数据集 C: \ \ Addresses.gdb FMEData2016 \ Data \地址

When prompted,只选择postallocations表,也没有别人:

3)添加作家
现在让我们添加一个写入器来编写输出数据。从菜单栏中选择authors > Add Writer并使用以下命令:

作家格式 GML(地理标记语言)
Writer Dataset C: \ FMEData2016 \ \培训\ AddressFile.gml输出

在对话框的“添加特性类型”部分中选择“从Dataset导入”。然后单击OK添加写入器。


4)导入功能类型
当提示时,设置以下参数。The Dataset can be left as it is or emptied (left blank).It is not the important part:

读者的格式 GML(地理标记语言)
读者数据集
Reader Parameters 应用程序模式C: \ \ AddressSchema.xsd FMEData2016 \资源

您可能还需要设置名称空间前缀参数:

Click OK to accept the values.The new feature type will be created to match the chosen GML application schema.

The workspace will now look like this:


5) Add AttributeManager
好吧,我们现在有了读者和作者。Now we can start to map the schema from Reader to Writer.你们会注意到,目前,这两家公司并不十分匹配。

所以,在这两种特性类型之间连接一个AttributeManager。对话框将如下所示:

首先,让我们通过删除一些不需要的属性来清理Reader模式。

点击以下属性,按-按钮删除:

  • OBJECTID
  • GlobalID
  • OWNERNM1
  • OWNERNM2
  • INTSTATE
  • INTPSTLCD
  • 代表
  • 状态
  • LASTUPDATE
  • LASTEDITOR


6)重命名属性
Several source attributes can be written to the output as they are,但首先需要重命名。

在AttributeManager中重命名如下:

  • PSTLCITY to City
  • PSTLPROV到省
  • POSTALCODE, POSTALCODE
  • COUNTRY to Country

If the AttributeManager is connected to the Writer feature type then you should be able to select the Output Attribute field from a drop-down list instead of typing it in.


7)创建属性
Two attributes on the output (Provider and UpdateDate) are new and cannot be copied from the source data.它们必须被创造出来。

在AttributeManager中创建新的属性“Provider”。因为属性还不存在,你需要输入新名字,rather than select it from a drop-down list.

值可以是您自己的组织名称,或者“安亚搏在线全软件”或者“国际大都市”。


8)创建属性
Now create the new attribute "UpdateDate".单击属性值字段中的下拉箭头并选择Open Text Editor,而不是硬编码值。

在文本编辑器中找到名为Timestamp的FME功能函数,并双击将其放入编辑器中。Now replace the 部分与Y ^ - ^ - ^ d

By doing this not only will we get the correct date each time the workspace is run,它也将是正确的ISO语法的GML格式。

Click OK (and again) to close the AttributeManager dialog.


提示
为什么现在不运行翻译,打开重定向到FME数据检查器,看看我们到目前为止的努力结果如何?


9) Add AttributeSplitter
查看输出模式,Number和Street有两个字段(例如“3305”和“w10av”)。然而,源模式将该信息压缩到一个字段中 characters separating the fields ("3305 W 10th Av").因此,为了匹配Writer模式,我们必须将source属性拆分。

插入AttributeSplitter转换器。插入之前the AttributeManager - then if there are any actions to carry out on the split attributes we can use the same AttributeManager transformer.

打开AttributeSplitter参数对话框。Set PSTLADDRESS as the attribute to split and enter a space character into the Delimiter parameter.Ensure that a list name is set in that particular parameter.

单击OK关闭对话框。If you run the workspace now you'll see the address as a list attribute:

_list{0}(编码:utf-8) 3305_list{1}(编码:utf-8) W_list{2}(编码:utf-8) 10th_list{3}(编码:utf-8) Av

请记住,list属性是一个可以在单个名称(_list)下存储多个值的属性。


10) Rename Attribute
现在让我们处理输出中的Number字段。

打开AttributeManager参数。

注意,列表属性现在有一个名为_list{}的条目。然而,AttributeManager不会像其他转换器那样公开列表元素。So instead of renaming the attribute we have to copy its value into the new attribute.

在Output属性字段中,从下拉列表中选择Number。

For the Attribute Value field click the drop-down arrow and select Attribute Value > _list{}...

现在将提示您选择列表中的元素。确保将其设置为0(0)并单击OK。

Click OK to close the dialog and run the workspace to ensure the number is being copied.


11)构造属性
The final step is to recreate the Street attribute,without it being prefixed by the address number.

Open the AttributeManager again.This time in the Output Attribute field select Street from the list.

For the Attribute Value field there are multiple list elements to concatenate.So click the drop down arrow and choose Open Text Editor.

Locate _list{} in the FME Feature Attributes menu and double-click it to place it in the editor.您将再次被提示选择list元素。This time select element 1

Press the spacebar to enter a character.

再次双击_list{},这次选择list item 2。

再次按下空格键 character.

Double-click _list{} again,这次选择项目3。

对话框现在看起来是这样的:

这样我们就可以把街道名称的所有部分连接起来,for example:

“W”“17”“St”变成“w17 St”

We're assuming that no street name has more than three parts to it,但这对于我们的例子来说是合理的。

12)运行的工作区
Save and then run the workspace (remember to turn off any Redirect option!)

Open the containing folder to check the output has been written.There should be both an output file and schema document.Inspect the data in the FME Data Inspector.输出(打开背景地图)应该是这样的:


Tiles Courtesy ofMapQuest

查询一个功能将返回我们刚刚放在一起的所有属性:


祝贺你
By completing this exercise you have learned how to:
  • 使用AttributeManager转换器创建,删除,and rename attributes
  • 使用AttributeSplitter将属性拆分为列表属性
  • 处理AttributeManager中的列表属性
  • 在AttributeManager文本编辑器中使用FME函数
  • Import feature types from an XML schema document

results matching ""

    No results matching ""