src/AircraftTrajectories/Models/Visualisation/KML/AnimationSections/ContourKMLAnimator.cs
/// <summary>
/// Return a string in KML format containing all updates
/// for the contour animation at the given moment in time
/// </summary>
/// <returns></returns>
Return a string in KML format containing all updates
for the contour animation at the given moment in time
Return a string in KML format containing all updates for the contour animation at the given moment in time
public string KMLAnimationStep(int t)
        {
            if (_gradientContours.Count == 0 && _highlightedContours.Count == 0) { return ""; }
            string updateStep = "";
            Grid grid = _temporalGrid.GetGrid(t);
            List<string> visibleContours = new List<string>();
            Dictionary<int, int> occurrenceIndexes = new Dictionary<int, int>();
            foreach (Contour contour in grid.Contours)
            {
                int value = contour.Value;
                if (!_highlightedContours.Contains(value) && !_gradientContours.Contains(value)) { continue; }
                string contourId = "";
                for (int i = 0; i < _numberOfContours; i++)
                {
                    if (value == LowestContourValue + i)
                    {
                        contourId = i+"_";
                    }
                }
                int o;
                if(!occurrenceIndexes.TryGetValue(value, out o))
                {
                    o = 0;
                } else
                {
                    o++;
                }
                occurrenceIndexes[value] = o;
                contourId = contourId + o;
                visibleContours.Add(contourId);
                var coordinateString = "";
                GeoPoint3D firstContourPoint = grid.GridGeoCoordinate(contour.Points[0].Location.X, contour.Points[0].Location.Y);
                GeoPoint3D contourPoint = firstContourPoint;
                foreach (ContourPoint p in contour.Points)
                {
                    contourPoint = grid.GridGeoCoordinate(p.Location.X, p.Location.Y);
                    coordinateString += contourPoint.Longitude + "," + contourPoint.Latitude + ",";
                    coordinateString += (AltitudeOffset) ? "50\n" : "0\n";
                }
                if (!contour.IsClosed)
                {
                    coordinateString += firstContourPoint.Longitude + "," + firstContourPoint.Latitude + ",";
                    coordinateString += (AltitudeOffset) ? "50\n" : "0\n";
                }
                updateStep += plotUpdate("LinearRing", coordinateString, "contour" + contourId);
                if (_trajectory == null || !_highlightedContours.Contains(value)) { continue; }
                double pointLongitude = contourPoint.Longitude;
                double pointLatitude = contourPoint.Latitude;
                double smallestHeadingDeviation = 180;
                double desiredHeading = (_trajectory.Heading(t) + 160) % 360;
                foreach (ContourPoint p in contour.Points)
                {
                    contourPoint = grid.GridGeoCoordinate(p.Location.X, p.Location.Y);
                    double pointHeading = contourPoint.HeadingTo(_trajectory.GeoPoint(t));
                    if (pointHeading < desiredHeading && Math.Abs(pointHeading - desiredHeading) < smallestHeadingDeviation)
                    {
                        smallestHeadingDeviation = Math.Abs(pointHeading - desiredHeading);
                        pointLongitude = contourPoint.Longitude;
                        pointLatitude = contourPoint.Latitude;
                    }
                }
                if (_highlightedContours.Contains(contour.Value))
                {
                    var planeCoord = new GeoCoordinate(_trajectory.Latitude(t), _trajectory.Longitude(t));
                    var contourCoord = new GeoCoordinate(pointLatitude, pointLongitude);
                    var distance = planeCoord.GetDistanceTo(contourCoord);
                    var labelPoint = _trajectory.GeoPoint(t).MoveInDirection(distance, desiredHeading);
                    updateStep += plotUpdate("Point", labelPoint.Longitude + "," + labelPoint.Latitude + ",0", "contourPoint" + contourId);
                }
            }
            return updateStep;
        }
