ryanjdillon
ryanjdillon

Reputation: 18978

Producing 3D tracks in Google Earth kml files

I already have some code to generate 2D kml files, but I am interested in reproducing an image similar to this, with an associated depth profile to each position:

enter image description here

Is there a good reference (or perhaps python library) for doing this? I have not managed to find anything.

Image reference: Baird, R.W., S.W. Martin, D.L. Webster, and B.L. Southall. 2014. Assessment of Modeled Received Sound Pressure Levels and Movements of Satellite-Tagged Odontocetes Exposed to Mid-Frequency Active Sonar at the Pacific Missile Range Facility: February 2011 Through February 2013. Prepared for U.S. Pacific Fleet, submitted to NAVFAC PAC by HDR Environmental, Operations and Construction, Inc.

Upvotes: 0

Views: 1031

Answers (2)

dennis_chen_canada
dennis_chen_canada

Reputation: 82

If you are using java, I have code to generate kml to display 3D tracking in google earth. (plus, a vertical line from air to ground for each point). (assumption: Since you had code for 2D, you may already have java pojo code that converted from kml21.xsd.) (p.s. I can attached you an image if you know any free site for me to upload image.) Hope this help:

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;
    }


}

Upvotes: 1

dennis_chen_canada
dennis_chen_canada

Reputation: 82

You may use other language to generate some kml files like the one in the following link:

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

  • click download the attached file
  • select "save as" to see the KML content
  • select "open" to see result in Google Earth

hope this help

Upvotes: 1

Related Questions