我有一个简单的 KML 文件,其中包含 1 个线串(实际文件有数千个)。我的坐标有问题,因为谷歌地球将单行字符串绘制为两条线。而我转换为 SQL Server Spatial 并最终 C# 代码只会画一条线。
<?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>Test.kmz</name>
<Style id="styleOSR">
<LineStyle id="lineStyleOSR">
<color>ff0f00ff</color>
<width>2</width>
</LineStyle>
</Style>
<Folder>
<name>TEST</name>
<description>
</description>
<Folder>
<name>TEST</name>
<Placemark>
<name>OSR 0038</name>
<styleUrl>#styleOSR</styleUrl>
<LineString>
<tessellate>1</tessellate>
<altitudeMode>relativeToGround</altitudeMode>
<coordinates>
68.208,86.306,0 70.926,86.203,0 72.984,86.106,0 75.029,85.98900000000002,0 76.32599999999999,85.917,0 78.40300000000001,85.768,0 81.10299999999999,85.639,0 83.143,85.556,0 84.80200000000001,85.5,0 86.80200000000001,85.41800000000001,0 88.486,85.346,0 89.98,85.29600000000001,0 92.313,85.229,0 94.155,85.155,0 95.839,85.102,0 97.27300000000001,85.02800000000001,0 98.568,84.95999999999999,0 99.444,84.911,0 102.918,84.664,0 103.943,84.57800000000002,0 105.302,84.485,0 106.759,84.369,0 107.709,84.295,0 108.939,84.194,0 109.727,84.11,0 110.959,83.965,0 111.974,83.824,0 112.843,83.67400000000002,0 113.723,83.512,0 114.558,83.321,0 115.258,83.151,0 115.793,83.014,0 116.582,82.74,0 117.171,82.539,0 117.755,82.298,0 119.1,82.087,0 119.984,81.595,0 121.004,81.115,0 121.898,80.643,0 122.639,80.206,0 123.408,79.759,0 125.188,78.99,0 125.679,78.133,0 -29.60900000000001,39.993,0 -29.613,40.033,0 -29.58,40.079,0 -29.588,40.106,0
</coordinates>
</LineString>
</Placemark>
</Folder>
</Folder>
</Document>
</kml>
我的问题是,如果我在谷歌地球上加载它,它会在地球上画两条单独的线。这实际上是我想要做的。你可以在下图中看到两条红线,两条独立的线!
但是当我处理线串然后从 SQL Server 几何体中渲染线时,我得到了一条线
所以解析这条坐标线并放入SQL Server给了我
LINESTRING (68.208 86.306, 70.926 86.203, 72.984 86.106, 75.029 85.989000000000019, 76.326 85.917, 78.403 85.768, 81.103 85.639, 83.143 85.556, 84.802 85.5, 86.802 85.418, 88.486 85.346, 89.98 85.296, 92.313 85.229, 94.155 85.155, 95.839 85.102, 97.27300000000001 85.028, 98.568 84.96, 99.444 84.911, 102.918 84.664, 103.943 84.578000000000017, 105.302 84.485, 106.759 84.369, 107.709 84.295, 108.939 84.194, 109.727 84.11, 110.959 83.965, 111.974 83.824, 112.843 83.674000000000021, 113.723 83.512, 114.558 83.321, 115.258 83.151, 115.793 83.014, 116.582 82.74 , 117.171 82.539, 117.755 82.298, 119.1 82.087, 119.984 81.595, 121.004 81.115, 121.898 80.643, 122.639 80.206, 123.408 79.759, 125.188 78.99, 125.679 78.133, -29.609000000000009 39.993, -29.613 40.033, -29.58 40.079, -29.588 40.106 )
问题是最后 4 个坐标包含这些值
-29.609000000000009 39.993,-29.613 40.033,-29.58 40.079,-29.588 40.106
现在谷歌地球似乎知道坐标彼此不同,并没有渲染一条线而是将它分成两条线。
所以我的问题是如何做到这一点?请记住,我有很多这些,我想将它们作为自定义图层放在 Google 地图上 - 这是我的问题 - 我的地图上有奇怪的线条。
以下是 google earth 实际呈现完整 KML 文件的方式。
如果有人有兴趣查看原始 KML 文件,那么您可以从这里获取
这是为了我在新西兰的地震现场在地图上显示技术板块。
http://canterburyquakelive.co.nz
干杯
克里斯