我正在尝试在Google Earth(使用KML)中创建曲目
我正在使用Sharpkml进行C#
我可以成功创建一个路径。
如何创建曲目?我知道我需要添加一个"点"和一个"当"时,我需要做以下操作 -
SharpKml.Dom.GX.Track myTrack = new SharpKml.Dom.GX.Track();
GpsSensorDataPoint data = (GpsSensorDataPoint)myGPSDataList[i];
double lat = data.Latitude;
double lon = data.Longitude;
double height = data.Height;
SharpKml.Dom.Point myPoint = new SharpKml.Dom.Point();
myPoint.Coordinate = new Vector(lat, lon, height);
myTrack.AddCoordication(mypoint.coordic); mytrack.addwhen(data.calendartime.tolongtimestring());
但是,创建的KML没有正确的语法我在KML中获得以下内容,这是不正确的:
<when xmlns="http://www.opengis.net/kml/2.2">12:00:17 AM</when>
<gx:coord xmlns:gx="http://www.google.com/kml/ext/2.2">-81.3184973901226 29.0765012024324 50.5</gx:coord>
添加时间并与Sharpkml轨道协调的正确方法是什么?
您应该将曲目添加到placemark中,尝试这样的东西:
var root = new Document();
var track = new SharpKml.Dom.GX.Track();
foreach (var gc in myCoords)
{
var vector = new Vector(gc.Latitude, gc.Longitude);
track.AddCoordinate(vector);
track.AddWhen(gc.gpsDateTime);
}
Placemark trackPm = new Placemark();
trackPm.Geometry = track;
root.AddFeature(trackPm);
KmlFile kml = KmlFile.Create(root, false);