在 Google 个地球 kml 文件中生成 3D 轨道

Producing 3D tracks in Google Earth kml files

我已经有了一些生成 2D kml 文件的代码,但我有兴趣再现与此类似的图像,每个位置都有相关的深度剖面:

是否有一个很好的参考资料(或者 python 库)可以做到这一点?我还没有找到任何东西。

图片参考: 贝尔德 R.W., S.W.马丁,D.L。韦伯斯特和 B.L。绍索尔。 2014. 太平洋导弹靶场设施暴露于中频主动声纳的卫星标记齿鲸模型接收声压级和运动评估:2011 年 2 月至 2013 年 2 月。准备 U.S。太平洋舰队,由 HDR Environmental, Operations and Construction, Inc. 提交给 NAVFAC PAC

如果您使用的是 java,我有生成 kml 的代码以在 google earth 中显示 3D 跟踪。 (另外,每个点都有一条从空中到地面的垂直线)。 (假设:由于您有 2D 代码,您可能已经有从 kml21.xsd 转换而来的 java pojo 代码。) (p.s。如果你知道任何免费网站供我上传图片,我可以附上图片。) 希望对您有所帮助:

package com.googleearth.util;

import java.util.List;

import javax.xml.bind.JAXBElement;

import com.a.googleearth.entities.GoogleEarthView;
import com.a.googleearth.model.AltitudeModeEnum;
import com.a.googleearth.model.DocumentType;
import com.a.googleearth.model.FolderType;
import com.a.googleearth.model.KmlType;
import com.a.googleearth.model.LineStringType;
import com.a.googleearth.model.LineStyleType;
import com.a.googleearth.model.ObjectFactory;
import com.a.googleearth.model.PlacemarkType;
import com.a.googleearth.model.StyleType;

public class KmlService {

    public static final byte[] blue = new byte[]{(byte)0x64,(byte)0xF0,(byte)0x00,(byte)0xFF};

    private static ObjectFactory factory = new ObjectFactory();

    static final String DEFAULT_REGISTRATION_FOR_EMPTY = "EMPTY";

    public static JAXBElement<KmlType> createKml(List<GoogleEarthView> listGoogleEarthDBView) {

        KmlType kml = factory.createKmlType();

        DocumentType document = factory.createDocumentType();
        kml.setFeature(factory.createDocument(document));

        {
            LineStyleType redLineStyle = factory.createLineStyleType();
            // http://www.zonums.com/gmaps/kml_color/
            redLineStyle.setColor(new byte[]{(byte)0xFF,(byte)0xF0,(byte)0x00,(byte)0x14});
            redLineStyle.setWidth(5f);

            StyleType style = factory.createStyleType();
            style.setId("blueLine");
            style.setLineStyle(redLineStyle);
            document.getStyleSelector().add(factory.createStyle(style));
        }

        FolderType folder = factory.createFolderType();

        folder.setName(listGoogleEarthDBView.get(0).getFolderName());

        document.getFeature().add(factory.createFolder(folder));

        PlacemarkType currentPlacemark = null;

        for (GoogleEarthView view : listGoogleEarthDBView) {

            if (currentPlacemark == null || currentPlacemark.getName().equalsIgnoreCase("F0001") == false) {

                    if (currentPlacemark != null) {
                        JAXBElement<LineStringType> lineString = (JAXBElement<LineStringType>) currentPlacemark.getGeometry();
                        lineString.getValue().getCoordinates().add(view.getLongitude() + "," + view.getLatitude() + "," + view.getPressureAltitude()+"\n");
                    }

                    currentPlacemark = createF0001Placemark();
                    folder.getFeature().add(factory.createPlacemark(currentPlacemark));
                }

                JAXBElement<LineStringType> lineString = (JAXBElement<LineStringType>) currentPlacemark.getGeometry();
                lineString.getValue().getCoordinates().add(view.getLongitude() + "," + view.getLatitude() + "," + view.getPressureAltitude()+"\n");

        }

        JAXBElement<KmlType> kmlElement = factory.createKml(kml);

        return kmlElement;
    }

    private static PlacemarkType createF0001Placemark() {
        PlacemarkType placeMark = factory.createPlacemarkType();
        placeMark.setName("F0001");

        placeMark.setStyleUrl("#blueLine");

        LineStringType flyhtStreamLineString = factory.createLineStringType();
        flyhtStreamLineString.setAltitudeMode(AltitudeModeEnum.ABSOLUTE);
        flyhtStreamLineString.setExtrude(Boolean.TRUE);
        placeMark.setGeometry(factory.createLineString(flyhtStreamLineString));
        return placeMark;
    }


}

您可以使用其他语言生成一些如下所示的 kml 文件link:

https://sites.google.com/site/canadadennischen888/home/kml/3d-tracking

  • 点击下载附件
  • select "save as" 查看 KML 内容
  • select "open" 在 Google 地球上查看结果

希望对您有所帮助