Google Earth KML高度模式

时间:2014-11-22 14:20:34

标签: kml google-earth


我有谷歌地球的kml文件的问题。当我使用高度模式clampToGround时,它完全符合我的预期,它可以很好地跟随地面

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom"    xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2">
    <Document>
        <name>pm1kml</name>
        <Style id="poly">
            <LineStyle>
                <color>a000ff00</color>
            </LineStyle>
            <PolyStyle>
                <color>a000ff00</color>
        </PolyStyle>
    </Style>
    <Placemark>
        <styleUrl>#poly</styleUrl>
        <Polygon>
            <extrude>0</extrude>
            <tessellate>0</tessellate>
            <altitudeMode>clampToGround</altitudeMode>
            <outerBoundaryIs>
                <LinearRing>
                    <coordinates>-5.255885800498265,36.11513548688032,123 -5.257614986927059,36.097578762436825,123 -5.257614986927059,36.097578762436825,123 -5.262736094548725,36.08069673306777,123 -5.262736094548725,36.08069673306777,123 -5.27105232206931,36.06513816569425,123 -5.27105232206931,36.06513816569425,123 -5.282244081528993,36.051500967335095,123 -5.282244081528993,36.051500967335095,123 -5.29588127988815,36.04030920787541,123 -5.29588127988815,36.04030920787541,123 -5.311439847261665,36.03199298035483,123 -5.311439847261665,36.03199298035483,123 -5.3283218766307225,36.02687187273316,123 -5.3283218766307225,36.02687187273316,123 -5.345878601074219,36.02514268630436,123 -5.345878601074219,36.02514268630436,123 -5.363435325517715,36.02687187273316,123 -5.363435325517715,36.02687187273316,123 -5.380317354886772,36.03199298035483,123 -5.380317354886772,36.03199298035483,123 -5.395875922260288,36.04030920787541,123 -5.395875922260288,36.04030920787541,123 -5.409513120619445,36.051500967335095,123 -5.409513120619445,36.051500967335095,123 -5.4207048800791275,36.06513816569425,123 -5.4207048800791275,36.06513816569425,123 -5.429021107599713,36.08069673306777,123 -5.429021107599713,36.08069673306777,123 -5.434142215221378,36.097578762436825,123 -5.434142215221378,36.097578762436825,123 -5.435871401650172,36.11513548688032,123 -5.435871401650172,36.11513548688032,123 -5.434142215221378,36.132692211323814,123 -5.434142215221378,36.132692211323814,123 -5.429021107599713,36.14957424069287,123 -5.429021107599713,36.14957424069287,123 -5.4207048800791275,36.16513280806639,123 -5.4207048800791275,36.16513280806639,123 -5.409513120619445,36.178770006425545,123 -5.409513120619445,36.178770006425545,123 -5.395875922260288,36.18996176588523,123 -5.395875922260288,36.18996176588523,123 -5.380317354886771,36.19827799340581,123 -5.380317354886771,36.19827799340581,123 -5.363435325517715,36.20339910102748,123 -5.363435325517715,36.20339910102748,123 -5.345878601074219,36.205128287456276,123 -5.345878601074219,36.205128287456276,123 -5.3283218766307225,36.20339910102748,123 -5.3283218766307225,36.20339910102748,123 -5.311439847261665,36.19827799340581,123 -5.311439847261665,36.19827799340581,123 -5.29588127988815,36.18996176588523,123 -5.29588127988815,36.18996176588523,123 -5.282244081528993,36.178770006425545,123 -5.282244081528993,36.178770006425545,123 -5.27105232206931,36.16513280806639,123 -5.27105232206931,36.16513280806639,123 -5.262736094548725,36.14957424069287,123 -5.262736094548725,36.14957424069287,123 -5.257614986927059,36.132692211323814,123 -5.257614986927059,36.132692211323814,123 -5.255885800498265,36.11513548688032,123 -5.255885800498265,36.11513548688032,123 -5.255885800498265,36.11513548688032,123  </coordinates>
                </LinearRing>
            </outerBoundaryIs>
        </Polygon>
    </Placemark>
</Document>

