在Google Earth kml文件中生成3D曲目

时间:2015-08-18 10:59:37

标签: google-earth kml python

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

enter image description here

有没有一个很好的参考(或可能是python库)这样做?我没有找到任何东西。

图片参考: Baird,R.W.,S.W。马丁,D.L。韦伯斯特和B.L.索撒尔。 2014年。在太平洋导弹射程设施中暴露于中频主动声纳的卫星标记的Odontocetes的模拟接收声压级和移动的评估:2011年2月至2013年2月。为美国太平洋舰队准备,由HDR Environmental提交给NAVFAC PAC,运营与建设公司

2 个答案:

答案 0 :(得分:1)

如果您使用的是java,我有代码生成kml以在Google地球中显示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;
    }


}

答案 1 :(得分:1)

您可以使用其他语言生成一些kml文件,例如以下链接中的文件:

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

  • 点击下载附件
  • 选择&#34;另存为&#34;查看KML内容
  • 选择&#34;打开&#34;在Google地球中查看结果

希望这个帮助