所以我正在尝试编写一个程序(没有依赖项),它将从谷歌地图(见下文)读取 KML 文件以获取坐标并将它们存储在矩阵中以供以后数据操作。
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.2">
<Document>
<name>Driving directions to Commercial St/A1202</name>
<description><![CDATA[]]></description>
<Style id="style1">
<IconStyle>
<Icon>
<href></href>
</Icon>
</IconStyle>
</Style>
<Style id="style2">
<LineStyle>
<color>73FF0000</color>
<width>5</width>
</LineStyle>
</Style>
<Style id="style3">
<IconStyle>
<Icon>
<href></href>
</Icon>
</IconStyle>
</Style>
<Placemark>
<name>From: Unknown road</name>
<styleUrl>#style1</styleUrl>
<Point>
<coordinates>-0.168942,51.520180,0.000000</coordinates>
</Point>
</Placemark>
<Placemark>
<name>Driving directions to Commercial St/A1202</name>
<styleUrl>#style2</styleUrl>
<ExtendedData>
<Data name="_SnapToRoads">
<value>true</value>
</Data>
</ExtendedData>
<LineString>
<tessellate>1</tessellate>
<coordinates>
-0.168942,51.520180,0.000000
-0.167752,51.520447,0.000000
-0.167371,51.520481,0.000000
</coordinates>
</LineString>
</Placemark>
<Placemark>
<name>To: Commercial St/A1202</name>
<styleUrl>#style3</styleUrl>
<Point>
<coordinates>-0.073247,51.516960,0.000000</coordinates>
</Point>
</Placemark>
</Document>
</kml>
虽然这对于像上面这样的小文件来说并不是低效的,但我有 500+KB 的文件需要稍后解析!那么关于获取这些坐标并将它们存储为矩阵的有效方法(不涉及需要安装的“非标准”导入)的任何建议?