然而,当我使用relativeToGround时,只有外部顶点跟随地面。在圆圈的中间,岩石位于绿色区域上方,而不是在其下方123米处。
图片:http://nl.tinypic.com/r/2vcsvq1/8

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom"    xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2">
    <Document>
        <name>pm1kml</name>
        <Style id="poly">
            <LineStyle>
                <color>a000ff00</color>
            </LineStyle>
            <PolyStyle>
                <color>a000ff00</color>
        </PolyStyle>
    </Style>
    <Placemark>
        <styleUrl>#poly</styleUrl>
        <Polygon>
            <extrude>0</extrude>
            <tessellate>0</tessellate>
            <altitudeMode>relativeToGround</altitudeMode>
            <outerBoundaryIs>
                <LinearRing>
                    <coordinates>-5.255885800498265,36.11513548688032,123 -5.257614986927059,36.097578762436825,123 -5.257614986927059,36.097578762436825,123 -5.262736094548725,36.08069673306777,123 -5.262736094548725,36.08069673306777,123 -5.27105232206931,36.06513816569425,123 -5.27105232206931,36.06513816569425,123 -5.282244081528993,36.051500967335095,123 -5.282244081528993,36.051500967335095,123 -5.29588127988815,36.04030920787541,123 -5.29588127988815,36.04030920787541,123 -5.311439847261665,36.03199298035483,123 -5.311439847261665,36.03199298035483,123 -5.3283218766307225,36.02687187273316,123 -5.3283218766307225,36.02687187273316,123 -5.345878601074219,36.02514268630436,123 -5.345878601074219,36.02514268630436,123 -5.363435325517715,36.02687187273316,123 -5.363435325517715,36.02687187273316,123 -5.380317354886772,36.03199298035483,123 -5.380317354886772,36.03199298035483,123 -5.395875922260288,36.04030920787541,123 -5.395875922260288,36.04030920787541,123 -5.409513120619445,36.051500967335095,123 -5.409513120619445,36.051500967335095,123 -5.4207048800791275,36.06513816569425,123 -5.4207048800791275,36.06513816569425,123 -5.429021107599713,36.08069673306777,123 -5.429021107599713,36.08069673306777,123 -5.434142215221378,36.097578762436825,123 -5.434142215221378,36.097578762436825,123 -5.435871401650172,36.11513548688032,123 -5.435871401650172,36.11513548688032,123 -5.434142215221378,36.132692211323814,123 -5.434142215221378,36.132692211323814,123 -5.429021107599713,36.14957424069287,123 -5.429021107599713,36.14957424069287,123 -5.4207048800791275,36.16513280806639,123 -5.4207048800791275,36.16513280806639,123 -5.409513120619445,36.178770006425545,123 -5.409513120619445,36.178770006425545,123 -5.395875922260288,36.18996176588523,123 -5.395875922260288,36.18996176588523,123 -5.380317354886771,36.19827799340581,123 -5.380317354886771,36.19827799340581,123 -5.363435325517715,36.20339910102748,123 -5.363435325517715,36.20339910102748,123 -5.345878601074219,36.205128287456276,123 -5.345878601074219,36.205128287456276,123 -5.3283218766307225,36.20339910102748,123 -5.3283218766307225,36.20339910102748,123 -5.311439847261665,36.19827799340581,123 -5.311439847261665,36.19827799340581,123 -5.29588127988815,36.18996176588523,123 -5.29588127988815,36.18996176588523,123 -5.282244081528993,36.178770006425545,123 -5.282244081528993,36.178770006425545,123 -5.27105232206931,36.16513280806639,123 -5.27105232206931,36.16513280806639,123 -5.262736094548725,36.14957424069287,123 -5.262736094548725,36.14957424069287,123 -5.257614986927059,36.132692211323814,123 -5.257614986927059,36.132692211323814,123 -5.255885800498265,36.11513548688032,123 -5.255885800498265,36.11513548688032,123 -5.255885800498265,36.11513548688032,123  </coordinates>
                </LinearRing>
            </outerBoundaryIs>
        </Polygon>
    </Placemark>
</Document>

我需要的是来自clampToGround的多边形提升了123米。这可能与谷歌地球的kml文件。如果是这样,我该怎么做? 提前谢谢!

编辑:已经报告为问题:https://code.google.com/p/kml-samples/issues/detail?id=432

1 个答案:

答案 0 :(得分:0)

KML规范中定义的clampToGroundrelativeToGround之间存在明显的行为差异。

根据定义,

clampToGround 跟随地形,如果多边形将与地形相交,它将包裹山峰或山丘的表面。

另一方面,

relativeToGround 创建一个平行于地面的平面,切割穿过任何山脉和山丘,如下图所示。 123米的relativeToGround是地面以上123的地面标高,不在岩石顶部之上。相对于地面零高度是这个例子是岩石的基础。

KML polygon rendering with relativeToGround altitudeMode

直布罗陀岩石位于山顶地面上方约390米处,因此相对高度为123米,穿过岩石。如果你想要多边形在岩石尖端上方123米处,那么你应该将相对高度设置为513米,就像在该位置上的一个低悬的绿云。

或者,如果你想要用绿色多边形包裹岩石的顶部并且多边形的平面高度为123米(切割岩石),那么建议你使用relativeToGround定义第二个多边形的MultiGeometry (如上所列)和一个覆盖岩石尖端的较小圆圈,其高度为模式= clampToGround。

<MultiGeometry>
 <Polygon>
  <altitudeMode>relativeToGround</altitudeMode>
  ... use coordinates of original polygon here
 </Polygon>
 <Polygon>
  <altitudeMode>clampToGround</altitudeMode>
  ... use coordinates of smaller polygon here
 </Polygon>
</MultiGeometry>

但是如果你希望clampToGround行为的多边形遵循地形的形状,但是高于地面,那么你需要在relativeToGround模式下创建每个多边形的小网格。