我正在从Google地球多边形创建KML文件。但是,创建的KML文件将以两种不同的格式显示。当一种类型出现在Google地球中时,将显示为链接。另一个将显示为纯文本。 显示为链接的KML格式如下:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">
<Placemark>
<name>GHG</name>
<ExtendedData>
<Data name="stroke">
<value>#555555</value>
</Data>
<Data name="stroke-width">
<value>2</value>
</Data>
<Data name="stroke-opacity">
<value>1</value>
</Data>
<Data name="fill">
<value>#555555</value>
</Data>
<Data name="fill-opacity">
<value>0.5</value>
</Data>
<Data name="Code">
<value>GHG</value>
</Data>
</ExtendedData>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>
35.54397940635681,33.17158011534832,0 35.54336249828339,33.16975707112739,0 35.54345905780792,33.16957296849484,0 35.54412424564362,33.17153521323674,0 35.54397940635681,33.17158011534832,0
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
</kml>
以纯文本格式显示的图表的kml格式如下所示:
?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">
<Document>
<name>BFB.kml</name>
<StyleMap id="msn_ylw-pushpin">
<Pair>
<key>normal</key>
<styleUrl>#sn_ylw-pushpin</styleUrl>
</Pair>
<Pair>
<key>highlight</key>
<styleUrl>#sh_ylw-pushpin</styleUrl>
</Pair>
</StyleMap>
<Style id="sn_ylw-pushpin">
<LineStyle>
<color>99ffffff</color>
</LineStyle>
</Style>
<Style id="sh_ylw-pushpin">
<IconStyle>
<scale>1.2</scale>
</IconStyle>
<LineStyle>
<color>99ffffff</color>
</LineStyle>
</Style>
<Placemark>
<name>BFB</name>
<visibility>0</visibility>
<styleUrl>#msn_ylw-pushpin</styleUrl>
<Polygon>
<tessellate>1</tessellate>
<outerBoundaryIs>
<LinearRing>
<coordinates>
35.42654700219181,32.70002475720476,0 35.43086711604241,32.70023107874993,0 35.43106772797857,32.7007191672116,0 35.42656173211241,32.70057776992705,0 35.42654700219181,32.70002475720476,0
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
</Document>
</kml>
我需要解析这些kml文件,当格式标准化时,这是一个更容易的任务。我更喜欢第一种(GHG)格式。