samcragg / sharpkml

SharpKML is an implementation of the Open Geospatial Consortium (OGC) KML 2.2 standard developed in C#, able to read/write both KML files and KMZ files.
MIT License
158 stars 51 forks source link

CalculateBounds() returns null #50

Open timeichfeld-msa opened 1 year ago

timeichfeld-msa commented 1 year ago

Hello,

I have a geometry with many points, and need to get the boundingBox.
However, when I call Feature.CalculateBounds() it returns null. Example: (1000 points in datapoints)

var track = new SharpKml.Dom.GX.Track();
foreach (var p in dataPoints)
{
    var vector = new SharpKml.Base.Vector(p.LatDeg, p.LonDeg, p.Z);
    track.AddCoordinate(vector);
    track.AddWhen(p.Timestamp);
    track.AddAngle(new SharpKml.Base.Angle(pitch, p.Heading, roll));
}

Placemark trackPm = new Placemark();
trackPm.Geometry = track;
var bb = trackPm.CalculateBounds();

BoundingBox bb is null;

Is there a step I am missing?