span8
第4排
在上一个示例,请we learned how to create folders using a feature type fanout.在这个例子中,我们将专注于通过使用kml id和kml父属性创建文件夹。这种方法最适合在需要对文件夹命名和父子关系进行直接控制的情况下,尽可能深地控制这些级别。In other words,此方法用于创建自定义文件夹层次结构。
Not sure what folders are?没问题!kml文件夹定义了GoogleEarthPlaces窗格中的嵌套树结构。Check out the articleCreating KML Folders by Feature Type Fanoutfor a full definition.
Similar to the feature type fanout approach,these methods of creating folders are intended for use in KML rather than the KMZ (which is the zipped KML file).
我们可以通过kml id分两部分创建kml文件夹:通过创建文件夹结构,然后通过创建文件夹元素,并使用kml_父属性将我们的所有功能与其相应的文件夹关联起来。
对于这个例子,我们将使用温哥华快速中转站的csv文件。而不是在kml上有一个庞大的站点列表,将传奇放在谷歌地球上,我们想把它组织成一个文件夹层次结构。我们可以通过火车线将车站分隔开来,然后将市区车站与加拿大线分开,如下结构:
The KML ID approach to folder setup using three levels of folders.This is the file structure that we will use in our example.The parent level is Train Route.It has three children: Connection,博览会,and CanadaLine.加拿大行有自己的子文件夹,市中心。
要创建空文件夹结构,we will first use a造物主transformer to create a Null Geometry Object.删除创建实例属性“创建实例”。您可以将所有其他参数保留为默认值。
我们要用一个属性创建器Transformer创建每个文件夹。换句话说,如果我想要五个文件夹,我将使用五个属性创建器。每个attributeCreator都将连接到创建者。参考上述文件结构的图像,we are creating our Parent folder first.用以下属性和值填写变压器参数:
新建属性 | 属性值 |
公里标识 | TrainRoute |
kml_name | Train Route |
kml_文件 | 运输 |
这是我们的父文件夹,我们将其命名为火车路线(kml_名称)。请注意,kml_id没有任何空格。我们这样做是为了减少以后在需要将数据关联到此文件夹时出错的可能性。我们将通过将数据与所需文件夹的kml_id关联,将数据放入这些文件夹中。我们需要知道空格和区分大小写因为如果我们有错误的ID,我们的数据就不会进入正确的文件夹!
The last thing to point out here is the kml_document.通常,从数据集读取时,kml_文档默认设置为fme_basename(源数据文件名)。然而,当使用一个创造者,我们需要设置kml_文件。在这里,如果我们想将所有随后的attributeCreators写入相同的kml文件名,那么将其设置为相同的kml_文档名是非常重要的。The name of the kml_document must also be the same name of the file that you are writing out.使用与文件名不同的文档名标记的文件夹和数据将不会写入该文件。
kml_文档在attributeCreator参数中命名为“transportation”。
稍后我们将连接一个编写器,并命名kml文件,‘transportation'.
高级用户注意:This means that by controlling what you name your kml_document,you can write out different KML files using the same workspace.For example,如果我想要一份叫做土豆的外线文件,I would name the kml_document ‘potatoes' in the AttributeCreator,and I would get an empty folder called potatoes.kml in addition to what I'm writing out in my workspace.Just be sure that your data is also being written to the desired folder and kml_document name.
我们现在使用另外三个属性创建器创建下一级文件夹。我们要创建文件夹:connection,博览会,and Canada Line.好吧,you got me!For those of you who are familiar with Vancouver,没有称为连接的线路。这只是我为海滨站划分的一个类别,它连接了这个数据集中的两条火车线。
让我们将一个新的attributeCreator连接到创建者。像下面的文件夹一样,填写第一个变压器,连接:
新建属性 | 属性值 |
kml_parent | TrainRoute |
公里标识 | 连接 |
kml_name | 连接 |
kml_文件 | 运输 |
注意,这里有一个新的属性,叫做kml_parent。这种分配父文件夹的方法就是创建层次结构的方法。Duplicate this AttributeCreator twice (select the transformer and hit Ctrl-D) and make the following changes for each:
AttributeCreator Duplicate 1:
AttributeCreator Duplicate 2:
对于这些文件夹,kml_父级将保持不变,因为所有这些文件夹都处于同一级别。kml_文档也将保持不变,以便我们将整个文件夹层次结构写入相同的kml文件。将新的属性创建者连接到创建者。
复制最后一个attributeCreator并将其附加到创建者。这是文件夹加拿大行的子文件夹。对变压器参数进行以下更改:
属性kml_document将不会更改。
The parameters for the folder,“市中心”。此文件夹是Canadaline文件夹的子文件夹。
为Google KML格式添加一个编写器。Set your dataset path,and set the ‘Feature Type Definition' to自动.Press OK,and in the next dialog,命名“功能类型名称”,Folder.This feature type must be named Folder for Google Earth to recognize your folder structure.单击“确定”。现在运行工作区并检查GoogleEarth中的输出,以查看您是否创建了所需的文件夹结构。
GoogleEarth中显示的输出文件夹结构放置图例。
已完成部分创建空文件夹结构的工作区。
既然我们有了文件夹结构,我们可以将数据添加到这些文件夹中。
在与A部分相同的工作区中,read in the CSV file rapid_train_stations.csv.按“确定”之前,将坐标系设置为UTM84-10N。下一步,进入参数并将属性定义设置为Manual.将X设置为X轴坐标,Y设置为Y轴坐标。
下一步,我们将使用测试筛选器要按火车线和最后一个文件夹过滤数据,属于加拿大线路的市中心车站。我们希望以设置文件夹的相同方式筛选数据,以便将数据与正确的文件夹相关联。如下表所示填写参数:
试验条件 | 输出端口 | |
如果 | 线路=连接 | 连接 |
其他 | line=世博会 | Expo |
否则如果 | STATION CONTAINS Vancouer OR | |
STATION CONTAINS YALETOWN | 市中心 | |
其他 |
|
卡纳达林 |
Except for Waterfront,which we have categorized as a Connection,加拿大线上只有另外两个车站我们认为是市中心的一部分:雅勒敦圆屋和温哥华市中心车站。利用这些信息,我们正在筛选出市中心的站点,条件是站点名称包含我们要查找的部分站点(关键词:温哥华和亚勒敦)。
第七章。为每条列车线的车站设置父文件夹
Add a new AttributeCreator to the CONNECTION output port of the TestFilter.在这一步中,我们正在将kml父文件夹设置为数据,并为站点提供一个默认情况下将在Google kml中显示的ID名称。
We will set the kml_parent to the corresponding folder (Connection port has a kml_parent: Connection,世博会有一个kml_的父母:世博会,Downtown has a kml_parent: Downtown,Canada Line has a kml_parent: CanadaLine).我们使用文件夹的kml_id作为kml_父级。Remember that we did not use any spaces in the kml_id's.下面是连接到testfilter的连接输出端口的attributeCreator的参数。
新建属性 | 属性值 |
kml_parent | 连接 |
公里标识 | STATION |
对于这里的国民党,我们在所有四个属性创建器中将其设置为属性“station”。此属性包含火车站名称。同样的做法也适用于与世博会和卡纳达林有关的自然资源创造者,使用各自的kml_父ID。
AttributeCreators connected to the TestFilter with annotations showing their respective parameters.
At this point in our workspace,all of our folders now have data.在这一步中,我们通过设置图标和图标颜色的可视化来设计我们的站点。Add four克姆斯特勒到工作区,并将一个附加到步骤7中的每个attributeCreator。
随意设置图标和图标颜色。我已选择使用图标名称:GME/GX_铁路以及连接的洋红色,yellow for Expo,绿松石代表卡纳达林,市区的两个车站是橙色的。
如果我们现在运行工作区,we would find that all of our stations are written in capital letters.为了让这个看起来更好,we will connect all of our KMLStylers to a singleKML属性发送器变压器。In the transformer parameters,open the text editor for ‘Name' in the section Navigation Tree.双击FullTitleCase在字符串函数和STATIONin the FME Feature Attributes.我们的字符串应该如下所示:
@FullTitleCase(@Value(STATION))
This string function will convert our STATION name to title case.
最后,to write out our KML,右键单击并插入一个编写器功能类型,并将其连接到kmlpropertySetter的输出端口。Name the feature type,Placemarks.Run the workspace.
KML结果显示在Google Earth中。火车站按文件夹进行颜色编码,并显示所代表的车站名称。
生成的文件夹显示在谷歌地球的“位置”面板中。
祝贺你!您已经成功学习了如何使用kml_id和kml_父属性创建自定义文件夹。The key here is to create your folder structure first using a Creator,and then putting your data into those folders.Compared to the feature fanout method,this method gives you direct control to create as many subfolders as you need.以下是在使用kml id方法时要记住的一些提示和技巧:
注:为了使用kml id方法来创建文件夹,可以使用更自动化的方法。请参见皮通卡勒变压器产品.
此处使用的数据源于温哥华市,请British Columbia.It contains information licensed under the Open Government License - Vancouver.
?2019安全亚搏在线软件公司|法律