KML应绘制红色折线还是蓝色折线?

问题描述 投票:2回答:1

请告诉我哪一个是“KML文件格式的正确行为”。

您可能知道,KML的<color>标签包含订单AABBGGRR的颜色信息。这在OGC KML文档中定义。

16.9 kml:colorType

表达式的顺序是aabbggrr,其中aa = alpha(00到ff); bb =蓝色(00到ff); gg =绿色(00到ff); rr =红色(00到ff)。 http://docs.opengeospatial.org/is/12-007r2/12-007r2.html

所以,<color>7f0000ff</color>应该是红色。


例1:

使用此KML文件,Google地球和Google Maps API(KmlLayer)可以正确绘制红色折线。

<?xml version="1.0" encoding="utf-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
  <Document>
    <Style id="globalStyles">
      <LineStyle id="line">
        <color>7f0000ff</color>
        <width>4</width>
      </LineStyle>
    </Style>
    <Placemark>
      <styleUrl>#globalStyles</styleUrl>
      <LineString>
        <tessellate>1</tessellate>
        <coordinates>-14.405821,-7.963539 -14.381448,-7.975707</coordinates>
      </LineString>
    </Placemark>
  </Document>
</kml>

https://jsfiddle.net/wf9a5m75/xnw0hvvf/6/ enter image description here


例2:

但是,使用此KML文件时,Google Maps API会绘制一条蓝线,但Google地球仍然会绘制一条红色折线。

<?xml version="1.0" encoding="utf-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
  <Document>
    <Style id="globalStyles">
      <LineStyle id="line">
        <color>7f0000ff</color>
        <width>4</width>
      </LineStyle>
    </Style>
      <Placemark>
        <name>runway</name>
        <styleUrl>#globalStyles</styleUrl>
        <Style>
          <LineStyle>
            <!--
            Coloring is implicitly merged from the global style, width is
            explicitly overridden.
            -->
            <width>10</width>
          </LineStyle>
        </Style>
        <LineString>
          <tessellate>1</tessellate>
          <coordinates>-14.405821,-7.963539 -14.381448,-7.975707</coordinates>
        </LineString>
      </Placemark>
  </Document>
</kml>

https://jsfiddle.net/wf9a5m75/xnw0hvvf/5/

enter image description here


谷歌的回答

我相信这是Google Maps JS API v3的一个错误,我向Google报告了此问题。

但谷歌说

状态:无法修复(预期行为)

是。我相信Google Maps Javascript API遵循“十六进制”1格式的颜色。如果可能,我建议您调整颜色设置以遵循Google Maps Javascript API的十六进制格式。

https://issuetracker.google.com/issues/71991422#comment2

哇,他们真的打算这个吗?


在实际情况问题

丢失颜色信息意味着失去折线/多边形的含义。

例如,美国国家海洋和大气管理局(NOAA)使用KMZ文件提供实时天气危害。 https://www.weather.gov/source/crh/shapefiles/

Google地球使用正确的颜色绘制多边形(至少我认为是这样),但Google Maps API v3的KmlLayer绘制了所有蓝色多边形。改变颜色意味着改变多边形的含义。你不觉得这是严重的问题吗?

enter image description here


因此,为了要求解决Google Maps JS API v3的问题,我需要知道哪一个(红色或蓝色)是正确的。请用有效的信息告诉我你的答案。

google-maps-api-3 kml google-earth
1个回答
0
投票

对于KML的官方解释,请直接参考Open Geospatial Consortium (OGC) KML 2.2 standard。注意KML 2.3已发布但尚未在Google地球或Google地图中实施。关于visibility tag存在一个问题,其中Google Earth实现了与KML规范相反的行为,但修复会破坏现有代码,因此不会“修复”。如果存在违规行为,官方OGC KML标准将取代任何供应商文档或实施。

KML 2.2(文件#07-147r2)在第16.8.1节中说明如下:

表达式的顺序是aabbggrr,其中aa = alpha(00到ff); bb =蓝色(00到ff); gg =绿色(00到ff); rr =红色(00到ff)

它还给出了16.7.1中的一个例子,显示ff0000ff的值是红色的,其中最后的2个字符(ff)代表红色分量。

这意味着Google地球使用红色的<color>7f0000ff</color>正确显示KML渲染功能。 Google Maps API无法正确呈现并且是一个错误。

参考:

© www.soinside.com 2019 - 2024. All rights reserved.