public string KMLAnimationStep ( int t ) { if ( _gradientContours . Count == 0 && _highlightedContours . Count == 0 ) { return " " ; } string updateStep = " " ; Grid grid = _temporalGrid . GetGrid ( t ) ; List < string > visibleContours = new List < string > ( ) ; Dictionary < int , int > occurrenceIndexes = new Dictionary < int , int > ( ) ; foreach ( Contour contour in grid . Contours ) { int value = contour . Value ; if ( ! _highlightedContours . Contains ( value ) && ! _gradientContours . Contains ( value ) ) { continue ; } string contourId = " " ; for ( int i = 0 ; i < _numberOfContours ; i ++ ) { if ( value == LowestContourValue + i ) { contourId = i + " " ; } } int o ; if ( ! occurrenceIndexes . TryGetValue ( value , out o ) ) { o = 0 ; } else { o ++ ; } occurrenceIndexes [ value ] = o ; contourId = contourId + o ; visibleContours . Add ( contourId ) ; var coordinateString = " " ; GeoPoint3D firstContourPoint = grid . GridGeoCoordinate ( contour . Points [ 0 ] . Location . X , contour . Points [ 0 ] . Location . Y ) ; GeoPoint3D contourPoint = firstContourPoint ; foreach ( ContourPoint p in contour . Points ) { contourPoint = grid . GridGeoCoordinate ( p . Location . X , p . Location . Y ) ; coordinateString += contourPoint . Longitude + " " + contourPoint . Latitude + " " ; coordinateString += ( AltitudeOffset ) ? " \n " : " \n " ; } if ( ! contour . IsClosed ) { coordinateString += firstContourPoint . Longitude + " " + firstContourPoint . Latitude + " " ; coordinateString += ( AltitudeOffset ) ? " \n " : " \n " ; } updateStep += plotUpdate ( " " , coordinateString , " " + contourId ) ; if ( _trajectory == null || ! _highlightedContours . Contains ( value ) ) { continue ; } double pointLongitude = contourPoint . Longitude ; double pointLatitude = contourPoint . Latitude ; double smallestHeadingDeviation = 180 ; double desiredHeading = ( _trajectory . Heading ( t ) + 160 ) % 360 ; foreach ( ContourPoint p in contour . Points ) { contourPoint = grid . GridGeoCoordinate ( p . Location . X , p . Location . Y ) ; double pointHeading = contourPoint . HeadingTo ( _trajectory . GeoPoint ( t ) ) ; if ( pointHeading < desiredHeading && Math . Abs ( pointHeading - desiredHeading ) < smallestHeadingDeviation ) { smallestHeadingDeviation = Math . Abs ( pointHeading - desiredHeading ) ; pointLongitude = contourPoint . Longitude ; pointLatitude = contourPoint . Latitude ; } } if ( _highlightedContours . Contains ( contour . Value ) ) { var planeCoord = new GeoCoordinate ( _trajectory . Latitude ( t ) , _trajectory . Longitude ( t ) ) ; var contourCoord = new GeoCoordinate ( pointLatitude , pointLongitude ) ; var distance = planeCoord . GetDistanceTo ( contourCoord ) ; var labelPoint = _trajectory . GeoPoint ( t ) . MoveInDirection ( distance , desiredHeading ) ; updateStep += plotUpdate ( " " , labelPoint . Longitude + " " + labelPoint . Latitude + " " , " " + contourId ) ; } } return updateStep ; }
Return a string in KML format containing all updates
for the contour animation at the given moment in time
Return a string in KML format containing all updates for the contour animation at the given moment in time
//if (!contour.IsClosed) { continue; } // Plot Contour // Plot Labels /*
            for (int i = 0; i < _numberOfContours; i++)
            {
                int value = LowestContourValue + i;
                if (!_highlightedContours.Contains(value) && !_gradientContours.Contains(value)) { continue; }
                //foreach ()
                if (!visibleContours.Contains(i))
                {
                    string longLat = (_trajectory == null) ? "0,0," : _trajectory.Longitude(t) + "," + _trajectory.Latitude(t);
                    updateStep += plotUpdate("LinearRing", longLat + ",0", "contour" + i);
                }
            }
            */
None
t
int